Bug 1164729

Summary: set-label can only set <=63 bytes for btrfs and ntfs filesystem which not meet the help message. Also for btrfs and ntfs it should give a warning message when the length exceed the limited length
Product: Red Hat Enterprise Linux 6 Reporter: Lingfei Kong <lkong>
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 6.6CC: huzhan, leiwang, linl, mbooth, ptoscano, wshi, xchen
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.20.11-16.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-10 19:55:37 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:
Bug Depends On:    
Bug Blocks: 1301844    

Description Lingfei Kong 2014-11-17 09:11:50 UTC
Description of problem:
For btrfs:
I can confirm that the label length for btrfs is less than 256 bytes both in libguestfs and linux system. Check 'help set-label' in guestfish and 'man mkfs.btrfs' in linux system. When i try to set a label who's length is 180 bytes, i can set the label successfully, but when i get the new label via 'vfs-label' i only got 63 bytes. Also it should give a warning message when the length > 255 bytes. 

In 'help set-label' i can obtain that i can set 256 bytes for btrfs, obviously this is wrong, for btrfs the max bytes is 255:
><fs> help set-label
[...]
   btrfs
        The label is limited to 256 bytes and some characters are not
        allowed. Setting the label on a btrfs subvolume will set the label
        on its parent filesystem. The filesystem must not be mounted when
        trying to set the label.


For ntfs:
set-label for ntfs can only set <=63 bytes which is less than 128 bytes according to 'help set-label', also it should give a warning message when the length > 128 bytes. 

Version-Release number of selected component (if applicable):
libguestfs-1.20.11-11.el6


How reproducible:
100%


Steps to Reproduce:
1. # str="2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d"
   # echo ${#str}
180

2. #guestfish -N fs:btrfs
><fs> set-label  /dev/sda1 2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d
><fs> vfs-label /dev/sda1
2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955

# str2="2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955"
# echo ${#str2}
63

3. Check 'help set-label' in guestfish

4. # str="2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d"
   # echo ${#str}
180

5. #guestfish -N fs:ntfs
><fs> set-label  /dev/sda1 2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d
><fs> vfs-label /dev/sda1
2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955

# str2="2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955"
# echo ${#str2}
126

6. Check 'help set-label' in guestfish


Actual results:
At step 2, only get the first 127 bytes of the label name
At step 3, the limited number is 256 which is wrong
At step 5, only get the first 126 bytes of the label name


Expected results:
At step 2, i can get the right label name(180 bytes) when i run 'vfs-label /dev/sda1'
At step 3, the limited number should be 255
At step 5, can get the first 128 bytes of the label name when i run 'vfs-label /dev/sda1'

Additional info:

Comment 1 Richard W.M. Jones 2014-11-17 10:04:44 UTC
See my script and analysis starting here:
https://bugzilla.redhat.com/show_bug.cgi?id=1164708#c1

Comment 5 Xianghua Chen 2015-12-07 05:08:05 UTC
Verified with the packages:
libguestfs-1.20.11-16.el6.x86_64
libguestfs-winsupport-1.0-7.el6.x86_64


Verify steps:
1. # str="2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d"
# echo ${#str}
180

2. # guestfish -N fs:btrfs
><fs>  set-label  /dev/sda1 2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d
><fs>  vfs-label /dev/sda1
2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d
><fs> quit

Can get the right label name(180 bytes)

3. # str="2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d"
   # echo ${#str}
180

4. guestfish -N fs:ntfs
><fs> help set-label

You can find the following info is correct:
btrfs
        The label is limited to 255 bytes

><fs> set-label  /dev/sda1 2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d
><fs>  vfs-label /dev/sda1
2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-816c-955bf2c0b43d2c395734-c68b-4181-8
><fs> quit

Can get the first 128 bytes of the label name.


So verified.

Comment 7 errata-xmlrpc 2016-05-10 19:55:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0762.html