[comp.sys.atari.st] The horrible UNLINK bug

hafer@infbs (Udo Hafermann) (12/01/88)

Consider the following situation:

- A process opens and writes to a file;
- the file is deleted (unlinked);
- the process writes to the handle, which remains accessable,
- and then closes the handle.

When deleting a file, TOS updates the directory entry for the file,
freeing its clusters, but does not free any associated handles.  When
the handle is closed, TOS writes the information in the File Control
Block to the (invalid) directory entry. 

This can have desastrous effects:
	A new file reusing the directory entry may be destroyed;
	if the directory entry is still deleted, TOS will write to the
	(non-existent) cluster 0, i.e., garbage is written to the
	root directory!

What was the intended behaviour of TOS?
Bug or feature?

There are, by the way, quite a few programs which don't close the handle
when deleting an associated file, e.g. Mark Williams' micro-shell during
'mv'-operations.

Any comments?  Any comments, ATARI?

hyc@math.lsa.umich.edu (Howard Chu) (12/02/88)

In article <109@infbsgr.infbs> hafer@infbsgr.UUCP (Udo Hafermann) writes:
>Consider the following situation:
>
>- A process opens and writes to a file;
>- the file is deleted (unlinked);
>- the process writes to the handle, which remains accessable,
>- and then closes the handle.

Same thing can happen on a Unix system. (Try it some time...)
I s'pose we don't give Atari any credit for successfully emulating
this feature of Unix though, eh?  }-)
--
  /
 /_ , ,_.                      Howard Chu
/ /(_/(__                University of Michigan
    /           Computing Center          College of LS&A
   '              Unix Project          Information Systems

peter@sugar.uu.net (Peter da Silva) (12/05/88)

In article <501@stag.math.lsa.umich.edu>, hyc@math.lsa.umich.edu (Howard Chu) writes:
> In article <109@infbsgr.infbs> hafer@infbsgr.UUCP (Udo Hafermann) writes:
> >- A process opens and writes to a file;
> >- the file is deleted (unlinked);
> >- the process writes to the handle, which remains accessable,
> >- and then closes the handle.

> Same thing can happen on a Unix system. (Try it some time...)

But on a UNIX system a deleted file is just another file with no name. There's
no problem with it, and when you finally close the file the space will be
re-used... not before. UNIX doesn't care if a file has one, two, ten, or
zero names.

Other operating systems where the file name is part of the file will not
let you delete an open file. This isn't as much fun, but it's just as safe.

Anyone know what MS-DOS does in this case?
-- 
		    Peter da Silva  `-_-'  peter@sugar.uu.net
		     Have you hugged  U  your wolf today?

	          Disclaimer: My typos are my own damn busines#!rne

wheels@mks.UUCP (Gerry Wheeler) (12/06/88)

In article <3058@sugar.uu.net>, peter@sugar.uu.net (Peter da Silva) writes:
> But on a UNIX system a deleted file is just another file with no name. 
> There's no problem with it, and when you finally close the file the
> space will be re-used...  not before.  Anyone know what MS-DOS does in
> this case?

It messes up, just like TOS. We had to alter some of the code in the MKS
Toolkit to get around this one. It was originally written and run on
a UNIX system, with no problems. But DOS Dumbness bit us. Ah well.
-- 
     Gerry Wheeler                           Phone: (519)884-2251
Mortice Kern Systems Inc.               UUCP: uunet!watmath!mks!wheels
   35 King St. North                             BIX: join mks
Waterloo, Ontario  N2J 2W9                  CompuServe: 73260,1043

hafer@infbs (Udo Hafermann) (12/08/88)

Just for the record:  How many of you have had or heard of directories
messed up by the write-to-cluster-0 bug?  Which programs are known to do
it?