---
name: "chkdoreload"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/build_iovec"
---

# chkdoreload(3)

mount point operations

Part of [build\_iovec(3)](/build_iovec/3.md).

## NAME

**getmntopts**, **getmntpoint**, **chkdoreload**, **build\_iovec**, **build\_iovec\_argf**, **free\_iovec**, **checkpath**, **rmslashes** – mount point operations

## LIBRARY

System Utilities Library (libutil, -lutil)

## SYNOPSIS

**#include \<mntopts.h\>**

*void*\

**getmntopts**(*const char \*options*, *const struct mntopt \*mopts*, *int \*flagp*, *int \*altflagp*);

*struct* *statfs* *\**\

**getmntpoint**(*const char \*name*);

*int*\

**chkdoreload**(*struct statfs \*mntp*, *void (\*prtmsg)(const char \*fmt, ...)*);

*void*\

**build\_iovec**(*struct iovec \*\*iov*, *int \*iovlen*, *const char \*name*, *void \*val*, *size\_t len*);

*void*\

**build\_iovec\_argf**(*struct iovec \*\*iov*, *int \*iovlen*, *const char \*name*, *const char \*fmt*, *...*);

*void*\

**free\_iovec**(*struct iovec \*\*iov*, *int \*iovlen*);

*int*\

**checkpath**(*const char \*path*, *char \*resolved*);

*void*\

**rmslashes**(*char \*rrpin*, *char \*rrpout*);

## DESCRIPTION

The **mntopts** functions support operations associated with a mount point.

The **getmntopts**() function takes a comma separated option list and a list of valid option names, and computes the bitmask corresponding to the requested set of options.

The string *options* is broken down into a sequence of comma separated tokens. Each token is looked up in the table described by *mopts* and the bits in the word referenced by either *flagp* or *altflagp* (depending on the *m\_altloc* field of the option's table entry) are updated. The flag words are not initialized by **getmntopts**(). The table, *mopts*, has the following format:

```
struct mntopt {
	char *m_option;	/* option name */
	int m_inverse;	/* is this a negative option, e.g., "dev" */
	int m_flag;	/* bit to set, e.g., MNT_RDONLY */
	int m_altloc;	/* non-zero to use altflagp rather than flagp */
};
```

The members of this structure are:

- *m\_option*

  the option name, for example “suid”.

- *m\_inverse*

  tells **getmntopts**() that the name has the inverse meaning of the bit. For example, “suid” is the string, whereas the mount flag is MNT\_NOSUID. In this case, the sense of the string and the flag are inverted, so the *m\_inverse* flag should be set.

- *m\_flag*

  the value of the bit to be set or cleared in the flag word when the option is recognized. The bit is set when the option is discovered, but cleared if the option name was preceded by the letters “no”. The *m\_inverse* flag causes these two operations to be reversed.

- *m\_altloc*

  the bit should be set or cleared in *altflagp* rather than *flagp*.

Each of the user visible MNT\_ flags has a corresponding MOPT\_ macro which defines an appropriate *struct mntopt* entry. To simplify the program interface and ensure consistency across all programs, a general purpose macro, MOPT\_STDOPTS, is defined which contains an entry for all the generic VFS options. In addition, the macros MOPT\_FORCE and MOPT\_UPDATE exist to enable the MNT\_FORCE and MNT\_UPDATE flags to be set. Finally, the table must be terminated by an entry with a NULL first element.

The **getmntpoint**() function takes the pathname of a possible mount point or of a device (with or without */dev/* prepended to it). If the pathname is a directory or a file, **getmntpoint**() checks to see if the mount point currently has a filesystem mounted on it. If the pathname is a device, **getmntpoint**() checks to see if it is currently mounted. If there is an associated mount, a pointer to a *struct statfs* is returned. The returned result is stored in a static buffer that is over-written each time the **getmntpoint**() function or the [getmntinfo(3)](/getmntinfo/3.md) library routine is called. If no mount is found, NULL is returned.

The **chkdoreload**() function takes a pointer to a *struct statfs*. If the filesystem associated with the mount point is mounted read-only, **chkdoreload**() requests the filesystem to reload all of its metadata from its backing store. The second parameter is the function to call to print an error message if the reload fails. If no error message is desired, a NULL can be passed as the second argument. The **chkdoreload**() function returns zero on success or non-zero on failure.

The **build\_iovec**() function adds a parameter to a list of parameters to be passed to the [nmount(2)](/nmount/2.md) system call. The parameter list is built up in *iov* and its length is kept in *iovlen*. Before the first call to **build\_iovec**(), *iov* should be set to NULL and *iovlen* should be set to 0. The parameter name is passed in *name*. The value of the parameter name is pointed to by *val*. The size of the value is passed in *len*. If the value is a string, a *len* of -1 is passed to indicate that the length should be determined using [strlen(3)](/strlen/3.md). If the parameter has no value, *name* should be NULL and *len* should be 0.

The **build\_iovec\_argf**() function adds a formatted parameter to a list of parameters to be passed to the [nmount(2)](/nmount/2.md) system call. The parameter list is built up in *iov* and its length is kept in *iovlen*. Before the first call to **build\_iovec\_argf**(), *iov* should be set to NULL and *iovlen* should be set to 0. The parameter name is passed in *name*. The value of the parameter name is described by a format string pointed to by *fmt*. If the parameter has no value, *name* should be NULL.

The **free\_iovec**() function frees the memory in the *iov* vector of the length specified in *iovlen* that was previously allocated by the **build\_iovec**() and / or **build\_iovec\_argf**() functions. The *iov* is set to NULL and the *iovlen* is set to 0 to indicate that the space has been freed.

The **checkpath**() function uses [realpath(3)](/realpath/3.md) to verify that its *path* argument is valid and references a directory. The **checkpath**() function returns zero on success or non-zero on failure.

The **rmslashes**() function removes all double slashes and trailing slashes from its *rrpin* pathname parameter and returns the resulting pathname in its *rrpout* parameter.

## EXAMPLES

Most commands will use the standard option set. Local file systems which support the MNT\_UPDATE flag, would also have an MOPT\_UPDATE entry. This can be declared and used as follows:

```
#include <mntopts.h>
struct mntopt mopts[] = {
	MOPT_STDOPTS,
	MOPT_UPDATE,
	{ NULL }
};
	...
	mntflags = mntaltflags = 0;
	...
	getmntopts(options, mopts, &mntflags, &mntaltflags);
	...
```

## DIAGNOSTICS

If the external integer variable *getmnt\_silent* is zero, then the **getmntopts**() function displays an error message and exits if an unrecognized option is encountered. Otherwise unrecognized options are silently ignored. By default *getmnt\_silent* is zero.

## SEE ALSO

[nmount(2)](/nmount/2.md), [err(3)](/err/3.md), [mount(8)](/mount/8.md)

## HISTORY

The **getmntopts**() function appeared in 4.4BSD. The **build\_iovec**(), **build\_iovec\_argf**(), **free\_iovec**(), **checkpath**(), and **rmslashes**() functions were added with [nmount(2)](/nmount/2.md) in FreeBSD 5.0. The **getmntpoint**() and **chkdoreload**() functions were added in FreeBSD 13.2.

Historically, these functions were found in *getmntopts.c* in the source code of the [mount(8)](/mount/8.md) program. As of FreeBSD 15.0 they are part of **libutil**.
