Skip to content

Commit

Permalink
ext2: fix ctime, atime updating
Browse files Browse the repository at this point in the history
JIRA: RTOS-972
  • Loading branch information
adamdebek committed Jan 14, 2025
1 parent 99fee50 commit 9a7a3c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
11 changes: 1 addition & 10 deletions ext2/ext2.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ int ext2_open(ext2_t *fs, id_t id)
if ((obj = ext2_obj_get(fs, id)) == NULL)
return -EINVAL;

mutexLock(obj->lock);

obj->inode->atime = time(NULL);

mutexUnlock(obj->lock);

return EOK;
}

Expand Down Expand Up @@ -493,10 +487,7 @@ int ext2_setattr(ext2_t *fs, id_t id, int type, long long attr, const void *data
}

if (err == EOK) {
if (type != atMTime && type != atATime) {
obj->inode->mtime = obj->inode->atime = time(NULL);
}

obj->inode->ctime = time(NULL);
obj->flags |= OFLAG_DIRTY;
err = _ext2_obj_sync(fs, obj);
}
Expand Down
4 changes: 2 additions & 2 deletions ext2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ ssize_t _ext2_file_write(ext2_t *fs, ext2_obj_t *obj, off_t offs, const char *bu
obj->inode->size = offs + len;
}

obj->inode->mtime = obj->inode->atime = time(NULL);
obj->inode->mtime = obj->inode->ctime = time(NULL);
obj->flags |= OFLAG_DIRTY;

err = _ext2_obj_sync(fs, obj);
Expand Down Expand Up @@ -209,7 +209,7 @@ int _ext2_file_truncate(ext2_t *fs, ext2_obj_t *obj, size_t size)
obj->inode->size = size;
/* FIXME: blocks counting is broken, move it to iblock_destroy */
obj->inode->blocks -= (end - start) * fs->blocksz / fs->sectorsz;
obj->inode->mtime = obj->inode->atime = time(NULL);
obj->inode->mtime = obj->inode->ctime = time(NULL);
obj->flags |= OFLAG_DIRTY;

return EOK;
Expand Down

0 comments on commit 9a7a3c0

Please sign in to comment.