Ignore the error ENXIO and ENOMEDIUM during a devs scan
authorGoffredo Baroncelli <kreijack@inwind.it>
Fri, 21 Oct 2011 17:00:28 +0000 (19:00 +0200)
committerDavid Sterba <dsterba@suse.cz>
Fri, 18 Jan 2013 17:25:50 +0000 (18:25 +0100)
Ignore the error ENXIO (device don't exists) and ENOMEDIUM (
No medium found -> like a cd tray empty) in the function
btrfs_scan_one_dir.
This avoids spurios errors due to an empty CD or a block device node
without a device (which is frequent in a static /dev).

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
utils.c

diff --git a/utils.c b/utils.c
index 938f9a5..8e1e66c 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -1016,8 +1016,14 @@ again:
                }
                fd = open(fullpath, O_RDONLY);
                if (fd < 0) {
-                       fprintf(stderr, "failed to read %s: %s\n", fullpath,
-                                       strerror(errno));
+                       /* ignore the following errors:
+                               ENXIO (device don't exists) 
+                               ENOMEDIUM (No medium found -> 
+                                       like a cd tray empty)
+                       */
+                       if(errno != ENXIO && errno != ENOMEDIUM) 
+                               fprintf(stderr, "failed to read %s: %s\n", 
+                                       fullpath, strerror(errno));
                        continue;
                }
                ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,