Module rsyscall.sys.mount
#include <sys/mount.h>
Expand source code Browse git
"`#include <sys/mount.h>`"
from rsyscall._raw import lib # type: ignore
import os
import typing as t
import enum
class MS(enum.IntFlag):
NONE = 0
BIND = lib.MS_BIND
DIRSYNC = lib.MS_DIRSYNC
LAZYTIME = lib.MS_LAZYTIME
MANDLOCK = lib.MS_MANDLOCK
MOVE = lib.MS_MOVE
NODEV = lib.MS_NODEV
NOEXEC = lib.MS_NOEXEC
NOSUID = lib.MS_NOSUID
RDONLY = lib.MS_RDONLY
REC = lib.MS_REC
RELATIME = lib.MS_RELATIME
REMOUNT = lib.MS_REMOUNT
SILENT = lib.MS_SILENT
SLAVE = lib.MS_SLAVE
STRICTATIME = lib.MS_STRICTATIME
SYNCHRONOUS = lib.MS_SYNCHRONOUS
UNBINDABLE = lib.MS_UNBINDABLE
class UMOUNT(enum.IntFlag):
NONE = 0
FORCE = lib.MNT_FORCE
DETACH = lib.MNT_DETACH
EXPIRE = lib.MNT_EXPIRE
NOFOLLOW = lib.UMOUNT_NOFOLLOW
#### Classes ####
import rsyscall.far
from rsyscall.handle.pointer import WrittenPointer
class MountTask(rsyscall.far.Task):
async def mount(self,
source: WrittenPointer[t.Union[str, os.PathLike]],
target: WrittenPointer[t.Union[str, os.PathLike]],
filesystemtype: WrittenPointer[t.Union[str, os.PathLike]],
mountflags: MS,
data: WrittenPointer[t.Union[str, os.PathLike]]) -> None:
with source.borrow(self):
with target.borrow(self):
with filesystemtype.borrow(self):
with data.borrow(self):
try:
return (await _mount(
self.sysif,
source.near, target.near, filesystemtype.near,
mountflags, data.near))
except OSError as exn:
exn.filename = source.value
exn.filename2 = (target.value, filesystemtype.value, data.value)
raise
async def umount(self, target: WrittenPointer[t.Union[str, os.PathLike]], flags: UMOUNT=UMOUNT.NONE) -> None:
with target.borrow(self):
await _umount2(self.sysif, target.near, flags)
#### Raw syscalls ####
import rsyscall.near.types as near
from rsyscall.near.sysif import SyscallInterface
from rsyscall.sys.syscall import SYS
async def _mount(sysif: SyscallInterface, source: near.Address, target: near.Address,
filesystemtype: near.Address, mountflags: MS,
data: near.Address) -> None:
await sysif.syscall(SYS.mount, source, target, filesystemtype, mountflags, data)
async def _umount2(sysif: SyscallInterface, target: near.Address, flags: UMOUNT) -> None:
await sysif.syscall(SYS.umount2, target, flags)
Classes
class MS (value, names=None, *, module=None, qualname=None, type=None, start=1)-
An enumeration.
Expand source code Browse git
class MS(enum.IntFlag): NONE = 0 BIND = lib.MS_BIND DIRSYNC = lib.MS_DIRSYNC LAZYTIME = lib.MS_LAZYTIME MANDLOCK = lib.MS_MANDLOCK MOVE = lib.MS_MOVE NODEV = lib.MS_NODEV NOEXEC = lib.MS_NOEXEC NOSUID = lib.MS_NOSUID RDONLY = lib.MS_RDONLY REC = lib.MS_REC RELATIME = lib.MS_RELATIME REMOUNT = lib.MS_REMOUNT SILENT = lib.MS_SILENT SLAVE = lib.MS_SLAVE STRICTATIME = lib.MS_STRICTATIME SYNCHRONOUS = lib.MS_SYNCHRONOUS UNBINDABLE = lib.MS_UNBINDABLEAncestors
- enum.IntFlag
- builtins.int
- enum.Flag
- enum.Enum
Class variables
var NONEvar BINDvar DIRSYNCvar LAZYTIMEvar MANDLOCKvar MOVEvar NODEVvar NOEXECvar NOSUIDvar RDONLYvar RECvar RELATIMEvar REMOUNTvar SILENTvar SLAVEvar STRICTATIMEvar SYNCHRONOUSvar UNBINDABLE
class UMOUNT (value, names=None, *, module=None, qualname=None, type=None, start=1)-
An enumeration.
Expand source code Browse git
class UMOUNT(enum.IntFlag): NONE = 0 FORCE = lib.MNT_FORCE DETACH = lib.MNT_DETACH EXPIRE = lib.MNT_EXPIRE NOFOLLOW = lib.UMOUNT_NOFOLLOWAncestors
- enum.IntFlag
- builtins.int
- enum.Flag
- enum.Enum
Class variables
var NONEvar FORCEvar DETACHvar EXPIREvar NOFOLLOW
class MountTask (sysif: SyscallInterface, near_process: Process, fd_table: FDTable, address_space: AddressSpace, pidns: PidNamespace)-
A wrapper around
SyscallInterfacewhich tracks the namespaces of the underlying processNote that this is a base class for the more fully featured
Task.We store namespace objects to represent the namespaces that we believe that underlying processes is in. Since we have complete control over the process, we can make sure this belief is accurate, by updating our stored namespaces when the process changes namespace. That isn't done here; it's done in handle.Task.
Currently, we store only one
PidNamespace. But each process actually has two pid namespaces:- the process's own pid namespace, which determines the pids returned from getpid, clone, and other syscalls.
- the pid namespace that new children will be in.
The two pid namespaces only differ if we call unshare(CLONE.NEWPID). Currently we don't do that because unshare(CLONE.NEWPID) makes monitoring children more complex, since they can be deleted without leaving a zombie at any time if the pid namespace shuts down. But if we did call unshare(CLONE.NEWPID), we'd need to handle this right.
In the analogy to near and far pointers, this is like a segment register, if a segment register was write-only. Then we'd need to maintain the knowledge of what the segment register was set to, outside the segment register itself. That's what we do here.
There actually were systems where segment registers were, if not quite write-only, at least expensive to set and expensive to read. For example, x86_64 - the FS and GS segment registers can only be set via syscall. If you wanted to use segmentation on such systems, you'd probably have a structure much like this one.
Expand source code Browse git
class MountTask(rsyscall.far.Task): async def mount(self, source: WrittenPointer[t.Union[str, os.PathLike]], target: WrittenPointer[t.Union[str, os.PathLike]], filesystemtype: WrittenPointer[t.Union[str, os.PathLike]], mountflags: MS, data: WrittenPointer[t.Union[str, os.PathLike]]) -> None: with source.borrow(self): with target.borrow(self): with filesystemtype.borrow(self): with data.borrow(self): try: return (await _mount( self.sysif, source.near, target.near, filesystemtype.near, mountflags, data.near)) except OSError as exn: exn.filename = source.value exn.filename2 = (target.value, filesystemtype.value, data.value) raise async def umount(self, target: WrittenPointer[t.Union[str, os.PathLike]], flags: UMOUNT=UMOUNT.NONE) -> None: with target.borrow(self): await _umount2(self.sysif, target.near, flags)Ancestors
Subclasses
Class variables
var sysif : SyscallInterfacevar near_process : Processvar fd_table : FDTablevar address_space : AddressSpacevar pidns : PidNamespace
Methods
async def mount(self, source: WrittenPointer[typing.Union[str, os.PathLike]], target: WrittenPointer[typing.Union[str, os.PathLike]], filesystemtype: WrittenPointer[typing.Union[str, os.PathLike]], mountflags: MS, data: WrittenPointer[typing.Union[str, os.PathLike]]) ‑> NoneType-
Expand source code Browse git
async def mount(self, source: WrittenPointer[t.Union[str, os.PathLike]], target: WrittenPointer[t.Union[str, os.PathLike]], filesystemtype: WrittenPointer[t.Union[str, os.PathLike]], mountflags: MS, data: WrittenPointer[t.Union[str, os.PathLike]]) -> None: with source.borrow(self): with target.borrow(self): with filesystemtype.borrow(self): with data.borrow(self): try: return (await _mount( self.sysif, source.near, target.near, filesystemtype.near, mountflags, data.near)) except OSError as exn: exn.filename = source.value exn.filename2 = (target.value, filesystemtype.value, data.value) raise async def umount(self, target: WrittenPointer[typing.Union[str, os.PathLike]], flags: UMOUNT = UMOUNT.NONE) ‑> NoneType-
Expand source code Browse git
async def umount(self, target: WrittenPointer[t.Union[str, os.PathLike]], flags: UMOUNT=UMOUNT.NONE) -> None: with target.borrow(self): await _umount2(self.sysif, target.near, flags)