From e2f2a27ee83c8d05ca665acb5a5910e2594c4cc8 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 10 Mar 2001 20:25:19 +0000 Subject: [PATCH] * syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't exist (from Kazuhiro Fujieda ). Also set EACCES when directory is not writable. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/gcrt0.c | 2 +- winsup/cygwin/syscalls.cc | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index cd09e486b..dc2e3b66e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Sat Mar 10 15:22:44 2001 Christopher Faylor + + * syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't + exist (from Kazuhiro Fujieda ). Also set EACCES + when directory is not writable. + Wed Mar 7 15:49:47 2001 Christopher Faylor * syscalls.cc (_read): Change definition to return ssize_t to be diff --git a/winsup/cygwin/gcrt0.c b/winsup/cygwin/gcrt0.c index e565f092f..b06159784 100644 --- a/winsup/cygwin/gcrt0.c +++ b/winsup/cygwin/gcrt0.c @@ -16,7 +16,7 @@ extern u_char eprol asm ("__eprol"); extern void _mcleanup (void); extern void monstartup (u_long, u_long); -void _monstartup (void) __attribute__((__constructor__)); +foo void _monstartup (void) __attribute__((__constructor__)); /* startup initialization for -pg support */ diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 81394f0db..dbb55f321 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1268,8 +1268,8 @@ _rename (const char *oldpath, const char *newpath) if (real_old.error) { - set_errno (real_old.error); syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); + set_errno (real_old.error); return -1; } @@ -1293,8 +1293,8 @@ _rename (const char *oldpath, const char *newpath) if (real_new.error) { - set_errno (real_new.error); syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); + set_errno (real_new.error); return -1; } @@ -1302,12 +1302,14 @@ _rename (const char *oldpath, const char *newpath) || !writable_directory (real_new.get_win32 ())) { syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); + set_errno (EACCES); return -1; } if (real_old.file_attributes () == (DWORD) -1) /* file to move doesn't exist */ { syscall_printf ("file to move doesn't exist"); + set_errno (ENOENT); return (-1); }