|
|
ffd6ed |
From 0c4c35fc3efe4a82b644dfff8e93119fd10ff5a4 Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
ffd6ed |
Date: Wed, 14 Jan 2015 18:59:57 +0100
|
|
|
ffd6ed |
Subject: [PATCH] daemon: use ntfslabel(1) to get ntfs labels
|
|
|
ffd6ed |
|
|
|
ffd6ed |
blkid(1) (or actually, libblkid) seems to handle filesystem labels up
|
|
|
ffd6ed |
to 127 characters. Considering that btrfs labels can be up to 128
|
|
|
ffd6ed |
characters, this means long labels are not read correctly (i.e. get
|
|
|
ffd6ed |
truncated) by blkid. Furthermore, ntfs labels are actually unicode,
|
|
|
ffd6ed |
and libblkid seems to not decode them correctly.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Hence, if ntfsprogs is available invoke `ntfslabel` to get the label
|
|
|
ffd6ed |
of ntfs filesystems.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Related to RHBZ#1164708.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 8ad667f1983e98347f4d292c07f971d5362ff052)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
daemon/blkid.c | 2 ++
|
|
|
ffd6ed |
daemon/daemon.h | 3 +++
|
|
|
ffd6ed |
daemon/ntfs.c | 24 ++++++++++++++++++++++++
|
|
|
ffd6ed |
3 files changed, 29 insertions(+)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/daemon/blkid.c b/daemon/blkid.c
|
|
|
ffd6ed |
index e8e7b58..1ac42b4 100644
|
|
|
ffd6ed |
--- a/daemon/blkid.c
|
|
|
ffd6ed |
+++ b/daemon/blkid.c
|
|
|
ffd6ed |
@@ -82,6 +82,8 @@ do_vfs_label (const mountable_t *mountable)
|
|
|
ffd6ed |
if (type) {
|
|
|
ffd6ed |
if (STREQ (type, "btrfs") && optgroup_btrfs_available ())
|
|
|
ffd6ed |
return btrfs_get_label (mountable->device);
|
|
|
ffd6ed |
+ if (STREQ (type, "ntfs") && optgroup_ntfsprogs_available ())
|
|
|
ffd6ed |
+ return ntfs_get_label (mountable->device);
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
|
|
|
ffd6ed |
return get_blkid_tag (mountable->device, "LABEL");
|
|
|
ffd6ed |
diff --git a/daemon/daemon.h b/daemon/daemon.h
|
|
|
ffd6ed |
index 24ee46a..e65bcb0 100644
|
|
|
ffd6ed |
--- a/daemon/daemon.h
|
|
|
ffd6ed |
+++ b/daemon/daemon.h
|
|
|
ffd6ed |
@@ -260,6 +260,9 @@ extern int copy_xattrs (const char *src, const char *dest);
|
|
|
ffd6ed |
/*-- in btrfs.c --*/
|
|
|
ffd6ed |
extern char *btrfs_get_label (const char *device);
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+/*-- in ntfs.c --*/
|
|
|
ffd6ed |
+extern char *ntfs_get_label (const char *device);
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
/* ordinary daemon functions use these to indicate errors
|
|
|
ffd6ed |
* NB: you don't need to prefix the string with the current command,
|
|
|
ffd6ed |
* it is added automatically by the client-side RPC stubs.
|
|
|
ffd6ed |
diff --git a/daemon/ntfs.c b/daemon/ntfs.c
|
|
|
ffd6ed |
index 762ca88..f1d12e0 100644
|
|
|
ffd6ed |
--- a/daemon/ntfs.c
|
|
|
ffd6ed |
+++ b/daemon/ntfs.c
|
|
|
ffd6ed |
@@ -33,6 +33,7 @@
|
|
|
ffd6ed |
GUESTFSD_EXT_CMD(str_ntfs3g_probe, ntfs-3g.probe);
|
|
|
ffd6ed |
GUESTFSD_EXT_CMD(str_ntfsresize, ntfsresize);
|
|
|
ffd6ed |
GUESTFSD_EXT_CMD(str_ntfsfix, ntfsfix);
|
|
|
ffd6ed |
+GUESTFSD_EXT_CMD(str_ntfslabel, ntfslabel);
|
|
|
ffd6ed |
|
|
|
ffd6ed |
int
|
|
|
ffd6ed |
optgroup_ntfs3g_available (void)
|
|
|
ffd6ed |
@@ -46,6 +47,29 @@ optgroup_ntfsprogs_available (void)
|
|
|
ffd6ed |
return prog_exists (str_ntfsresize);
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+char *
|
|
|
ffd6ed |
+ntfs_get_label (const char *device)
|
|
|
ffd6ed |
+{
|
|
|
ffd6ed |
+ int r;
|
|
|
ffd6ed |
+ CLEANUP_FREE char *err = NULL;
|
|
|
ffd6ed |
+ char *out = NULL;
|
|
|
ffd6ed |
+ size_t len;
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ r = command (&out, &err, str_ntfslabel, device, NULL);
|
|
|
ffd6ed |
+ if (r == -1) {
|
|
|
ffd6ed |
+ reply_with_error ("%s", err);
|
|
|
ffd6ed |
+ free (out);
|
|
|
ffd6ed |
+ return NULL;
|
|
|
ffd6ed |
+ }
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ /* Trim trailing \n if present. */
|
|
|
ffd6ed |
+ len = strlen (out);
|
|
|
ffd6ed |
+ if (len > 0 && out[len-1] == '\n')
|
|
|
ffd6ed |
+ out[len-1] = '\0';
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ return out;
|
|
|
ffd6ed |
+}
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
int
|
|
|
ffd6ed |
do_ntfs_3g_probe (int rw, const char *device)
|
|
|
ffd6ed |
{
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|