mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: use ntfslabel(1) to get ntfs labels
blkid(1) (or actually, libblkid) seems to handle filesystem labels up to 127 characters. Considering that btrfs labels can be up to 128 characters, this means long labels are not read correctly (i.e. get truncated) by blkid. Furthermore, ntfs labels are actually unicode, and libblkid seems to not decode them correctly. Hence, if ntfsprogs is available invoke `ntfslabel` to get the label of ntfs filesystems. Related to RHBZ#1164708.
This commit is contained in:
@@ -82,6 +82,8 @@ do_vfs_label (const mountable_t *mountable)
|
||||
if (type) {
|
||||
if (STREQ (type, "btrfs") && optgroup_btrfs_available ())
|
||||
return btrfs_get_label (mountable->device);
|
||||
if (STREQ (type, "ntfs") && optgroup_ntfsprogs_available ())
|
||||
return ntfs_get_label (mountable->device);
|
||||
}
|
||||
|
||||
return get_blkid_tag (mountable->device, "LABEL");
|
||||
|
||||
@@ -265,6 +265,9 @@ extern char *debug_bmap_device (const char *subcmd, size_t argc, char *const *co
|
||||
/*-- in btrfs.c --*/
|
||||
extern char *btrfs_get_label (const char *device);
|
||||
|
||||
/*-- in ntfs.c --*/
|
||||
extern char *ntfs_get_label (const char *device);
|
||||
|
||||
/* ordinary daemon functions use these to indicate errors
|
||||
* NB: you don't need to prefix the string with the current command,
|
||||
* it is added automatically by the client-side RPC stubs.
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
GUESTFSD_EXT_CMD(str_ntfs3g_probe, ntfs-3g.probe);
|
||||
GUESTFSD_EXT_CMD(str_ntfsresize, ntfsresize);
|
||||
GUESTFSD_EXT_CMD(str_ntfsfix, ntfsfix);
|
||||
GUESTFSD_EXT_CMD(str_ntfslabel, ntfslabel);
|
||||
|
||||
int
|
||||
optgroup_ntfs3g_available (void)
|
||||
@@ -46,6 +47,29 @@ optgroup_ntfsprogs_available (void)
|
||||
return prog_exists (str_ntfsresize);
|
||||
}
|
||||
|
||||
char *
|
||||
ntfs_get_label (const char *device)
|
||||
{
|
||||
int r;
|
||||
CLEANUP_FREE char *err = NULL;
|
||||
char *out = NULL;
|
||||
size_t len;
|
||||
|
||||
r = command (&out, &err, str_ntfslabel, device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("%s", err);
|
||||
free (out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Trim trailing \n if present. */
|
||||
len = strlen (out);
|
||||
if (len > 0 && out[len-1] == '\n')
|
||||
out[len-1] = '\0';
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
int
|
||||
do_ntfs_3g_probe (int rw, const char *device)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user