]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/commit - usr.bin/fstat/fstat.c
MFC 196399: fstat: fix fsid comparison when executed on systems with 64-bit long
authoravg <avg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 20 Aug 2009 11:04:31 +0000 (11:04 +0000)
committeravg <avg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 20 Aug 2009 11:04:31 +0000 (11:04 +0000)
commitf04c220ff2bad6dc8ed3e0dbec4c5634cbb8fa9f
tree7240b795e780eee38499d59d47bd7ed0ca351d87
parent425fe1a2ac0d68e15da31003d9102643efb838ad
MFC 196399: 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)

git-svn-id: svn://svn.freebsd.org/base/stable/8@196400 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.bin/fstat/fstat.c
usr.bin/fstat/zfs.c