X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fuse%2Fguestmount.c;h=9b7e520adae2f895cb9a8f7122658f68494102cf;hb=ff4ae8633e0ca7c1e679870600830ee4d9f1cd71;hp=07c28c015d9d8be15ff8fd5d7a445e0afa986a53;hpb=c372c7c23a298a940b8a0868396ef2ae0d824e4d;p=libguestfs.git diff --git a/fuse/guestmount.c b/fuse/guestmount.c index 07c28c0..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,15 +1075,18 @@ 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 (0); + usage (EXIT_SUCCESS); default: - usage (1); + usage (EXIT_FAILURE); } } @@ -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); }