Introduction to Operating Systems

Introduction to Operating Systems

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Index | Next >

Working with short 8.3 filenames

Learning objective: Explain what a short 8.3 filename is


Click on image to enlarge.

Long filenames (LFN), are Microsoft's way of implementing filenames longer than the 8.3 filename, or short-filename, naming scheme used in Microsoft DOS in their modern FAT and NTFS filesystems. Because these filenames can be longer than an 8.3 filename, they can be more descriptive. Another advantage of this scheme is that it allows for longer extensions common on other operating systems (e.g. .jpeg, .tiff, .html, and .xhtml) rather than specialized shortened names (e.g. .jpg, .tif, .htm, .xht). The first Microsoft Windows operating system to implement long filenames on FAT was Windows NT 3.5 in 1994. The long filename system allows a maximum length of 255 UTF-16 characters, including spaces and non-alphanumeric characters (excluding the following characters, which have special meaning within the command interpreter or the operating system kernel: \ / : * ? " < > |). This is achieved by chaining up to 20 directory entries of 13 2-byte unicode characters each. To maintain compatibility with older operating systems, Microsoft formulated a method of generating an 8.3 filename from the long filename (for example, "Microsoft.txt" to "MICROS~1.TXT") and associating it with the file. [Wikipedia]

An 8.3 filename (also called a short filename or SFN) is a filename convention used by old versions of DOS, versions of Microsoft Windows prior to Windows 95, and Windows NT 3.51. It is also used in modern Microsoft operating systems as an alternate filename to the long filename for compatibility with legacy programs. The filename convention is limited by the FAT file system. Similar 8.3 file naming schemes have also existed on earlier CP/M, Atari, and some Data General and Digital Equipment Corporation minicomputer operating systems. [Wikipedia]

This legacy technology is used in a wide range of products and devices, as a standard for interchanging information, such as compact flash cards used in cameras. VFAT LFN Long filenames introduced by Windows 95/98/ME retained compatibility. But the VFAT LFN used on NT-based systems (Windows NT/2K/XP) uses a modified 8.3 shortname. If a filename contains only lowercase letters, or is a combination of a lowercase basename with an uppercase extension, or vice-versa; and has no special characters, and fits within the 8.3 limits, a VFAT entry is not created on Windows NT and later versions such as XP. Instead, two bits in byte 0x0c of the directory entry are used to indicate that the filename should be considered as entirely or partially lowercase. Specifically, bit 4 means lowercase extension and bit 3 lowercase basename, which allows for combinations such as "example.TXT" or "HELLO.txt" but not "Mixed.txt". Few other operating systems support this. This creates a backwards-compatibility problem with older Windows versions (95, 98, ME) that see all-uppercase filenames if this extension has been used, and therefore can change the name of a file when it is transported, such as on a USB flash drive. Current 2.6.x versions of Linux will recognize this extension when reading (source: kernel 2.6.18 /fs/fat/dir.c and fs/vfat/namei.c); the mount option shortname determines whether this feature is used when writing. [Wikipedia]

Use dir /x to view short filenames

To find out for sure the SFN or 8.3 names of the files in a directory use: "dir /x" shows the short names if there is one, and the long names or : "dir /-n" shows only the short names, in the original DIR listing format. [Wikipedia]

Converting long to short filenames

Windows supports long file names up to 255 characters in length. Windows also generates an MS-DOS-compatible (short) file name in 8.3 format to allow MS-DOS-based or 16-bit Windows-based programs to access the files. [Microsoft]

Step 1: Remove invalid characters

Windows deletes any invalid characters and spaces from the file name. Invalid characters include: . " / \ [ ] : ; = ,

Step 2: Remove additional periods

Because short file names can contain only one period (.), Windows removes additional periods from the file name if valid, non-space characters follow the final period in the file name. For example, Windows generates the short file name Thisis~1.txt from the long file name This is a really long filename.123.456.789.txt Otherwise, Windows ignores the final period and uses the next to the last period. For example, Windows generates the short file name Thisis~1.789 from the long file name This is a really long filename.123.456.789.

Step 3: Truncates the file name, start with six characters and appends a tilde (~)

To make the short filename, Windows truncates the file name, if necessary, to six characters and appends a tilde (~) and a digit. For example, each unique file name created ends with "~1." Duplicate file names end with "~2," "~3," and so on.

Step 4: Truncates the file name extension

Windows truncates the file name extension, like .doc or .txt, to three characters or less.

Step 5: Convert to uppercase

Windows translates all characters in the file name and extension to uppercase.

Example: Alongf~1.txt from "A long filename.txt"

The short file name "Alongf~1.txt" is generated from the long file name "A long filename.txt" because the long file name contains more than eight characters.

Note that if a folder or file name contains a space, but less than eight characters, Windows still creates a short file name. This behavior may cause problems if you attempt to access such a file or folder over a network. To work around this situation, substitute a valid character, such as an underscore (_), for the space. If you do so, Windows does not create a different short file name. [Microsoft]

No short file name is generated from "A_file.doc" because the file name contains less than eight characters and does not contain a space. [Microsoft]

Thinking: Why does Microsoft use short filenames in their OS and why does it support backwards compatibility?

Key terms: FAT, long filename, short filename

Resources:
To maximize your learning, please visit these Web sites and review their content to help reinforce the concepts presented in this section.

Quick links:
Short filename @ Wikipedia
Long filename @ Wikipedia

Embedded Resources

Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.

Short filename @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Long filename @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Index | Next >