--- /dev/null
+^.*\.java$
+^.*\.pl$
printf ("Result11-1\nResult11-2");
} else {
fprintf (stderr, "unknown parameter: %s\n", argv[1]);
- exit (1);
+ exit (EXIT_FAILURE);
}
} else {
fprintf (stderr, "missing parameter\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
- exit (0);
+ exit (EXIT_SUCCESS);
}
case '?':
usage ();
- exit (0);
+ exit (EXIT_SUCCESS);
default:
fprintf (stderr, "guestfsd: unexpected command line option 0x%x\n", c);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
if (optind < argc) {
usage ();
- exit (1);
+ exit (EXIT_FAILURE);
}
cmdline = read_cmdline ();
vmchannel = strndup (p + 18, len);
if (!vmchannel) {
perror ("strndup");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
vmchannel = strndup (p + 4, len);
if (!vmchannel) {
perror ("strndup");
- exit (1);
+ exit (EXIT_FAILURE);
}
memcpy (vmchannel, "tcp:", 4);
}
vmchannel = strdup ("tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT);
if (!vmchannel) {
perror ("strdup");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
} else {
fprintf (stderr, "vmchannel: expecting \"tcp:<ip>:<port>\": %s\n",
vmchannel);
- exit (1);
+ exit (EXIT_FAILURE);
}
memset (&hints, 0, sizeof hints);
if (r != 0) {
fprintf (stderr, "%s:%s: %s\n",
host, port, gai_strerror (r));
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Connect to the given TCP socket. */
"unknown vmchannel connection type: %s\n"
"expecting \"tcp:<ip>:<port>\"\n",
vmchannel);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (sock == -1) {
"or on the libguestfs redhat com mailing list.\n"
"\n",
vmchannel);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Send the magic length message which indicates that
xdr_uint32_t (&xdr, &len);
if (xwrite (sock, lenbuf, sizeof lenbuf) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
xdr_destroy (&xdr);
if (!dont_fork) {
if (daemon (0, 1) == -1) {
perror ("daemon");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
/* Enter the main loop, reading and performing actions. */
main_loop (sock);
- exit (0);
+ exit (EXIT_SUCCESS);
}
/* Read /proc/cmdline. */
/* Read the length word. */
if (xread (sock, lenbuf, 4) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
xdrmem_create (&xdr, lenbuf, 4, XDR_DECODE);
xdr_uint32_t (&xdr, &len);
if (len > GUESTFS_MESSAGE_MAX) {
fprintf (stderr, "guestfsd: incoming message is too long (%u bytes)\n",
len);
- exit (1);
+ exit (EXIT_FAILURE);
}
buf = malloc (len);
}
if (xread (sock, buf, len) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
#ifdef ENABLE_PACKET_DUMP
if (verbose) {
xdrmem_create (&xdr, buf, len, XDR_DECODE);
if (!xdr_guestfs_message_header (&xdr, &hdr)) {
fprintf (stderr, "guestfsd: could not decode message header\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Check the version etc. */
if (!xdr_guestfs_message_header (&xdr, &hdr)) {
fprintf (stderr, "guestfsd: failed to encode error message header\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
err.error_message = (char *) msg;
if (!xdr_guestfs_message_error (&xdr, &err)) {
fprintf (stderr, "guestfsd: failed to encode error message body\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
len = xdr_getpos (&xdr);
if (xwrite (sock, lenbuf, 4) == -1) {
fprintf (stderr, "xwrite failed\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (xwrite (sock, buf, len) == -1) {
fprintf (stderr, "xwrite failed\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
if (!xdr_guestfs_message_header (&xdr, &hdr)) {
fprintf (stderr, "guestfsd: failed to encode reply header\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (xdrp) {
if (xwrite (sock, lenbuf, 4) == -1) {
fprintf (stderr, "xwrite failed\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (xwrite (sock, buf, len) == -1) {
fprintf (stderr, "xwrite failed\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
for (;;) {
/* Read the length word. */
if (xread (sock, lenbuf, 4) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
xdrmem_create (&xdr, lenbuf, 4, XDR_DECODE);
xdr_uint32_t (&xdr, &len);
if (len > GUESTFS_MESSAGE_MAX) {
fprintf (stderr, "guestfsd: incoming message is too long (%u bytes)\n",
len);
- exit (1);
+ exit (EXIT_FAILURE);
}
buf = malloc (len);
}
if (xread (sock, buf, len) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
xdrmem_create (&xdr, buf, len, XDR_DECODE);
memset (&chunk, 0, sizeof chunk);
&& xwrite (sock, buf, len) == 0 ? 0 : -1);
if (err) {
fprintf (stderr, "send_chunk: write failed\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
return err;
if (argc != 3 || access (argv[1], F_OK) != 0) {
fprintf (stderr, "Usage: hello disk-image partition\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
- if (!(g = guestfs_create ())) exit (1);
+ if (!(g = guestfs_create ())) exit (EXIT_FAILURE);
- if (guestfs_add_drive (g, argv[1]) == -1) exit (1);
+ if (guestfs_add_drive (g, argv[1]) == -1) exit (EXIT_FAILURE);
- if (guestfs_launch (g) == -1) exit (1);
+ if (guestfs_launch (g) == -1) exit (EXIT_FAILURE);
- if (guestfs_mount (g, argv[2], "/") == -1) exit (1);
+ if (guestfs_mount (g, argv[2], "/") == -1) exit (EXIT_FAILURE);
- if (guestfs_touch (g, "/hello") == -1) exit (1);
+ if (guestfs_touch (g, "/hello") == -1) exit (EXIT_FAILURE);
guestfs_sync (g);
guestfs_close (g);
* to stderr already.
*/
#define CALL(call,errcode) \
- if ((call) == (errcode)) exit (1);
+ if ((call) == (errcode)) exit (EXIT_FAILURE);
static void display_partition (guestfs_h *g, const char *dev);
static void display_partitions (guestfs_h *g, const char *dev);
if (argc < 2 || access (argv[1], F_OK) != 0) {
fprintf (stderr, "Usage: to-xml guest.img [guest.img ...]\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (!(g = guestfs_create ())) {
fprintf (stderr, "Cannot create libguestfs handle.\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
for (i = 1; i < argc; ++i)
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr, _("guestfs_create: failed to create handle\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
guestfs_set_autosync (g, 1);
if (sscanf (optarg, "%d", &remote_control) != 1) {
fprintf (stderr, _("%s: --listen=PID: PID was not a number: %s\n"),
program_name, optarg);
- exit (1);
+ exit (EXIT_FAILURE);
}
} else {
p = getenv ("GUESTFISH_PID");
fprintf (stderr, _("%s: remote: $GUESTFISH_PID must be set"
" to the PID of the remote process\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
} else if (STREQ (long_options[option_index].name, "selinux")) {
} else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
- exit (1);
+ exit (EXIT_FAILURE);
}
break;
case 'a':
if (access (optarg, R_OK) != 0) {
perror (optarg);
- exit (1);
+ exit (EXIT_FAILURE);
}
drv = malloc (sizeof (struct drv));
if (!drv) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
drv->filename = optarg;
drv->next = drvs;
if (file) {
fprintf (stderr, _("%s: only one -f parameter can be given\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
file = optarg;
break;
display_command (argv[optind++]);
else
list_commands ();
- exit (0);
+ exit (EXIT_SUCCESS);
case 'i':
inspector = 1;
mp = malloc (sizeof (struct mp));
if (!mp) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
p = strchr (optarg, ':');
if (p) {
case 'V':
printf ("%s %s\n", program_name, PACKAGE_VERSION);
- exit (0);
+ exit (EXIT_SUCCESS);
case 'x':
echo_commands = 1;
fprintf (stderr, _("%s: cannot use -i option with -a, -m,"
" --listen, --remote or --selinux\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (optind >= argc) {
fprintf (stderr,
_("%s: -i requires a libvirt domain or path(s) to disk image(s)\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
strcpy (cmd, "a=`virt-inspector");
fprintf (stderr,
_("%s: virt-inspector command too long for fixed-size buffer\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
strcat (cmd, " '");
strcat (cmd, argv[optind]);
r = system (cmd);
if (r == -1) {
perror ("system");
- exit (1);
+ exit (EXIT_FAILURE);
}
exit (WEXITSTATUS (r));
}
/* If we've got mountpoints, we must launch the guest and mount them. */
if (mps != NULL) {
- if (launch (g) == -1) exit (1);
+ if (launch (g) == -1) exit (EXIT_FAILURE);
mount_mps (mps);
}
fprintf (stderr,
_("%s: cannot use --listen and --remote options at the same time\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (remote_control_listen) {
fprintf (stderr,
_("%s: extra parameters on the command line with --listen flag\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (file) {
fprintf (stderr,
_("%s: cannot use --listen and --file options at the same time\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
rc_listen ();
}
close (0);
if (open (file, O_RDONLY) == -1) {
perror (file);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
cleanup_readline ();
- exit (0);
+ exit (EXIT_SUCCESS);
}
void
else
r = guestfs_mount_ro (g, mp->device, mp->mountpoint);
if (r == -1)
- exit (1);
+ exit (EXIT_FAILURE);
}
}
else
r = guestfs_add_drive_ro (g, drv->filename);
if (r == -1)
- exit (1);
+ exit (EXIT_FAILURE);
}
}
(WIFSIGNALED (r) &&
(WTERMSIG (r) == SIGINT || WTERMSIG (r) == SIGQUIT)) ||
WEXITSTATUS (r) != 0)
- exit (1);
+ exit (EXIT_FAILURE);
}
continue;
}
len = strcspn (p, "\"");
if (p[len] == '\0') {
fprintf (stderr, _("%s: unterminated double quote\n"), program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t')) {
fprintf (stderr,
_("%s: command arguments not separated by whitespace\n"),
program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
p[len] = '\0';
len = strcspn (p, "'");
if (p[len] == '\0') {
fprintf (stderr, _("%s: unterminated single quote\n"), program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t')) {
fprintf (stderr,
_("%s: command arguments not separated by whitespace\n"),
program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
p[len] = '\0';
if (c != 0) {
fprintf (stderr,
_("%s: unterminated \"[...]\" sequence\n"), program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
if (*pend && (*pend != ' ' && *pend != '\t')) {
fprintf (stderr,
_("%s: command arguments not separated by whitespace\n"),
program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
*(pend-1) = '\0';
if (i == sizeof argv / sizeof argv[0]) {
fprintf (stderr, _("%s: too many arguments\n"), program_name);
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
goto next_command;
}
got_command:
if (issue_command (cmd, argv, pipe) == -1) {
- if (exit_on_error) exit (1);
+ if (exit_on_error) exit (EXIT_FAILURE);
}
next_command:;
cmd = argv[optind++];
if (STREQ (cmd, ":")) {
fprintf (stderr, _("%s: empty command on command line\n"), program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
params = &argv[optind];
optind++;
if (optind == argc) {
- if (issue_command (cmd, params, NULL) == -1) exit (1);
+ if (issue_command (cmd, params, NULL) == -1) exit (EXIT_FAILURE);
} else {
argv[optind] = NULL;
- if (issue_command (cmd, params, NULL) == -1) exit (1);
+ if (issue_command (cmd, params, NULL) == -1) exit (EXIT_FAILURE);
cmdline (argv, optind+1, argc);
}
}
perror ("realloc");
free_n_strings (argv, argv_len);
free (tok);
- exit (1);
+ exit (EXIT_FAILURE);
}
tok = tok_new;
perror ("realloc");
free_n_strings (argv, argv_len-1);
free (tok);
- exit (1);
+ exit (EXIT_FAILURE);
}
argv = argv_new;
if (NULL == argv_new) {
perror ("realloc");
free_n_strings (argv, argv_len-1);
- exit (1);
+ exit (EXIT_FAILURE);
}
argv = argv_new;
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
ssize_t n = recvmsg (s, &msg, 0);
if (n < 0) {
perror ("recvmsg stdout fd");
- exit (1);
+ exit (EXIT_FAILURE);
}
h = CMSG_FIRSTHDR(&msg);
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
cmptr->cmsg_level = SOL_SOCKET;
if (sendmsg (s, &msg, 0) != 1) {
perror ("sendmsg stdout fd");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
pid = fork ();
if (pid == -1) {
perror ("fork");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (pid > 0) {
sock = socket (AF_UNIX, SOCK_STREAM, 0);
if (sock == -1) {
perror ("socket");
- exit (1);
+ exit (EXIT_FAILURE);
}
unlink (sockpath);
if (bind (sock, (struct sockaddr *) &addr, sizeof addr) == -1) {
perror (sockpath);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (listen (sock, 4) == -1) {
perror ("listen");
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Now close stdout and substitute /dev/null. This is necessary
argv = realloc (call.args.args_val, (argc+1) * sizeof (char *));
if (argv == NULL) {
perror ("realloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
call.args.args_val = argv;
argv[argc] = NULL;
/* Exit on error? */
if (call.exit_on_error && reply.r == -1) {
unlink (sockpath);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
}
unlink (sockpath);
- exit (0);
+ exit (EXIT_SUCCESS);
}
/* Remote control client. */
str = malloc (len);
if (str == NULL) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
strcpy (str, home);
strcat (str, rest);
str = malloc (len);
if (str == NULL) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
strcpy (str, home);
rlc_ht = hash_initialize (1024, NULL, gen_hash, gen_compare, rlc_free);
if (!lsc_ht || !xac_ht || !rlc_ht) {
fprintf (stderr, "guestmount: could not initialize dir cache hashtables\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
{
const char *tmp_argv[] = { program_name, "--help", NULL };
fuse_main (2, (char **) tmp_argv, &fg_operations, NULL);
- exit (0);
+ exit (EXIT_SUCCESS);
}
static void __attribute__((noreturn))
fuse_argv = realloc (fuse_argv, (1+fuse_argc) * sizeof (char *)); \
if (!fuse_argv) { \
perror ("realloc"); \
- exit (1); \
+ exit (EXIT_FAILURE); \
} \
fuse_argv[fuse_argc-1] = (str); \
fuse_argv[fuse_argc] = NULL; \
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr, _("guestfs_create: failed to create handle\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
guestfs_set_autosync (g, 1);
else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
- exit (1);
+ exit (EXIT_FAILURE);
}
break;
case 'a':
if (access (optarg, R_OK) != 0) {
perror (optarg);
- exit (1);
+ exit (EXIT_FAILURE);
}
drv = malloc (sizeof (struct drv));
if (!drv) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
drv->filename = optarg;
drv->next = drvs;
mp = malloc (sizeof (struct mp));
if (!mp) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
p = strchr (optarg, ':');
if (p) {
case 'V':
printf ("%s %s\n", program_name, PACKAGE_VERSION);
- exit (0);
+ exit (EXIT_SUCCESS);
case HELP_OPTION:
usage (0);
fprintf (stderr,
_("%s: must have at least one -a and at least one -m option\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* We'd better have a mountpoint. */
fprintf (stderr,
_("%s: you must specify a mountpoint in the host filesystem\n"),
program_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Do the guest drives and mountpoints. */
add_drives (drvs);
if (guestfs_launch (g) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
mount_mps (mps);
/* FUSE example does this, not clear if it's necessary, but ... */
if (guestfs_umask (g, 0) == -1)
- exit (1);
+ exit (EXIT_FAILURE);
/* At the last minute, remove the libguestfs error handler. In code
* above this point, the default error handler has been used which
else
r = guestfs_add_drive_ro (g, drv->filename);
if (r == -1)
- exit (1);
+ exit (EXIT_FAILURE);
}
}
else
r = guestfs_mount_ro (g, mp->device, mp->mountpoint);
if (r == -1)
- exit (1);
+ exit (EXIT_FAILURE);
}
}
{
if (argc < 3 || argc > 4) {
fprintf (stderr, "hivexget regfile path [key]\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
char *file = argv[1];
char *path = argv[2];
if (path[0] != '\\') {
fprintf (stderr, "hivexget: path must start with a \\ character\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (path[1] == '\\') {
doubled:
fprintf (stderr, "hivexget: %s: \\ characters in path are doubled - are you escaping the path parameter correctly?\n", path);
- exit (1);
+ exit (EXIT_FAILURE);
}
hive_h *h = hivex_open (file, 0);
if (h == NULL) {
error:
perror (file);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Navigate to the desired node. */
if (hivex_close (h) == -1)
goto error;
- exit (0);
+ exit (EXIT_SUCCESS);
}
do { \
if ((proc args) == -1) { \
fprintf (stderr, "%s: failed to write XML document\n", #proc); \
- exit (1); \
+ exit (EXIT_FAILURE); \
} \
} while (0)
break;
default:
fprintf (stderr, "hivexml [-dk] regfile > output.xml\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
if (optind + 1 != argc) {
fprintf (stderr, "hivexml: missing name of input file\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
hive_h *h = hivex_open (argv[optind], open_flags);
if (h == NULL) {
perror (argv[optind]);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Note both this macro, and xmlTextWriterStartDocument leak memory. There
writer = xmlNewTextWriterFilename ("/dev/stdout", 0);
if (writer == NULL) {
fprintf (stderr, "xmlNewTextWriterFilename: failed to create XML writer\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
XML_CHECK (xmlTextWriterStartDocument, (writer, NULL, "utf-8", NULL));
if (hivex_visit (h, &visitor, sizeof visitor, writer, visit_flags) == -1) {
perror (argv[optind]);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (hivex_close (h) == -1) {
perror (argv[optind]);
- exit (1);
+ exit (EXIT_FAILURE);
}
XML_CHECK (xmlTextWriterEndElement, (writer));
XML_CHECK (xmlTextWriterEndDocument, (writer));
xmlFreeTextWriter (writer);
- exit (0);
+ exit (EXIT_SUCCESS);
}
static int
g = guestfs_create ();
if (g == NULL) {
printf (\"guestfs_create FAILED\\n\");
- exit (1);
+ exit (EXIT_FAILURE);
}
guestfs_set_error_handler (g, print_error, NULL);
fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
if (fd == -1) {
perror (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (lseek (fd, %d, SEEK_SET) == -1) {
perror (\"lseek\");
close (fd);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (write (fd, &c, 1) == -1) {
perror (\"write\");
close (fd);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (close (fd) == -1) {
perror (filename);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_add_drive (g, filename) == -1) {
printf (\"guestfs_add_drive %%s FAILED\\n\", filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
filename = \"test2.img\";
fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
if (fd == -1) {
perror (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (lseek (fd, %d, SEEK_SET) == -1) {
perror (\"lseek\");
close (fd);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (write (fd, &c, 1) == -1) {
perror (\"write\");
close (fd);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (close (fd) == -1) {
perror (filename);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_add_drive (g, filename) == -1) {
printf (\"guestfs_add_drive %%s FAILED\\n\", filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
filename = \"test3.img\";
fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
if (fd == -1) {
perror (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (lseek (fd, %d, SEEK_SET) == -1) {
perror (\"lseek\");
close (fd);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (write (fd, &c, 1) == -1) {
perror (\"write\");
close (fd);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (close (fd) == -1) {
perror (filename);
unlink (filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_add_drive (g, filename) == -1) {
printf (\"guestfs_add_drive %%s FAILED\\n\", filename);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_add_drive_ro (g, \"../images/test.iso\") == -1) {
printf (\"guestfs_add_drive_ro ../images/test.iso FAILED\\n\");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_launch (g) == -1) {
printf (\"guestfs_launch FAILED\\n\");
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Set a timeout in case qemu hangs during launch (RHBZ#505329). */
pr " if (n_failed > 0) {\n";
pr " printf (\"***** %%lu / %%d tests FAILED *****\\n\", n_failed, nr_tests);\n";
- pr " exit (1);\n";
+ pr " exit (EXIT_FAILURE);\n";
pr " }\n";
pr "\n";
- pr " exit (0);\n";
+ pr " exit (EXIT_SUCCESS);\n";
pr "}\n"
and generate_one_test name i (init, prereq, test) =
if (mkdir ("/tmp", 0700) == -1) {
perror ("mkdir");
fprintf (stderr, "This program should not be run directly. Use libguestfs-test-tool instead.\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (geteuid () != 0) {
fprintf (stderr, "helper: This program doesn't appear to be running as root.\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (mkdir ("/tmp/helper", 0700) == -1) {
perror ("/tmp/helper");
- exit (1);
+ exit (EXIT_FAILURE);
}
fd = open ("/tmp/helper/a", O_CREAT|O_EXCL|O_WRONLY, 0600);
if (fd == -1) {
perror ("create /tmp/helper/a");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (write (fd, buffer, sizeof buffer) != sizeof buffer) {
perror ("write");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (close (fd) == -1) {
perror ("close");
- exit (1);
+ exit (EXIT_FAILURE);
}
- exit (0);
+ exit (EXIT_SUCCESS);
}
fprintf (stderr,
_("libguestfs-test-tool: unknown long option: %s (%d)\n"),
long_options[option_index].name, option_index);
- exit (1);
+ exit (EXIT_FAILURE);
}
break;
fprintf (stderr,
_("libguestfs-test-tool: invalid timeout: %s\n"),
optarg);
- exit (1);
+ exit (EXIT_FAILURE);
}
break;
case '?':
usage ();
- exit (0);
+ exit (EXIT_SUCCESS);
default:
fprintf (stderr,
_("libguestfs-test-tool: unexpected command line option 0x%x\n"),
c);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
if (g == NULL) {
fprintf (stderr,
_("libguestfs-test-tool: failed to create libguestfs handle\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_add_drive (g, tmpf) == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to add drive '%s'\n"),
tmpf);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_add_drive (g, isof) == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to add drive '%s'\n"),
isof);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Print any version info etc. */
vers = guestfs_version (g);
if (vers == NULL) {
fprintf (stderr, _("libguestfs-test-tool: guestfs_version failed\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
printf ("library version: %"PRIi64".%"PRIi64".%"PRIi64"%s\n",
vers->major, vers->minor, vers->release, vers->extra);
if (guestfs_launch (g) == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to launch appliance\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
alarm (0);
if (guestfs_sfdiskM (g, "/dev/sda", sfdisk_lines) == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to run sfdisk\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_mkfs (g, "ext2", "/dev/sda1") == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to mkfs.ext2\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_mount (g, "/dev/sda1", "/") == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to mount /dev/sda1 on /\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_mkdir (g, "/iso") == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to mkdir /iso\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
if (guestfs_mount (g, "/dev/sdb", "/iso") == -1) {
fprintf (stderr,
_("libguestfs-test-tool: failed to mount /dev/sdb on /iso\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Let's now run some simple tests using the helper program. */
if (str == NULL) {
fprintf (stderr,
_("libguestfs-test-tool: could not run helper program, or helper failed\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
free (str);
printf ("===== TEST FINISHED OK =====\n");
- exit (0);
+ exit (EXIT_SUCCESS);
}
static char qemuwrapper[] = "/tmp/libguestfs-test-tool-wrapper-XXXXXX";
fprintf (stderr,
_("LIBGUESTFS_QEMU environment variable is already set, so\n"
"--qemu/--qemudir options cannot be used.\n"));
- exit (1);
+ exit (EXIT_FAILURE);
}
if (!use_wrapper) {
fprintf (stderr,
_("Binary '%s' does not exist or is not executable\n"),
path);
- exit (1);
+ exit (EXIT_FAILURE);
}
setenv ("LIBGUESTFS_QEMU", path, 1);
fprintf (stderr,
_("%s: does not look like a qemu source directory\n"),
path);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Make a wrapper script. */
fd = mkstemp (qemuwrapper);
if (fd == -1) {
perror (qemuwrapper);
- exit (1);
+ exit (EXIT_FAILURE);
}
fchmod (fd, 0700);
"\n"
"Use the --helper option to specify the location of this program.\n"),
helper);
- exit (1);
+ exit (EXIT_FAILURE);
}
snprintf (cmd, sizeof cmd, "file '%s'", helper);
fp = popen (cmd, "r");
if (fp == NULL) {
perror (cmd);
- exit (1);
+ exit (EXIT_FAILURE);
}
r = fread (buffer, 1, sizeof buffer - 1, fp);
if (r == 0) {
fprintf (stderr, _("command failed: %s"), cmd);
- exit (1);
+ exit (EXIT_FAILURE);
}
pclose (fp);
buffer[r] = '\0';
"is not statically linked. This is a build error when this test tool\n"
"was built.\n"),
helper);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
fd = mkstemp (isof);
if (fd == -1) {
perror (isof);
- exit (1);
+ exit (EXIT_FAILURE);
}
close (fd);
if (r == -1 || WEXITSTATUS(r) != 0) {
fprintf (stderr,
_("mkisofs command failed: %s\n"), cmd);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Allocate the sparse file for /dev/sda. */
if (fd == -1) {
perror (tmpf);
unlink (isof);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (lseek (fd, 100 * 1024 * 1024 - 1, SEEK_SET) == -1) {
close (fd);
unlink (tmpf);
unlink (isof);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (write (fd, "\0", 1) == -1) {
close (fd);
unlink (tmpf);
unlink (isof);
- exit (1);
+ exit (EXIT_FAILURE);
}
close (fd);