Bug 824718

Summary: file reported incorrect type for zero device
Product: Red Hat Enterprise Linux 7 Reporter: Mohua Li <moli>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: leiwang, qguan, qwan, yuzhou
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-24 07:59:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mohua Li 2012-05-24 03:59:52 UTC
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, 
 
 file.c:do_file(),
 
 623       free (buf);
 624 
 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):
libguestfs-1.17.43-1.el7.x86_64

How reproducible:
always

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

Expected results:



Additional info:

Comment 1 Richard W.M. Jones 2012-05-24 07:54:19 UTC
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 07:59:12 UTC
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.