summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c6
-rw-r--r--sys/ufs/ufs/inode.h18
-rw-r--r--sys/ufs/ufs/ufs_vnops.c16
3 files changed, 29 insertions, 11 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index b241b75af6c..4ee2119c56c 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_alloc.c,v 1.86 2008/08/08 16:17:38 thib Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.87 2009/01/17 18:50:25 grange Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */
/*
@@ -894,7 +894,9 @@ ffs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred,
* XXX - just increment for now, this is wrong! (millert)
* Need a way to preserve randomization.
*/
- if (DIP(ip, gen) == 0 || ++(DIP(ip, gen)) == 0)
+ if (DIP(ip, gen) != 0)
+ DIP_ADD(ip, gen, 1);
+ if (DIP(ip, gen) == 0)
DIP_ASSIGN(ip, gen, arc4random() & INT_MAX);
if (DIP(ip, gen) == 0 || DIP(ip, gen) == -1)
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index f9cd5b4ae32..1ac77c46f65 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.h,v 1.36 2008/01/05 19:49:26 otto Exp $ */
+/* $OpenBSD: inode.h,v 1.37 2009/01/17 18:50:25 grange Exp $ */
/* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */
/*
@@ -281,6 +281,22 @@ struct inode_vtbl {
(ip)->i_ffs2_##field += (value); \
} while (0)
+#define DIP_AND(ip, field, value) \
+ do { \
+ if ((ip)->i_ump->um_fstype == UM_UFS1) \
+ (ip)->i_ffs1_##field &= (value); \
+ else \
+ (ip)->i_ffs2_##field &= (value); \
+ } while (0)
+
+#define DIP_OR(ip, field, value) \
+ do { \
+ if ((ip)->i_ump->um_fstype == UM_UFS1) \
+ (ip)->i_ffs1_##field |= (value); \
+ else \
+ (ip)->i_ffs2_##field |= (value); \
+ } while (0)
+
#define SHORTLINK(ip) \
(((ip)->i_ump->um_fstype == UM_UFS1) ? \
(caddr_t)(ip)->i_ffs1_db : (caddr_t)(ip)->i_ffs2_db)
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index eb79e6ef8eb..8cf16d58735 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.88 2008/08/13 15:45:30 thib Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.89 2009/01/17 18:50:25 grange Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -336,8 +336,8 @@ ufs_setattr(void *v)
if (DIP(ip, flags) & (SF_IMMUTABLE | SF_APPEND) ||
(vap->va_flags & UF_SETTABLE) != vap->va_flags)
return (EPERM);
- DIP(ip, flags) &= SF_SETTABLE;
- DIP(ip, flags) |= (vap->va_flags & UF_SETTABLE);
+ DIP_AND(ip, flags, SF_SETTABLE);
+ DIP_OR(ip, flags, vap->va_flags & UF_SETTABLE);
}
ip->i_flag |= IN_CHANGE;
if (vap->va_flags & (IMMUTABLE | APPEND))
@@ -426,8 +426,8 @@ ufs_chmod(struct vnode *vp, int mode, struct ucred *cred, struct proc *p)
if (!groupmember(DIP(ip, gid), cred) && (mode & ISGID))
return (EPERM);
}
- DIP(ip, mode) &= ~ALLPERMS;
- DIP(ip, mode) |= (mode & ALLPERMS);
+ DIP_AND(ip, mode, ~ALLPERMS);
+ DIP_OR(ip, mode, mode & ALLPERMS);
ip->i_flag |= IN_CHANGE;
if ((vp->v_flag & VTEXT) && (DIP(ip, mode) & S_ISTXT) == 0)
(void) uvm_vnp_uncache(vp);
@@ -501,9 +501,9 @@ ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred,
if (ouid != uid || ogid != gid)
ip->i_flag |= IN_CHANGE;
if (ouid != uid && cred->cr_uid != 0)
- DIP(ip, mode) &= ~ISUID;
+ DIP_AND(ip, mode, ~ISUID);
if (ogid != gid && cred->cr_uid != 0)
- DIP(ip, mode) &= ~ISGID;
+ DIP_AND(ip, mode, ~ISGID);
return (0);
error:
@@ -1876,7 +1876,7 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
if ((DIP(ip, mode) & ISGID) &&
!groupmember(DIP(ip, gid), cnp->cn_cred) &&
suser_ucred(cnp->cn_cred))
- DIP(ip, mode) &= ~ISGID;
+ DIP_AND(ip, mode, ~ISGID);
/*
* Make sure inode goes to disk before directory entry.