aboutsummaryrefslogtreecommitdiff
path: root/sys/fs
diff options
context:
space:
mode:
authorJaakko Heinonen <jh@FreeBSD.org>2012-04-16 18:10:34 +0000
committerJaakko Heinonen <jh@FreeBSD.org>2012-04-16 18:10:34 +0000
commit587fdb536fc253ba450f4d1712c3ae6dbec5516e (patch)
treed9daf4812756f9b08bdf4f9cd6267a8ca4afdd98 /sys/fs
parentc5ab5ce3452719eadf49526c0f4c4f69b48fe99f (diff)
downloadsrc-587fdb536fc253ba450f4d1712c3ae6dbec5516e.tar.gz
src-587fdb536fc253ba450f4d1712c3ae6dbec5516e.zip
Sync tmpfs_chflags() with the recent changes to UFS:
- Add a check for unsupported file flags. - Return EPERM when an user without PRIV_VFS_SYSFLAGS privilege attempts to toggle SF_SETTABLE flags.
Notes
Notes: svn path=/head/; revision=234347
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 96615d2fade2..1a0de177c426 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1078,6 +1078,11 @@ tmpfs_chflags(struct vnode *vp, int flags, struct ucred *cred, struct thread *p)
node = VP_TO_TMPFS_NODE(vp);
+ if ((flags & ~(UF_NODUMP | UF_IMMUTABLE | UF_APPEND | UF_OPAQUE |
+ UF_NOUNLINK | SF_ARCHIVED | SF_IMMUTABLE | SF_APPEND |
+ SF_NOUNLINK | SF_SNAPSHOT)) != 0)
+ return (EOPNOTSUPP);
+
/* Disallow this operation if the file system is mounted read-only. */
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return EROFS;
@@ -1093,27 +1098,22 @@ tmpfs_chflags(struct vnode *vp, int flags, struct ucred *cred, struct thread *p)
* flags, or modify flags if any system flags are set.
*/
if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) {
- if (node->tn_flags
- & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) {
+ if (node->tn_flags &
+ (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) {
error = securelevel_gt(cred, 0);
if (error)
return (error);
}
- /* Snapshot flag cannot be set or cleared */
- if (((flags & SF_SNAPSHOT) != 0 &&
- (node->tn_flags & SF_SNAPSHOT) == 0) ||
- ((flags & SF_SNAPSHOT) == 0 &&
- (node->tn_flags & SF_SNAPSHOT) != 0))
+ /* The snapshot flag cannot be toggled. */
+ if ((flags ^ node->tn_flags) & SF_SNAPSHOT)
return (EPERM);
- node->tn_flags = flags;
} else {
- if (node->tn_flags
- & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) ||
- (flags & UF_SETTABLE) != flags)
+ if (node->tn_flags &
+ (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) ||
+ ((flags ^ node->tn_flags) & SF_SETTABLE))
return (EPERM);
- node->tn_flags &= SF_SETTABLE;
- node->tn_flags |= (flags & UF_SETTABLE);
}
+ node->tn_flags = flags;
node->tn_status |= TMPFS_NODE_CHANGED;
MPASS(VOP_ISLOCKED(vp));