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
This commit is contained in:
Pawel Jakub Dawidek 2005-10-06 11:18:34 +00:00
parent 5e66cbaeaf
commit 720f3948c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=150995

View File

@ -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 @@ nfs_setup_diskless(void)
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;
}