daemon: do not fail list-disk-labels w/o labels set

If there are no labels set for the disks, the directory with the
symlinks will not even exists, causing list-disk-labels to fail with
ENOENT.  In this situation, act as if the directory was there, but
empty.
This commit is contained in:
Pino Toscano
2016-03-02 14:42:02 +01:00
parent 4d4f16067e
commit e8408fe3c3
2 changed files with 19 additions and 0 deletions

View File

@@ -316,6 +316,13 @@ do_list_disk_labels (void)
dir = opendir (GUESTFSDIR);
if (!dir) {
if (errno == ENOENT) {
/* The directory does not exist, and usually this happens when
* there are no labels set. In this case, act as if the directory
* was empty.
*/
return empty_list ();
}
reply_with_perror ("opendir: %s", GUESTFSDIR);
return NULL;
}