Strip off common mount arguments


#include <sys/mount.h>

char * mount_parse_generic_args( char * options, 
                                 int * flags );


The string of options that you want to parse; see below.
A pointer to a location where the function can store a set of bits corresponding to the options that it finds; see below.



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The mount_parse_generic_args() function parses the given options, removes any options that it recognizes, and sets or clears the appropriate bits in the location pointed to by flags.

This function lets you strip out common flags to help you parse mount arguments. This is useful when you want to create a custom mount utility.

Here's a list of the supported options that may be stripped:

Option: Set/Clear this bit: Description:
after Set _MOUNT_AFTER Call resmgr_attach() with _RESMGR_FLAG_AFTER.
atime Clear _MOUNT_NOATIME Log file access times (default).
before Set _MOUNT_BEFORE Call resmgr_attach() with _RESMGR_FLAG_BEFORE.
creat Clear _MOUNT_NOCREAT Allow file creation on the filesystem (default).
enumerate Set _MOUNT_ENUMERATE Auto-detect on this device.
exec Clear _MOUNT_NOEXEC Load executables (default).
force Set _MOUNT_FORCE Force an unmount or a remount change.
implied Set _MOUNT_IMPLIED The mountpoint is unspecified by the client.
noatime Set _MOUNT_NOATIME Disable logging of file access times.
nocreat Set _MOUNT_NOCREAT Don't allow file creation on the filesystem.
noexec Set _MOUNT_NOEXEC Don't allow executables to load.
nostat Set _MFLAG_OCB Don't attempt to stat() the special device before mounting (i.e., -t).
nosuid Set _MOUNT_NOSUID Don't honor setuid bits on the filesystem.
opaque Set _MOUNT_OPAQUE Call resmgr_attach() with _RESMGR_FLAG_OPAQUE.
remount Set _MOUNT_REMOUNT This path is already mounted; perform an update.
ro Set _MOUNT_READONLY Mark the filesystem mountpoint as read-only.
rw Clear _MOUNT_READONLY Mark the filesystem mountpoint as read/write (default).
suid Clear _MOUNT_NOSUID Honor setuid bits on the filesystem (default).
update Set _MOUNT_REMOUNT This path is already mounted; perform an update.


A pointer to the modified options string, which contains any options that it didn't recognize, or NULL if the function processed all the options.


while ((c = getopt(argv, argc, "o:"))) {
  switch (c) {
  case 'o':
    if ((mysteryop = mount_parse_generic_args(optarg, &flags))) {
            You can do your own getsubopt type processing here.
            mysteryop doesn't contain the common options.


QNX Neutrino

Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes