From c65a318355fdcd81841088825972d86e642619dd Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 22 Jan 2001 20:29:24 +0000 Subject: [PATCH] * include/cygwin/version.h: Bump API to reflect setlogmask. --- winsup/cygwin/ChangeLog | 4 +++ winsup/cygwin/include/cygwin/version.h | 3 +- winsup/cygwin/path.cc | 39 ++++++++++++++++++++++---- winsup/cygwin/path.h | 3 ++ winsup/cygwin/syscalls.cc | 7 ++--- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 328a575dd..91f63fa9d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 22 15:27:12 2001 Christopher Faylor + + * include/cygwin/version.h: Bump API to reflect setlogmask. + Sun Jan 21 22:40:25 2001 Jason Tishler * cygwin.din: Add export for setlogmask(). diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index a8ce9894c..a9de98d7a 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -123,10 +123,11 @@ details. */ 30: CW_GET_CYGDRIVE_INFO addition to external.cc 31: Export inet_aton 32: Export getrlimit/setrlimit + 33: Export setlogmask */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 32 +#define CYGWIN_VERSION_API_MINOR 33 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index d86f19464..de13b0572 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -298,6 +298,7 @@ path_conv::check (const char *src, unsigned opt, these operations again on the newly derived path. */ else if (len > 0) { + set_has_symlinks (); if (component == 0 && !need_directory && !(opt & PC_SYM_FOLLOW)) { set_symlink (); // last component of path is a symlink. @@ -315,7 +316,7 @@ path_conv::check (const char *src, unsigned opt, (tail > path_copy && tail[-1] == ':')) goto out; // all done - /* Haven't found a valid pathname component yet. + /* Haven't found an existing pathname component yet. Pinch off the tail and try again. */ *tail = '\0'; component++; @@ -2372,10 +2373,7 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes) /* Not a symlink, see if executable. */ if (!(pflags & PATH_ALL_EXEC) && has_exec_chars (cookie_buf, got)) -{ -debug_printf ("setting exec flag"); pflags |= PATH_EXEC; -} close_and_return: CloseHandle (h); goto file_not_symlink; @@ -2572,10 +2570,41 @@ chdir (const char *dir) native_dir[3] = '\0'; } int res = SetCurrentDirectoryA (native_dir) ? 0 : -1; + if (res == -1) __seterrno (); + else if (!path.has_symlinks ()) + cygcwd.set (path, dir); else - cygcwd.set (path, strpbrk (dir, ":\\") != NULL ? NULL : dir); + { + char curcwd[MAX_PATH]; + char fulldir[MAX_PATH]; + char *p; + char **tail[MAX_PATH / 2]; + int len = strlen (dir) + 1; + + if (isabspath (dir)) + p = fulldir; + else + { + p = strchr (strcpy (fulldir, cygcwd.get (curcwd)), '\0'); + if (p > fulldir + 1) + strcpy (p++, "/"); + } + strcpy (p, dir); + dir = fulldir; + for (;;) + { + path_conv resolved (dir, PC_SYM_NOFOLLOW | PC_FULL); + if (resolved.get_attributes () & FILE_ATTRIBUTE_DIRECTORY) + { + cygcwd.set (path, dir); + break; + } + char *p = strrchr (dir) + tail[i] = + } + } /* Note that we're accessing cwd.posix without a lock here. I didn't think it was worth locking just for strace. */ diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index ca039e200..6d0a195e3 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -37,6 +37,7 @@ enum path_types PATH_EXEC = MOUNT_EXEC, PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC, PATH_ALL_EXEC = PATH_CYGWIN_EXEC | PATH_EXEC, + PATH_HAS_SYMLINKS = 0x10000000, PATH_HASBUGGYOPEN = 0x20000000, PATH_SOCKET = 0x40000000, PATH_HASACLS = 0x80000000 @@ -50,6 +51,7 @@ class path_conv unsigned path_flags; int has_acls () {return path_flags & PATH_HASACLS;} + int has_symlinks () {return path_flags & PATH_HAS_SYMLINKS;} int hasgood_inode () {return path_flags & PATH_HASACLS;} // Not strictly correct int has_buggy_open () {return path_flags & PATH_HASBUGGYOPEN;} int isbinary () {return path_flags & PATH_BINARY;} @@ -60,6 +62,7 @@ class path_conv void set_binary () {path_flags |= PATH_BINARY;} void set_symlink () {path_flags |= PATH_SYMLINK;} + void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;} void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTHING;} void set_has_acls (int x = 1) {path_flags |= x ? PATH_HASACLS : PATH_NOTHING;} void set_has_buggy_open (int x = 1) {path_flags |= x ? PATH_HASBUGGYOPEN : PATH_NOTHING;} diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index b7b2f5cb9..f42c9e126 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -245,10 +245,7 @@ beg: if (!wait) set_sig_errno (EAGAIN); /* Don't really need 'set_sig_errno' here, but... */ else - { - set_sig_errno (EINTR); - sawsig = 1; - } + set_sig_errno (EINTR); res = -1; goto out; } @@ -264,7 +261,7 @@ beg: } out: - if (sawsig && call_signal_handler ()) + if (res < 0 && get_errno () == EINTR && call_signal_handler ()) goto beg; syscall_printf ("%d = read (%d<%s>, %p, %d), bin %d, errno %d", res, fd, fh->get_name (), ptr, len, fh->get_r_binary (), get_errno ());