- Use more natural ip->i_flags instead of vap->va_flags in the final

flags check.
- Add a comment for the immutable/append check done after handling of
  the flags.
- Style improvements.

No functional change intended.

Submitted by:	bde
MFC after:	2 weeks
This commit is contained in:
Jaakko Heinonen 2012-04-02 16:33:21 +00:00
parent bff5cf1648
commit fccf286d24

View File

@ -545,8 +545,8 @@ ufs_setattr(ap)
* processes.
*/
if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) {
if (ip->i_flags
& (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) {
if (ip->i_flags &
(SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) {
error = securelevel_gt(cred, 0);
if (error)
return (error);
@ -560,8 +560,8 @@ ufs_setattr(ap)
ip->i_flags = vap->va_flags;
DIP_SET(ip, i_flags, vap->va_flags);
} else {
if (ip->i_flags
& (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) ||
if (ip->i_flags &
(SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) ||
(vap->va_flags & UF_SETTABLE) != vap->va_flags)
return (EPERM);
ip->i_flags &= SF_SETTABLE;
@ -570,9 +570,15 @@ ufs_setattr(ap)
}
ip->i_flag |= IN_CHANGE;
error = UFS_UPDATE(vp, 0);
if (vap->va_flags & (IMMUTABLE | APPEND))
if (ip->i_flags & (IMMUTABLE | APPEND))
return (error);
}
/*
* If immutable or append, no one can change any of its attributes
* except the ones already handled (exec atime and, in some cases
* for the superuser, file flags including the immutability flags
* themselves).
*/
if (ip->i_flags & (IMMUTABLE | APPEND))
return (EPERM);
/*