A filesystem philosophy question

From: Andrew Valencia <vandys_at_nospam.org>
Date: Wed Mar 09 1994 - 19:23:20 PST

In porting ar(1), I ran into quite a neat little problem. ar(1) uses
rename(2) to change the name of a file. How do you do that in VSTa?

Recall that there is no global namespace. So simply telling "the"
filesystem about the two paths is nowhere near good enough. If, in fact,
both files are in the same filesystem, I guess you could trim off everything
except the filesystem-relative part and pass that. But this doesn't seem
like a very good solution. In fact, what I'm tending towards is a routine
where you open (for update, to establish your ability to write it) the
existing file, and then create the new file (with whatever policy you need,
such as error if it already exists, or truncate, this is all in the C
library).

Then the tricky part--wstat() a message to the new file, indicating that
this file wants to *swap* contents with another file. You either send a
secret number (to stymie a 3rd party trying to intercept the file) or get
one back, and then you wstat() with this on the original file. On success,
the two files have had their contents swapped. On failure, nothing's
changed. On success, you finish by removing the (now empty) original file.

Of course, the library version of rename() falls back to a bulk data copy if
it can't do this. This is compatible with old filesystems (who won't
recognize the new wstat() message) and also with cross-filesystem renames.

What do you think?

On another topic, the next version will be out in a couple weeks. It'll
have the new multi-screen support, scheduler optimizations, and a lot
of cleanup in drivers as they convert to syslog(). Robert Mayer supplied
some patches to make the cursor keys emulate a VTXX, Dave Hudson has
cleaned up the handling of disk partitions in WD, moving the common code into
a library. Mike Larson's has converted his SCSI disk driver to use this
as well.

I'd like to finish porting BSD's "ash" Bourne shell clone, but we'll see.
I've finally added <errno.h> emulation, though, which should help in your
porting efforts in general.

                                                        Regards,
                                                        Andy
Received on Wed Mar 9 19:47:29 1994

This archive was generated by hypermail 2.1.8 : Wed Sep 21 2005 - 21:02:16 PDT