Crate libfs

Source

Structs§

Extent
Struct representing a file extent metadata.

Enums§

Error
FileType
Enum mapping for various *nix file types. Mapped from std::fs::FileType and rustix::fs::FileTypeExt.

Constants§

XATTR_SUPPORTED
Flag whether the current OS support xattrs.

Functions§

allocate_file
Allocate file space on disk. Uses Posix ftruncate().
copy_file
Copy a file. This differs from std::fs::copy in that it looks for sparse blocks and skips them.
copy_file_bytes
File copy operation that defers file offset tracking to the underlying call. On Linux this attempts to use copy_file_range and falls back to user-space if that is not available.
copy_file_offset
File copy operation that that copies a block at offsetoff. On Linux this attempts to use copy_file_range and falls back to user-space if that is not available.
copy_node
Create a clone of a special file (unix socket, char-device, etc.)
copy_owner
copy_permissions
Copy file permissions. Will also copy xattr’s if possible.
copy_sparse
Copy data between files, looking for sparse blocks and skipping them.
copy_timestamps
Copy file timestamps.
is_same_file
Determine if two files are the same by examining their inodes.
map_extents
Attempt to retrieve a map of the underlying allocated extents for a file. Will return None if the filesystem doesn’t support extents. On Linux this is the raw list from fiemap. See merge_extents for a tool to merge contiguous extents.
merge_extents
Merge any contiguous extents in a list. See merge_extents.
next_sparse_segments
Search the file for the next non-sparse file section. Returns the start and end of the data segment.
probably_sparse
Guestimate if file is sparse; if it has less blocks that would be expected for its stated size. This is the same test used by coreutils cp.
reflink
Reflink a file. This will reuse the underlying data on disk for the target file, utilising copy-on-write for any future updates. Only certain filesystems support this; if not supported the function returns false.
sync
Sync an open file to disk. Uses fsync(2).