summaryrefslogtreecommitdiffstats
path: root/utils/mount/mount.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-08-03 13:24:10 -0400
committerNeil Brown <neilb@suse.de>2007-08-04 08:27:40 +1000
commit0ab024c2ffddfdb8262c1355c97573327c2b8539 (patch)
tree67d592a95e4ae8b946b2d49ae9399e5da349ce3c /utils/mount/mount.c
parent7a92dbf8cc01ed3b32c124d8f23348a39b992b54 (diff)
downloadnfs-utils-0ab024c2ffddfdb8262c1355c97573327c2b8539.tar.gz
nfs-utils-0ab024c2ffddfdb8262c1355c97573327c2b8539.tar.xz
nfs-utils-0ab024c2ffddfdb8262c1355c97573327c2b8539.zip
mount.nfs: Refactor mount logic to allow support for "bg" option
Refactor main() a bit to make adding support for "bg" option easier. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils/mount/mount.c')
-rw-r--r--utils/mount/mount.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/utils/mount/mount.c b/utils/mount/mount.c
index 9ac817c..c0c3971 100644
--- a/utils/mount/mount.c
+++ b/utils/mount/mount.c
@@ -361,6 +361,31 @@ static int chk_mountpoint(char *mount_point)
return 0;
}
+static int try_mount(char *spec, char *mount_point, int flags,
+ char *fs_type, char **extra_opts, char *mount_opts,
+ int fake, int nomtab, int bg)
+{
+ int ret;
+
+ if (strcmp(fs_type, "nfs4") == 0)
+ ret = nfs4mount(spec, mount_point, flags,
+ extra_opts, fake, bg);
+ else
+ ret = nfsmount(spec, mount_point, flags,
+ extra_opts, fake, bg);
+
+ if (ret)
+ return ret;
+
+ if (!fake)
+ print_one(spec, mount_point, fs_type, mount_opts);
+
+ if (!nomtab)
+ ret = add_mtab(spec, mount_point, fs_type, flags, *extra_opts,
+ 0, 0 /* these are always zero for NFS */ );
+ return ret;
+}
+
int main(int argc, char *argv[])
{
int c, flags = 0, mnt_err = 1, fake = 0;
@@ -492,22 +517,8 @@ int main(int argc, char *argv[])
goto out;
}
- if (strcmp(fs_type, "nfs4") == 0)
- mnt_err = nfs4mount(spec, mount_point, flags,
- &extra_opts, fake, 0);
- else
- mnt_err = nfsmount(spec, mount_point, flags,
- &extra_opts, fake, 0);
-
- if (mnt_err)
- exit(EX_FAIL);
-
- if (!fake)
- print_one(spec, mount_point, fs_type, mount_opts);
-
- if (!nomtab)
- mnt_err = add_mtab(spec, mount_point, fs_type, flags, extra_opts,
- 0, 0 /* these are always zero for NFS */ );
+ mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts,
+ mount_opts, fake, nomtab, 0);
out:
free(mount_point);