166460Sbostic.\" Copyright (c) 1994 266460Sbostic.\" The Regents of the University of California. All rights reserved. 366460Sbostic.\" 466460Sbostic.\" %sccs.include.redist.roff% 566460Sbostic.\" 6*68650Spendry.\" @(#)getmntopts.3 8.3 (Berkeley) 03/30/95 766460Sbostic.\" 866460Sbostic.Dd 966460Sbostic.Dt GETMNTOPTS 3 1066460Sbostic.Os BSD 4.4 1166460Sbostic.Sh NAME 1266460Sbostic.Nm getmntopts 1366460Sbostic.Nd scan mount options 1466460Sbostic.Sh SYNOPSIS 1566460Sbostic.Fd #include <mntopts.h> 1666460Sbostic.Ft void 1768640Smckusick.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp" 1866460Sbostic.Sh DESCRIPTION 1966460SbosticThe 2066460Sbostic.Nm getmntopts 2166460Sbosticfunction takes a comma separated option list and a list 2266460Sbosticof valid option names, and computes the bitmask 2366460Sbosticcorresponding to the requested set of options. 2466460Sbostic.Pp 2566460SbosticThe string 2666460Sbostic.Dv options 2766460Sbosticis broken down into a sequence of comma separated tokens. 2866460SbosticEach token is looked up in the table described by 2966460Sbostic.Dv mopts 3066460Sbosticand the bits in 3168640Smckusickthe word referenced by either 3266460Sbostic.Dv flagp 3368640Smckusickor 3468640Smckusick.Dv altflagp 3568640Smckusick(depending on the 3668640Smckusick.Dv m_altloc 3768640Smckusickfield of the option's table entry) 3866460Sbosticare updated. 39*68650SpendryThe flag words are not initialized by 4066460Sbostic.Nm getmntopt . 4166460SbosticThe table, 4266460Sbostic.Dv mopts , 4366460Sbostichas the following format: 4466460Sbostic.Bd -literal 4566460Sbosticstruct mntopt { 4666460Sbostic char *m_option; /* option name */ 4766460Sbostic int m_inverse; /* is this a negative option, eg "dev" */ 4866460Sbostic int m_flag; /* bit to set, eg MNT_RDONLY */ 4968640Smckusick int m_altloc; /* non-zero to use altflagp rather than flagp */ 5066460Sbostic}; 5166460Sbostic.Ed 5266460Sbostic.Pp 5366460SbosticThe members of this structure are: 5466460Sbostic.Bl -tag -width m_inverse 5566460Sbostic.It Fa m_option 5666460Sbosticthe option name, 5766460Sbosticfor example 5866460Sbostic.Dq suid . 5966460Sbostic.It Fa m_inverse 6066460Sbostictells 6166460Sbostic.Nm getmntopts 6266460Sbosticthat the name has the inverse meaning of the 6366460Sbosticbit. 6466460SbosticFor example, 6566460Sbostic.Dq suid 6666460Sbosticis the string, whereas the 6766460Sbosticmount flag is 6866460Sbostic.Dv MNT_NOSUID . 6966460SbosticIn this case, the sense of the string and the flag 7066460Sbosticare inverted, so the 7166460Sbostic.Dv m_inverse 7266460Sbosticflag should be set. 7366460Sbostic.It Fa m_flag 7466460Sbosticthe value of the bit to be set or cleared in 7566460Sbosticthe flag word when the option is recognized. 7666460SbosticThe bit is set when the option is discovered, 7766460Sbosticbut cleared if the option name was preceded 7866460Sbosticby the letters 7966460Sbostic.Dq no . 8066460SbosticThe 8166460Sbostic.Dv m_inverse 8266460Sbosticflag causes these two operations to be reversed. 8368640Smckusick.It Fa m_altloc 8468640Smckusickthe bit should be set or cleared in 8568640Smckusick.Dv altflagp 8668640Smckusickrather than 8768640Smckusick.Dv flagp . 8866460Sbostic.El 8966460Sbostic.Pp 9066460SbosticEach of the user visible 9166460Sbostic.Dv MNT_ 9266460Sbosticflags has a corresponding 9366460Sbostic.Dv MOPT_ 9466460Sbosticmacro which defines an appropriate 9566460Sbostic.Li "struct mntopt" 9666460Sbosticentry. 9766460SbosticTo simplify the program interface and ensure consistency across all 9866460Sbosticprograms, a general purpose macro, 9966460Sbostic.Dv MOPT_STDOPTS , 10066460Sbosticis defined which 10166460Sbosticcontains an entry for all the generic VFS options. 10266460SbosticIn addition, the macros 10366460Sbostic.Dv MOPT_FORCE 10466460Sbosticand 10566460Sbostic.Dv MOPT_UPDATE 10666460Sbosticexist to enable the 10766460Sbostic.Dv MNT_FORCE 10866460Sbosticand 10966460Sbostic.Dv MNT_UPDATE 11066460Sbosticflags to be set. 11166460SbosticFinally, the table must be terminated by an entry with a NULL 11266460Sbosticfirst element. 11366460Sbostic.Sh EXAMPLES 11466460SbosticMost commands will use the standard option set. 11566460SbosticLocal filesystems which support the 11666460Sbostic.Dv MNT_UPDATE 11766460Sbosticflag, would also have an 11866460Sbostic.Dv MOPT_UPDATE 11966460Sbosticentry. 12066460SbosticThis can be declared and used as follows: 12166460Sbostic.Bd -literal 12266460Sbostic#include "mntopts.h" 12366460Sbostic 12466460Sbosticstruct mntopt mopts[] = { 12566460Sbostic MOPT_STDOPTS, 12666460Sbostic MOPT_UPDATE, 12766460Sbostic { NULL } 12866460Sbostic}; 12966460Sbostic 13066460Sbostic ... 131*68650Spendry mntflags = mntaltflags = 0; 13266460Sbostic ... 133*68650Spendry getmntopts(options, mopts, &mntflags, &mntaltflags); 13466460Sbostic ... 13566460Sbostic.Ed 13666460Sbostic.Sh DIAGNOSTICS 137*68650SpendryIf the external integer variable 138*68650Spendry.Dv getmnt_silent 139*68650Spendryis non-zero then the 14066460Sbostic.Nm getmntopts 14166460Sbosticfunction displays an error message and exits if an 14266460Sbosticunrecognized option is encountered. 143*68650SpendryBy default 144*68650Spendry.Dv getmnt_silent 145*68650Spendryis zero. 14666460Sbostic.Sh SEE ALSO 14766460Sbostic.Xr err 3 , 14866460Sbostic.Xr mount 8 14966460Sbostic.Sh HISTORY 15066460SbosticThe 15166460Sbostic.Fn getmntopts 15266460Sbosticfunction appeared in 15366460Sbostic.Bx 4.4 . 154