Module rsyscall.fcntl

#include <fnctl.h>

Expand source code Browse git
"`#include <fnctl.h>`"
from rsyscall._raw import lib, ffi # type: ignore
import enum
import typing as t

class AT(enum.IntFlag):
    """The flags argument to many *at syscall; mostly specifies changes to path resolution.

    Except for `AT.REMOVEDIR`, these are all path resolution changes.

    """
    NONE = 0
    FDCWD = lib.AT_FDCWD
    REMOVEDIR = lib.AT_REMOVEDIR
    "When passed to `FileDescriptor.unlinkat`, remove directories instead of linking files."
    EMPTY_PATH = lib.AT_EMPTY_PATH
    SYMLINK_NOFOLLOW = lib.AT_SYMLINK_NOFOLLOW
    SYMLINK_FOLLOW = lib.AT_SYMLINK_FOLLOW

class O(enum.IntFlag):
    "The flags argument to open and some other syscalls."
    NONE = 0
    RDONLY = lib.O_RDONLY
    WRONLY = lib.O_WRONLY
    RDWR = lib.O_RDWR
    CREAT = lib.O_CREAT
    EXCL = lib.O_EXCL
    NOCTTY = lib.O_NOCTTY
    TRUNC = lib.O_TRUNC
    APPEND = lib.O_APPEND
    NONBLOCK = lib.O_NONBLOCK
    DSYNC = lib.O_DSYNC
    DIRECT = lib.O_DIRECT
    LARGEFILE = lib.O_LARGEFILE
    DIRECTORY = lib.O_DIRECTORY
    NOFOLLOW = lib.O_NOFOLLOW
    NOATIME = lib.O_NOATIME
    CLOEXEC = lib.O_CLOEXEC
    SYNC = lib.O_SYNC
    PATH = lib.O_PATH
    TMPFILE = lib.O_TMPFILE
    # internal kernel flags, visible through FUSE and possibly other places
    FMODE_EXEC = 0x20
    FMODE_NONOTIFY = 0x4000000

class F(enum.IntEnum):
    "The cmd argument to fcntl; specifies what fcntl operation we want to do."
    SETFD = lib.F_SETFD
    GETFD = lib.F_GETFD
    SETFL = lib.F_SETFL
    ADD_SEALS = lib.F_ADD_SEALS
    GET_SEALS = lib.F_GET_SEALS

class F_SEAL(enum.IntEnum):
    "The single argument used with fcntl F.ADD_SEALS and F.GET_SEALS"
    SEAL = lib.F_SEAL_SEAL
    SHRINK = lib.F_SEAL_SHRINK
    GROW = lib.F_SEAL_GROW
    WRITE = lib.F_SEAL_WRITE
    FUTURE_WRITE = lib.F_SEAL_FUTURE_WRITE

class FD(enum.IntFlag):
    """The argument to fcntl F.SETFD and return value of fcntl F.GETFD

    This is totally different from `rsyscall.FileDescriptor`, despite
    "FD" being a frequently-used abbreviation for that class name.

    """
    CLOEXEC = lib.FD_CLOEXEC

#### Classes ####
from rsyscall.handle.fd import BaseFileDescriptor

class FcntlFileDescriptor(BaseFileDescriptor):
    async def fcntl(self, cmd: F, arg: t.Optional[int]=None) -> int:
        self._validate()
        try:
            return (await _fcntl(self.task.sysif, self.near, cmd, arg))
        except OSError as exn:
            exn.filename = (self, cmd, arg)
            raise

#### Raw syscalls ####
import rsyscall.near.types as near
from rsyscall.near.sysif import SyscallInterface
from rsyscall.sys.syscall import SYS

async def _fcntl(sysif: SyscallInterface, fd: near.FileDescriptor,
                 cmd: F, arg: t.Optional[t.Union[int, near.Address]]=None) -> int:
    if arg is None:
        arg = 0
    return (await sysif.syscall(SYS.fcntl, fd, cmd, arg))

Classes

class AT (value, names=None, *, module=None, qualname=None, type=None, start=1)

The flags argument to many *at syscall; mostly specifies changes to path resolution.

Except for AT.REMOVEDIR, these are all path resolution changes.

Expand source code Browse git
class AT(enum.IntFlag):
    """The flags argument to many *at syscall; mostly specifies changes to path resolution.

    Except for `AT.REMOVEDIR`, these are all path resolution changes.

    """
    NONE = 0
    FDCWD = lib.AT_FDCWD
    REMOVEDIR = lib.AT_REMOVEDIR
    "When passed to `FileDescriptor.unlinkat`, remove directories instead of linking files."
    EMPTY_PATH = lib.AT_EMPTY_PATH
    SYMLINK_NOFOLLOW = lib.AT_SYMLINK_NOFOLLOW
    SYMLINK_FOLLOW = lib.AT_SYMLINK_FOLLOW

Ancestors

  • enum.IntFlag
  • builtins.int
  • enum.Flag
  • enum.Enum

Class variables

var NONE
var FDCWD
var REMOVEDIR

When passed to FileDescriptor.unlinkat, remove directories instead of linking files.

var EMPTY_PATH
class O (value, names=None, *, module=None, qualname=None, type=None, start=1)

The flags argument to open and some other syscalls.

Expand source code Browse git
class O(enum.IntFlag):
    "The flags argument to open and some other syscalls."
    NONE = 0
    RDONLY = lib.O_RDONLY
    WRONLY = lib.O_WRONLY
    RDWR = lib.O_RDWR
    CREAT = lib.O_CREAT
    EXCL = lib.O_EXCL
    NOCTTY = lib.O_NOCTTY
    TRUNC = lib.O_TRUNC
    APPEND = lib.O_APPEND
    NONBLOCK = lib.O_NONBLOCK
    DSYNC = lib.O_DSYNC
    DIRECT = lib.O_DIRECT
    LARGEFILE = lib.O_LARGEFILE
    DIRECTORY = lib.O_DIRECTORY
    NOFOLLOW = lib.O_NOFOLLOW
    NOATIME = lib.O_NOATIME
    CLOEXEC = lib.O_CLOEXEC
    SYNC = lib.O_SYNC
    PATH = lib.O_PATH
    TMPFILE = lib.O_TMPFILE
    # internal kernel flags, visible through FUSE and possibly other places
    FMODE_EXEC = 0x20
    FMODE_NONOTIFY = 0x4000000

Ancestors

  • enum.IntFlag
  • builtins.int
  • enum.Flag
  • enum.Enum

Class variables

var NONE
var RDONLY
var WRONLY
var RDWR
var CREAT
var EXCL
var NOCTTY
var TRUNC
var APPEND
var NONBLOCK
var DSYNC
var DIRECT
var LARGEFILE
var DIRECTORY
var NOFOLLOW
var NOATIME
var CLOEXEC
var SYNC
var PATH
var TMPFILE
var FMODE_EXEC
var FMODE_NONOTIFY
class F (value, names=None, *, module=None, qualname=None, type=None, start=1)

The cmd argument to fcntl; specifies what fcntl operation we want to do.

Expand source code Browse git
class F(enum.IntEnum):
    "The cmd argument to fcntl; specifies what fcntl operation we want to do."
    SETFD = lib.F_SETFD
    GETFD = lib.F_GETFD
    SETFL = lib.F_SETFL
    ADD_SEALS = lib.F_ADD_SEALS
    GET_SEALS = lib.F_GET_SEALS

Ancestors

  • enum.IntEnum
  • builtins.int
  • enum.Enum

Class variables

var SETFD
var GETFD
var SETFL
var ADD_SEALS
var GET_SEALS
class F_SEAL (value, names=None, *, module=None, qualname=None, type=None, start=1)

The single argument used with fcntl F.ADD_SEALS and F.GET_SEALS

Expand source code Browse git
class F_SEAL(enum.IntEnum):
    "The single argument used with fcntl F.ADD_SEALS and F.GET_SEALS"
    SEAL = lib.F_SEAL_SEAL
    SHRINK = lib.F_SEAL_SHRINK
    GROW = lib.F_SEAL_GROW
    WRITE = lib.F_SEAL_WRITE
    FUTURE_WRITE = lib.F_SEAL_FUTURE_WRITE

Ancestors

  • enum.IntEnum
  • builtins.int
  • enum.Enum

Class variables

var SEAL
var SHRINK
var GROW
var WRITE
var FUTURE_WRITE
class FD (value, names=None, *, module=None, qualname=None, type=None, start=1)

The argument to fcntl F.SETFD and return value of fcntl F.GETFD

This is totally different from FileDescriptor, despite "FD" being a frequently-used abbreviation for that class name.

Expand source code Browse git
class FD(enum.IntFlag):
    """The argument to fcntl F.SETFD and return value of fcntl F.GETFD

    This is totally different from `rsyscall.FileDescriptor`, despite
    "FD" being a frequently-used abbreviation for that class name.

    """
    CLOEXEC = lib.FD_CLOEXEC

Ancestors

  • enum.IntFlag
  • builtins.int
  • enum.Flag
  • enum.Enum

Class variables

var CLOEXEC
class FcntlFileDescriptor (task: FileDescriptorTask, near: FileDescriptor, valid: bool)

A file descriptor accessed through some Task

This is an rsyscall-internal base class, which other FileDescriptor objects inherit from for core lifecycle methods. See FileDescriptor for more information.

Expand source code Browse git
class FcntlFileDescriptor(BaseFileDescriptor):
    async def fcntl(self, cmd: F, arg: t.Optional[int]=None) -> int:
        self._validate()
        try:
            return (await _fcntl(self.task.sysif, self.near, cmd, arg))
        except OSError as exn:
            exn.filename = (self, cmd, arg)
            raise

Ancestors

Subclasses

Methods

async def fcntl(self, cmd: F, arg: Optional[int] = None) ‑> int
Expand source code Browse git
async def fcntl(self, cmd: F, arg: t.Optional[int]=None) -> int:
    self._validate()
    try:
        return (await _fcntl(self.task.sysif, self.near, cmd, arg))
    except OSError as exn:
        exn.filename = (self, cmd, arg)
        raise

Inherited members