1.\" Copyright (c) 1994 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)getmntopts.3 8.1 (Berkeley) 03/27/94 7.\" 8.Dd 9.Dt GETMNTOPTS 3 10.Os BSD 4.4 11.Sh NAME 12.Nm getmntopts 13.Nd scan mount options 14.Sh SYNOPSIS 15.Fd #include <mntopts.h> 16.Ft void 17.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" 18.Sh DESCRIPTION 19The 20.Nm getmntopts 21function takes a comma separated option list and a list 22of valid option names, and computes the bitmask 23corresponding to the requested set of options. 24.Pp 25The string 26.Dv options 27is broken down into a sequence of comma separated tokens. 28Each token is looked up in the table described by 29.Dv mopts 30and the bits in 31the word referenced by 32.Dv flagp 33are updated. 34The flag word is not initialized by 35.Nm getmntopt . 36The table, 37.Dv mopts , 38has the following format: 39.Bd -literal 40struct mntopt { 41 char *m_option; /* option name */ 42 int m_inverse; /* is this a negative option, eg "dev" */ 43 int m_flag; /* bit to set, eg MNT_RDONLY */ 44}; 45.Ed 46.Pp 47The members of this structure are: 48.Bl -tag -width m_inverse 49.It Fa m_option 50the option name, 51for example 52.Dq suid . 53.It Fa m_inverse 54tells 55.Nm getmntopts 56that the name has the inverse meaning of the 57bit. 58For example, 59.Dq suid 60is the string, whereas the 61mount flag is 62.Dv MNT_NOSUID . 63In this case, the sense of the string and the flag 64are inverted, so the 65.Dv m_inverse 66flag should be set. 67.It Fa m_flag 68the value of the bit to be set or cleared in 69the flag word when the option is recognized. 70The bit is set when the option is discovered, 71but cleared if the option name was preceded 72by the letters 73.Dq no . 74The 75.Dv m_inverse 76flag causes these two operations to be reversed. 77.El 78.Pp 79Each of the user visible 80.Dv MNT_ 81flags has a corresponding 82.Dv MOPT_ 83macro which defines an appropriate 84.Li "struct mntopt" 85entry. 86To simplify the program interface and ensure consistency across all 87programs, a general purpose macro, 88.Dv MOPT_STDOPTS , 89is defined which 90contains an entry for all the generic VFS options. 91In addition, the macros 92.Dv MOPT_FORCE 93and 94.Dv MOPT_UPDATE 95exist to enable the 96.Dv MNT_FORCE 97and 98.Dv MNT_UPDATE 99flags to be set. 100Finally, the table must be terminated by an entry with a NULL 101first element. 102.Sh EXAMPLES 103Most commands will use the standard option set. 104Local filesystems which support the 105.Dv MNT_UPDATE 106flag, would also have an 107.Dv MOPT_UPDATE 108entry. 109This can be declared and used as follows: 110.Bd -literal 111#include "mntopts.h" 112 113struct mntopt mopts[] = { 114 MOPT_STDOPTS, 115 MOPT_UPDATE, 116 { NULL } 117}; 118 119 ... 120 mntflags = 0; 121 ... 122 getmntopts(options, mopts, &mntflags) 123 ... 124.Ed 125.Sh DIAGNOSTICS 126The 127.Nm getmntopts 128function displays an error message and exits if an 129unrecognized option is encountered. 130.Sh SEE ALSO 131.Xr err 3 , 132.Xr mount 8 133.Sh HISTORY 134The 135.Fn getmntopts 136function appeared in 137.Bx 4.4 . 138