Richard W.M. Jones
2009-Nov-18 16:05 UTC
[Libguestfs] [PATCH] daemon/RHEL: Choose correct udev settle script.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw -------------- next part -------------->From 018e8b562b3980a002bd2f9c42cf7dab541ac005 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at centos5x32.home.annexia.org> Date: Wed, 18 Nov 2009 16:02:53 +0000 Subject: [PATCH] daemon/RHEL: Choose correct udev settle script. On RHEL/CentOS 5.4, udevadm settle command does not work. This didn't affect us before, but now that we're using parted for partitioning, we *do* need to wait for udev to settle (because parted isn't waiting for this, unlike sfdisk). This commit chooses the correct program to run. --- daemon/guestfsd.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index db0bff9..9375ede 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -976,5 +976,25 @@ device_name_translation (char *device, const char *func) void udev_settle (void) { - command (NULL, NULL, "/sbin/udevadm", "settle", NULL); + static int which_prog = 0; + + if (which_prog == 0) { + if (access ("/sbin/udevsettle", X_OK) == 0) + which_prog = 2; + else if (access ("/sbin/udevadm", X_OK) == 0) + which_prog = 1; + else + which_prog = 3; + } + + switch (which_prog) { + case 1: + command (NULL, NULL, "/sbin/udevadm", "settle", NULL); + break; + case 2: + command (NULL, NULL, "/sbin/udevsettle", NULL); + break; + default: + ; + } } -- 1.5.5.6
Jim Meyering
2009-Nov-18 17:50 UTC
[Libguestfs] [PATCH] daemon/RHEL: Choose correct udev settle script.
Richard W.M. Jones wrote:> Subject: [PATCH] daemon/RHEL: Choose correct udev settle script. > > On RHEL/CentOS 5.4, udevadm settle command does not work. This didn't > affect us before, but now that we're using parted for partitioning, we > *do* need to wait for udev to settle (because parted isn't waiting for > this, unlike sfdisk). > > This commit chooses the correct program to run. > --- > daemon/guestfsd.c | 22 +++++++++++++++++++++- > 1 files changed, 21 insertions(+), 1 deletions(-) > > diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c > index db0bff9..9375ede 100644 > --- a/daemon/guestfsd.c > +++ b/daemon/guestfsd.c > @@ -976,5 +976,25 @@ device_name_translation (char *device, const char *func) > void > udev_settle (void) > { > - command (NULL, NULL, "/sbin/udevadm", "settle", NULL); > + static int which_prog = 0; > + > + if (which_prog == 0) { > + if (access ("/sbin/udevsettle", X_OK) == 0) > + which_prog = 2; > + else if (access ("/sbin/udevadm", X_OK) == 0) > + which_prog = 1; > + else > + which_prog = 3; > + } > + switch (which_prog) { > + case 1: > + command (NULL, NULL, "/sbin/udevadm", "settle", NULL); > + break; > + case 2: > + command (NULL, NULL, "/sbin/udevsettle", NULL); > + break; > + default: > + ; > + }Looks fine. Only thought was "why bother with the static var and separate switch" just to save a call or two to access. If you're about to invoke one of those programs, the expense of a syscall is nil.
Maybe Matching Threads
- [PATCH] daemon: Work around udevsettle issue (RHBZ#548121).
- "connection refused", but server is listening
- [PATCH] appliance: Set $PATH instead of hard-coding paths to binaries everywhere.
- Re: Why libguestfs guest exist exceptionally?
- Re: Why libguestfs guest exist exceptionally?