Bug 1164708
Summary: | set-label can only set <=127 bytes for btrfs and <=126 bytes for ntfs filesystem which not meet the help message. Also for ntfs it should give a warning message when the length >128 bytes | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Lingfei Kong <lkong> | ||||
Component: | libguestfs | Assignee: | Richard W.M. Jones <rjones> | ||||
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> | ||||
Severity: | low | Docs Contact: | |||||
Priority: | low | ||||||
Version: | 7.1 | CC: | kzak, leiwang, linl, mbooth, ptoscano, wshi, xchen | ||||
Target Milestone: | rc | ||||||
Target Release: | --- | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | libguestfs-1.32.0-2.el7 | Doc Type: | Bug Fix | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2016-11-03 17:47:18 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: | 1218766 | ||||||
Bug Blocks: | 1288337, 1301891 | ||||||
Attachments: |
|
Description
Lingfei Kong
2014-11-17 08:26:35 UTC
Created attachment 958200 [details]
test-label.pl
Attached is a useful script to test the behaviour of labels.
$ ./test-label.pl btrfs 0 256 ascii
0 ok
1 ok
2 ok
3 ok
4 ok
5 ok
[...]
125 ok
126 ok
127 ok
128 truncated to 127
129 truncated to 127
130 truncated to 127
131 truncated to 127
[...]
254 truncated to 127
255 truncated to 127
256 error setting label: set_label: ERROR: Label aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa is too long (max 255) at /tmp/test-label.pl line 36.
or:
$ ./test-label.pl btrfs 0 256 unicode
So using my script it looks as if the real limits are: - ext2/3/4: 16 bytes - btrfs: 127 bytes (this contradicts the btrfs documentation) - ntfs: behaviour is very strange, especially when using non-ASCII I'm not sure that libguestfs should be checking limits at all. It seems to invite trouble. We should just pass labels through to the underlying utilities and let them deal with error cases. (In reply to Richard W.M. Jones from comment #2) > So using my script it looks as if the real limits are: > > - ext2/3/4: 16 bytes > - btrfs: 127 bytes (this contradicts the btrfs documentation) > - ntfs: behaviour is very strange, especially when using non-ASCII > > I'm not sure that libguestfs should be checking limits at all. > It seems to invite trouble. We should just pass labels through > to the underlying utilities and let them deal with error cases. I have encountered many cases that a software auto truncate a long name without give a warning message, anyway extX, btrfs, xfs,ntfs should have the same behavior(give or not give warning messages) when the label length > limited number. (In reply to Richard W.M. Jones from comment #2) > So using my script it looks as if the real limits are: > > - btrfs: 127 bytes (this contradicts the btrfs documentation) This does not seem a bug in btrfs, but rather in util-linux. If I change vfs_label to use `btrfs filesystem label` to get the label of a btrfs filesystem, I get the correct result, not truncated. I'm going to post a patch to use `btrfs` to get the label of btrfs filesystems, if present; this should give the actual value. I'll deal with util-linux later, as it seems libblkid cannot cope with file system labels longer than 127 characters. Added to libblkid TODO, will be fixed later this year (I guess it's no urgent issue). (In reply to Pino Toscano from comment #4) > I'm going to post a patch to use `btrfs` to get the label of btrfs > filesystems, if present; this should give the actual value. Patch posted: https://www.redhat.com/archives/libguestfs/2015-January/msg00037.html (In reply to Richard W.M. Jones from comment #2) > So using my script it looks as if the real limits are: > > - ntfs: behaviour is very strange, especially when using non-ASCII This is another issue in util-linux, as it seems (at least with util-linux 2.24.x) it does not decode the label (the volume name, actually) correctly. If I change vfs_label to use `ntfslabel` for getting the label of ntfs filesystems, then I get the correct result, which is at most 128 unicode characters as stated in the man page. Unfortunately, even ntfslabel (at least as part of ntfsprogs/ntfs-3g 2014.2.15-1.fc20) silently truncates to the maximum, printing a warning and still exiting with 0... https://github.com/libguestfs/libguestfs/commit/6db3c100e7c18820ff9ecc22415940eb5fedc64e this uses btrfs(1) for btrfs partitions https://github.com/libguestfs/libguestfs/commit/8ad667f1983e98347f4d292c07f971d5362ff052 this uses ntfslabel(1) for ntfs partitions Not fixed completely. Test with libguestfs-1.28.1-1.29.el7. Step to verify: 1. For btrfs, the 'help set-label' in guestfish says that The label is limited to 256 bytes. Now from the result following, we can only set a label with 255 bytes. So need some modification here. # ./test-label.pl btrfs 0 256 ascii 0 ok 1 ok 2 ok ... 253 ok 254 ok 255 ok 256 error setting label: set_label: ERROR: Label aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa is too long (max 255) at ./test-label.pl line 36. 2. For ntfs, works well now. # ./test-label.pl ntfs 0 129 unicode 0 ok 1 ok 2 ok ... 127 ok 128 ok 129 truncated to 384 So, for btrfs, the limited number is 256 which is wrong. Move to RHEL 7.3 since we don't have a working upstream fix yet. (In reply to Hu Zhang from comment #12) > 1. For btrfs, the 'help set-label' in guestfish says that The label is > limited to 256 bytes. Now from the result following, we can only set a label > with 255 bytes. So need some modification here. We don't do checks on btrfs labels, as luckly the btrfs tools (e.g. `btrfs filesystem label`) do proper checks on their own, issuing errors (unlike tools for most of the other filesystems for which we can set labels). This is just a documentation issue for set-label, and I've just pushed https://github.com/libguestfs/libguestfs/commit/1f47ba92f20b812c8fe2fd6359b648863a8bcac4 which is in libguestfs >= 1.31.11. Verified with the packages:
libguestfs-1.32.5-6.el7.x86_64
Verify steps:
1. # ./test-label.pl ntfs 0 129 unicode
0 ok
1 ok
2 ok
...
127 ok
128 ok
129 truncated to 384
It's ok.
2. # guestfish
><fs> help set-label
btrfs
The label is limited to 255 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.
It has been changed to 255 from 256.
So verified.
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/RHSA-2016-2576.html |