Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-07-05 06:05:07 +0400
committerChristopher Faylor <me@cgf.cx>2005-07-05 06:05:07 +0400
commit26edeb6a7f6c541a25ee7fa4c201b24fea01cc50 (patch)
tree037b544f95c625b879b2bf518e69313c42a5245f /winsup
parenta64b8b2dec5ba82dd3933a959e3e3f5f09116963 (diff)
* cygtls.h (_cygtls): Perform minor reformatting.
* winsup.h (close_all_files): Reflect argument change. * dtable.cc (close_all_files): Ditto. * dtable.h: Ditto. * fhandler.h: Ditto. * spawn.cc (spawn_guts): Move close_all_files back to its original location in first P_OVERLAY test but use argument denoting that handles are only supposed to be closed, not released (more work to be done here). * syscalls.cc (close_all_files): Take an argument denoting whether to release closed files or not. * path.cc (symlink): Change argument names to reflect linux man page. (symlink_worker): Ditto. Also appropriately set ENOENT for empty strings.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog19
-rw-r--r--winsup/cygwin/cygtls.h5
-rw-r--r--winsup/cygwin/dtable.h2
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/path.cc76
-rw-r--r--winsup/cygwin/spawn.cc2
-rw-r--r--winsup/cygwin/syscalls.cc5
-rw-r--r--winsup/cygwin/winsup.h2
8 files changed, 65 insertions, 48 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 067225241..7f7bab980 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,22 @@
+2005-07-04 Christopher Faylor <cgf@timesys.com>
+
+ * cygtls.h (_cygtls): Perform minor reformatting.
+
+ * winsup.h (close_all_files): Reflect argument change.
+ * dtable.cc (close_all_files): Ditto.
+ * dtable.h: Ditto.
+ * fhandler.h: Ditto.
+ * spawn.cc (spawn_guts): Move close_all_files back to its original
+ location in first P_OVERLAY test but use argument denoting that handles
+ are only supposed to be closed, not released (more work to be done
+ here).
+ * syscalls.cc (close_all_files): Take an argument denoting whether to
+ release closed files or not.
+
+ * path.cc (symlink): Change argument names to reflect linux man page.
+ (symlink_worker): Ditto. Also appropriately set ENOENT for empty strings.
+
+
2005-07-04 Pierre Humblet <pierre.humblet@ieee.org>
* cygheap.h (struct init_cygheap): Delete cygwin_regname member.
diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
index 2ac6d04b3..3a5adba8a 100644
--- a/winsup/cygwin/cygtls.h
+++ b/winsup/cygwin/cygtls.h
@@ -252,10 +252,7 @@ class myfault
{
jmp_buf buf;
public:
- ~myfault () __attribute__ ((always_inline))
- {
- _my_tls.clear_fault (buf);
- }
+ ~myfault () __attribute__ ((always_inline)) { _my_tls.clear_fault (buf); }
inline int faulted (int myerrno = 0) __attribute__ ((always_inline))
{
return _my_tls.setup_fault (buf, myerrno);
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index 343eb8cc8..9e0523808 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -84,7 +84,7 @@ public:
fhandler_base **add_archetype ();
void delete_archetype (fhandler_base *);
friend void dtable_init ();
- friend void __stdcall close_all_files ();
+ friend void __stdcall close_all_files (bool);
friend class cygheap_fdmanip;
friend class cygheap_fdget;
friend class cygheap_fdnew;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index b3a478bea..cb0f5b196 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -82,7 +82,7 @@ enum query_state {
class fhandler_base
{
friend class dtable;
- friend void close_all_files ();
+ friend void close_all_files (bool);
struct status_flags
{
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 2aeb1f198..bba75b0e9 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2615,48 +2615,48 @@ set_symlink_ea (const char* frompath, const char* topath)
bool allow_winsymlinks = true;
extern "C" int
-symlink (const char *topath, const char *frompath)
+symlink (const char *oldpath, const char *newpath)
{
- return symlink_worker (topath, frompath, allow_winsymlinks, false);
+ return symlink_worker (oldpath, newpath, allow_winsymlinks, false);
}
int
-symlink_worker (const char *topath, const char *frompath, bool use_winsym,
+symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
bool isdevice)
{
HANDLE h;
int res = -1;
- path_conv win32_path, win32_topath;
+ path_conv win32_path, win32_oldpath;
char from[CYG_MAX_PATH + 5];
char cwd[CYG_MAX_PATH], *cp = NULL, c = 0;
- char w32topath[CYG_MAX_PATH];
- char reltopath[CYG_MAX_PATH] = { 0 };
+ char w32oldpath[CYG_MAX_PATH];
+ char reloldpath[CYG_MAX_PATH] = { 0 };
DWORD written;
SECURITY_ATTRIBUTES sa = sec_none_nih;
security_descriptor sd;
- /* POSIX says that empty 'frompath' is invalid input while empty
- 'topath' is valid -- it's symlink resolver job to verify if
+ /* POSIX says that empty 'newpath' is invalid input while empty
+ 'oldpath' is valid -- it's symlink resolver job to verify if
symlink contents point to existing filesystem object */
myfault efault;
if (efault.faulted (EFAULT))
goto done;
- if (!*topath || !*frompath)
+ if (!*oldpath || !*newpath)
{
- set_errno (EINVAL);
+ set_errno (ENOENT);
goto done;
}
- if (strlen (topath) >= CYG_MAX_PATH)
+ if (strlen (oldpath) >= CYG_MAX_PATH)
{
set_errno (ENAMETOOLONG);
goto done;
}
- win32_path.check (frompath, PC_SYM_NOFOLLOW);
+ win32_path.check (newpath, PC_SYM_NOFOLLOW);
if (use_winsym && !win32_path.exists ())
{
- strcpy (from, frompath);
+ strcpy (from, newpath);
strcat (from, ".lnk");
win32_path.check (from, PC_SYM_NOFOLLOW);
}
@@ -2667,7 +2667,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
goto done;
}
- syscall_printf ("symlink (%s, %s)", topath, win32_path.get_win32 ());
+ syscall_printf ("symlink (%s, %s)", oldpath, win32_path.get_win32 ());
if (win32_path.is_auto_device ())
{
@@ -2680,13 +2680,13 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
create_how = CREATE_NEW;
else if (isdevice)
{
- strcpy (w32topath, topath);
+ strcpy (w32oldpath, oldpath);
create_how = CREATE_ALWAYS;
(void) SetFileAttributes (win32_path, FILE_ATTRIBUTE_NORMAL);
}
else
{
- if (!isabspath (topath))
+ if (!isabspath (oldpath))
{
getcwd (cwd, CYG_MAX_PATH);
if ((cp = strrchr (from, '/')) || (cp = strrchr (from, '\\')))
@@ -2695,23 +2695,23 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
*cp = '\0';
chdir (from);
}
- backslashify (topath, reltopath, 0);
+ backslashify (oldpath, reloldpath, 0);
/* Creating an ITEMIDLIST requires an absolute path. So if we
create a shortcut file, we create relative and absolute Win32
paths, the first for the relpath field and the latter for the
ITEMIDLIST field. */
- if (GetFileAttributes (reltopath) == INVALID_FILE_ATTRIBUTES)
+ if (GetFileAttributes (reloldpath) == INVALID_FILE_ATTRIBUTES)
{
- win32_topath.check (topath, PC_SYM_NOFOLLOW);
- if (win32_topath.error != ENOENT)
- strcpy (use_winsym ? reltopath : w32topath, win32_topath);
+ win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW);
+ if (win32_oldpath.error != ENOENT)
+ strcpy (use_winsym ? reloldpath : w32oldpath, win32_oldpath);
}
else if (!use_winsym)
- strcpy (w32topath, reltopath);
+ strcpy (w32oldpath, reloldpath);
if (use_winsym)
{
- win32_topath.check (topath, PC_SYM_NOFOLLOW);
- strcpy (w32topath, win32_topath);
+ win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW);
+ strcpy (w32oldpath, win32_oldpath);
}
if (cp)
{
@@ -2721,8 +2721,8 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
}
else
{
- win32_topath.check (topath, PC_SYM_NOFOLLOW);
- strcpy (w32topath, win32_topath);
+ win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW);
+ strcpy (w32oldpath, win32_oldpath);
}
create_how = CREATE_NEW;
}
@@ -2761,7 +2761,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
hres = SHGetDesktopFolder (&psl);
if (SUCCEEDED (hres))
{
- MultiByteToWideChar (CP_ACP, 0, w32topath, -1, wc_path,
+ MultiByteToWideChar (CP_ACP, 0, w32oldpath, -1, wc_path,
CYG_MAX_PATH);
hres = psl->ParseDisplayName (NULL, NULL, wc_path, NULL,
&pidl, NULL);
@@ -2780,19 +2780,19 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
psl->Release ();
}
/* Creating a description */
- *(unsigned short *)cp = len = strlen (topath);
- memcpy (cp += 2, topath, len);
+ *(unsigned short *)cp = len = strlen (oldpath);
+ memcpy (cp += 2, oldpath, len);
cp += len;
/* Creating a relpath */
- if (reltopath[0])
+ if (reloldpath[0])
{
- *(unsigned short *)cp = len = strlen (reltopath);
- memcpy (cp += 2, reltopath, len);
+ *(unsigned short *)cp = len = strlen (reloldpath);
+ memcpy (cp += 2, reloldpath, len);
}
else
{
- *(unsigned short *)cp = len = strlen (w32topath);
- memcpy (cp += 2, w32topath, len);
+ *(unsigned short *)cp = len = strlen (w32oldpath);
+ memcpy (cp += 2, w32oldpath, len);
}
cp += len;
success = WriteFile (h, buf, cp - buf, &written, NULL)
@@ -2803,7 +2803,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
/* This is the old technique creating a symlink. */
char buf[sizeof (SYMLINK_COOKIE) + CYG_MAX_PATH + 10];
- __small_sprintf (buf, "%s%s", SYMLINK_COOKIE, topath);
+ __small_sprintf (buf, "%s%s", SYMLINK_COOKIE, oldpath);
DWORD len = strlen (buf) + 1;
/* Note that the terminating nul is written. */
@@ -2828,7 +2828,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
SetFileAttributes (win32_path, attr);
if (!isdevice && win32_path.fs_has_ea ())
- set_symlink_ea (win32_path, topath);
+ set_symlink_ea (win32_path, oldpath);
res = 0;
}
else
@@ -2840,8 +2840,8 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym,
}
done:
- syscall_printf ("%d = symlink_worker (%s, %s, %d, %d)", res, topath,
- frompath, use_winsym, isdevice);
+ syscall_printf ("%d = symlink_worker (%s, %s, %d, %d)", res, oldpath,
+ newpath, use_winsym, isdevice);
return res;
}
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 7f4d8fb0f..6aef5feb6 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -800,6 +800,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
strace.execing = 1;
myself.hProcess = hExeced = pi.hProcess;
strcpy (myself->progname, real_path); // FIXME: race?
+ close_all_files (true);
sigproc_printf ("new process name %s", myself->progname);
/* If wr_proc_pipe doesn't exist then this process was not started by a cygwin
process. So, we need to wait around until the process we've just "execed"
@@ -869,7 +870,6 @@ spawn_guts (const char * prog_arg, const char *const *argv,
switch (mode)
{
case _P_OVERLAY:
- close_all_files ();
if (!synced)
/* let myself.exit handle this */;
else if (myself->wr_proc_pipe)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 804965f36..6f06bb1d7 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -94,7 +94,7 @@ static int __stdcall stat_worker (const char *name, struct __stat64 *buf,
ensure we don't leave any such files lying around. */
void __stdcall
-close_all_files ()
+close_all_files (bool norelease)
{
cygheap->fdtab.lock ();
@@ -106,7 +106,8 @@ close_all_files ()
debug_printf ("closing fd %d", i);
#endif
fh->close ();
- cygheap->fdtab.release (i);
+ if (!norelease)
+ cygheap->fdtab.release (i);
}
if (cygheap->ctty)
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 374e5052f..7bec1854e 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -223,7 +223,7 @@ void uinfo_init (void);
void events_init (void);
void events_terminate (void);
-void __stdcall close_all_files ();
+void __stdcall close_all_files (bool = false);
/* Globals that handle initialization of winsock in a child process. */
extern HANDLE wsock32_handle;