Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
-/* Map from -o and fstab option strings to the flag argument to mount(2). */
+/*
+ * Map from -o and fstab option strings to the flag argument to mount(2).
+ */
- const char *opt; /* option name */
- int skip; /* skip in mtab option string */
- int inv; /* true if flag value should be inverted */
- int mask; /* flag mask value */
+ const char *opt; /* option name */
+ int skip; /* skip in mtab option string */
+ int inv; /* true if flag value should be inverted */
+ int mask; /* flag mask value */
};
static const struct opt_map opt_map[] = {
};
static const struct opt_map opt_map[] = {
-/* Try to build a canonical options string. */
-static char * fix_opts_string (int flags, const char *extra_opts) {
+/*
+ * Build a canonical mount option string for /etc/mtab.
+ */
+static char *fix_opts_string(int flags, const char *extra_opts)
+{
const struct opt_map *om;
char *new_opts;
const struct opt_map *om;
char *new_opts;
printf("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n");
}
printf("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n");
}
-static inline void
-parse_opt(const char *opt, int *mask, char *extra_opts, int len) {
+static void parse_opt(const char *opt, int *mask, char *extra_opts, int len)
+{
const struct opt_map *om;
for (om = opt_map; om->opt != NULL; om++) {
const struct opt_map *om;
for (om = opt_map; om->opt != NULL; om++) {
strcat(extra_opts, opt);
}
strcat(extra_opts, opt);
}
-/* Take -o options list and compute 4th and 5th args to mount(2). flags
- gets the standard options (indicated by bits) and extra_opts all the rest */
-static void parse_opts (const char *options, int *flags, char **extra_opts)
+/*
+ * Convert the provided mount command-line options into the 4th &
+ * 5th arguments to mount(2). Output parameter "@flags" gets the
+ * standard options (indicated by MS_ bits), and output parameter
+ * "@extra_opts" gets all the filesystem-specific options.
+ */
+static void parse_opts(const char *options, int *flags, char **extra_opts)
{
if (options != NULL) {
char *opts = xstrdup(options);
char *opt, *p;
{
if (options != NULL) {
char *opts = xstrdup(options);
char *opt, *p;
- int len = strlen(opts) + 1; /* include room for a null */
+ int len = strlen(opts) + 1; /* include room for a null */
int open_quote = 0;
*extra_opts = xmalloc(len);
**extra_opts = '\0';
int open_quote = 0;
*extra_opts = xmalloc(len);
**extra_opts = '\0';
- for (p=opts, opt=NULL; p && *p; p++) {
+ for (p = opts, opt = NULL; p && *p; p++) {
- opt = p; /* begin of the option item */
+ opt = p; /* begin of the option item */
- open_quote ^= 1; /* reverse the status */
+ open_quote ^= 1; /* reverse the status */
- continue; /* still in a quoted block */
+ continue; /* still in a quoted block */
- *p = '\0'; /* terminate the option item */
+ *p = '\0'; /* terminate the option item */
+
/* end of option item or last item */
/* end of option item or last item */
- if (*p == '\0' || *(p+1) == '\0') {
+ if (*p == '\0' || *(p + 1) == '\0') {
parse_opt(opt, flags, *extra_opts, len);
opt = NULL;
}
parse_opt(opt, flags, *extra_opts, len);
opt = NULL;
}
- if (optind != argc-2) {
- /* Extra non-option words at the end... */
+
+ /*
+ * Extra non-option words at the end are bogus...
+ */
+ if (optind != argc - 2) {
mount_usage();
exit(EX_USAGE);
}
mount_usage();
exit(EX_USAGE);
}
free(mount_point);
exit(mnt_err);
}
free(mount_point);
exit(mnt_err);
}
#endif
#endif /* _NFS_MOUNT_CONSTANTS_H */
#endif
#endif /* _NFS_MOUNT_CONSTANTS_H */
if (access(GSSDLCK, F_OK)) { \
printf(_("Warning: rpc.gssd appears not to be running.\n")); \
} \
if (access(GSSDLCK, F_OK)) { \
printf(_("Warning: rpc.gssd appears not to be running.\n")); \
} \
#ifndef NFS_PORT
#define NFS_PORT 2049
#ifndef NFS_PORT
#define NFS_PORT 2049
- if (!strcmp(opt, "bg"))
+ if (!strcmp(opt, "bg"))
- else if (!strcmp(opt, "fg"))
+ else if (!strcmp(opt, "fg"))
bg = !val;
else if (!strcmp(opt, "soft"))
soft = val;
bg = !val;
else if (!strcmp(opt, "soft"))
soft = val;
*
* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
* - added Native Language Support
*
* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
* - added Native Language Support
* Modified by Olaf Kirch and Trond Myklebust for new NFS code,
* plus NFSv3 stuff.
*
* Modified by Olaf Kirch and Trond Myklebust for new NFS code,
* plus NFSv3 stuff.
*
- if (!strcmp(opt, "bg"))
+ if (!strcmp(opt, "bg"))
- else if (!strcmp(opt, "fg"))
+ else if (!strcmp(opt, "fg"))
*bg = !val;
else if (!strcmp(opt, "soft")) {
data->flags &= ~NFS_MOUNT_SOFT;
*bg = !val;
else if (!strcmp(opt, "soft")) {
data->flags &= ~NFS_MOUNT_SOFT;
clnt_addr_t mnt_server = { &mounthost, };
clnt_addr_t nfs_server = { &hostname, };
struct sockaddr_in *nfs_saddr = &nfs_server.saddr;
clnt_addr_t mnt_server = { &mounthost, };
clnt_addr_t nfs_server = { &hostname, };
struct sockaddr_in *nfs_saddr = &nfs_server.saddr;
- struct pmap *mnt_pmap = &mnt_server.pmap,
+ struct pmap *mnt_pmap = &mnt_server.pmap,
*nfs_pmap = &nfs_server.pmap;
struct pmap save_mnt, save_nfs;
*nfs_pmap = &nfs_server.pmap;
struct pmap save_mnt, save_nfs;
#if NFS_MOUNT_VERSION >= 5
mountres = &mntres.nfsv3.mountres3_u.mountinfo;
i = mountres->auth_flavors.auth_flavors_len;
#if NFS_MOUNT_VERSION >= 5
mountres = &mntres.nfsv3.mountres3_u.mountinfo;
i = mountres->auth_flavors.auth_flavors_len;
goto noauth_flavors;
flavor = mountres->auth_flavors.auth_flavors_val;
goto noauth_flavors;
flavor = mountres->auth_flavors.auth_flavors_val;