summaryrefslogtreecommitdiff
path: root/usr.bin/fstat
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2009-08-20 10:57:14 +0000
committerAndriy Gapon <avg@FreeBSD.org>2009-08-20 10:57:14 +0000
commit497e910cd321dbdc45c010417bb7079365234fcf (patch)
treef9fcf0b99a48325c78752a17b36f2ea0260d16a4 /usr.bin/fstat
parent52e12426d18affcdae36089493f2b01ab704d216 (diff)
downloadsrc-test-497e910cd321dbdc45c010417bb7079365234fcf.tar.gz
src-test-497e910cd321dbdc45c010417bb7079365234fcf.zip
fstat: fix fsid comparison when executed on systems with 64-bit long
This affects only fstat on zfs and devfs, only on 64-bit systems and only when fsid is greater than 2^31 - 1. When fstat examines a file via stat(2) it takes uint32_t st_dev and assigns to (signed) (64-bit) long fsid, this results in a positive value. When fstat examines opened files it takes int32_t f_fsid.val[0] and assigns to (signed) (64-bit) long fsid, this results in a negative value. So, while initially st_dev and f_fsid.val[0] have the same bit values they get promoted to different 64-bit values because of the signed-vs-unsigned difference. A fix is to use "more natural" positive numbers by introducing intermediate unsigned cast for f_fsid.val[0]. Reviewed by: jhb, lulf Approved by: re (kib) MFC after: 1 week (to stable/7)
Notes
Notes: svn path=/head/; revision=196399
Diffstat (limited to 'usr.bin/fstat')
-rw-r--r--usr.bin/fstat/fstat.c2
-rw-r--r--usr.bin/fstat/zfs.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index 53561e88e033e..f82e964395b27 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -658,7 +658,7 @@ devfs_filestat(struct vnode *vp, struct filestat *fsp)
(void *)devfs_dirent.de_vnode, Pid);
return 0;
}
- fsp->fsid = (long)mount.mnt_stat.f_fsid.val[0];
+ fsp->fsid = (long)(uint32_t)mount.mnt_stat.f_fsid.val[0];
fsp->fileid = devfs_dirent.de_inode;
fsp->mode = (devfs_dirent.de_mode & ~S_IFMT) | S_IFCHR;
fsp->size = 0;
diff --git a/usr.bin/fstat/zfs.c b/usr.bin/fstat/zfs.c
index 008f1746b0baf..96cdff6870a03 100644
--- a/usr.bin/fstat/zfs.c
+++ b/usr.bin/fstat/zfs.c
@@ -117,7 +117,7 @@ zfs_filestat(struct vnode *vp, struct filestat *fsp)
goto bad;
}
- fsp->fsid = (long)mount.mnt_stat.f_fsid.val[0];
+ fsp->fsid = (long)(uint32_t)mount.mnt_stat.f_fsid.val[0];
fsp->fileid = *zid;
/*
* XXX: Shows up wrong in output, but UFS has this error too. Could