[][src]Crate fcntl

Wrapper around fcntl (2) and convenience methods to make interacting with it easier. Currently only supports commands related to Advisory record locking.

Structs

flock

Enums

FcntlArg

Allowed types for the arg parameter for the fcntl syscall.

FcntlCmd

Allowed commands (cmd parameter) for the fcntl syscall.

FcntlError

Error type which functions of this crate will return.

FcntlLockType

Defines which types of lock can be set onto files.

Traits

FlockOperations

This trait is used to define functions wich directly operate on flock.

Functions

fcntl

Calls fcntl with the given cmd and arg. On success, the structure passed to the arg parameter is returned as returned by the kernel. Note: Where possible convenience wrappers (such as is_file_locked, lock_file, etc.) should be used as they correctly interpret possible return values of the syscall.

flock
is_file_locked

Checks whether the given file is locked.

lock_file

Locks the given file (using FcntlCmd::SetLock). If flock is None all parameters of the flock structure ( l_whence, l_start, l_len, l_pid) will be set to 0. locktype controls the l_type parameter. When it is None, FcntlLockType::Read is used. flock.l_type will be overwritten in all cases to avoid passing an invalid parameter to the syscall.

unlock_file

Releases the lock on the given file (using FcntlCmd::SetLock). If flock is None all parameters of the flock structure (l_whence, l_start, l_len, l_pid) will be set to 0. flock.l_type will be set to libc::F_UNLCK regardless of its original value.

Type Definitions

c_int
c_short