X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fmount.c;h=3abdabddaf53af11d64751880b69492b3eceaaaa;hb=5e62afd7ce5145eee1894fab6f0722119fee1d31;hp=fd9c8e4327677951e65e31e79770aa60b356bbaf;hpb=b4d2a01828e5de85e5eee3631f7fe3925a0312ca;p=libguestfs.git diff --git a/daemon/mount.c b/daemon/mount.c index fd9c8e4..3abdabd 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -30,7 +30,8 @@ int root_mounted = 0; /* The "simple mount" call offers no complex options, you can just - * mount a device on a mountpoint. + * mount a device on a mountpoint. The variations like mount_ro, + * mount_options and mount_vfs let you set progressively more things. * * It's tempting to try a direct mount(2) syscall, but that doesn't * do any autodetection, so we are better off calling out to @@ -38,7 +39,8 @@ int root_mounted = 0; */ int -do_mount (const char *device, const char *mountpoint) +do_mount_vfs (const char *options, const char *vfstype, + const char *device, const char *mountpoint) { int len, r, is_root; char *mp; @@ -61,8 +63,12 @@ do_mount (const char *device, const char *mountpoint) snprintf (mp, len, "/sysroot%s", mountpoint); - r = command (NULL, &error, - "mount", "-o", "sync,noatime", device, mp, NULL); + if (vfstype) + r = command (NULL, &error, + "mount", "-o", options, "-t", vfstype, device, mp, NULL); + else + r = command (NULL, &error, + "mount", "-o", options, device, mp, NULL); if (r == -1) { reply_with_error ("mount: %s on %s: %s", device, mountpoint, error); free (error); @@ -75,6 +81,25 @@ do_mount (const char *device, const char *mountpoint) return 0; } +int +do_mount (const char *device, const char *mountpoint) +{ + return do_mount_vfs ("sync,noatime", NULL, device, mountpoint); +} + +int +do_mount_ro (const char *device, const char *mountpoint) +{ + return do_mount_vfs ("ro", NULL, device, mountpoint); +} + +int +do_mount_options (const char *options, const char *device, + const char *mountpoint) +{ + return do_mount_vfs (options, NULL, device, mountpoint); +} + /* Again, use the external /bin/umount program, so that /etc/mtab * is kept updated. */