X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fguestfsd.c;h=9375ede2785481718f4067fe5db68eea0bee3a98;hb=c477e2fb78347728aaacbbc89666dcda1481a4b9;hp=370eea8ddcdabc668804dd4e307cadbc1fbdfd8a;hpb=a25d175cf6e8283288fd6d209b37b09ffee0dcf3;p=libguestfs.git diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 370eea8..9375ede 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -226,7 +226,7 @@ main (int argc, char *argv[]) /* Connect to vmchannel. */ int sock = -1; - if (strncmp (vmchannel, "tcp:", 4) == 0) { + if (STREQLEN (vmchannel, "tcp:", 4)) { /* Resolve the hostname. */ struct addrinfo *res, *rr; struct addrinfo hints; @@ -548,7 +548,7 @@ commandf (char **stdoutput, char **stderror, int flags, const char *name, ...) va_end (args); - r = commandvf (stdoutput, stderror, flags, (char **) argv); + r = commandvf (stdoutput, stderror, flags, (const char * const*) argv); /* NB: Mustn't free the strings which are on the stack. */ free (argv); @@ -605,7 +605,8 @@ commandrf (char **stdoutput, char **stderror, int flags, const char *name, ...) /* Same as 'command', but passing an argv. */ int -commandvf (char **stdoutput, char **stderror, int flags, char *const *argv) +commandvf (char **stdoutput, char **stderror, int flags, + char const *const *argv) { int r; @@ -640,7 +641,7 @@ commandvf (char **stdoutput, char **stderror, int flags, char *const *argv) */ int commandrvf (char **stdoutput, char **stderror, int flags, - char const* const *argv) + char const* const *argv) { int so_size = 0, se_size = 0; int so_fd[2], se_fd[2]; @@ -745,19 +746,19 @@ commandrvf (char **stdoutput, char **stderror, int flags, if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; } if (r > 0) { - if (verbose) - ignore_value (write (2, buf, r)); - - if (stderror) { - se_size += r; - p = realloc (*stderror, se_size); - if (p == NULL) { - perror ("realloc"); - goto quit; - } - *stderror = p; - memcpy (*stderror + se_size - r, buf, r); - } + if (verbose) + ignore_value (write (2, buf, r)); + + if (stderror) { + se_size += r; + p = realloc (*stderror, se_size); + if (p == NULL) { + perror ("realloc"); + goto quit; + } + *stderror = p; + memcpy (*stderror + se_size - r, buf, r); + } } } } @@ -830,7 +831,7 @@ split_lines (char *str) int size = 0, alloc = 0; char *p, *pend; - if (strcmp (str, "") == 0) + if (STREQ (str, "")) goto empty_list; p = str; @@ -944,7 +945,7 @@ device_name_translation (char *device, const char *func) } /* If the name begins with "/dev/sd" then try the alternatives. */ - if (strncmp (device, "/dev/sd", 7) != 0) + if (STRNEQLEN (device, "/dev/sd", 7)) goto error; device[5] = 'h'; /* /dev/hd (old IDE driver) */ @@ -975,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: + ; + } }