| 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) %G% |
| 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 |
| 19 | The |
| 20 | .Nm getmntopts |
| 21 | function takes a comma separated option list and a list |
| 22 | of valid option names, and computes the bitmask |
| 23 | corresponding to the requested set of options. |
| 24 | .Pp |
| 25 | The string |
| 26 | .Dv options |
| 27 | is broken down into a sequence of comma separated tokens. |
| 28 | Each token is looked up in the table described by |
| 29 | .Dv mopts |
| 30 | and the bits in |
| 31 | the word referenced by |
| 32 | .Dv flagp |
| 33 | are updated. |
| 34 | The flag word is not initialized by |
| 35 | .Nm getmntopt . |
| 36 | The table, |
| 37 | .Dv mopts , |
| 38 | has the following format: |
| 39 | .Bd -literal |
| 40 | struct 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 |
| 47 | The members of this structure are: |
| 48 | .Bl -tag -width m_inverse |
| 49 | .It Fa m_option |
| 50 | the option name, |
| 51 | for example |
| 52 | .Dq suid . |
| 53 | .It Fa m_inverse |
| 54 | tells |
| 55 | .Nm getmntopts |
| 56 | that the name has the inverse meaning of the |
| 57 | bit. |
| 58 | For example, |
| 59 | .Dq suid |
| 60 | is the string, whereas the |
| 61 | mount flag is |
| 62 | .Dv MNT_NOSUID . |
| 63 | In this case, the sense of the string and the flag |
| 64 | are inverted, so the |
| 65 | .Dv m_inverse |
| 66 | flag should be set. |
| 67 | .It Fa m_flag |
| 68 | the value of the bit to be set or cleared in |
| 69 | the flag word when the option is recognized. |
| 70 | The bit is set when the option is discovered, |
| 71 | but cleared if the option name was preceded |
| 72 | by the letters |
| 73 | .Dq no . |
| 74 | The |
| 75 | .Dv m_inverse |
| 76 | flag causes these two operations to be reversed. |
| 77 | .El |
| 78 | .Pp |
| 79 | Each of the user visible |
| 80 | .Dv MNT_ |
| 81 | flags has a corresponding |
| 82 | .Dv MOPT_ |
| 83 | macro which defines an appropriate |
| 84 | .Li "struct mntopt" |
| 85 | entry. |
| 86 | To simplify the program interface and ensure consistency across all |
| 87 | programs, a general purpose macro, |
| 88 | .Dv MOPT_STDOPTS , |
| 89 | is defined which |
| 90 | contains an entry for all the generic VFS options. |
| 91 | In addition, the macros |
| 92 | .Dv MOPT_FORCE |
| 93 | and |
| 94 | .Dv MOPT_UPDATE |
| 95 | exist to enable the |
| 96 | .Dv MNT_FORCE |
| 97 | and |
| 98 | .Dv MNT_UPDATE |
| 99 | flags to be set. |
| 100 | Finally, the table must be terminated by an entry with a NULL |
| 101 | first element. |
| 102 | .Sh EXAMPLES |
| 103 | Most commands will use the standard option set. |
| 104 | Local filesystems which support the |
| 105 | .Dv MNT_UPDATE |
| 106 | flag, would also have an |
| 107 | .Dv MOPT_UPDATE |
| 108 | entry. |
| 109 | This can be declared and used as follows: |
| 110 | .Bd -literal |
| 111 | #include "mntopts.h" |
| 112 | |
| 113 | struct 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 |
| 126 | The |
| 127 | .Nm getmntopts |
| 128 | function displays an error message and exits if an |
| 129 | unrecognized option is encountered. |
| 130 | .Sh SEE ALSO |
| 131 | .Xr err 3 , |
| 132 | .Xr mount 8 |
| 133 | .Sh HISTORY |
| 134 | The |
| 135 | .Fn getmntopts |
| 136 | function appeared in |
| 137 | .Bx 4.4 . |