Bug 598883 - fsid is not correct in statvfs command of guestfish
fsid is not correct in statvfs command of guestfish
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
Depends On:
  Show dependency treegraph
Reported: 2010-06-02 05:40 EDT by Yufang Zhang
Modified: 2010-06-02 11:00 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-06-02 11:00:55 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Yufang Zhang 2010-06-02 05:40:33 EDT
Description of problem:
For statvfs command in guestfish, fsid is truncated as an 'int', but actually it is an 'unsigned long'. Thus the fsid value reflected by statvfs command is negative, which is not correct. 

Version-Release number of selected component (if applicable):
major: 1
minor: 2
release: 7

How reproducible:

Steps to Reproduce:
><fs> statvfs /
bsize: 1024
frsize: 1024
blocks: 99150
bfree: 93487
bavail: 88367
files: 25688
ffree: 25677
favail: 25677
fsid: -3268369665409063091
flag: 0

Actual results:
fsid is not negative.

Expected results:

Additional info:

statvfs structure defined as follows, in which f_fsid is an 'unsigned long':

struct statvfs {
               unsigned long  f_bsize;    /* file system block size */
               unsigned long  f_frsize;   /* fragment size */
               fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */
               fsblkcnt_t     f_bfree;    /* # free blocks */
               fsblkcnt_t     f_bavail;   /* # free blocks for non-root */
               fsfilcnt_t     f_files;    /* # inodes */
               fsfilcnt_t     f_ffree;    /* # free inodes */
               fsfilcnt_t     f_favail;   /* # free inodes for non-root */
               unsigned long  f_fsid;     /* file system ID */
               unsigned long  f_flag;     /* mount flags */
               unsigned long  f_namemax;  /* maximum filename length */

But actually in guestfish it is represented as follows, in which 'PRIi64'is 'i':

printf ("%sfsid: %" PRIi64 "\n", indent, statvfs->fsid);
Comment 1 Richard W.M. Jones 2010-06-02 11:00:55 EDT
On 32 bit machines, Linux gives us a 32 bit f_fsid
unsigned int from the statvfs system call.  On 64 bit
machines this field is returned as a 64 bit unsigned

We pass a 64 bit signed integer over the daemon
protocol on all architectures.

The only issue I can see would be on a 32 bit machine
if a f_fsid value >= 0x80000000 was to be sign-
extended when it was passed over the protocol.
I have checked and this does not happen.

Therefore callers can simply cast the value to
uint64_t in order to recover the original f_fsid
value (on 32 or 64 bit machines).

So although printing a negative number in guestfish
doesn't look pretty, I don't think this is an actual bug.
Therefore I am closing this as NOTABUG.

Note You need to log in before you can comment on or make changes to this bug.