On Tue, Feb 17, 2015 at 12:06 AM, Oliver Neukum <oneu...@suse.de> wrote: > > On Mon, 2015-02-16 at 14:52 -0800, Hans Scholze wrote: > > Hi, > > > > > > I'm not sure if this is considered a problem but I noticed some > > spurious error messages during boot. The source appears to be: > > > > > > 1. a USB media card reader is plugged in at boot > > 2. the device node exists regardless of whether a card is present > > (expected) > > 3. line 70 of 60-persistent-storage.rules (KERNEL!="sr*", > > IMPORT{builtin}="blkid") attempts blkid on the device with no card > > present > > 4. the open() call in builtin_blkid() in udev-builtin-blkid.c fails > > resulting in an "error: /dev/sdd: No medium found" message printed to > > stderr > > > That seems to be the error. You cannot guarantee that blkid will never > see this error if the drive has removable media. It should have an > option for silently failing in these cases.
Sounds like a good idea to me but I am not too familiar with the code. How about this?
From 8e1994f37169a95134a73a21efecceb1a13cc28a Mon Sep 17 00:00:00 2001 From: Hans Scholze <hans.scho...@gmail.com> Date: Wed, 18 Feb 2015 23:13:12 -0800 Subject: [PATCH 1/2] Add option to silently ignore ENOMEDIUM to udev builtin blkid. --- src/udev/udev-builtin-blkid.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 810f27d..ac70827 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -217,6 +217,7 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t const char *root_partition; int64_t offset = 0; bool noraid = false; + bool ignore_enomedium = false; _cleanup_close_ int fd = -1; blkid_probe pr; const char *data; @@ -229,13 +230,14 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t static const struct option options[] = { { "offset", optional_argument, NULL, 'o' }, { "noraid", no_argument, NULL, 'R' }, + { "ignore-enomedium", no_argument, NULL, 'q' }, {} }; for (;;) { int option; - option = getopt_long(argc, argv, "oR", options, NULL); + option = getopt_long(argc, argv, "oRq", options, NULL); if (option == -1) break; @@ -246,6 +248,9 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t case 'R': noraid = true; break; + case 'q': + ignore_enomedium = true; + break; } } @@ -263,7 +268,8 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t fd = open(udev_device_get_devnode(dev), O_RDONLY|O_CLOEXEC); if (fd < 0) { - fprintf(stderr, "error: %s: %m\n", udev_device_get_devnode(dev)); + if(!(ignore_enomedium && errno == ENOMEDIUM)) + fprintf(stderr, "error: %s: %m\n", udev_device_get_devnode(dev)); goto out; } -- 2.3.0
From 73992d2ee525a3fccf476c15f2522259027ca59e Mon Sep 17 00:00:00 2001 From: Hans Scholze <hans.scho...@gmail.com> Date: Wed, 18 Feb 2015 23:14:30 -0800 Subject: [PATCH 2/2] Ignore ENOMEDIUM in blkidduring persistent storage naming to prevent empty removable devices from causing spurious error messages. --- rules/60-persistent-storage.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules index 475b151..3ba4fcd 100644 --- a/rules/60-persistent-storage.rules +++ b/rules/60-persistent-storage.rules @@ -67,7 +67,7 @@ KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DAT IMPORT{builtin}="blkid --noraid" # probe filesystem metadata of disks -KERNEL!="sr*", IMPORT{builtin}="blkid" +KERNEL!="sr*", IMPORT{builtin}="blkid --ignore-enomedium" # watch metadata changes by tools closing the device after writing KERNEL!="sr*", OPTIONS+="watch" -- 2.3.0
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel