mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -11336,6 +11336,18 @@ silently create an ext2 filesystem instead." };
|
||||
name = "list_disk_labels"; added = (1, 19, 49);
|
||||
style = RHashtable "labels", [], [];
|
||||
proc_nr = Some 369;
|
||||
tests = [
|
||||
(* The test disks have no labels, so we can be sure there are
|
||||
* no labels. See in tests/disk-labels/ for tests checking
|
||||
* for actual disk labels.
|
||||
*
|
||||
* Also, we make use of the assumption that RHashtable is a
|
||||
* char*[] in C, so an empty hash has just a NULL element.
|
||||
*)
|
||||
InitScratchFS, Always, TestResult (
|
||||
[["list_disk_labels"]],
|
||||
"is_string_list (ret, 0)"), [];
|
||||
];
|
||||
shortdesc = "mapping of disk labels to devices";
|
||||
longdesc = "\
|
||||
If you add drives using the optional C<label> parameter
|
||||
|
||||
Reference in New Issue
Block a user