Method for backup and recovery of the long filename in computer system6374265Abstract This invention discloses a method for backup and recovery of the long filename in the computer system (e.g., DOS) that not support the long filename. The technique of the backup operation of this invention is to read the file directory table (FDT) from the logic partition of the hard disk by calling the basic input output system (BIOS) function; then transfer the long filename and short filename items into long filename format and saving to a backup file. Alternatively, recovering the backup is to search the short filename of each directory and sub directory and obtaining the data in the back up file; then write the matched long filename back to the original FDT. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
TABLE 1
DPB structures of FAT16 format
Location Contents
0B-0C Bytes per sector (0 .times. 0002 = 512)
0D Sectors per cluster (decided by size of partition)
0E-0F Reserved (0 .times. 0100)
10 Number of FAT (0 .times. 02)
11-12 Maximum number of file directory items (0 .times. 0002)
13-14 Total sectors (0, maximum is 65535)
15 Media description code (0 .times. 18)
16-17 Sectors per FAT (equation 1)
18-19 Sectors per track
1A-1B Head number
1C-1D Hidden sectors (no influence to the result)
20-23 Total sector number if byte 13-14 is 0
24 Physical drive number (first = 0 .times. 80, second = 0 .times.
81)
25 Reserved
26 Characteristic byte of extension index record (0 .times. 29)
27-2A Serial number of disk (generated randomly)
2B-35 Label (11 bytes)
36-3D File system type (FAT16)
The structure of the short filename and long filename item of FDT are shown in table 3.
TABLE 3
Long/short filename structures of FDT
Long filename item (including ending mark)
Long filename item
.
.
.
Long filename item
Short filename item
Data Structure of Long Filename Item and Short Filename Item In Win95 system, there is a method for storing long filenames with directory items of 8.3 format (short filename format). Microsoft calls it as virtual file allocation table (VFAT). Every file that stores VFAT system has a relative 8.3 format alias storing in the same FDT. Every FDT consists many file directory items (including short filename directory item and long filename directory item). Every long filename directory item stores 13 characters of the long filename in "unicode" format. Every character uses two bits. In order to distinguish between long filename and short filename in FDT, Microsoft Win95 sets the attribute of long filename as 0F. Since 0F is an illegal filename and cannot be accessed in DOS, the long-name file is protected from being deleted or renamed by DOS but DOS can access the short-name file. Table 4 and table 5 show the format of the long and short filename directory items respectively.
TABLE 4
Format of long filename directory item
Offset length Description
00H 1 byte Bit 0.about.bit 5 are the address of directory item
respect
to short filename, bit 6 is an ending mark
01H 10 bytes Including 5 characters of long filename
0BH 1 byte Attribute, 0FH in long filename
0CH 1 byte Reserved
0DH 1 byte Checking sum of short filename
0EH 12 bytes Including 6 characters of long filename
1AH 1 word Reserved (always 0)
1CH 4 bytes Including 2 characters of long filename
For example, there is a file in long filename formatted as "RunOnceLog.txt" and in short filename formatted as "RUNONC.about.1.TXT", it stores in forms as follows
1370:04E0 42 2E 00 74 00 78 00 74- 00 00 00 0F 00 D0 FF FF B..t.x.t........
1370:04F0 FF FF FF FF FF FF FF-FF FF FF 00 00 FF FF FF FF ................
1370:0500 01 52 00 75 00 6E 00 4F-00 6E 00 0F 00 D0 63 00 .R.u.n.O.n....c.
1370:0510 65 00 45 00 78 00 20 00 -4C 00 00 00 6F 00 67 00 e.E.x..L...o.g.
1370:0520 52 55 4E 4F 4E 43 7E 31-54 58 54 20 00 15 2B 6D
RUNONE.about.1TXT.. +m
1370:0530 67 25 67 25 00 00 16 72-65 25 14 00 B3 45 00 00 g%g%...re%...E..
From 1370:04E0 to 1370:04FF, 32 bytes are long filename rear item. From 1370:0500 to 1370:051F, 32 bytes are long filename item. From 1370:0520 to 1370:053F, 32 bytes are short filename directory item. Windows can check whether the short filename was modified under non-Win9x environment by calculating the checksum of short filename and comparing with the checksum data in the long filename item. According to the technique disclosed in the present invention, all we need is to back up the long filename item and corresponding short filename of the file directory region into a backup file. Then we can use the backup file to recover the long filename by finding the corresponding short filename in the backup file and obtaining the long filename from the backup file writing back to the file directory region of the disk. Referring to FIG. 3, the long filename backup operation flow of the present invention includes the steps of: 1. Obtaining the first sector of partition (i.e., the DPB) of the hard disk 30 according to the partition table. 2. Storing the long filename item and short filename item of the FDT into the current directory as a long filename backup file. 3. Search the FDT of the subdirectories. 4. Storing the long filename item and short filename item of the FDT of subdirectories into the current subdirectory as a long filename backup file. 5. Checking whether other subdirectories have not been backed up; if the answer is yes, going back to step 4; otherwise, finishing the operation. With reference to FIG. 5, since there may be short filenames in the same FDT such as shortname1.about.shortname3 of FIG. 5, they have no corresponding long filenames. The short filename items of those short filenames are useless in the long filename recovery process. Therefore, after the backup file was created, the short filename that has no corresponding long filename item existed will be eliminated. Referring to FIG. 7, the main process to back up the long filename of this invention includes the steps of: 1. Starting to back up long filenames of the FDT. 2. Reading the DPB data of the hard disk that is backed up to get the file system ID (FSID). 3. According to FSID, if the disk partition is FAT 16, going to step 4; if disk partition is FAT 32, going to step 6; otherwise, going to step 9. 4. Calculating the location of boot directory table (BDT). 5. Setting the size of BDT including disk capacity and cluster. 6. Obtaining the start point of BDT. 7. Calculating the BDT start location. 8. Searching each FDT and creating the long filename backup file in the current directory. 9. Finishing the backup process. The technique of process in FIG. 7 is followed by by searching and obtaining the root directory location according to the partition table of the disk drive. It is the first sector after the FAT for FAT 16 system, and normally the second cluster for FAT 32 system. In the case of FAT 32 system, the root directory location can also be read from DPB. After the root directory location was found, the backup of the long filename of the root directory and subdirectories can be proceeded. Referring to FIG. 8, the detail process of step 8 in FIG. 7 includes the steps of: 1. Checking whether the backup operation of current directory is finished? If the answer is yes, going to step 5, otherwise, going to next step. 2. Reading a filename item and write to the long filename backup file in the current directory. 3. Checking whether the file directory item is the ending item of long filename? If the answer is yes, going to next step, otherwise, going back to step 1. 4. Saving the backup file under the current directory as a backup document then going back to step 1. 5. Setting the starting directory as the current directory 6. Checking whether the backup operation of current directory is finished? If the answer is yes, stopping the long filename backup operation, otherwise, going to next step. 7. Reading filename item and writing it to the long filename backup file in the current directory. 8. Checking whether the file directory item is a subdirectory? If the answer is yes, going to next step, otherwise, going back to step 6. 9. Proceeding the next subdirectory in a recursive manner, then going back to step 6. The method to search FDT and backup the long filename in FIG. 8 is by two-pass searching method. First, analyze and keep every long filename item and corresponding short filename item of every sector in the first pass. Next, analyze and keep every long filename item and corresponding short filename item of every subdirectory in the second pass. Since this invention uses the recursive method, it was counted that we can manage the subdirectory deep to 40 levels for both FAT 16 system and FAT 32 system. Further more, if the current directory is not kept, it can be increase to 80 levels. Operation Process for Recovering the Long Filename FIG. 4 is the procedures for using the long filename backup file to recover the long filename of the disk drive. Basically, it is the reverse operation of backup operation, which includes the steps of: 1. Searching the first sector (i.e., the DPB) of the hard disk 30 according to the partition table. 2. Obtaining the corresponding data including the short filename item and the long filename item in the long filename backup file according to short filename items in the FDT of the partition. Then replacing the corresponding short file name item of the FDT of the current directory with the data read from the backup file including short filename item and long filename item. Thus, the data of the FDT becomes a new file directory item (see FIG. 6). 3. Searching the FDT of the subdirectories. 4. Obtaining the corresponding data including short filename item and long filename item in the long filename backup file according to short filename items of the FDT in the subdirectory. Then replacing the corresponding short file name item of the FDT of the current directory with the data read from the backup file including short filename item and long filename item. Thus, the data of the FDT become a new file directory item (see FIG. 4). 5. Checking whether there are subdirectories that have not completed the recovery process. If the answer is yes, going back to step 4, otherwise, finishing the recovery process. With reference to FIG. 9, the main process to recover the long filename of this invention includes the steps of: 1. Starting to recover the long filename of the FDT. 2. Reading the FDT data of the hard disk that is recovered. 3. Obtaining the long filename backup file in the current directory. 4. Checking whether the long filename backup file is obtained. If the answer is yes, going to next step, otherwise, going to step 9. 5. Recovering the long filename. Obtaining corresponding data including short filename item and long filename item in the long filename backup file according to the short filename item of the current FDT. Then replacing the corresponding short file name item of the FDT of the current directory with the data read from the backup file including short filename item and long filename item. Thus, the data of the FDT become a new file directory item. 6. Obtaining the subdirectory of current directory. 7. Checking whether there are sub-directories? If the answer is yes, going to next step, otherwise, going to step 9; 8. Recovering the long filename of current subdirectory, then going back to step 6 to recurring other subdirectories. 9. Finishing the recovery process. It is similarly that the technique of process in FIG. 9 is by searching and obtaining the root directory location according to the partition table of the disk drive. For FAT 16 system, it is the first sector after the FAT, and normally the second cluster for FAT 32 system. In the case of FAT 32 system, the root directory location can also be read from DPB. After the root directory location was obtained, the short filename item of the root directory and subdirectories can be replaced with a new file directory item including short filename item and long filename item. Referring to FIG. 10, the method for recovery of the long filename in FIG. 9 includes the steps of: 1. Reading a short filename item from the current directory. 2. Checking whether the long filename recovery process is finished? If the answer is yes, finishing the operation, otherwise, going to step 3. 3. Obtaining the long filename backup file. 4. Checking whether the backup file is obtained? If the answer is yes, going to next step, otherwise, going back to step 1. 5. Storing the short filename item data temporally. 6. Deleting the short filename item. 7. Moving the data that has the same short filename item and corresponding long filename item from the long filename backup file to FDT. 8. Modifying the pointer of the short filename item to point to the first cluster of the file, making it the same as the pointer of the short filename item that was stored temporally in step 5 and deleted in step 6. The technique of recovery operation process in FIG. 10 is by obtaining a short filename and searching the corresponding long filename item in the long filename backup file of the current directory (see FIG. 11). If the short filename is obtained, the file directory block thereof will be deleted. The short filename item and corresponding long filename item will be added into file directory block, then the pointer of the short filename item will be modified to point to the first cluster of the file, making it the same as the pointer of the short filename item. Table 6 is an application of the present invention. It shows the contents of the same directory in the conditions before backup, after system is crashed and after the recovery process by the method of this invention. The example shows that by the method of this invention, we can recover the file directory from the condition of only short filename left back to what it was before system crashed after system is crashed.
TABLE 6
Example of this invention
Three long filename in the directory before backup are as follow:
1370:0460 42 4C 41 43 4B 54 7E 31-42 4D 50 20 00 0F 2B 6D
BLACKT.about.1BMP..+m
1370:0470 67 25 67 25 00 00 20 A0-AB 24 0D 00 B6 00 00 00 G%g%....$...
1370:0480 42 6E 00 20 00 53 00 61-00 76 00 0F 60 6B 65 00 Bn..S.a.v...ke.
1370:0490 72 00 2E 00 53 00 43 00-52 00 00 00 00 00 FF FF r...S.C.R...
1370:04A0 01 43 00 68 00 61 00 6E-00 6E 00 0F 00 6B 65 00
.C.h.a.n.n...ke.
1370:04B0 6C 00 20 00 53 00 63 00-72 00 00 00 65 00 65 00 1..S.c.r...e.e.
1370:04C0 43 48 41 4E 4E 45 7E 31-53 43 52 20 00 10 2B 6D
CHANNE.about.1SCR..+m
1370:04D0 67 25 67 25 00 00 20 A0-AB 24 0E 00 40 48 01 00 g%g%....$..@H..
1370:04E0 42 2E 00 74 00 78 00 74-00 00 00 0F 00 D0 FF FF B..t.x.t...
1370:04F0 FF FF FF FF FF FF FF FF-FF FF 00 00 FF FF FF FF
................
1370:0500 01 52 00 75 00 6E 00 4F-00 6E 00 0F 00 D0 63 00
.R.u.n.O.n....c.
1370:0510 65 00 45 00 78 00 20 00-4C 00 00 00 6F 00 67 00 e.E.x..L...o.g.
1370:0520 52 55 4E 4F 43 7E 31-54 58 54 20 00 15 2B 6D
RUNONC.about.1TXT..+m
1370:0530 67 25 67 25 00 00 16 72-65 25 14 00 B3 45 00 00
G%g%...re%...E..
1370:0540 42 69 00 66 00 00 00 FF-FF FF FF 0F 00 23 FF FF Bi.f......#..
1370:0550 FF FF FF FF FF FF FF FF-FF FF 00 00 FF FF FF FF
................
1370:0560 01 45 00 78 00 69 00 74-00 20 00 0F 00 23 54 00 .E.x.i.t....#T.
1370:0570 6F 00 20 00 44 00 6F 00-73 00 00 00 2E 00 70 00 o...D.o.s..p.
1370:0580 45 58 49 54 54 4F 7E 31-50 49 46 20 00 1E 2B 6D
EXITTO.about.1PIF..+m
1370:0590 67 25 67 25 00 00 EC 49-66 25 16 00 C7 03 00 00 G%g%...If...
Contents of the same directory after system is crashed are as follow:
1370:0460 42 4C 41 43 4B 54 7E 31-42 4D 50 20 00 0F 2B 6D
BLACKT.about.1BMP..+m
1370:0470 67 25 67 25 00 00 20 A0-AB 24 0D 00 B6 00 00 00 G%g%....$...
1370:0480 43 48 41 4E 4E 45 7E 31-53 43 52 20 00 10 2B 6D
CHANNE.about.1SCR..+m
1370:0490 67 25 67 25 00 00 20 A0-AB 24 0E 00 40 48 01 00 g%g%....$..@H..
1370:04A0 52 55 4E 4F 43 7E 31-54 58 54 20 00 15 2B 6D
RUNONC.about.1TXT..+m
1370:04B0 67 25 67 25 00 00 16 72-65 25 14 00 B3 45 00 00
G%g%...re%...E..
1370:04C0 45 58 49 54 54 4F 7E 31-50 49 46 20 00 1E 2B 6D
EXITTO.about.IPIF..+m
1370:04D0 67 25 67 25 00 00 EC 49-66 25 16 00 C7 03 00 00 G%g%...If...
Contents of the same directory after the recovery operation of this
invention are as follow:
1370:0000 42 4C 41 43 4B 54 7E 31-42 4D 50 20 00 0F 2B 6D
BLACKT.about.1BMP..+m
1370:0010 67 25 67 25 00 00 20 A0-AB 24 0D 00 B6 00 00 00 G%g%....$...
1370:0020 42 6E 00 20 00 53 00 61-00 76 00 0F 00 6B 65 00 Bn..S.a.v..ke.
1370:0030 72 00 2E 00 53 00 43 00-52 00 00 00 00 00 FF FF r..SCR.......
1370:0040 01 43 00 68 00 61 00 6E-00 6E 00 0F 00 6B 65 00
.C.h.a.n.n...ke.
1370:0050 6C 00 20 00 53 00 63 00-72 00 00 00 65 00 65 00 1..S.c.r...e.e.
1370:0060 43 48 41 4E 4E 45 7E 31-53 43 52 20 00 10 2B 6D
CHANNE.about.1SCR..+m
1370:0070 67 25 67 25 00 00 20 A0-AB 24 0E 00 40 48 01 00 g%g%....$..@H..
1370:0080 42 2E 00 74 00 78 00 74-00 00 00 0F 00 D0 FF FF B..t.x.t...
1370:0090 FF FF FF FF FF FF FF FF-FF FF 00 00 FF FF FF FF
................
1370:00A0 01 52 00 75 00 6E 00 4F-00 6E 00 0F 00 D0 63 00
.R.u.n.O.n....c.
1370:00B0 65 00 45 00 78 00 20 00-4C 00 00 00 6F 00 67 00 e.E.x..L...o.g.
1370:00C0 52 55 4E 4F 43 7E 31-54 58 54 20 00 15 2B 6D
RUNONC.about.1TXT..+m
1370:00D0 67 25 67 25 00 00 16 72-65 25 14 00 B3 45 00 00
G%g%...re%...E..
1370:00E0 42 69 00 66 00 00 00 FF-FF FF FF 0F 00 23 FF FF Bi.f.....#..
1370:00F0 FF FF FF FF FF FF FF FF-FF FF 00 00 FF FF FF FF
................
1370:0100 01 45 00 78 00 69 00 74-00 20 00 0F 00 23 54 00 .E.x.i.t....#T.
1370:0110 6F 00 20 00 44 00 6F 00-73 00 00 00 2E 00 70 00 o...D.o.s..p.
1370:0120 45 58 49 54 54 4F 7E 31-50 49 46 20 00 1E 2B 6D
EXITTO.about.1PIF..+m
1370:0130 67 25 67 25 00 00 EC 49-66 25 16 00 C7 03 00 00 G%g%...If...
Other embodiments of the invention will appear to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. It is intended that the specification and examples to be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
|
Same subclass Same class Consider this |
||||||||||
