1 .\" Copyright (c) 2023 Marshall Kirk McKusick
2 .\" Copyright (c) 1994 The Regents of the University of California.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95
35 .Nm build_iovec_argf ,
39 .Nd "mount point operations"
44 .Fa "const char *options" "const struct mntopt *mopts"
45 .Fa "int *flagp" "int *altflagp"
48 .Fn getmntpoint "const char *name"
51 .Fa "struct statfs *mntp"
52 .Fa "void (*prtmsg)(const char *fmt, ...)"
56 .Fa "struct iovec **iov" "int *iovlen" "const char *name" "void *val"
61 .Fa "struct iovec **iov" "int *iovlen" "const char *name"
62 .Fa "const char *fmt" "..."
65 .Fn free_iovec "struct iovec **iov" "int *iovlen"
67 .Fn checkpath "const char *path" "char *resolved"
69 .Fn rmslashes "char *rrpin" "char *rrpout"
73 functions support operations associated with a mount point.
74 For historic reasons are in a file in the sources for the
77 Thus, to access them the following lines need to be added to the
79 of the program wanting to use them:
82 MOUNT= ${SRCTOP}/sbin/mount
89 function takes a comma separated option list and a list
90 of valid option names, and computes the bitmask
91 corresponding to the requested set of options.
95 is broken down into a sequence of comma separated tokens.
96 Each token is looked up in the table described by
99 the word referenced by either
105 field of the option's table entry)
107 The flag words are not initialized by
111 has the following format:
114 char *m_option; /* option name */
115 int m_inverse; /* is this a negative option, e.g., "dev" */
116 int m_flag; /* bit to set, e.g., MNT_RDONLY */
117 int m_altloc; /* non-zero to use altflagp rather than flagp */
121 The members of this structure are:
122 .Bl -tag -width m_inverse
130 that the name has the inverse meaning of the
134 is the string, whereas the
137 In this case, the sense of the string and the flag
142 the value of the bit to be set or cleared in
143 the flag word when the option is recognized.
144 The bit is set when the option is discovered,
145 but cleared if the option name was preceded
150 flag causes these two operations to be reversed.
152 the bit should be set or cleared in
158 Each of the user visible
160 flags has a corresponding
162 macro which defines an appropriate
165 To simplify the program interface and ensure consistency across all
166 programs, a general purpose macro,
169 contains an entry for all the generic VFS options.
170 In addition, the macros
179 Finally, the table must be terminated by an entry with a
185 function takes the pathname of a possible mount point
186 or of a device (with or without
189 If the pathname is a directory or a file,
191 checks to see if the mount point currently has a filesystem
193 If the pathname is a device,
195 checks to see if it is currently mounted.
196 If there is an associated mount, a pointer to a
199 The returned result is stored in a static buffer that is over-written
204 library routine is called.
205 If no mount is found, NULL is returned.
209 function takes a pointer to a
210 .Vt "struct statfs" .
211 If the filesystem associated with the mount point is mounted read-only,
213 requests the filesystem to reload all of its metadata from its backing store.
214 The second parameter is the function to call to print an error message
216 If no error message is desired, a
218 can be passed as the second argument.
221 function returns zero on success or non-zero on failure.
225 function adds a parameter to a list of parameters to be passed to the
228 The parameter list is built up in
230 and its length is kept in
232 Before the first call to
240 The parameter name is passed in
242 The value of the parameter name is pointed to by
244 The size of the value is passed in
246 If the value is a string, a
248 of -1 is passed to indicate that the length should be determined using
250 If the parameter has no value,
260 function adds a formatted parameter to a list of parameters to be passed
264 The parameter list is built up in
266 and its length is kept in
268 Before the first call to
269 .Fn build_iovec_argf ,
276 The parameter name is passed in
278 The value of the parameter name is described by a format string pointed to by
280 If the parameter has no value,
287 function frees the memory in the
289 vector of the length specified in
291 that was previously allocated by the
302 is set to 0 to indicate that the space has been freed.
310 argument is valid and references a directory.
313 function returns zero on success or non-zero on failure.
317 function removes all double slashes and trailing slashes from its
319 pathname parameter and returns the resulting pathname in its
323 Most commands will use the standard option set.
324 Local file systems which support the
326 flag, would also have an
329 This can be declared and used as follows:
333 struct mntopt mopts[] = {
340 mntflags = mntaltflags = 0;
342 getmntopts(options, mopts, &mntflags, &mntaltflags);
346 If the external integer variable
350 function displays an error message and exits if an
351 unrecognized option is encountered.
352 Otherwise unrecognized options are silently ignored.
367 .Fn build_iovec_argf ,
372 functions were added with
380 functions were added in