Module rustix::fs

Documentation

Filesystem operations.

Structs

*_OK constants for use with accessat.

AT_* constants for use with openat, statat, and other *at functions.

DIR*

struct dirent

FALLOC_FL_* constants for use with fallocate.

FD_* constants for use with fcntl_getfd and fcntl_setfd.

MFD_* constants for use with memfd_create.

S_I* constants for use with openat, chmodat, and fchmod.

O_* constants for use with openat.

RENAME_* constants for use with renameat_with.

RESOLVE_* constants for use with openat2.

F_SEAL_* constants for use with fcntl_add_seals and fcntl_get_seals.

STATX_* constants for use with statx.

Timestamps used by utimensat and futimens.

Enums

POSIX_FADV_* constants for use with fadvise.

S_IF* constants for use with mknodat and Stat’s st_mode field.

LOCK_* constants for use with flock

Functions

accessat not(target_os = "illumos")

faccessat(dirfd, path, access, flags)—Tests permissions for a file or directory.

chmodat not(target_os = "wasi")

fchmodat(dirfd, path, mode, 0)—Sets file or directory permissions.

chownat not(any(target_os = "wasi"))

fchownat(dirfd, path, owner, group, flags)—Sets file or directory ownership.

copy_file_range(fd_in, off_in, fd_out, off_out, len, 0)—Copies data from one file to another.

AT_FDCWD—Returns a handle representing the current working directory.

posix_fadvise(fd, offset, len, advice)—Declares an expected access pattern for a file.

fallocate not(any(target_os = "dragonfly", target_os = "illumos", target_os = "netbsd", target_os = "openbsd", target_os = "redox"))

fallocate(fd, mode, offset, len)—Adjusts file allocation.

fchmod not(target_os = "wasi")

fchmod(fd)—Sets open file or directory permissions.

fchown not(target_os = "wasi")

fchown(fd)—Sets open file or directory ownership.

fcntl_add_seals any(target_os = "android", target_os = "linux", target_os = "fuchsia", target_os = "freebsd",)

fcntl(fd, F_ADD_SEALS)

fcntl_dupfd_cloexec not(target_os = "wasi")

fcntl(fd, F_DUPFD_CLOEXEC)—Creates a new OwnedFd instance, with value at least min, that has O_CLOEXEC set and that shares the same underlying [file description] as fd.

fcntl_get_seals any(target_os = "android", target_os = "linux", target_os = "fuchsia", target_os = "freebsd",)

fcntl(fd, F_GET_SEALS)

fcntl(fd, F_GETFD)—Returns a file descriptor’s flags.

fcntl(fd, F_GETFL)—Returns a file descriptor’s access mode and status.

fcntl(fd, F_SETFD, flags)—Sets a file descriptor’s flags.

fcntl(fd, F_SETFL, flags)—Sets a file descriptor’s status.

fdatasync not(any(target_os = "dragonfly", target_os = "ios", target_os = "macos", target_os = "redox"))

fdatasync(fd)—Ensures that file data is written to the underlying storage device.

flock not(target_os = "wasi")

flock(fd, operation)—Acquire or release an advisory lock on an open file.

fstat(fd)—Queries metadata for an open file or directory.

fstatfs not(any(target_os = "illumos", target_os = "netbsd", target_os = "redox", target_os = "wasi"))

fstatfs(fd)—Queries filesystem statistics for an open file or directory.

fsync(fd)—Ensures that file data and metadata is written to the underlying storage device.

ftruncate(fd, length)—Sets the length of a file.

futimens(fd, times)—Sets timestamps for an open file or directory.

fcntl(fd, F_GETFL) & O_ACCMODE

linkat(old_dirfd, old_path, new_dirfd, new_path, flags)—Creates a hard link.

major(dev)

makedev(maj, min)

memfd_create(path, flags)

minor(dev)

mkdirat(fd, path, mode)—Creates a directory.

mknodat not(any(target_os = "ios", target_os = "macos", target_os = "wasi"))

mknodat(dirfd, path, mode, dev)—Creates special or normal files.

openat(dirfd, path, oflags, mode)—Opens a file.

openat2(dirfd, path, OpenHow { oflags, mode, resolve }, sizeof(OpenHow))

readlinkat(fd, path)—Reads the contents of a symlink.

renameat(old_dirfd, old_path, new_dirfd, new_path)—Renames a file or directory.

renameat_with any(linux_raw, all(libc, any(target_os = "android", target_os = "linux")))

renameat2(old_dirfd, old_path, new_dirfd, new_path, flags)—Renames a file or directory.

lseek(fd, offset, whence)—Repositions a file descriptor within a file.

sendfile any(linux_raw, all(libc, any(target_os = "android", target_os = "linux")))

sendfile(out_fd, in_fd, offset, count)

fstatat(dirfd, path, flags)—Queries metadata for a file or directory.

statfs not(any(target_os = "illumos", target_os = "netbsd", target_os = "redox", target_os = "wasi"))

statfs—Queries filesystem metadata.

statx(dirfd, path, flags, mask, statxbuf)

symlinkat(old_dirfd, old_path, new_dirfd, new_path)—Creates a symlink.

lseek(fd, 0, SEEK_CUR)—Returns the current position within a file.

unlinkat(fd, path, flags)—Unlinks a file or remove a directory.

utimensat(dirfd, path, times, flags)—Sets file or directory timestamps.

Type Definitions

dev_t

__fsword_t

RawMode not(any(target_arch = "x86", target_arch = "sparc", target_arch = "avr", target_arch = "arm"))

mode_t

Stat target_pointer_width = "64"

struct stat for use with statat and fstat.

StatFs target_pointer_width = "64"

struct statfs for use with fstatfs.

struct statx for use with statx.

Constants

NFS_SUPER_MAGIC any(linux_raw, all(libc, any(target_os = "android", target_os = "linux")))

The filesystem magic number for NFS.

PROC_SUPER_MAGIC any(linux_raw, all(libc, any(target_os = "android", target_os = "linux")))

The filesystem magic number for procfs.

UTIME_NOW any(linux_raw, all(libc, not(target_os = "redox")))

UTIME_NOW for use with utimensat.

UTIME_OMIT any(linux_raw, all(libc, not(target_os = "redox")))

UTIME_OMIT for use with utimensat.