X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fuse%2Fguestmount.c;h=9b7e520adae2f895cb9a8f7122658f68494102cf;hp=9f0a39ecbcbe7c8272fa385203ca420b54598b3f;hb=ed74706d80394fef709ec0258fc5cf7d974ff8b1;hpb=4d45c45f0928c7791429d351dc69b75167888f7d diff --git a/fuse/guestmount.c b/fuse/guestmount.c index 9f0a39e..9b7e520 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include #include @@ -652,7 +654,17 @@ fg_write (const char *path, const char *buf, size_t size, dir_cache_invalidate (path); - return -ENOSYS; /* XXX */ + /* See fg_read. */ + const size_t limit = 2 * 1024 * 1024; + if (size > limit) + size = limit; + + int r; + r = guestfs_pwrite (g, path, buf, size, offset); + if (r == -1) + return error (); + + return r; } static int @@ -896,6 +908,10 @@ usage (int status) 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 @@ -923,7 +939,7 @@ main (int argc, char *argv[]) struct mp *mps = NULL; struct mp *mp; char *p; - int c, i, r; + int c, r; int option_index; struct sigaction sa; @@ -1059,9 +1075,12 @@ main (int argc, char *argv[]) guestfs_set_verbose (g, verbose); break; - case 'V': - printf ("%s %s\n", program_name, PACKAGE_VERSION); + case 'V': { + struct guestfs_version *v = guestfs_version (g); + printf ("%s %"PRIi64".%"PRIi64".%"PRIi64"%s\n", program_name, + v->major, v->minor, v->release, v->extra); exit (EXIT_SUCCESS); + } case HELP_OPTION: usage (EXIT_SUCCESS); @@ -1156,10 +1175,13 @@ mount_mps (struct mp *mp) 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 (EXIT_FAILURE); }