Strip off common mount arguments
#include <sys/mount.h> char * mount_parse_generic_args( char * options, int * flags );
libc
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_ATIME | Log file access times (default). |
before | Set _MOUNT_BEFORE | Call resmgr_attach() with _RESMGR_FLAG_BEFORE. |
creat | Clear _MOUNT_CREAT | 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. |
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_SUID | 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. */ } break; } }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
mount(), resmgr_attach(), umount()
mount in the Utilities Reference
“Layers in a resource manager” in the Bones of a Resource Manager chapter, and “Handling mount()” in the Handling Other Messages chapter, of Writing a Resource Manager