From 7cf9f75795a4e08519808db380cfffb535127d8c Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 28 Jun 2013 18:46:05 +0200 Subject: mount: fix mount -oremount with one parameter This fixes mount -oremount when just given the mountpoint, e. g.: % mount -oremount,ro /tmp * util/mount.c (main): Add a one-argument form for remount. --- utils/mount.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'utils/mount.c') diff --git a/utils/mount.c b/utils/mount.c index ea30f7af..f1d5750d 100644 --- a/utils/mount.c +++ b/utils/mount.c @@ -526,6 +526,12 @@ main (int argc, char **argv) fstab = fstab_argp_create (&fstab_params, SEARCH_FMTS, sizeof SEARCH_FMTS); + /* This is a convenient way of checking for any `remount' options. */ + remount = 0; + err = argz_replace (&options, &options_len, "remount", "update", &remount); + if (err) + error (3, ENOMEM, "collecting mount options"); + if (device) /* two-argument form */ { struct mntent m = @@ -544,6 +550,23 @@ main (int argc, char **argv) if (fst->program == 0) error (2, 0, "filesystem type %s not recognized", fstype); + err = fstab_add_mntent (fstab, &m, &fs); + if (err) + error (2, err, "%s", mountpoint); + } + else if (mountpoint && remount) /* one-argument remount */ + { + struct mntent m = + { + mnt_fsname: mountpoint, /* since we cannot know the device, + using mountpoint here leads to more + helpful error messages */ + mnt_dir: mountpoint, + mnt_type: fstype, + mnt_opts: 0, + mnt_freq: 0, mnt_passno: 0 + }; + err = fstab_add_mntent (fstab, &m, &fs); if (err) error (2, err, "%s", mountpoint); @@ -557,12 +580,6 @@ main (int argc, char **argv) else fs = 0; - /* This is a convenient way of checking for any `remount' options. */ - remount = 0; - err = argz_replace (&options, &options_len, "remount", "update", &remount); - if (err) - error (3, ENOMEM, "collecting mount options"); - if (fs != 0) err = do_mount (fs, remount); else -- cgit v1.2.3