Skip to main content

Module fs

Module fs 

Source
Available on crate feature fs only.
Expand description

Filesystem operations.

Modules§

inotifylinux_raw_dep
inotify support for working with inotify objects.

Structs§

Access
*_OK constants for use with accessat.
AtFlags
AT_* constants for use with openat, statat, and other *at functions.
Diralloc and neither target_os=espidf nor Redox
DIR*
DirEntryalloc and neither target_os=espidf nor Redox
struct dirent
FallocateFlags
FALLOC_FL_* constants for use with fallocate.
Fsid
fsid_t for use with StatFs.
Gid
gid_t—A Unix group ID.
IFlagslinux_kernel
FS_* constants for use with ioctl_getflags.
MemfdFlags
MFD_* constants for use with memfd_create.
Mode
S_I* constants for use with openat, chmodat, and fchmod.
OFlags
O_* constants for use with openat.
RawDirlinux_kernel
A directory iterator implemented with getdents.
RawDirEntrylinux_kernel
A raw directory entry, similar to std::fs::DirEntry.
RenameFlags
RENAME_* constants for use with renameat_with.
ResolveFlags
RESOLVE_* constants for use with openat2.
SealFlags
F_SEAL_* constants for use with fcntl_add_seals and fcntl_get_seals.
Statx86-64
struct stat for use with statat and fstat.
StatFs
struct statfs for use with statfs and fstatfs.
StatVfs
struct statvfs for use with statvfs and fstatvfs.
StatVfsMountFlags
ST_* constants for use with StatVfs.
Statxlinux_kernel
struct statx for use with statx.
StatxAttributeslinux_kernel
STATX_ATTR_* flags for use with Statx.
StatxFlagslinux_kernel
STATX_* constants for use with statx.
StatxTimestamplinux_kernel
struct statx_timestamp for use with Statx.
Timespec
struct timespec—A quantity of time in seconds plus nanoseconds.
Timestamps
Timestamps used by utimensat and futimens.
Uid
uid_t—A Unix user ID.
XattrFlagsapple or linux_kernel or target_os=hurd
XATTR_* constants for use with setxattr, and other *setxattr functions.

Enums§

Advice
POSIX_FADV_* constants for use with fadvise.
FileType
S_IF* constants for use with mknodat and Stat’s st_mode field.
FlockOperation
LOCK_* constants for use with flock and fcntl_lock.
SeekFrom
Enumeration of possible methods to seek within an I/O object.

Constants§

ABSNon-target_os=espidf
-EBADF—A handle that requires paths to be absolute.
CWDNon-target_os=espidf and non-target_os=horizon
AT_FDCWD—A handle representing the current working directory.
NFS_SUPER_MAGIClinux_kernel
The filesystem magic number for NFS.
PROC_SUPER_MAGIClinux_kernel
The filesystem magic number for procfs.
UTIME_NOWNeither target_os=espidf nor target_os=horizon nor Redox nor target_os=vita
UTIME_NOW for use with utimensat.
UTIME_OMITNeither target_os=espidf nor target_os=horizon nor Redox nor target_os=vita
UTIME_OMIT for use with utimensat.

Traits§

DirEntryExtstd and Unix
Re-export types common to POSIX-ish platforms. Unix-specific extension methods for fs::DirEntry.
FileExtstd and Unix
Re-export types common to POSIX-ish platforms. Unix-specific extensions to fs::File.
FileTypeExtstd and Unix
Re-export types common to POSIX-ish platforms. Unix-specific extensions for fs::FileType.
MetadataExtstd and Unix
Re-export types common to POSIX-ish platforms. Unix-specific extensions to fs::Metadata.
OpenOptionsExtstd and Unix
Re-export types common to POSIX-ish platforms. Unix-specific extensions to fs::OpenOptions.

Functions§

accessNeither target_os=espidf nor target_os=horizon nor target_os=vita
access(path, access)—Tests permissions for a file or directory.
accessatNeither target_os=espidf nor target_os=horizon nor target_os=vita nor Redox
faccessat(dirfd, path, access, flags)—Tests permissions for a file or directory.
chmodNon-WASI
chmod(path, mode)—Sets file or directory permissions.
chmodatNeither target_os=espidf nor WASI nor Redox
fchmodat(dirfd, path, mode, flags)—Sets file or directory permissions.
chownNon-WASI
chown(path, owner, group)—Sets open file or directory ownership.
chownatNeither target_os=espidf nor WASI nor Redox
fchownat(dirfd, path, owner, group, flags)—Sets file or directory ownership.
copy_file_rangelinux_kernel
copy_file_range(fd_in, off_in, fd_out, off_out, len, 0)—Copies data from one file to another.
ext4_ioc_resize_fslinux_kernel and linux_raw_dep
ioctl(fd, EXT4_IOC_RESIZE_FS, blocks)—Resize ext4 filesystem on fd.
fadviseNeither apple nor netbsdlike nor DragonFly BSD nor target_os=espidf nor Haiku nor target_os=horizon nor Redox nor Solaris nor target_os=vita
posix_fadvise(fd, offset, len, advice)—Declares an expected access pattern for a file.
fallocateNeither netbsdlike nor DragonFly BSD nor target_os=espidf nor target_os=horizon nor target_os=nto nor Redox nor target_os=vita
fallocate(fd, mode, offset, len)—Adjusts file allocation.
fchmodNon-WASI
fchmod(fd, mode)—Sets open file or directory permissions.
fchownNon-WASI
fchown(fd, owner, group)—Sets open file or directory ownership.
fcntl_add_sealslinux_kernel or FreeBSD or Fuchsia
fcntl(fd, F_ADD_SEALS)—Add seals to fd’s inode.
fcntl_get_sealslinux_kernel or FreeBSD or Fuchsia
fcntl(fd, F_GET_SEALS)—Return the seals for fd’s inode.
fcntl_getfl
fcntl(fd, F_GETFL)—Returns a file descriptor’s access mode and status.
fcntl_lockNeither Emscripten nor target_os=espidf nor Fuchsia nor target_os=horizon nor Redox nor target_os=vita nor WASI
fcntl(fd, F_SETLK)—Acquire or release an fcntl-style lock.
fcntl_setfl
fcntl(fd, F_SETFL, flags)—Sets a file descriptor’s status.
fdatasyncNeither apple nor DragonFly BSD nor target_os=espidf nor Haiku nor target_os=horizon nor Redox nor target_os=vita
fdatasync(fd)—Ensures that file data is written to the underlying storage device.
fgetxattrapple or linux_kernel or target_os=hurd
fgetxattr(fd, name, value.as_ptr(), value.len())—Get extended filesystem attributes on an open file descriptor.
flistxattrapple or linux_kernel or target_os=hurd
flistxattr(fd, list.as_ptr(), list.len())—List extended filesystem attributes on an open file descriptor.
flockNeither target_os=espidf nor target_os=horizon nor Solaris nor target_os=vita nor WASI
flock(fd, operation)—Acquire or release an advisory lock on an open file.
fremovexattrapple or linux_kernel or target_os=hurd
fremovexattr(fd, name)—Remove an extended filesystem attribute on an open file descriptor.
fsetxattrapple or linux_kernel or target_os=hurd
fsetxattr(fd, name, value.as_ptr(), value.len(), flags)—Set extended filesystem attributes on an open file descriptor.
fstat
fstat(fd)—Queries metadata for an open file or directory.
fstatfsNeither solarish nor target_os=espidf nor Haiku nor target_os=horizon nor NetBSD nor target_os=nto nor Redox nor target_os=vita nor WASI
fstatfs(fd)—Queries filesystem statistics for an open file or directory.
fstatvfsNon-WASI
fstatvfs(fd)—Queries filesystem statistics for an open file or directory, POSIX version.
fsync
fsync(fd)—Ensures that file data and metadata is written to the underlying storage device.
ftruncate
ftruncate(fd, length)—Sets the length of a file.
futimensNeither target_os=espidf nor target_os=horizon nor target_os=vita
futimens(fd, times)—Sets timestamps for an open file or directory.
getxattrapple or linux_kernel or target_os=hurd
getxattr(path, name, value)—Get extended filesystem attributes.
ioctl_blkpbszgetlinux_kernel
ioctl(fd, BLKPBSZGET)—Returns the physical block size of a block device.
ioctl_blksszgetlinux_kernel
ioctl(fd, BLKSSZGET)—Returns the logical block size of a block device.
ioctl_ficlonelinux_kernel and neither target_arch=sparc nor SPARC64
ioctl(fd, FICLONE, src_fd)—Share data between open files.
ioctl_getflagslinux_kernel and linux_raw_dep
ioctl(fd, FS_IOC_GETFLAGS)—Returns the inode flags attributes
ioctl_setflagslinux_kernel and linux_raw_dep
ioctl(fd, FS_IOC_SETFLAGS)—Modify the inode flags attributes
lgetxattrapple or linux_kernel or target_os=hurd
lgetxattr(path, name, value.as_ptr(), value.len())—Get extended filesystem attributes, without following symlinks in the last path component.
link
link(old_path, new_path)—Creates a hard link.
linkatNeither target_os=espidf nor Redox
linkat(old_dirfd, old_path, new_dirfd, new_path, flags)—Creates a hard link.
listxattrapple or linux_kernel or target_os=hurd
listxattr(path, list.as_ptr(), list.len())—List extended filesystem attributes.
llistxattrapple or linux_kernel or target_os=hurd
llistxattr(path, list.as_ptr(), list.len())—List extended filesystem attributes, without following symlinks in the last path component.
lremovexattrapple or linux_kernel or target_os=hurd
lremovexattr(path, name)—Remove an extended filesystem attribute, without following symlinks in the last path component.
lsetxattrapple or linux_kernel or target_os=hurd
setxattr(path, name, value.as_ptr(), value.len(), flags)—Set extended filesystem attributes, without following symlinks in the last path component.
lstat
lstat(path)—Queries metadata for a file or directory, without following symlinks.
majorNeither target_os=espidf nor Haiku nor target_os=horizon nor target_os=vita nor WASI
major(dev)—Compute the major ID of a given device ID.
makedevNeither target_os=espidf nor Haiku nor target_os=horizon nor target_os=vita nor WASI
makedev(maj, min)—Compute a device ID from a given major and minor ID.
memfd_createlinux_kernel or FreeBSD
memfd_create(name, flags)—Create an anonymous file.
minorNeither target_os=espidf nor Haiku nor target_os=horizon nor target_os=vita nor WASI
minor(dev)—Compute the minor ID of a given device ID.
mkdir
mkdir(path, mode)—Creates a directory.
mkdiratNon-Redox
mkdirat(fd, path, mode)—Creates a directory.
mkfifoatNeither apple nor target_os=espidf nor target_os=horizon nor target_os=vita nor WASI nor Redox
mkfifoat(dirfd, path, mode)—Make a FIFO special file.
mknodatNeither apple nor target_os=espidf nor target_os=horizon nor target_os=vita nor WASI nor Redox
mknodat(dirfd, path, mode, dev)—Creates special or normal files.
open
open(path, oflags, mode)—Opens a file.
openatNon-Redox
openat(dirfd, path, oflags, mode)—Opens a file.
openat2linux_raw_dep
openat2(dirfd, path, OpenHow { oflags, mode, resolve }, sizeof(OpenHow))— Opens a file with more options.
readlinkalloc
readlink(path)—Reads the contents of a symlink.
readlinkatalloc
readlinkat(fd, path)—Reads the contents of a symlink.
readlinkat_rawNon-Redox
readlinkat(fd, path)—Reads the contents of a symlink, without allocating.
removexattrapple or linux_kernel or target_os=hurd
removexattr(path, name)—Remove an extended filesystem attribute.
rename
rename(old_path, new_path)—Renames a file or directory.
renameat
renameat(old_dirfd, old_path, new_dirfd, new_path)—Renames a file or directory.
renameat_withapple or linux_kernel or Redox
renameat2(old_dirfd, old_path, new_dirfd, new_path, flags)—Renames a file or directory.
rmdir
rmdir(path)—Removes a directory.
seek
lseek(fd, offset, whence)—Repositions a file descriptor within a file.
sendfileLinux
sendfile(out_fd, in_fd, offset, count)—Transfer data between file descriptors.
setxattrapple or linux_kernel or target_os=hurd
setxattr(path, name, value.as_ptr(), value.len(), flags)—Set extended filesystem attributes.
stat
stat(path)—Queries metadata for a file or directory.
statatNeither target_os=espidf nor Redox
fstatat(dirfd, path, flags)—Queries metadata for a file or directory.
statfsNeither solarish nor target_os=espidf nor Haiku nor target_os=horizon nor NetBSD nor target_os=nto nor Redox nor target_os=vita nor WASI
statfs—Queries filesystem metadata.
statvfsNeither WASI
statvfs—Queries filesystem metadata, POSIX version.
statxlinux_kernel
statx(dirfd, path, flags, mask, statxbuf)—Extended stat.
symlink
symlink(old_path, new_path)—Creates a symlink.
symlinkatNon-Redox
symlinkat(old_path, new_dirfd, new_path)—Creates a symlink.
syncNeither target_os=espidf nor target_os=horizon nor Redox nor target_os=vita nor WASI
sync—Flush cached filesystem data for all filesystems.
syncfslinux_kernel
syncfs(fd)—Flush cached filesystem data.
tell
lseek(fd, 0, SEEK_CUR)—Returns the current position within a file.
unlink
unlink(path)—Unlinks a file.
unlinkatNeither target_os=espidf nor Redox
unlinkat(fd, path, flags)—Unlinks a file or remove a directory.
utimensatNeither target_os=espidf nor target_os=horizon nor target_os=vita nor Redox
utimensat(dirfd, path, times, flags)—Sets file or directory timestamps.

Type Aliases§

Dev
dev_t
FsWordNeither MIPS-64 nor MIPS-64 Release 6 nor s390x
__fsword_t
Nsecs
A type for the tv_nsec field of Timespec.
RawMode
mode_t
Secs
A type for the tv_sec field of Timespec.