Bug 824718 - file reported incorrect type for zero device
file reported incorrect type for zero device
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Richard W.M. Jones
Virtualization Bugs
Depends On:
  Show dependency treegraph
Reported: 2012-05-23 23:59 EDT by Mohua Li
Modified: 2012-05-24 03:59 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-05-24 03:59:12 EDT
Type: Bug
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 Mohua Li 2012-05-23 23:59:52 EDT
Description of problem:
for zero device, it reported as "data" for file api, but in el7, it reported as "\0", which not quite make sense, 
 actually, it should reply the below result, 
 623       free (buf);
 625       if (S_ISDIR (statbuf.st_mode))
 626         ret = strdup ("directory");
 627       else if (S_ISCHR (statbuf.st_mode))
 628         ret = strdup ("character device");
 629       else if (S_ISBLK (statbuf.st_mode))
 630         ret = strdup ("block device");
 631       else if (S_ISFIFO (statbuf.st_mode))
 632         ret = strdup ("FIFO");
 633       else if (S_ISLNK (statbuf.st_mode))
 634         ret = strdup ("symbolic link");
 635       else if (S_ISSOCK (statbuf.st_mode))
 636         ret = strdup ("socket");
 637       else
 638         ret = strdup ("unknown, not regular file");

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.guestfish -N fs zero-device /dev/vda : file /dev/vda
Actual results:
it reported zero device as "\0" for file api

Expected results:

Additional info:
Comment 1 Richard W.M. Jones 2012-05-24 03:54:19 EDT
I've noticed this too.  It's a bug (or change?) in the regular
'file(1)' command:

  $ truncate -s 100k data
  $ file data
  data: \0

Note that libguestfs doesn't define the output of the
guestfs_file function.  It says in the documentation:

  The output depends on the output of the underlying file(1) command and
  it can change in future in ways beyond our control.  In other words,
  the output is not guaranteed by the ABI.

If you want to check if a file contains zeroes, use
guestfs_is_zero instead.
Comment 2 Richard W.M. Jones 2012-05-24 03:59:12 EDT
file 5.11 prints:

MAGIC=magic/magic ./src/file /tmp/data 
/tmp/data: data

The version of file in Fedora 17 is 5.10, which is older than
upstream, so I think it just needs an update.

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