Long filename
Long filenames (LFNs), also known as long file name support, are a file naming extension in Microsoft Windows operating systems that allow file and directory names to exceed the traditional 8.3 character limit (eight characters for the base name plus a three-character extension) originally imposed by MS-DOS and early FAT file systems.[1] Introduced with Windows 95 in 1995, this feature uses the VFAT (Virtual File Allocation Table) driver to enable descriptive, user-friendly names on FAT file systems while maintaining backward compatibility with legacy applications through automatically generated 8.3 short filename aliases.[1] LFNs are implemented by storing additional directory entries in the directory structure, where each LFN entry holds up to 13 Unicode characters (26 bytes), allowing a complete filename of up to 255 characters per component when multiple entries are chained together.[1] This system supports international characters via Unicode, replacing the ASCII limitations of short filenames, and is available on FAT file systems through the VFAT extension and natively on NTFS file systems in Windows.[1] For compatibility, Windows generates a shortened 8.3 alias (e.g., using tildes like "LONGFI~1.TXT") for each LFN unless explicitly disabled via registry settings, ensuring older software can still access files.[1] Over time, LFN support has evolved to address path length limitations; prior to Windows 10 version 1607, the overall file path was capped at MAX_PATH (260 characters, including the null terminator), but individual filename components could reach 255 characters.[2] Starting with Windows 10 version 1607 and continuing in Windows 11, extended-length paths up to approximately 32,767 characters are possible by enabling the LongPathsEnabled registry key and using the "\?" prefix, though this requires application manifests to declare long path awareness for full functionality.[2] Despite these advances, certain restrictions persist, such as the inability to use reserved characters (e.g., <, >, :, ", /, , |, ?, *) in names and the need for quotation marks around paths containing spaces in command-line operations.[1]History and Development
Origins in DOS Limitations
The 8.3 filename convention in MS-DOS and the early FAT file system restricted file names to a maximum of eight alphanumeric characters for the base name, followed by a period and up to three characters for the extension, with all characters converted to uppercase and limited to the ASCII set excluding certain reserved symbols like. " / \ [ ] : ; | = ,.[3] This format was a direct holdover from CP/M, the operating system that MS-DOS emulated for compatibility, as the fixed 11-character structure (8+3) fit efficiently within CP/M's 32-byte directory entry size, allocating 8 bytes for the name, 3 for the extension, and space for metadata like timestamps and attributes.[4][5]
Introduced with MS-DOS 1.0 in August 1981, the FAT file system provided basic file allocation without any support for longer or more descriptive names, reflecting its origins in Microsoft's 1977 Stand-alone Disk BASIC and adaptations for IBM's PC hardware.[6] Over the subsequent versions, from MS-DOS 2.0's addition of subdirectory support in 1983 to MS-DOS 6.22 released in May 1994, the core filename limitations persisted unchanged, as the system evolved primarily to accommodate larger hard drives and improved compression without altering the directory structure.[3][7]
These constraints arose from deliberate design choices emphasizing simplicity and reliability on resource-limited early hardware, such as 160 KB floppy disks, where fixed-length fields in 32-byte directory entries enabled quick parsing without variable-length processing or complex string handling.[8] Compatibility with CP/M applications and avoidance of overhead in low-memory environments further reinforced the 8.3 limit, preventing issues like name collisions on media with minimal storage.[4] For instance, a file named "PROGRAM.EXE" complied fully, but a descriptive name like "My Document File.txt" would fail due to exceeding the character limit, spaces, and multiple periods.[3] This rigidity motivated later extensions like VFAT to enable longer names while preserving backward compatibility.
Introduction with VFAT in Windows 95
Windows 95, released on August 24, 1995, marked the debut of long filename support through the VFAT file system extension, enabling users to employ descriptive filenames up to 255 characters in length using Unicode characters.[9][10] This capability addressed the limitations of prior DOS systems, where filenames were confined to an 8.3 format of eight characters for the base name and three for the extension.[11] VFAT extended the existing FAT12 and FAT16 file systems without requiring a complete overhaul, allowing seamless integration into the graphical interface of Windows 95 while preserving access to legacy applications.[10] Microsoft's development of VFAT stemmed from the need to bridge the gap between DOS-era constraints and the more intuitive file management required for modern consumer operating systems.[10] The extension was crafted in collaboration with original equipment manufacturers (OEMs) to facilitate broad deployment on pre-installed PCs, ensuring that VFAT could handle the growing complexity of file naming in a GUI environment.[12] By storing long names in hidden directory entries marked with specific attributes, VFAT maintained backward compatibility, automatically generating short 8.3 aliases for files with extended names.[10] Among the key innovations, VFAT permitted the use of spaces within filenames, preserved the case of lowercase letters, and allowed multiple extensions separated by periods, enhancing usability for everyday tasks like document organization.[10] These features were initially rolled out in the original Windows 95 release and further refined in subsequent updates, such as OEM Service Release 2 in 1996, which expanded file system capabilities overall.[13] Adoption extended to enterprise environments with integration into Windows NT 3.5, released in September 1994, where VFAT provided FAT-based long filename support to align with upcoming Windows 95 compatibility needs.[14]Technical Implementation
LFN Directory Entry Structure
In the VFAT file system, long filenames (LFNs) are stored using one or more specialized 32-byte directory entries that precede the corresponding 8.3 short filename (SFN) entry in the directory cluster.[15] Each LFN entry accommodates up to 13 Unicode characters, allowing a maximum filename length of 255 characters across up to 20 consecutive entries.[15] These entries are identified by a specific attribute value and include a checksum for verifying integrity against the associated SFN.[15] The ordinal field at offset 0 (1 byte) serves as a sequence number, with values ranging from 0x01 to 0x14 for non-terminal entries and 0x41 to 0x54 for the terminal entry (where bit 6 is set to indicate the end of the LFN chain).[15] The first entry in the chain (lowest ordinal) corresponds to the beginning of the filename, while the terminal entry immediately precedes the SFN entry in the directory order, with subsequent entries appearing in reverse numerical order upward from there.[15] Unused directory slots are filled with 0xFF to distinguish them from valid entries.[15] The character data is stored in UCS-2 (a precursor to UTF-16) little-endian format, divided into three segments: 5 characters (10 bytes) at offsets 1-10, 6 characters (12 bytes) at offsets 14-25, and 2 characters (4 bytes) at offsets 28-31, for a total of 13 characters per entry.[15] The attribute byte at offset 11 is set to 0x0F (combining read-only, hidden, system, and volume label flags) to mark the entry as an LFN and hide it from legacy DOS applications.[15] A 1-byte checksum at offset 13 ensures the LFN matches its SFN, computed from the uppercase ASCII characters of the SFN (including trailing spaces).[15] The type byte at offset 12 and low-word cluster field at offsets 26-27 are reserved and set to 0.[15] For deleted LFNs, the ordinal field is modified to 0xE5, mirroring the deletion marker in standard FAT entries.[15] The following table outlines the complete LFN directory entry layout:| Offset (bytes) | Size (bytes) | Field Name | Description |
|---|---|---|---|
| 0 | 1 | LDIR_Ord | Sequence number (1-20; bit 6 set for terminal entry). |
| 1-10 | 10 | LDIR_Name1 | First 5 Unicode characters (UCS-2LE). |
| 11 | 1 | LDIR_Attr | Attributes (always 0x0F). |
| 12 | 1 | LDIR_Type | Entry type (always 0). |
| 13 | 1 | LDIR_Chksum | Checksum of the corresponding SFN. |
| 14-25 | 12 | LDIR_Name2 | Next 6 Unicode characters (UCS-2LE). |
| 26-27 | 2 | LDIR_FstClusLO | First cluster low (always 0). |
| 28-31 | 4 | LDIR_Name3 | Last 2 Unicode characters (UCS-2LE). |
Short Filename Generation Algorithm
The short filename generation algorithm in VFAT ensures backward compatibility by deriving a deterministic 8.3-format alias (up to 8 characters for the base name and 3 for the extension, separated by a period) from any long filename, which can exceed these limits and include Unicode characters. This process operates on the long filename provided via the operating system's API, converting it into an uppercase, ASCII-only short form while preserving the original long name in separate directory entries. The algorithm prioritizes simplicity and uniqueness within the directory, scanning existing short filenames case-insensitively to avoid collisions.[16] The process begins with preprocessing the long filename: all spaces are removed, trailing periods and dots are stripped (retaining only the last meaningful period if present to delineate the extension), and invalid characters for 8.3 format—such as * ? " < > | / \ : + , ; = [ ]—are replaced with underscores (_). The filename is then folded to uppercase. If the resulting name already fits within 8.3 constraints (base ≤8 characters, extension ≤3) and contains no invalid elements, it is used directly as the short filename, padded with spaces if necessary. Otherwise, for longer names, the base is truncated to the first 6 valid characters (skipping any remaining invalid or removed elements), and the extension (if present) to the first 3 characters; a tilde followed by a sequence number (~1) is appended to the base to form the initial candidate. For names without an extension, the entire truncated portion plusCompatibility and Limitations
Backward Compatibility with 8.3 Filenames
VFAT ensures backward compatibility with legacy 8.3 filenames by generating a short filename (SFN) alias for every long filename (LFN), allowing older MS-DOS applications to access files without modification.[12] The SFN is derived from the LFN through truncation and the addition of numeric tails (e.g., "~1" for uniqueness), stored in a standard directory entry that links to the LFN entries via a checksum.[12] This dual-naming approach enables applications to open files using the SFN, with the operating system transparently translating it to the full LFN during access.[12] In mixed environments combining DOS and Windows applications, legacy DOS programs interact solely with SFNs, as real-mode MS-DOS lacks native LFN support and relies on 8.3 conventions.[12] Windows applications, however, utilize the full LFNs, with the Installable File System Manager (IFSMgr) routing requests across modes (V86 for DOS, protected mode for Win32) to maintain seamless interoperability.[12] Renaming a file via its SFN updates the associated LFN without data loss, preserving the file's integrity and the checksum linkage between entries.[12] For pure DOS compatibility, Windows 95 supports MS-DOS extensions like Interrupt 21h functions 71A0h–71Aah only within its environment, not in standalone real-mode DOS, allowing selective disabling of LFN processing to avoid conflicts with legacy software.[12] Early Windows 95 releases exhibited bugs impacting SFN-LFN interactions, such as failures in short-to-file control block (FCB) conversions that mishandled wildcard translations (e.g., "*" not properly converted to "?"), leading to meta-matching errors and reduced visibility of LFNs in certain searches.[12] These issues were mitigated in subsequent updates, enhancing overall stability.[12]Length and Character Restrictions
In the VFAT file system, long filenames are limited to a maximum of 255 Unicode characters per component, excluding the path separator and null terminator.[17] The overall path length, including all components and the null terminator, is restricted to 260 characters under the Windows API's MAX_PATH constant, though extended paths up to 32,767 characters are possible with specific prefixes in modern implementations.[2] This per-component limit ensures compatibility while allowing significantly longer names than the legacy 8.3 format. VFAT supports Unicode characters encoded in UTF-16 (initially UCS-2) for long filenames, enabling international character sets beyond basic ASCII.[1] This Unicode capability was introduced with VFAT in Windows 95 and enhanced in the OSR2 release, which added FAT32 support while maintaining LFN encoding.[17] Allowed characters include printable Unicode code points, such as letters, digits, spaces, and symbols from the current code page, but exclude control characters (ASCII 0-31) and the null terminator.[1] Certain elements are prohibited to prevent conflicts with system devices and commands. Invalid characters include the path separator\, colon :, asterisk *, question mark ?, double quote ", less-than <, greater-than >, and vertical bar |.[1] Reserved names, such as CON, PRN, AUX, NUL, COM1 through COM9, and LPT1 through LPT9, cannot be used as filenames or directory names, regardless of case or extension.[1] Additionally, trailing spaces and periods are automatically trimmed by the Windows shell, although the underlying file system may store them if created via API calls.[1]
Unicode normalization is not enforced in VFAT long filenames, meaning equivalent characters in different normalization forms (e.g., composed vs. decomposed) may coexist as distinct names.[18] This behavior persisted through early Windows versions and was not standardized until later file systems like NTFS introduced optional normalization in Windows Vista and beyond.[19]
Drivers and Support
VFAT LFN Drivers for Windows
In Windows 95 and 98, the VFAT LFN functionality relies on a set of core drivers that operate in protected mode to virtualize access to long filenames on FAT volumes. The Virtual Machine Manager (VMM.VXD) serves as the foundational component, handling memory management, paging, and transitions between ring-0 and ring-3 modes while providing virtualization services essential for LFN operations, such as page attachment for shared DLLs and registration of Win32 services. Complementing this, IFSMgr.sys acts as the Installable File System Manager, routing file system requests to appropriate drivers, managing resources for multiple file systems, and offering ring-0 file I/O services like IFSMgr_Ring0_FileIO for efficient LFN handling. The primary VFAT driver, VFAT.386, implements the virtual FAT file system logic, enabling LFN support through additional long directory entries (up to 255 characters per filename) and managing volume mounting via FS_MountVolume, disk layouts, and local storage for floppies and fixed disks.[12] These drivers are loaded during system initialization via entries in CONFIG.SYS, with VFAT.386 specified as a static VxD in the Device Init phase, registered through IFSMgcRegisterMount, and configured via the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD. IFSMgr.sys initializes at order A0010000h, hooking legacy interrupts (e.g., Int 21h, 25h, 26h) to support LFN APIs, while VMM.VXD loads subsequently at IniOrder 0xa0010100 to oversee the virtualization layer. This setup allows seamless LFN access in both Win32 and DOS environments, with VFAT.386 using VCACHE for 4096-byte page caching and a block cache to optimize directory reads involving multiple LFN entries. Specific LFN APIs, such as FindFirstFile, are handled through VWIN32's mapping to Int 21h functions (e.g., 716Ch for extended opens, 71xxh series with the LFN flag in ECX bit 30), enabling case-preserved Unicode filenames; additionally, flags like FILE_FLAG_POSIX_SEMANTICS in related calls (e.g., CreateFile) enforce POSIX rules for case-sensitive matching on VFAT volumes.[12][20] The evolution of VFAT LFN drivers in later Windows versions shifted toward native, kernel-mode integration without reliance on DOS subsystems. Windows NT 4.0 introduced built-in VFAT support via the fastfat.sys kernel-mode driver, providing 255-character LFN compatibility on FAT volumes (FAT12 and FAT16), with support for partitions up to 4 GB, while eliminating the DOS dependency present in Windows 95/98, thus improving stability for enterprise environments. This driver handles LFN through Unicode storage and backward-compatible 8.3 aliases. Native FAT32 support, including LFN compatibility, was added in Windows 2000 and later versions without third-party extensions. In Windows 2000 and subsequent versions, fastfat.sys evolved further as a fully kernel-mode component within the I/O Manager framework, enhancing performance through integrated caching mechanisms that mitigate the overhead of multiple directory entries required for LFNs—typically 1-20 extra 32-byte entries per long filename, which can increase directory scan times by up to 20 times compared to short filenames in dense directories. Later iterations incorporated advanced caching, such as read-ahead buffers and lazy writes, to reduce this LFN-induced overhead during file enumeration and access.[3][21][12]Third-Party and DOS-Specific Drivers
Third-party drivers for long filename (LFN) support emerged to extend functionality beyond Microsoft's official VFAT implementations, particularly in pure DOS environments lacking native integration. These drivers, often implemented as terminate-and-stay-resident (TSR) programs, provide the LFN API (Interrupt 21h, AH=71h) to enable applications to handle filenames up to 255 characters on FAT file systems. Installation typically involves loading the driver via AUTOEXEC.BAT, such asDOSLFN, to hook into DOS's file system calls without requiring Windows.[22]
One prominent example is DOSLFN, a TSR driver developed initially by Henrik Haftmann in 2001 and later maintained by Jason Hood, offering full LFN API emulation for real-mode DOS versions from 4.0 onward on 386+ processors. It supports operations like directory creation (71h/39h), file finding (71h/4Eh), and renaming (71h/56h), allowing LFN-aware applications such as Volkov Commander to access extended names while maintaining backward compatibility with 8.3 short filenames. Early versions focused on FAT12/16/32 passthrough but lacked full Unicode handling, limiting international character support until later updates.[23][24]
In the FreeDOS ecosystem, LFN extensions were integrated into the kernel through community projects starting in 2001, enabling native support for long filenames alongside FAT32 without additional TSRs in versions like kernel 2043 and later. This kernel-level implementation updates metadata handling for LFN requirements, such as modified dates, and is compiled with assembly and C for broad compatibility in open-source DOS derivatives. Adoption persisted in legacy and embedded systems pre-2000, where resource constraints favored lightweight TSRs over full OS upgrades, though limitations like incomplete Unicode persisted in initial third-party releases.[25][26]
Drivers for alternative file systems, such as HPFS and NTFS, provided LFN passthrough in DOS by emulating VFAT-like access. For instance, HPFSDOS and HPFSA enable read-only mounting of HPFS partitions, preserving long filenames created by OS/2 while exposing them via the LFN API. Similarly, NTFS4DOS offers read/write access to NTFS volumes with LFN support in its professional edition, allowing DOS applications to interact with Windows NT/2000 files without conversion to 8.3 format. Microsoft's MS-DOS 7.0, bundled with early Windows 95, included partial LFN awareness via VFAT without extra drivers, but full real-mode functionality required these third-party extensions for standalone DOS use.[27][28]
For networked environments, Novell NetWare incorporated LFN support through server-side modules like LONG.NAM, loaded on NetWare 4.11 volumes to enable DOS clients to access extended filenames via the NetWare filename format, bridging DOS limitations in multi-OS setups. These drivers were particularly vital in pre-2000 legacy hardware and embedded applications, where they facilitated file sharing without migrating to Windows-dependent systems.[29]
Usage in DOS Environments
Driver-less Real Mode LFN Commands
In the context of Windows 95, the real-mode COMMAND.COM from MS-DOS 7.0 includes internal hooks that enable limited long filename (LFN) support for built-in commands when running in a DOS session on VFAT volumes, without requiring the explicit loading of additional drivers such as VFAT.386 in that session, as the underlying Windows environment provides the necessary LFN API extensions via interrupt 21h function AH=71h.[30] Specific commands like DIR with the /X option display both the LFN and the corresponding short filename (SFN), while REN and DEL can operate on LFNs directly if the volume is accessible as the boot partition.[30] This functionality relies on the presence of VFAT-formatted media and fails on non-VFAT volumes or non-boot partitions, as the support is tied to the system's primary file system configuration. Additionally, operations remain confined to real mode, lacking multitasking or protected-mode features.[30] MS-DOS 7.10, included in Windows 95 OSR 2 and later, continued this LFN support and added FAT32 file system compatibility.[31] For extended functionality beyond these built-in commands, third-party TSRs like LFNDOS could be employed in pure DOS setups.[30]Limitations in Pure DOS Setups
In pure MS-DOS 6.22 setups, long filenames (LFNs) are entirely ignored during the boot process, with the operating system recognizing only the corresponding short filenames (SFNs) in the 8.3 format. This leads to issues such as incorrect volume label reporting in directory listings, where MS-DOS 6.22 misinterprets LFN directory entries—marked with Read-Only, Hidden, System, and Volume Label attributes—as the actual volume label, rendering it unchangeable and causing display anomalies like garbage characters in place of LFN data.[32] Moreover, disk management operations pose significant risks, as tools like Fdisk may report errors such as "Volume label does not match" when attempting to remove partitions containing LFNs, while the LABEL command fails with "Cannot make directory entry" during volume label changes. These incompatibilities can result in incomplete file deletions or orphaned LFN entries if SFN-based operations are performed without LFN awareness, potentially leading to directory inconsistencies or data corruption over time, as non-aware DOS utilities may overwrite or fragment LFN structures without preserving them.[32] At the command line, early DOS versions like MS-DOS 6.22 provide no native mechanisms for creating, renaming, or fully accessing LFNs, confining all file operations to the restrictive 8.3 SFN format and rendering long descriptive names inaccessible or invisible. Users often resort to third-party shells such as 4DOS, which extends command-line functionality to handle LFNs when an appropriate driver is loaded, though this requires additional setup beyond standard DOS capabilities.[33] Hardware constraints further exacerbate these limitations, as LFNs depend on VFAT-formatted volumes, which pure DOS 6.22 cannot reliably access or create on floppy disks due to the inherent FAT12 structure and limited sector space for multiple LFN entries per file. Booting and operating on large VFAT partitions also demands a VFAT-aware BIOS or bootloader supporting extended INT 13h functions to handle drives exceeding 8 GB, as standard MS-DOS 6.22 lacks native LBA support and fails on non-extended FAT setups, often resulting in inaccessible or unrecognized volumes.[34] Around the Y2K transition, third-party patches and drivers, such as updated versions of DOSLFN, emerged to retrofit LFN compatibility into legacy DOS environments, addressing both date-handling issues and filename extensions. A key milestone came with FreeDOS 1.3 in 2022, which integrated native LFN support directly into its kernel, COMMAND.COM replacement, and core utilities, enabling seamless creation and manipulation of long filenames without external drivers in this open-source DOS variant.[35] As of 2025, no further major updates to this LFN feature have been introduced.[36] While driver-less real mode LFN commands provide limited visibility into existing long names on VFAT volumes, they fall short in pure DOS setups by lacking creation or editing capabilities, underscoring the overall incompleteness of support without supplemental software.Other Implementations
Support in Non-Windows Operating Systems
In Linux, the VFAT filesystem module, which provides full read and write support for long filenames (LFNs) on FAT volumes, has been integrated into the kernel since the 2.0 series released in 1996. This module enables seamless handling of extended filenames up to 255 characters, including Unicode support through mount options such asutf8, which interprets filenames in UTF-8 encoding to preserve international characters. Without proper options like iocharset or utf8, the driver may mangle or replace invalid characters to ensure compatibility with the underlying FAT structure.[37]
macOS natively uses the Hierarchical File System Plus (HFS+), which supports long filenames exceeding 255 characters, but provides VFAT compatibility through built-in drivers for reading and writing to FAT volumes with LFN support.[38] This allows macOS to access Windows-formatted drives while preserving extended names, though overall path lengths in macOS are limited to approximately 1024 characters.[39]
Other operating systems have implemented varying degrees of LFN support on VFAT. ReactOS, an open-source project aiming for binary compatibility with Windows, mirrors the VFAT driver from Windows NT, providing native read/write access to long and Unicode filenames on FAT volumes.[40] In embedded real-time operating systems like QNX Neutrino RTOS, the fs-dos.so module enables full LFN support on FAT12/16/32 volumes, creating long filenames for entries exceeding the 8.3 format or using mixed case, with a maximum length of 255 characters per the VFAT specification.[41][42] FreeBSD provides VFAT support via its msdosfs kernel module, allowing read/write access to LFNs since version 5.0 in 2003, with similar Unicode handling through mount options.[43] Android, based on Linux, supports VFAT on external storage like SD cards through the kernel's vfat module, preserving LFNs up to 255 characters with UTF-8 encoding.[44]
Unix-like systems, including Linux variants, typically handle invalid characters (such as colons or question marks disallowed in VFAT) by stripping or replacing them during file operations on mounted FAT volumes, often using the ? character as a substitute to avoid errors.[45] Cross-platform tools like Samba preserve LFNs when sharing VFAT volumes over networks, mapping extended names via the SMB protocol to ensure fidelity between Windows and Unix clients without truncation.[46]