Mail Archives: djgpp/1998/03/19/07:38:38
On Wed, 18 Mar 1998, Matthew H. Gerlach wrote:
> With the help of gdb and a couple of printfs, I seem to have issolated
> the problem. The function, chnamemod(), in rcsedit.c is trying
> to un_link() a nonexistant file. In my case I am trying to check in
> newfile.c for the first time. ci creates ,newfile.c on the NFS drive
> just fine. ci tried to un_link newfile.c,v before renaming ,newfile.c
> to newfile.c,v, and this failed because the file isn't there.
Do I inderstand correctly that this same code succeeds on a local
drive but fails on a remote drive?
If so, please post the code fragment that calls `un_link' and handles
its possible errors. (I don't have the RCS sources handy at this
time.) It seems that removing a non-existent file should always fail,
so I suspect RCS doesn't handle the failure correctly, or doesn't
expect to get EACCES in errno after such failures.
> In my configuration, the call to un_link() is actually a #define
> to unlink() which is in libc.a.
I attach the source code of `remove' from the library at the end of
this message (`unlink' just jmp's to `remove'). If the above
assumption about errno value is not true, please paste the source of
`remove' into one of the RCS source files, then rebuild the programs
and step with a debugger into `remove' when it tries to unlink
newfile.c,v. I would like to know what part of the function fails and
how (i.e., with what DOS code).
> I wonder if I should change conf.h so that has_NFS is 1 instead of
> defined to 0.
What does defining has_NFS do to RCS?
----------------------------- cut here ----------------------------
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <dpmi.h>
#include <go32.h>
#include <libc/dosio.h>
int
remove(const char *fn)
{
__dpmi_regs r;
unsigned attr;
int directory_p;
int use_lfn = _USE_LFN;
/* Get the file attribute byte. */
attr = _chmod(fn, 0);
directory_p = attr & 0x10;
/* Now, make the file writable. We must reset Vol, Dir, Sys and Hidden bits
in addition to the Read-Only bit, or else 214301 will fail. */
_chmod(fn, 1, attr & 0xffe0);
/* Now delete it. Note, _chmod leaves dir name in tranfer buffer. */
if (directory_p)
r.h.ah = 0x3a; /* DOS Remove Directory function */
else
r.h.ah = 0x41; /* DOS Remove File function */
if(use_lfn) {
r.h.al = r.h.ah;
r.h.ah = 0x71;
r.x.si = 0; /* No Wildcards */
}
r.x.dx = __tb_offset;
r.x.ds = __tb_segment;
__dpmi_int(0x21, &r);
if(r.x.flags & 1)
{
/* We failed. Leave the things as we've found them. */
int e = __doserr_to_errno(r.x.ax);
_chmod(fn, 1, attr & 0xffe7);
errno = e;
return -1;
}
return 0;
}
- Raw text -