#include <rpc/types.h>
#include <rpc/xdr.h>
#include <getopt.h>
-#include <netdb.h>
#include <sys/param.h>
-#include <sys/select.h>
#include <sys/types.h>
-#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifdef HAVE_PRINTF_H
#include <printf.h>
+#endif
#include "c-ctype.h"
+#include "ignore-value.h"
+
#include "daemon.h"
static char *read_cmdline (void);
/* 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;
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);
/* 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;
*/
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];
}
if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; }
- if (r > 0 && stderror) {
- se_size += r;
- p = realloc (*stderror, se_size);
- if (p == NULL) {
- perror ("realloc");
- goto 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);
}
- *stderror = p;
- memcpy (*stderror + se_size - r, buf, r);
}
}
}
int size = 0, alloc = 0;
char *p, *pend;
- if (strcmp (str, "") == 0)
+ if (STREQ (str, ""))
goto empty_list;
p = str;
}
/* 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) */
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:
+ ;
+ }
}