This file provides guidance to AI agents when working with code in this repository.
This is the reference implementation of the Linear Tape File System (LTFS) format specifications from SNIA, the LTFS format specification 2.5 (https://www.snia.org/sites/default/files/technical-work/ltfs/release/SNIA-LTFS-Format-v2.5-Technical-Position.pdf).
LTFS is a filesystem implementation that allows mounting LTFS-formatted tapes as regular filesystems. LTFS uses Filesystem in Userspace (FUSE) under the foot.
./autogen.sh
./configure --prefix=</path_to_install>make
make install
# May need: sudo ldconfig -v# Setup environment first:
export ICU_PATH="/usr/local/opt/icu4c/bin"
export LIBXML2_PATH="/usr/local/opt/libxml2/bin"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig"
export PATH="$PATH:$ICU_PATH:$LIBXML2_PATH"
./autogen.sh
LDFLAGS="-framework CoreFoundation -framework IOKit" ./configure --disable-snmp --prefix=</path_to_install>make
make installmake cleanmake clean
make distclean-
libltfs (
src/libltfs/) - Core LTFS libraryltfs.c/h- Main LTFS data structures and operationsltfs_fsops.c- Filesystem operations implementationtape.c/h- Tape drive abstraction layerindex_criteria.c- Index management logicxml_reader.c/xml_writer.c- XML index parsing/generation
-
Tape Drivers (
src/tape_drivers/)- Platform-specific tape drive implementations
linux/sg/- Linux SCSI generic driverlinux/lin_tape/- IBM lin_tape driverosx/iokit/- macOS IOKit driverfreebsd/cam/- FreeBSD CAM drivergeneric/file/- Debug purpose tape emulation on a directory (for creating situations hard to recreate)
-
I/O Schedulers (
src/iosched/)fcfs.c- First-come-first-served scheduler (This is sample of I/O scheduler. Not used at all.)unified.c- Unified I/O scheduler with optimization (This I/O scheduler can create 512KB block from chunked requests from FUSE layer)
-
Key Management (
src/kmi/)simple.c- Simple key management interface, receive keys from optionsflatfile.c- Flat file-based key storage, receive keys specified unencrypted file
-
Utilities (
src/utils/)mkltfs.c- Format tapes for LTFS likemkfsltfsck.c- Check and repair LTFS volumes likefsckltfsindextool.c- Manipulate LTFS indexes outside of LTFS filesystem implementationltfs_ordered_copy- Python script for optimized file copying
-
Entry point of
ltfsprocess (src/main.c)- This is the start point of LTFS filesystem process
-
ltfs internal filesystem operations (
src/libltfs/ltfs_fsops.c/h)- This is the ltfs own filesystem operations implementation
-
FUSE-LTFS bridge (
ltfs_fuse.c)- This layer converts request from FUSE to the ltfs own filesystem operations
- Plugin Architecture: Tape drivers, I/O schedulers, and key management are implemented as plugins loaded at runtime and called indirectly by pointer
- FUSE Integration: Uses FUSE (Filesystem in Userspace) for filesystem operations
- XML Indexes: Filesystem metadata stored as XML on tape (following LTFS format spec)
- Dual Partition: Uses tape partition feature - index on Index Partition, data on Data Partition
src/libltfs/ltfs_internal.c- This is low level function called from ltfs.csrc/libltfs/ltfs_fsops_raw.c- This is low level function to handle LTFS format called sequence is FUSE->FUSE-LTFS bridge->ltfs internal filesystem operations->I/O scheduler->low level function to handle LTFS format
- Language: C99 with gcc
contrib: Contribution code that is not a part of the project but is variable for this projectdocs: Documents and configuration files for system. See also docs/README.mdinit.d: Service script for initman: man pages for the commands provided by the projectman/sgml: Original documents for man pages written by docbook 4.1 formatmessages: Message files used in the code treesrc/libltfs: Source files for libltfs, the library that handles logical layer of the LTFS formatsrc/iosched: I/O scheduler plugins for libltfs. The libltfs makes indirect calls to an ioschead plugin loaded when a command is launched for creating 512KB block for tape R/Wsrc/tape_drivers: Tape drive handling plugins for libltfs. The libltfs makes indirect calls to an tape drive plugin loaded when a command is launched for issuing SCSI commands to different type of tape drivessrc/kmi: Encryption key management plugins for libltfsutils/mkltfs.c: Formatting tool for the LTFS likemkfsutils/ltfsck.c: Recovery tool for the LTFS likefsckutils/ltfsindextool.c: Tools for capturing indexes on the tape./main.c: Main function forltfscommand, it is the file system command for FUSE./ltfs_fuse.*: FUSE - LTFS file operation glue layer./ltfs_copyright.h: Copyright definition for injecting to compiled binaries
# List available tape drives
ltfs -o device_list
# Format a tape
mkltfs -d <device_name>
# Mount a tape
ltfs -o devname=<device_name> <mount_point>
# Unmount
umount <mount_point>
# Check/repair LTFS volume
ltfsck -d <device_name>- Use
--enable-debugconfigure option for debug builds - Set log level with
-o loglevel=<level>(0-4) - Check syslog for LTFS messages
- Linux: Supports both sg (SCSI generic) and lin_tape drivers
- macOS: Requires disabling SNMP support (
--disable-snmp) - FreeBSD/NetBSD: Uses platform-specific SCSI interfaces
- Messages defined in
messages/directory - Message is constructed a number and sevirity (Error, Warning, Info, Debug)
- Number part of message must be unique
- It means 11111W must not be used if 11111I is used
- Number part of message must not be reused once used
- It means 11111[EWID] must not be used if 11111[EWID] is already commented out
- Message ID must be commented out when it is not required anymore
- Each component has its own message file
- Run
make_message_src.shto regenerate message headers
- Do not commit directly to the any branches
- Do not provide any changes which cannot be compiled
- Do not use duplicated messege number under the
messagesdirectory - Do not reuse any message number which is commented out inder the
messagesdirectory