Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Apple » Apple II » Deleted files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Deleted files [message #389825] Wed, 12 February 2020 11:41 Go to next message
gids.rs is currently offline  gids.rs
Messages: 1395
Registered: October 2012
Karma: 0
Senior Member
After finally going through the Prodos source code, I don’t see why the pointers in the master blocks of a sapling or tree file are swapped, when the file is deleted.

Examining the undelete programs shows no advantage to this either.

There seems to be no rhyme or reason for it other than showing off a nifty routine for swapping pages.

Does anyone have any ideas on this.
Re: Deleted files [message #389826 is a reply to message #389825] Thu, 13 February 2020 02:42 Go to previous messageGo to next message
spectrumdaddy is currently offline  spectrumdaddy
Messages: 191
Registered: November 2012
Karma: 0
Senior Member
Rob,

> After finally going through the Prodos source code, I don't see why
> the pointers in the master blocks of a sapling or tree file are
> swapped, when the file is deleted.

It is simply to mark the file as being deleted, but allow for it to be
undeleted later, by swapping the data back. In my application Phoenix
for the IIgs, I use that feature to allow files to be exhumed, though
the integrity of an undeleted file will depend on what has happened
since the deletion, as blocks it used may have been overwritten. If you
undelete immediately aftter deletion, the recovery rate is 100%.

Cheers - Ewen
Re: Deleted files [message #389829 is a reply to message #389826] Thu, 13 February 2020 13:19 Go to previous messageGo to next message
gids.rs is currently offline  gids.rs
Messages: 1395
Registered: October 2012
Karma: 0
Senior Member
”It is simply to mark the file as being deleted, but allow for it to be
undeleted later, by swapping the data back. In my application Phoenix
for the IIgs, I use that feature to allow files to be exhumed, though
the integrity of an undeleted file will depend on what has happened
since the deletion, as blocks it used may have been overwritten. If you
undelete immediately aftter deletion, the recovery rate is 100%. “


Right. But the check for protected or free blocks is with the bits in the VBM (Volume Bit Map) and not with a file’s Master Block. The Master Block is also freed up, and that check is also made with the VBM.

This seems redundant to me as, for instance, if I want to check if a file is fully recoverable to report how much of a file is lost, now I have to write two sets of code. One that does the swap and one that doesn’t, which eliminates the need to have to read the Master block twice.

And there is no way to tell if any pointers have already been swapped, so if the program stalls due to it coming across a protected block, it would be up to the programmer what to do next.

Even checking a Master block for validity in case it was over-written, and then the block freed up again, the pointers would be random. But the check for sequential blocks can still be made without actually swapping the block pointers.

Whether one is deleting, undeleting or verifying a valid Master Block, I don’t see any advantage or reason to swapping the Master Block pointers. Especially since the Master Block itself is verified in the VBM.

I believe Apple originally thought they could use the reversed pointers to identify a deleted Master Block, but realized they can just as easily use the VBM and just left the code in for swapping pointers.

Now I guess programmers are stuck using that method or end up incorporating incompatibility.
Re: Deleted files [message #389830 is a reply to message #389829] Thu, 13 February 2020 15:16 Go to previous messageGo to next message
Jeff Blakeney is currently offline  Jeff Blakeney
Messages: 125
Registered: September 2013
Karma: 0
Senior Member
On 2020-02-13 1:19 p.m., I am Rob wrote:
[snip]
> Whether one is deleting, undeleting or verifying a valid Master
> Block, I don’t see any advantage or reason to swapping the Master
> Block pointers. Especially since the Master Block itself is verified
> in the VBM.
>
> I believe Apple originally thought they could use the reversed
> pointers to identify a deleted Master Block, but realized they can
> just as easily use the VBM and just left the code in for swapping
> pointers.
>
> Now I guess programmers are stuck using that method or end up
> incorporating incompatibility.
At first, reading this thread, I thought that it was pretty silly and,
as you say, redundant to modify the master block. All you should need
to do to delete a file is modify the directory entry so that you know it
has been deleted.

After thinking about it some more, perhaps this method is being used for
situations where the directories have been damaged and you are scanning
the volume looking for files. Having the master block modified means
that you know this is for a deleted file so you don't need to try to
reconstruct that file. If it isn't modified you can create a directory
entry for it and mark all the blocks as being in use.
Re: Deleted files [message #389831 is a reply to message #389830] Fri, 14 February 2020 01:13 Go to previous message
gids.rs is currently offline  gids.rs
Messages: 1395
Registered: October 2012
Karma: 0
Senior Member
”After thinking about it some more, perhaps this method is being used for
situations where the directories have been damaged and you are scanning
the volume looking for files. Having the master block modified means
that you know this is for a deleted file so you don't need to try to
reconstruct that file. If it isn't modified you can create a directory
entry for it and mark all the blocks as being in use. “


I accidentally trashed the root directory once (blocks 2-5) and wrote a Program to search the entire hard drive for sub-directories. I then manually entered them back in as file entries in the root and was able to recover all the sub-directories.

But for regular files in the root I just used a block editor as I didn’t have many and knew what they all were.

I could have written a program to search for a Master Block in that case to recover the files.

I guess in one formatted a volume and the VBM was reset there would be no way to distinguish If a Master block belonged to a good file or a deleted file.

For the most part the sub-directories should be in tact with their key pointers to a Master block, but a formatted or erased volume that just zeroes blocks 2-5 and resets the VBM would have to search for the Master block of any files in the root directory. The most number of files one would have to search for is 51. (Some new Prodos’s now allow more than 51 files and so swapped pointers become all the more important)

Ok, this makes sense. I now have justified the reason to swap a Master block’s pointers.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ProDOS port announce
Next Topic: OT: Book: Programming Boot Sector Games
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Mon Apr 15 23:59:24 EDT 2024

Total time taken to generate the page: 0.03572 seconds