#include <assert.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <locale.h>
#include <fuse.h>
#include <guestfs.h>
time_t mtsecs = ts[1].tv_sec;
long mtnsecs = ts[1].tv_nsec;
+#ifdef UTIME_NOW
if (atnsecs == UTIME_NOW)
atnsecs = -1;
+#endif
+#ifdef UTIME_OMIT
if (atnsecs == UTIME_OMIT)
atnsecs = -2;
+#endif
+#ifdef UTIME_NOW
if (mtnsecs == UTIME_NOW)
mtnsecs = -1;
+#endif
+#ifdef UTIME_OMIT
if (mtnsecs == UTIME_OMIT)
mtnsecs = -2;
+#endif
r = guestfs_utimens (g, path, atsecs, atnsecs, mtsecs, mtnsecs);
if (r == -1)
if (size > limit)
size = limit;
- /* Note the correct error handling here is tricky, because in the
- * case where the call returns a zero-length buffer, it might return
- * NULL. However it won't adjust rsize along the error path, so we
- * can set rsize to something beforehand and use that as a flag.
- */
- rsize = 1;
r = guestfs_pread (g, path, size, offset, &rsize);
- if (rsize == 1 && r == NULL)
+ if (r == NULL)
return error ();
/* This should never happen, but at least it stops us overflowing
{
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))
int
main (int argc, char *argv[])
{
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEBASEDIR);
+ textdomain (PACKAGE);
+
enum { HELP_OPTION = CHAR_MAX + 1 };
/* The command line arguments are broadly compatible with (a subset
struct mp *mps = NULL;
struct mp *mp;
char *p;
- int c, i, r;
+ int c, r;
int option_index;
struct sigaction sa;
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);
+ usage (EXIT_SUCCESS);
default:
- usage (1);
+ usage (EXIT_FAILURE);
}
}
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);
}
}
if (mp) {
mount_mps (mp->next);
- if (!read_only)
- r = guestfs_mount (g, mp->device, mp->mountpoint);
- else
- r = guestfs_mount_ro (g, mp->device, mp->mountpoint);
+
+ /* Don't use guestfs_mount here because that will default to mount
+ * options -o sync,noatime. For more information, see guestfs(3)
+ * section "LIBGUESTFS GOTCHAS".
+ */
+ const char *options = read_only ? "ro" : "";
+ r = guestfs_mount_options (g, options, mp->device, mp->mountpoint);
if (r == -1)
- exit (1);
+ exit (EXIT_FAILURE);
}
}