POSIX states that write(2) "shall mark for update the last data

modification and last file status change timestamps of the file".
Currently, tmpfs only modifies ctime when file was extended.  Since
r277828 followed tmpfs_write(), mmaped writes also do not modify
ctime.

Fix this, by updating both ctime and mtime for writes to tmpfs files.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
This commit is contained in:
kib 2015-01-31 12:27:18 +00:00
parent a2924f5fee
commit 8773784e5a
2 changed files with 3 additions and 2 deletions

View File

@ -1434,7 +1434,8 @@ tmpfs_check_mtime(struct vnode *vp)
if ((obj->flags & OBJ_TMPFS_DIRTY) != 0) {
obj->flags &= ~OBJ_TMPFS_DIRTY;
node = VP_TO_TMPFS_NODE(vp);
node->tn_status |= TMPFS_NODE_MODIFIED;
node->tn_status |= TMPFS_NODE_MODIFIED |
TMPFS_NODE_CHANGED;
}
VM_OBJECT_WUNLOCK(obj);
}

View File

@ -483,7 +483,7 @@ tmpfs_write(struct vop_write_args *v)
error = uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio);
node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
(extended ? TMPFS_NODE_CHANGED : 0);
TMPFS_NODE_CHANGED;
if (node->tn_mode & (S_ISUID | S_ISGID)) {
if (priv_check_cred(v->a_cred, PRIV_VFS_RETAINSUGID, 0))
node->tn_mode &= ~(S_ISUID | S_ISGID);