int c_system(string cmd)

Common function for calling external programs.

string getAppPath(string app)

Returns file path to the application (searches among system directories).

void createPipe(in string pipepath, uint mode = octal!666)

The function creates named pipe.

Parameters

pipepath

Name for pipe file.

mode

Specifies the FIFO's permission.

See Also:

man 3 mkfifo

string getAppShareDir()

Helper function for getting the standard path to the share directory of the current program.

string getAppHelpDir()

Helper function for getting the standard path to the help directory of the current program.

string readAppHelpText(string app, string lang = "")

This function returns help text of the current program using standard paths for help file.

string getNameByUID(uint uid)

The function returns user name by user ID.

string getNameByGID(uint gid)

The function returns group name by group ID.

void mount(
    string source,
    string target,
    string fs,
    ulong flags = 0,
    void* data = null
)

Attaches the filesystem specified by source.

Parameters

source

Filesystem source.

target

Location for mounting.

fs

Filesystem type, supported values are listed in "/proc/filesystems".

flags

Additional mount flags. Zero, by default.

data

Special data for required filesystem. Null pointer, by default.

See Also:

man 2 mount

void umount(string target, int flags = 0)

Removes the attachment of the filesystem mounted on target.

Parameters

target

Target directory with mounted filesystem.

flags

Additional flags: MNT_FORCE, MNT_FORCE, MNT_EXPIRE, UMOUNT_NOFOLLOW.

See Also:

man 2 umount2

auto MNT_FORCE

Ask the filesystem to abort pending requests before attempting the unmount. This may allow the unmount to complete without waiting for an inaccessible server, but could cause data loss. If, after aborting requests, some processes still have active references to the filesystem, the unmount will still fail. As at Linux 4.12, MNT_FORCE is supported only on the following filesystems: 9p, Ceph, CIFS, FUSE, Lustre, and NFS.

auto MNT_DETACH

Make the mount unavailable for new accesses, immediately disconnect the filesystem and all filesystems mounted below it from each other and from the mount table, and actually perform the unmount when the mount ceases to be busy.

auto MNT_EXPIRE

Mark the mount as expired. If a mount is not currently in use, then an initial call to umount() with this flag fails with the error EAGAIN, but marks the mount as expired. The mount remains expired as long as it isn't accessed by any process. A second umount() call specifying MNT_EXPIRE unmounts an expired mount. This flag cannot be specified with either MNT_FORCE or MNT_DETACH.

auto UMOUNT_NOFOLLOW

Don't dereference target if it is a symbolic link.

uint getGroupIdByName(string groupName)

Returns group numeric identifier, given the known group name.

gid_t[] getGroups(gid_t uid = uid_t.max)

Returns all system group IDs (if UID isn't specified) or group IDs that the specified user is associated with.

extern(C)
int getpagesize() pure nothrow @nogc

Gets memory page size. See: man getpagesize

void* createMapping(File f, size_t size, MapMode mode = MapMode.rdWr)

Creates a new mapping for the specified file.

Parameters

f

related file object

size

size of allocatable memory in bytes

mode

access mode (read/write, by default)

void* createAnonymousMapping(size_t size)

Allocates memory using anonymous mapping. New memory will contain zeros.

Parameters

size

size of allocatable memory in bytes

Returns

pointer to allocatable memory area.

void destroyMapping(T)(T* p, size_t size)

Releases the mapping.

Parameters

p

pointer to mapping

size

size used during the creation of the mapping

alias c_sigfn_t = extern(C) void function(int)

Alias for extern(C) void function(int). Used in signal handlers.

alias d_sigfn_t = extern(D) void function(Signal)

Alias for extern(D) void function(Signal). Used in signal handlers.

alias d_sigfn_int_t = extern(D) void function(int)

Alias for extern(D) void function(int). Used in signal handlers.

void addSignalHandler(S, H)(S sig, H handler) 
if ((is(S == Signal) || is(S : int)) && (is(H == c_sigfn_t) || is(H == d_sigfn_t) || is(H == d_sigfn_int_t)))

The function sets the handler for the signal number.

Parameters

sig

signal number of Signal or int-like type

handler

signal handler of c_sigfn_t or d_sigfn_t type

string getSignalDescription(Signal signal)

Gets UNIX signal string view.

Parameters

signal

explored signal value

Returns

string interpretation of the signal

string getSignalDescription(int signum)

Gets UNIX signal string view.

Parameters

signal

explored signal value

Returns

string interpretation of the signal

string[] findMountPoints(string blockDevicePath)

Gets a list of mount points related to the specified block device.

string[] findDevicesByMountPoint(string mountPoint)

Gets a list of devices related to the specified mount point.

mode_t getCurrentUmask()

Returns the file mode creation mask.

See Also:

man 2 umask.

The module provides mostly wrappers for low-level system functions, including functions for mounting/unmounting file systems, functions for working with loop devices, functions for getting information about users and groups, functions for mappings, for working with signals, etc.

Enums

MapMode

Enumeration of access modes for mappings.

Signal

UNIX signal enumeration.

Aliases

c_sigfn_t

Alias for extern(C) void function(int). Used in signal handlers.

d_sigfn_t

Alias for extern(D) void function(Signal). Used in signal handlers.

d_sigfn_int_t

Alias for extern(D) void function(int). Used in signal handlers.

Variables

MNT_FORCE

Ask the filesystem to abort pending requests before attempting the unmount. This may allow the unmount to complete without waiting for an inaccessible server, but could cause data loss. If, after aborting requests, some processes still have active references to the filesystem, the unmount will still fail. As at Linux 4.12, MNT_FORCE is supported only on the following filesystems: 9p, Ceph, CIFS, FUSE, Lustre, and NFS.

MNT_DETACH

Make the mount unavailable for new accesses, immediately disconnect the filesystem and all filesystems mounted below it from each other and from the mount table, and actually perform the unmount when the mount ceases to be busy.

MNT_EXPIRE

Mark the mount as expired. If a mount is not currently in use, then an initial call to umount() with this flag fails with the error EAGAIN, but marks the mount as expired. The mount remains expired as long as it isn't accessed by any process. A second umount() call specifying MNT_EXPIRE unmounts an expired mount. This flag cannot be specified with either MNT_FORCE or MNT_DETACH.

UMOUNT_NOFOLLOW

Don't dereference target if it is a symbolic link.

Functions

c_system getNameByGID createAnonymousMapping
getAppPath mount destroyMapping
createPipe umount addSignalHandler
getAppShareDir getGroupIdByName getSignalDescription
getAppHelpDir getGroups findMountPoints
readAppHelpText getpagesize findDevicesByMountPoint
getNameByUID createMapping getCurrentUmask

Classes

LoopDevControl

Set of functions for loop device management.

SysException

Exception for functions of this module