Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

File Systems & Mount Control

Mount and unmount file systems

mount

Supported functionality in SCML:

// Create a new mount
mount(
    source, target, filesystemtype,
    mountflags = 0,
    data
);

// Move the existing mount point
mount(
    source, target, filesystemtype,
    mountflags = MS_MOVE,
    data
);

// Create a bind mount
mount(
    source, target, filesystemtype,
    mountflags = MS_BIND | MS_REC,
    data
);

Partially supported mount flags:

  • MS_REC is only effective when used in conjunction with MS_BIND
  • MS_REMOUNT can be used, but the set options have no actual effect.
  • MS_DIRSYNC can be set but have no actual effect.
  • MS_LAZYTIME can be set but have no actual effect.
  • MS_MANDLOCK can be set but have no actual effect.
  • MS_NOATIME can be set but have no actual effect.
  • MS_NODEV can be set but have no actual effect.
  • MS_NODIRATIME can be set but have no actual effect.
  • MS_NOEXEC can be set but have no actual effect.
  • MS_NOSUID can be set but have no actual effect.
  • MS_RDONLY can be set but have no actual effect.
  • MS_RELATIME can be set but have no actual effect.
  • MS_SILENT can be set but have no actual effect.
  • MS_STRICTATIME can be set but have no actual effect.
  • MS_SYNCHRONOUS can be set but have no actual effect.

Unsupported mount flags:

  • MS_SHARED
  • MS_SLAVE
  • MS_UNBINDABLE

For more information, see the man page.

umount and umount2

Supported functionality in SCML:

// Unmount a mounted file system
umount(target);

// Unmount a mounted file system with enhanced behavior control
umount2(target, flags = UMOUNT_NOFOLLOW);

Silently-ignored flags:

  • MNT_FORCE
  • MNT_DETACH
  • MNT_EXPIRE

For more information, see the man page.

New mount API

fsconfig

Supported functionality in SCML:

// Configure a filesystem context
fsconfig(
    fs_fd,
    cmd = FSCONFIG_SET_FLAG | FSCONFIG_SET_STRING |
          FSCONFIG_CMD_CREATE | FSCONFIG_CMD_RECONFIGURE,
    key, value, aux
);

Unsupported commands:

  • FSCONFIG_SET_BINARY
  • FSCONFIG_SET_PATH
  • FSCONFIG_SET_PATH_EMPTY
  • FSCONFIG_SET_FD
  • FSCONFIG_CMD_CREATE_EXCL

For more information, see the man page.

fsmount

Supported functionality in SCML:

mount_attrs = MOUNT_ATTR_RDONLY | MOUNT_ATTR_NOSUID | MOUNT_ATTR_NODEV |
              MOUNT_ATTR_NOEXEC | MOUNT_ATTR_RELATIME | MOUNT_ATTR_NOATIME |
              MOUNT_ATTR_STRICTATIME | MOUNT_ATTR_NODIRATIME |
              MOUNT_ATTR_NOSYMFOLLOW;

// Create a mount object from a filesystem context
fsmount(fs_fd, flags = FSMOUNT_CLOEXEC, mount_attrs = <mount_attrs>);

Silently-ignored mount attributes:

  • MOUNT_ATTR_NOATIME
  • MOUNT_ATTR_NODIRATIME
  • MOUNT_ATTR_RELATIME
  • MOUNT_ATTR_STRICTATIME

For more information, see the man page.

move_mount

Supported functionality in SCML:

// Move or attach a mount object to the filesystem
move_mount(from_dfd, from_path, to_dfd, to_path, flags = MOVE_MOUNT_F_EMPTY_PATH);

Unsupported flags:

  • MOVE_MOUNT_F_SYMLINKS
  • MOVE_MOUNT_F_AUTOMOUNTS
  • MOVE_MOUNT_T_SYMLINKS
  • MOVE_MOUNT_T_AUTOMOUNTS
  • MOVE_MOUNT_T_EMPTY_PATH
  • MOVE_MOUNT_SET_GROUP
  • MOVE_MOUNT_BENEATH

For more information, see the man page.

Event notifications

inotify_init and inotify_init1

Supported functionality in SCML:

// Create an inotify instance
inotify_init();

// Create an inotify instance with enhanced behavior control
inotify_init1(flags = IN_CLOEXEC | IN_NONBLOCK);

For more information, see the man page.

inotify_add_watch

Supported functionality in SCML:

inotify_events = IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
                 IN_CLOSE_NOWRITE | IN_OPEN | IN_CREATE | IN_DELETE |
                 IN_DELETE_SELF | IN_CLOSE;

inotify_controls = IN_ONLYDIR | IN_DONT_FOLLOW | IN_MASK_CREATE |
                   IN_MASK_ADD | IN_ONESHOT;

// Add a watch to an initialized inotify instance
inotify_add_watch(fd, pathname, mask = <inotify_events> | <inotify_controls>);

Unsupported event flags:

  • IN_MOVED_FROM and IN_MOVED_TO - Move events are not generated
  • IN_MOVE_SELF - Self move events are not generated
  • IN_UNMOUNT - Unmount events are not generated
  • IN_Q_OVERFLOW - Queue overflow events are not generated (events are silently dropped when queue is full)
  • IN_ALL_EVENTS - Only includes actually supported events

Unsupported control flags:

  • IN_EXCL_UNLINK - Events on unlinked files are not excluded

For more information, see the man page.