summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2013-07-01 03:00:15 +0000
committerpfg <pfg@FreeBSD.org>2013-07-01 03:00:15 +0000
commit5eeda65400daadfcae0484d6e00abf8b37c2be21 (patch)
treebc01175493e103eb5471e847d6d525fa988d944c
parent8a0279994de9e2e860de4a740b1a7b6dfec51e3e (diff)
downloadFreeBSD-src-5eeda65400daadfcae0484d6e00abf8b37c2be21.zip
FreeBSD-src-5eeda65400daadfcae0484d6e00abf8b37c2be21.tar.gz
Change i_gen in UFS to an unsigned type.
In UFS, i_gen is a random generated value and there is not way for it to be negative. Actually, the value of i_gen is just used to match bit patterns and it is of not consequence if the values are signed or not. Following other filesystems, set it to unsigned and use it as such, Discussed by: mckusick Reviewed by: mckusick (previous version) MFC after: 4 weeks
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c2
-rw-r--r--sys/ufs/ufs/dinode.h4
-rw-r--r--sys/ufs/ufs/inode.h2
-rw-r--r--sys/ufs/ufs/ufs_extattr.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 57f092c..19b5615 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1791,7 +1791,7 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags)
* already have one. This should only happen on old filesystems.
*/
if (ip->i_gen == 0) {
- ip->i_gen = arc4random() / 2 + 1;
+ ip->i_gen = arc4random() + 1;
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
ip->i_flag |= IN_MODIFIED;
DIP_SET(ip, i_gen, ip->i_gen);
diff --git a/sys/ufs/ufs/dinode.h b/sys/ufs/ufs/dinode.h
index 8aa1fe0..6d06bde 100644
--- a/sys/ufs/ufs/dinode.h
+++ b/sys/ufs/ufs/dinode.h
@@ -138,7 +138,7 @@ struct ufs2_dinode {
int32_t di_atimensec; /* 68: Last access time. */
int32_t di_ctimensec; /* 72: Last inode change time. */
int32_t di_birthnsec; /* 76: Inode creation time. */
- int32_t di_gen; /* 80: Generation number. */
+ u_int32_t di_gen; /* 80: Generation number. */
u_int32_t di_kernflags; /* 84: Kernel flags. */
u_int32_t di_flags; /* 88: Status flags (chflags). */
int32_t di_extsize; /* 92: External attributes block. */
@@ -180,7 +180,7 @@ struct ufs1_dinode {
ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */
u_int32_t di_flags; /* 100: Status flags (chflags). */
int32_t di_blocks; /* 104: Blocks actually held. */
- int32_t di_gen; /* 108: Generation number. */
+ u_int32_t di_gen; /* 108: Generation number. */
u_int32_t di_uid; /* 112: File owner. */
u_int32_t di_gid; /* 116: File group. */
u_int64_t di_modrev; /* 120: i_modrev for NFSv4 */
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index 6416632..97ec63f 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -102,7 +102,7 @@ struct inode {
int16_t i_nlink; /* File link count. */
u_int64_t i_size; /* File byte count. */
u_int32_t i_flags; /* Status flags (chflags). */
- int64_t i_gen; /* Generation number. */
+ u_int64_t i_gen; /* Generation number. */
u_int32_t i_uid; /* File owner. */
u_int32_t i_gid; /* File group. */
/*
diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c
index d52f650..6e4e840 100644
--- a/sys/ufs/ufs/ufs_extattr.c
+++ b/sys/ufs/ufs/ufs_extattr.c
@@ -935,7 +935,7 @@ ufs_extattr_get(struct vnode *vp, int attrnamespace, const char *name,
* up by the next write or extattrctl clean.
*/
printf("ufs_extattr_get (%s): inode number inconsistency (%d, %jd)\n",
- mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (intmax_t)ip->i_gen);
+ mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (uintmax_t)ip->i_gen);
error = ENOATTR;
goto vopunlock_exit;
}
OpenPOWER on IntegriCloud