Last edited · 2 revisions  

 


This article was copied from Mike Riley's site http://www.elf-emulation.com/.

 This is a quick tutorial on how to use SEDIT to fix a filename.  In this demonstration I purposely created a file "TEST .BAS" in subdirectory "/RCBASIC".  I put the bad file into a subdirectory specifically so you can see you to navigate to a subdirectory while in SEDIT.

First starting Elf/OS.

Starting Elf/OS ...
Version 0.2.8
Copyright 2004-2007 by Michael H Riley

Elf/OS Shell V0.3

Now I will change into the RCBASIC subdirectory and list the file:

$ CD RCBASIC
$ LS
RCBASICL2       TEST .BAS

Here you can see my "TEST .BAS" file that we need to fix.  So first we execute SEDIT.

$ SEDIT

The first thing we need to do is find out where the master directory is.  The pointer to the master directory is in sector 0, so we start by reading sector 0:

>R0
Current sector: 0000

The sector pointer for the master directory is at $0105-$0106, which is in the high 256 bytes of the sector, so we use H to see these bytes.  I marked  the bytes that we are looking for:

>H
0100: 00 00 D0 00 01 00 30 00 00 00 08 1A 00 00 00 00 ......0.........
0110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 ................
0130: 02 20 00 44 FF 00 00 4D 44 00 00 00 00 00 00 00 . .D...MD.......#
0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

Ok, now we know that the master directory starts at $0030, so we load that sector:

>R30
Current sector: 0030

Now we have to find the entry for RCBASIC/.  Start by looking at the low half of the sector:

>L
0000: 00 00 00 07 03 00 01 44 FF 00 00 00 42 49 4E 00 .......D....BIN.
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0020: 00 00 00 1E 04 39 00 44 FF 00 00 00 5A 52 55 4E .....9.D....ZRUN
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040: 00 00 00 20 02 D9 00 44 FF 00 00 00 58 52 00 4E ... ...D....XR.N
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0060: 00 00 00 21 0C 00 00 44 FF 00 00 00 5A 4F 52 4B ...!...D....ZORK
0070: 31 2E 44 41 54 00 00 00 00 00 00 00 00 00 00 00 1.DAT...........
0080: 00 00 00 36 00 00 00 44 FF 00 00 00 5A 4F 52 4B ...6...D....ZORK
0090: 32 2E 44 41 54 00 00 00 00 00 00 00 00 00 00 00 2.DAT...........
00A0: 00 00 00 4D 02 81 00 44 FF 00 00 00 58 53 00 4B ...M...D....XS.K
00B0: 32 2E 44 41 54 00 00 00 00 00 00 00 00 00 00 00 2.DAT...........
00C0: 00 00 00 4E 04 00 00 44 FF 00 00 00 5A 4F 52 4B ...N...D....ZORK
00D0: 33 2E 44 41 54 00 00 00 00 00 00 00 00 00 00 00 3.DAT...........
00E0: 00 00 00 63 07 C0 01 44 FF 00 00 00 54 42 43 00 ...c...D....TBC.
00F0: 33 2E 44 41 54 00 00 00 00 00 00 00 00 00 00 00 3.DAT...........

The RCBASIC directory is not here, so look at the high half of the sector:

>H
0100: 00 00 00 9E 04 80 00 44 FF 00 00 00 5A 52 55 4E .......D....ZRUN
0110: 33 00 44 41 54 00 00 00 00 00 00 00 00 00 00 00 3.DAT...........
0120: 00 00 00 A0 00 80 01 44 FF 00 00 00 54 42 00 4E .......D....TB.N
0130: 33 00 44 41 54 00 00 00 00 00 00 00 00 00 00 00 3.DAT...........
0140: 00 00 00 AA 09 92 00 44 FF 00 00 00 52 43 42 41 .......D....RCBA
0150: 53 49 43 4C 32 00 00 00 00 00 00 00 00 00 00 00 SICL2...........
0160: 00 00 00 AC 0B 18 00 44 FF 00 00 00 52 43 4C 49 .......D....RCLI
0170: 53 50 00 4C 32 00 00 00 00 00 00 00 00 00 00 00 SP.L2...........
0180: 00 00 00 AE 0E 06 00 44 FF 00 00 00 52 43 46 4F .......D....RCFO
0190: 52 54 48 00 32 00 00 00 00 00 00 00 00 00 00 00 RTH.2...........
01A0: 00 00 00 B0 02 DA 00 44 FF 00 00 00 58 52 32 00 .......D....XR2.
01B0: 52 54 48 00 32 00 00 00 00 00 00 00 00 00 00 00 RTH.2...........
01C0: 00 00 00 B1 04 80 00 44 FF 00 00 00 5A 52 32 00 .......D....ZR2.
01D0: 52 54 48 00 32 00 00 00 00 00 00 00 00 00 00 00 RTH.2...........
01E0: 00 00 00 B3 07 E0 01 44 FF 00 00 00 53 42 43 00 .......D....SBC.
01F0: 52 54 48 00 32 00 00 00 00 00 00 00 00 00 00 00 RTH.2...........

Not here either, so the first master directory sector does not contain the subdirectory we are looking for, so load the next sector:

>N
Current sector: 0031

Start by looking at the low half:

>L
0000: 00 00 00 C3 00 60 01 44 FF 00 00 00 52 43 42 41 .....`.D....RCBA
0010: 53 49 43 00 32 00 00 00 00 00 00 00 00 00 00 00 SIC.2...........
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

Ok, we have found the subdirectory (marked in red), you can see the name RCBASIC in the ascii side of the display, and in the hex side we can see there is a 00 terminator following the C from RCBASIC, ignore everything beyond the 00 terminator, so that 2 that is there is not actually part of the name.  The first 4 bytes of a DIRENT contains the starting AU for the file, I have marked it in green.

SEDIT provides a shortcut to load the first sector of an AU so you do not have to convert it to a sector number first.  So, lets load the first sector of AU C3:

>AC3
Current sector: 0618

And display the low half of the sector:

>L
0000: 00 00 00 F4 09 92 00 44 FF 00 00 00 52 43 42 41 .......D....RCBA
0010: 53 49 43 4C 32 00 00 00 00 00 00 00 00 00 00 00 SICL2...........
0020: 00 00 00 F6 00 1B 00 44 FF 00 00 00 54 45 53 54 .......D....TEST
0030: 20 2E 42 41 53 00 00 00 00 00 00 00 00 00 00 00  .BAS...........
0040: 00 00 00 00 00 1B 00 44 FF 00 00 00 2E 42 41 53 .......D.....BAS
0050: 00 2E 42 41 53 00 00 00 00 00 00 00 00 00 00 00 ..BAS...........
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

Definitely looks like a directory sector, so we got the right one.  We also can see the bad filename as the second DIRENT in this sector.  And there is that pesky space ($20) right there at offset $0030.  We will replace the space with a '1':

>E30 31

And show the low half of the sector again to verify our change:

>L
0000: 00 00 00 F4 09 92 00 44 FF 00 00 00 52 43 42 41 .......D....RCBA
0010: 53 49 43 4C 32 00 00 00 00 00 00 00 00 00 00 00 SICL2...........
0020: 00 00 00 F6 00 1B 00 44 FF 00 00 00 54 45 53 54 .......D....TEST
0030: 31 2E 42 41 53 00 00 00 00 00 00 00 00 00 00 00 1.BAS...........
0040: 00 00 00 00 00 1B 00 44 FF 00 00 00 2E 42 41 53 .......D.....BAS
0050: 00 2E 42 41 53 00 00 00 00 00 00 00 00 00 00 00 ..BAS...........
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

The sector buffer now shows our filename as "TEST1.BAS".  So write the sector back to disk:

>W
Current sector: 0618

At this point we are done, so we can quite SEDIT:

>Q

Once back in Elf/OS we can go ahead and list our files again and see that the filename has been corrected:

$ LS
RCBASICL2       TEST1.BAS      

Here is the full command list for SEDIT:

L - Show low 256 bytes of loaded sector
H - Show high 256 bytes of loaded sector
Rsect - Read specified sector (sect is in hex)
N - Load next sector
P - Load previous sector
D - Display current sector number
Eofs byte byte ... - Enter bytes into sector buffer at specified offset
W - Write current sector buffer back to disk
Aau - Load first sector of specified AU.
Cau - Show the AU chain for the specified AU.
Q - Quit back to Elf/OS.

This gives you a brief introduction into what SEDIT can do for you.  Great care must be taken when modifying raw sector data, if you are not careful, you can corrupt your filesystem.  A more complete description of the Elf/OS filesystem disk structures can be found in the "Inside Elf/OS" document located on my site.