aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-04-17 11:47:37 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-04-17 11:47:37 +0000
commit0f565126273e2d9aafb956933fc5b86ca01fddf4 (patch)
treec078f7d7a7113dd906b5e4928604240f7563a7b6
parent77eb506d60c57c50773fe9e02daa7d83cfc31e49 (diff)
downloadnewlib-0f565126273e2d9aafb956933fc5b86ca01fddf4.zip
newlib-0f565126273e2d9aafb956933fc5b86ca01fddf4.tar.gz
newlib-0f565126273e2d9aafb956933fc5b86ca01fddf4.tar.bz2
* path.cc (path_conv::check): Set case_clash even if pcheck_case
is set to PCHECK_ADJUST when a case clash is given for the last component in path. (symlink_info::case_check): Ditto. * syscalls.cc (_rename): Avoid overwriting an already existing file if a case clash is given even if pcheck_case is set to PCHECK_ADJUST.
-rw-r--r--winsup/cygwin/path.cc22
-rw-r--r--winsup/cygwin/syscalls.cc6
2 files changed, 18 insertions, 10 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 02641f3..fe91bff 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -324,9 +324,18 @@ path_conv::check (const char *src, unsigned opt,
if (sym.case_clash)
{
- case_clash = TRUE;
- error = ENOENT;
- goto out;
+ if (pcheck_case == PCHECK_STRICT)
+ {
+ case_clash = TRUE;
+ error = ENOENT;
+ goto out;
+ }
+ /* If pcheck_case==PCHECK_ADJUST the case_clash is remembered
+ if the last component is concerned. This allows functions
+ which shall create files to avoid overriding already existing
+ files with another case. */
+ if (!component)
+ case_clash = TRUE;
}
if (!(opt & PC_SYM_IGNORE))
@@ -2754,13 +2763,12 @@ symlink_info::case_check (const char *path, char *orig_path)
/* If that part of the component exists, check the case. */
if (strcmp (c, data.cFileName))
{
+ case_clash = TRUE;
+
/* If check is set to STRICT, a wrong case results
in returning a ENOENT. */
if (pcheck_case == PCHECK_STRICT)
- {
- case_clash = TRUE;
- return FALSE;
- }
+ return FALSE;
/* PCHECK_ADJUST adjusts the case in the incoming
path which points to the path in *this. */
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 933baaf..5a9b24c 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1246,7 +1246,7 @@ _rename (const char *oldpath, const char *newpath)
/* Shortcut hack. */
char new_lnk_buf[MAX_PATH + 5];
- if (real_old.issymlink () && !real_new.error)
+ if (real_old.issymlink () && !real_new.error && !real_new.case_clash)
{
int len_old = strlen (real_old.get_win32 ());
if (strcasematch (real_old.get_win32 () + len_old - 4, ".lnk"))
@@ -1258,10 +1258,10 @@ _rename (const char *oldpath, const char *newpath)
}
}
- if (real_new.error)
+ if (real_new.error || real_new.case_clash)
{
syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath);
- set_errno (real_new.error);
+ set_errno (real_new.case_clash ? ECASECLASH : real_new.error);
return -1;
}