summaryrefslogtreecommitdiffstats
path: root/daemon/blkid.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/blkid.c')
-rw-r--r--daemon/blkid.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/daemon/blkid.c b/daemon/blkid.c
index 2885a8f3..f6310611 100644
--- a/daemon/blkid.c
+++ b/daemon/blkid.c
@@ -41,10 +41,13 @@ get_blkid_tag (const char *device, const char *tag)
unlink ("/etc/blkid/blkid.tab"); /* Red Hat, Fedora */
unlink ("/etc/blkid.tab"); /* Debian */
- r = command (&out, &err,
- "blkid", "-o", "value", "-s", tag, device, NULL);
- if (r == -1) {
- reply_with_error ("%s: %s", device, err);
+ r = commandr (&out, &err,
+ "blkid", "-o", "value", "-s", tag, device, NULL);
+ if (r != 0 && r != 2) {
+ if (r >= 0)
+ reply_with_error ("%s: %s (blkid returned %d)", device, err, r);
+ else
+ reply_with_error ("%s: %s", device, err);
free (out);
free (err);
return NULL;
@@ -52,6 +55,14 @@ get_blkid_tag (const char *device, const char *tag)
free (err);
+ if (r == 2) { /* means UUID etc not found */
+ free (out);
+ out = strdup ("");
+ if (out == NULL)
+ reply_with_perror ("strdup");
+ return out;
+ }
+
/* Trim trailing \n if present. */
size_t len = strlen (out);
if (len > 0 && out[len-1] == '\n')