Subject: Re: getmntopt change
To: Frank van der Linden <>
From: Simon J. Gerraty <>
List: tech-userlevel
Date: 02/19/2001 22:28:56
>I need to support some '-o foo=bar' options in mount_nfs, like

FWIW, I had the same need in my sNFS client.  I gave struct mntopt a

void *m_arg;	/* argument, bit to set,value or string */

and the following flags in m_optflags:

#define OPT_NEGATIVE	1
#define OPT_INT		2
#define OPT_STRING	4
#define OPT_FUNC	8

If OPT_INT, I point m_arg at a location to store the value.
If OPT_STRING I strdup() it and point m_arg at it, 
and if OPT_FUNC, I pass the opt=val bit (after strdup)
to the function pointed to by m_arg.
If none of the above, then m_arg just contains the bits to add to the mount 

#define MOPT_TCP		{ "tcp",	0, (void *)M_TCP }
#define MOPT_AUTH		{ "auth",	0, (void *)M_AUTH }
#define MOPT_PORT		{ "port",	OPT_INT, (void *)&SnfsPort }
#define MOPT_SSLVERIFY		{ "verify",	OPT_FUNC, (void *)ssl_setopt }
#define MOPT_SSLCERT		{ "cert",	OPT_FUNC, (void *)ssl_setopt }
#define MOPT_SSLKEY		{ "key",	OPT_FUNC, (void *)ssl_setopt }
#define MOPT_SSLCIPHER		{ "cipher",	OPT_FUNC, (void *)ssl_setopt }
#define MOPT_PROXY		{ "proxy",	OPT_FUNC, (void *)ssl_setopt }

ssl_setopt() is the routine in my ssl wrapper library that deals with
all the ssl related command line options.

I don't recall if I changed the prototype for getmntopts(), mine is simply:

void getmntopts __P((const char *, const struct mntopt *, int *));

So far I've only ported this (snfsc) to SunOS, Solaris and of course BSD.
I did part of a port for HPUX, but more important things got in the way.