Article View: comp.sys.atari.st
Article #29312Fcreate() bug and dLibs creat()
From: daemon
Date: Sun, 22 Nov 1987 23:48
Date: Sun, 22 Nov 1987 23:48
50 lines
2374 bytes
2374 bytes
>> Occasionally it would create two files
>> with the same name in a single directory.
>
> I found out why: in GEMDOS, Fcreate calls Fdelete, but doesn't check to see
> if the delete actually worked. If the delete fails for some reason, Fcreate
> doesn't notice, and creates another file by the same name.
>
>> I implemented a creat() call in dLibs which always
>> deletes the file before creating it[.]
>
> This won't help, because if Fcreate's call to Fdelete fails, yours will too.
>
This WILL* help, because I check the return value from Fdelete() to be sure
that it succeeds. The code is as follows (from the extended arg proposal):
/*
* Create a new file <filename> with <pmode> permissions
*/
int creat(filename, pmode)
register char *filename;
register int pmode;
{
register int rv;
rv = Fdelete(filename);
if((rv == 0) || (rv == -33)) /* SUCCESS or FILE-NOT-FOUND */
{
if((rv = Fcreate(filename, pmode)) >= 0)
iovector[rv] = 'F';
}
return(rv);
}
> Now here's the tricky part: Fdelete (as called from outside GEMDOS or
> within it, like from Fcreate) checks to see if anybody has the file open.
> If the current process has the file open, Fdelete closes it before deleting
> it. If some OTHER process has the file open, Fdelete returns EACCDN
> ("access denied"). This seems to be what is happening, but I can't
> figure out why, because nobody else has the file open!
Yes. In my implementation of creat(), any error except -33 (EFILNF) will
be returned without calling Fcreate(). Error code -36 (EACCDN) is therefore
returned if the file can't be deleted due to the Fcreate() bug. In emacs,
this causes a file write error and you can then write the file out under a
different name, which is better than silently creating a duplicate.
Dale Schumacher
..ihnp4!meccts!stag!syntel!dal
(alias: Dalnefre')
Technical Details
Message-ID:
<262@stag.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!umn-d-ub!umn-cs!ems!nis!stag!daemonShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!umn-d-ub!umn-cs!ems!nis!stag!daemon From: daemon@stag.UUCP Newsgroups: comp.sys.atari.st Subject: Fcreate() bug and dLibs creat() Message-ID: <262@stag.UUCP> Date: Sun, 22-Nov-87 18:48:46 EST Article-I.D.: stag.262 Posted: Sun Nov 22 18:48:46 1987 Date-Received: Wed, 25-Nov-87 20:48:27 EST Sender: daemon@stag.UUCP Lines: 50