text-based mount.nfs: Create helpers for invoking mount(2) system call
Subsystems (2)
PATCH 13/24 text-based mount.nfs: Create helpers for invoking mount(2) system call
Add a simple helper functions that invoke the mount(2) system call for text-based mounts. These functions will become more complex over the following patches as we implement fallback and background mounting.
Signed-off-by Chuck Lever <[email protected]>
---
utils/mount/stropts.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-)
utils/mount/stropts.c +64 -0
@@ -210,6 +210,38 @@ static int fix_up_mounthost_opt(struct mount_options *options) }/* +* Attempt an NFS mount via a mount(2) system call. +* +* Returns 1 if successful. Otherwise, returns zero. +* "errno" is set to reflect the individual error. +*/ +static int try_nfsmount (const char *spec,const char *node, +int flags,struct mount_options *options, +int fake,char **extra_opts) +{ +free (*extra_opts); + *extra_opts =po_join (options); +if (!*extra_opts) { +nfs_error (_ ("%s: internal option parsing error" ), progname); +return 0 ; + } + +if (verbose) +printf (_ ("%s: text-based options: '%s'\n" ), + progname, *extra_opts); + +if (fake) +return 1 ; + +if (!mount (spec, node,"nfs" , + flags & ~(MS_USER |MS_USERS ), *extra_opts)) +return 1 ; + +mount_error (spec, node, errno); +return 0 ; +} + +/* * nfsmount_s - Mount an NFSv2 or v3 file system using C string options * * @spec: C string hostname:path specifying remoteshare to mount
@@ -276,6 +308,38 @@ out: }/* +* Attempt an NFS v4 mount via a mount(2) system call. +* +* Returns 1 if successful. Otherwise, returns zero. +* "errno" is set to reflect the individual error. +*/ +static int try_nfs4mount (const char *spec,const char *node, +int flags,struct mount_options *options, +int fake,char **extra_opts) +{ +free (*extra_opts); + *extra_opts =po_join (options); +if (!*extra_opts) { +nfs_error (_ ("%s: internal option parsing error" ), progname); +return 0 ; + } + +if (verbose) +printf (_ ("%s: text-based options: '%s'\n" ), + progname, *extra_opts); + +if (fake) +return 1 ; + +if (!mount (spec, node,"nfs4" , + flags & ~(MS_USER |MS_USERS ), *extra_opts)) +return 1 ; + +mount_error (spec, node, errno); +return 0 ; +} + +/* * nfs4mount_s - Mount an NFSv4 file system using C string options * * @spec: C string hostname:path specifying remoteshare to mount
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs