* syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't exist

(from Kazuhiro Fujieda <fujieda@jaist.ac.jp>).  Also set EACCES when directory
is not writable.
This commit is contained in:
Christopher Faylor 2001-03-10 20:25:19 +00:00
parent 766de5ad55
commit e2f2a27ee8
3 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,9 @@
Sat Mar 10 15:22:44 2001 Christopher Faylor <cgf@cygnus.com>
* syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't
exist (from Kazuhiro Fujieda <fujieda@jaist.ac.jp>). Also set EACCES
when directory is not writable.
Wed Mar 7 15:49:47 2001 Christopher Faylor <cgf@cygnus.com> Wed Mar 7 15:49:47 2001 Christopher Faylor <cgf@cygnus.com>
* syscalls.cc (_read): Change definition to return ssize_t to be * syscalls.cc (_read): Change definition to return ssize_t to be

View File

@ -16,7 +16,7 @@ extern u_char eprol asm ("__eprol");
extern void _mcleanup (void); extern void _mcleanup (void);
extern void monstartup (u_long, u_long); extern void monstartup (u_long, u_long);
void _monstartup (void) __attribute__((__constructor__)); foo void _monstartup (void) __attribute__((__constructor__));
/* startup initialization for -pg support */ /* startup initialization for -pg support */

View File

@ -1268,8 +1268,8 @@ _rename (const char *oldpath, const char *newpath)
if (real_old.error) if (real_old.error)
{ {
set_errno (real_old.error);
syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath);
set_errno (real_old.error);
return -1; return -1;
} }
@ -1293,8 +1293,8 @@ _rename (const char *oldpath, const char *newpath)
if (real_new.error) if (real_new.error)
{ {
set_errno (real_new.error);
syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath);
set_errno (real_new.error);
return -1; return -1;
} }
@ -1302,12 +1302,14 @@ _rename (const char *oldpath, const char *newpath)
|| !writable_directory (real_new.get_win32 ())) || !writable_directory (real_new.get_win32 ()))
{ {
syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath);
set_errno (EACCES);
return -1; return -1;
} }
if (real_old.file_attributes () == (DWORD) -1) /* file to move doesn't exist */ if (real_old.file_attributes () == (DWORD) -1) /* file to move doesn't exist */
{ {
syscall_printf ("file to move doesn't exist"); syscall_printf ("file to move doesn't exist");
set_errno (ENOENT);
return (-1); return (-1);
} }