aboutsummaryrefslogtreecommitdiff
path: root/sys/nfsclient/nfs_diskless.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2005-10-06 11:18:34 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2005-10-06 11:18:34 +0000
commit720f3948c070256484244eae24a0238c27f9c8ab (patch)
treeb8d84aad719388f7c5aafad10a9545fcb9642f1f /sys/nfsclient/nfs_diskless.c
parent5e66cbaeaf39f75af2db190c66fa880888b735b8 (diff)
downloadsrc-720f3948c070256484244eae24a0238c27f9c8ab.tar.gz
src-720f3948c070256484244eae24a0238c27f9c8ab.zip
Add boot.nfsroot.options loader tunable.
It allows to specify options for NFS root file system. Currently supported options are: soft, intr, conn, lockd. I'm adding this functionality mostly for 'lockd' option, which is only honored when performing the initial mount and will be silently ignored if used while updating the mount options. This will allow to use flock(2) without the need of using varmfs or rpc.lockd and friends. Example of use: boot.nfsroot.options="intr,lockd" MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=150995
Diffstat (limited to 'sys/nfsclient/nfs_diskless.c')
-rw-r--r--sys/nfsclient/nfs_diskless.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/nfsclient/nfs_diskless.c b/sys/nfsclient/nfs_diskless.c
index 9f17cd9330a9..56a5a2faab9c 100644
--- a/sys/nfsclient/nfs_diskless.c
+++ b/sys/nfsclient/nfs_diskless.c
@@ -60,6 +60,31 @@ static int inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa);
static int hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa);
static int decode_nfshandle(char *ev, u_char *fh);
+static void
+nfs_parse_options(const char *envopts, struct nfs_diskless *nd)
+{
+ char *opts, *o;
+
+ opts = strdup(envopts, M_TEMP);
+ if (opts == NULL) {
+ printf("nfs_diskless: cannot allocate memory for options\n");
+ return;
+ }
+ for (o = strtok(opts, ":;, "); o != NULL; o = strtok(NULL, ":;, ")) {
+ if (strcmp(o, "soft") == 0)
+ nd->root_args.flags |= NFSMNT_SOFT;
+ else if (strcmp(o, "intr") == 0)
+ nd->root_args.flags |= NFSMNT_INT;
+ else if (strcmp(o, "conn") == 0)
+ nd->root_args.flags |= NFSMNT_NOCONN;
+ else if (strcmp(o, "lockd") == 0)
+ nd->root_args.flags |= NFSMNT_NOLOCKD;
+ else
+ printf("nfs_diskless: unknown option: %s\n", o);
+ }
+ free(opts, M_TEMP);
+}
+
/*
* Populate the essential fields in the nfsv3_diskless structure.
*
@@ -73,6 +98,7 @@ static int decode_nfshandle(char *ev, u_char *fh);
* boot.nfsroot.server IP address of root filesystem server
* boot.nfsroot.path path of the root filesystem on server
* boot.nfsroot.nfshandle NFS handle for root filesystem on server
+ * boot.nfsroot.options NFS options for the root filesystem
*/
void
nfs_setup_diskless(void)
@@ -148,6 +174,10 @@ match_done:
strncpy(nd->root_hostnam, cp, MNAMELEN - 1);
freeenv(cp);
}
+ if ((cp = getenv("boot.nfsroot.options")) != NULL) {
+ nfs_parse_options(cp, nd);
+ freeenv(cp);
+ }
nfs_diskless_valid = 1;
}