⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 long filename specification.htm

📁 硬盘ide和fat文件系统开发详解
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0040)http://home.teleport.com/~brainy/lfn.htm -->
<HTML><HEAD><TITLE>Long Filename Specification</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><!-- http://members.aol.com/vindaci/pub/doc/lfn/lfn.html --><!-- Copyright (c)1996-1998 vinDaci -->
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY>
<H2 align=center>Long Filename Specification</H2><FONT size=-1>
<P align=center>by vinDaci</FONT> <FONT size=-2><BR>fourth release</FONT> <FONT 
size=-1><BR>First Release: November 18th, 1996</FONT> <FONT size=-1><BR>Last 
Update: January 6th, 1998 (Document readability update)</FONT> </P>
<HR>

<H3>Compatibility</H3>
<P>Long filename (here on forth referred to as "LFN") design for Windows95 is 
designed to be 99% compatible with the old DOS 8.3 format. The 1% discripency 
comes in when old DOS programs can detect the <EM>presence</EM> of LFN (but 
unfortunately not the LFN itself), which in no way interferes with regular 
program operations except for perhaps low-level disk utility programs (such as 
disk error fixing programs, disk optimization programs, anti-virus program, 
etc.) <A name=background></P>
<HR>

<H3>DOS 8.3 Filename Background</H3>
<P>I trust that anyone who wish to know the details of LFN has at least a small 
knowledge in DOS 8.3 filename specification. In this document, however, I'll 
assume you know very little about the 8.3 filename specs, however. What you need 
to know in order to understand this documentation is that 8.3 filenames are 
stored in a place on the disk called the <DFN>directory table</DFN>. This place 
contains the list of filenames and other information associated with each file, 
such as the file date, time, size, attributes, etc. (Note: Contrary to some 
belief, the directory table is <EM>not</EM> the same as the FAT -- e-mail me if 
you wish to know what FAT is.) </P>
<P>The file attributes, mentioned above, play some big roles in LFN. It is 
important to note that a file's attributes are may consist of one or more of the 
following: </P>
<DIV align=center>
<CENTER>
<TABLE width="50%" border=1>
  <TBODY>
  <TR>
    <TD><CODE>Archive</CODE> </TD></TR>
  <TR>
    <TD><CODE>Read-Only</CODE> </TD></TR>
  <TR>
    <TD><CODE>System</CODE> </TD></TR>
  <TR>
    <TD><CODE>Hidden</CODE> </TD></TR>
  <TR>
    <TD><CODE>Directory</CODE> </TD></TR>
  <TR>
    <TD><CODE>Volume</CODE> </TD></TR></TBODY></TABLE></CENTER></DIV>
<P>Most programmers are aware of the Archive, Read-Only, System, and Hidden 
attrbiutes, but for those of you who don't know, please allow me to explain what 
each of these attributes is/does: 
<UL>
  <LI>The <DFN>Archive attribute</DFN> tells that a file has been backed up 
  (though most programs just ignore this). 
  <LI>The <DFN>Read-Only attribute</DFN> keeps a file from accidentally getting 
  overwritten; note that any program can unset this attribute should it know how 
  to detect this attribute and unset it -- that's why it is used just to keep a 
  file from <EM>accidentally</EM> getting overwritten. 
  <LI>The <DFN>System attribute</DFN> tells that the file is used for some 
  important operation so it should not be messed with except by the program that 
  created it; any file with this attribute cannot be seen with the 
  <KBD>DIR</KBD> command except with the <KBD>/a</KBD> or <KBD>/as</KBD> 
  arguments in DOS 5 and above. 
  <LI>The <DFN>Hidden</DFN> attribute tells that a file should normally be 
  hidden from the user's view. Any file with this attribute cannot be seen with 
  <KBD>DIR</KBD> command either, except with the <KBD>/a</KBD> or <KBD>/ah</KBD> 
  arguments in DOS 5 and above. </LI></UL>
<P>And the explanation of the other attributes (the <EM>really</EM> important 
ones): 
<UL>
  <LI>The <DFN>Directory attribute</DFN> is used to tell that a file is not 
  actually a file but a directory. This type of file contains a pointer to a 
  part of the disk that contains another directory table; this directory table 
  that's pointed to is the subdirectory of the directory that has the pointer. 
  In another words, when you "CD" to that file, you go into the directory table 
  the file points to, making it look as though you are "inside" that directory. 
  In reality, you only switch the directory tables. 
  <LI>The <DFN>volume attribute</DFN> too is used to tell that a file is not 
  actually a file. This attribute is used to indicate the volume label of the 
  drive (the name of the disk). A file with this attribute can never be 
  displayed with the <KBD>DIR</KBD> command. Furthermore, there can be only one 
  file with this attribute on the entire disk, and this file must be in the root 
  directory of the disk. <BR>&nbsp;&nbsp;&nbsp;&nbsp; The volume attribute has a 
  funny story attached to it -- There not only exists a file with the volume 
  attribute, but a copy of the volume label is also located in the boot sector 
  (the very beginning of the disk that has weird code and disk info on it) as a 
  readable text. But when you view a directory with the <KBD>DIR</KBD> command, 
  the one that actually gets displayed is the volume attributed file's name, not 
  the volume label in the boot sector. Furthermore, even though files with 
  volume attribute is hidden from the <KBD>DIR</KBD> command, programs, when 
  retrieving filenames, can retrieve volume labels.</A> All these factors about 
  volume attributes come into a big factor when we look at Long Filenames. 
</LI></UL>
<P>As an addendum, it might be interesting to note that each 8.3 file entry is 
32 bytes long but that not all 32 bytes are used to store data -- some of them 
are plainly left as blank bytes. In Windows95 version of the directory table, 
however, all 32 bytes are used. </P>
<HR>

<H3>General Specification</H3>
<P>Just like DOS 8.3 filenames, Windows95 LFNs are also stored on directory 
tables, side-by-side with DOS 8.3 filenames. On top of that, to achieve 
compatibility with old DOS programs Microsoft designed LFN in a way so it 
resembles the old DOS 8.3 format. Furthermore, an 8.3 format version of LFN 
(<CODE>tttttt~n.xxx</CODE>) is also present next to each LFN entry for 
compatibility with non-LFN supporting programs. <A name=organization></P>
<HR>

<H3>Organization</H3>
<P>From a low-level point-of-view, a normal directory table that only contains 
8.3 filenames look like this: </P>
<DIV align=center>
<CENTER>
<TABLE width="50%" border=1>
  <TBODY>
  <TR>
    <TD><CODE>...</CODE> </TD></TR>
  <TR>
    <TD><CODE>8.3 entry</CODE> </TD></TR>
  <TR>
    <TD><CODE>8.3 entry</CODE> </TD></TR>
  <TR>
    <TD><CODE>8.3 entry</CODE> </TD></TR>
  <TR>
    <TD><CODE>8.3 entry</CODE> </TD></TR></TBODY></TABLE></CENTER></DIV>
<P>If you look at a directory table that contains LFN entries, however, this is 
what you will see: </P>
<DIV align=center>
<CENTER>
<TABLE width="50%" border=1>
  <TBODY>
  <TR>
    <TD><CODE>...</CODE> </TD></TR>
  <TR>
    <TD><CODE>LFN entry 3</CODE> </TD></TR>
  <TR>
    <TD><CODE>LFN entry 2</CODE> </TD></TR>
  <TR>
    <TD><CODE>LFN entry 1</CODE> </TD></TR>
  <TR>
    <TD><CODE>8.3 entry (tttttt~n.xxx)</CODE> 
</TD></TR></TBODY></TABLE></CENTER></DIV>
<P>Notice that Long Filenames can be pretty long, so LFN entries in a 8.3 
directory structure can take up several 8.3 directory entry spaces. This is why 
the above file entry has several LFN entries for a single 8.3 file entry. </P>
<P>Despite taking up 8.3 filename spaces, Long Filenames do not show up with the 
<KBD>DIR</KBD> command or with any other program, even the ones that do not 
recognize the LFN. How, then, do LFN entries get hidden from DOS? The answer is 
quite simple: By giving LFN entries "Read-only, System, Hidden, and Volume" 
attributes. (If you do not know details about file attributes, read the above 
text about </A><A href="http://home.teleport.com/~brainy/lfn.htm#background">DOS 
8.3 Filename Background</A>.) </P>
<P>A special attention should be given to the fact that this combination of 
attributes -- Read-only, System, Hidden, Volume -- is not possible to make under 
normal circumstances using common utilities found in the market place (special 
disk-editing programs, such as Norton Disk Editor, is an exception.) </P>
<P>This technique of setting Read-only, System, Hidden, Volume attributes works 
because most programs ignore files with volume attributes altogether, and even 
if they don't, they won't display any program that has system or hidden 
attributes set. And since the Read-only attribute is set, programs won't write 
anything over it. However, you can view "parts" of the LFN entries if any 
program is designed to show Volume attributed files. </P><A name=storage>
<HR>

<H3>Storage Organization</H3>
<P>To understand the LFN storage organization within a directory table, it is 
important to understand the 8.3 storage organization. This is mainly due to the 
fact that LFN entries are stored similar to 8.3 filenames to avoid conflicts 
with DOS applications. </P>
<P>The format of the traditional DOS 8.3 is as follows: </P>
<DIV align=center>
<CENTER>
<TABLE width="80%" border=1>
  <TBODY>
  <TR>
    <TH align=middle width="15%">Offset </TH>
    <TH align=middle width="15%">Length </TH>
    <TH align=left width=*>&nbsp;&nbsp;Value </TH></TR>
  <TR>
    <TD align=middle>0 </TD>
    <TD align=middle>8 bytes </TD>
    <TD align=left>&nbsp;&nbsp;Name </TD></TR>
  <TR>
    <TD align=middle>8 </TD>
    <TD align=middle>3 bytes </TD>
    <TD align=left>&nbsp;&nbsp;Extension </TD></TR>
  <TR>
    <TD align=middle>11 </TD>
    <TD align=middle>byte </TD>
    <TD align=left>&nbsp;&nbsp;Attribute (<CODE>00ARSHDV</CODE>) 
      <BR>&nbsp;&nbsp;<CODE>0</CODE>: unused bit <BR>&nbsp;&nbsp;<CODE>A</CODE>: 
      archive bit, <BR>&nbsp;&nbsp;<CODE>R</CODE>: read-only bit 
      <BR>&nbsp;&nbsp;<CODE>S</CODE>: system bit <BR>&nbsp;&nbsp;<CODE>D</CODE>: 
      directory bit <BR>&nbsp;&nbsp;<CODE>V</CODE>: volume bit </TD></TR>
  <TR>
    <TD align=middle>22 </TD>
    <TD align=middle>word </TD>
    <TD align=left>&nbsp;&nbsp;Time </TD></TR>
  <TR>
    <TD align=middle>24 </TD>
    <TD align=middle>word </TD>
    <TD align=left>&nbsp;&nbsp;Date </TD></TR>
  <TR>
    <TD align=middle>26 </TD>
    <TD align=middle>word </TD>
    <TD align=left>&nbsp;&nbsp;Cluster (desc. below) </TD></TR>
  <TR>
    <TD align=middle>28 </TD>
    <TD align=middle>dword </TD>
    <TD align=left>&nbsp;&nbsp;File Size </TD></TR></TBODY></TABLE></CENTER></DIV>
<P align=center>Note: <DFN>WORD</DFN> = 2 bytes, <DFN>DWORD</DFN> = 4 bytes </P>
<P>Everything above you should know what they are except perhaps for the 
cluster. The cluster is a value representing another part of the disk, normally 
used to tell where the beginning of a file is. In case of a directory, it is the 
cluster that tells where the subdirectory's directory table starts. </P>
<P>You may not know this, but LFN specification not only added the capability of 
having longer filenames, but it also improved the capability of 8.3 filenames as 
well. This new 8.3 filename improvements are accomplished by using the unused 
directory table spaces (Remember how I told you that 8.3 filenames take up 32 
bytes but not all 32 bytes are used? Now it's all used up!) This new format is 
as follows -- try comparing it with the traditional format shown above!: </P>
<DIV align=center>
<CENTER>
<TABLE width="80%" border=1>
  <TBODY>
  <TR>
    <TH align=middle width="15%">Offset </TH>
    <TH align=middle width="15%">Length </TH>
    <TH align=left width=*>&nbsp;&nbsp;Value </TH></TR>
  <TR>
    <TD align=middle>0 </TD>
    <TD align=middle>8 bytes </TD>
    <TD align=left>&nbsp;&nbsp;Name </TD></TR>
  <TR>
    <TD align=middle>8 </TD>
    <TD align=middle>3 bytes </TD>
    <TD align=left>&nbsp;&nbsp;Extension </TD></TR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -