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
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-02-01 19:49:13 +0300
committerChristopher Faylor <me@cgf.cx>2005-02-01 19:49:13 +0300
commit74d8e12e16d5d5416ce37100f8767ff0affa90ec (patch)
treed10e1a02e7ba0ff1322cd3f3dd68c101aaf646f5
parent01a94cf8662ffe333b0b75fc98aa44ada4320aeb (diff)
* cygthread.cc (cygthread::terminate_thread): Wait briefly for notification
event in the event that the thread was actually in the process of exiting. * pipe.cc (fhandler_pipe::dup): read_state is not supposed to be inheritable. Fix that. * path.cc (path_conv::check): Set symlen = 0 to avoid a compiler warning. * devices.h (devices::parsedisk): Declare new function. * devices.in (devices::parsedisk): Define new function. * dtable.cc (dtable::init_std_file_from_handle): Use device numbers rather than name. * fhandler_proc.cc (format_proc_partitions): Use parsedisk to generate disk names from numeric codes. (This was broken on two of my systems previously and is still broken now)
-rw-r--r--winsup/cygwin/ChangeLog20
-rw-r--r--winsup/cygwin/cygthread.cc8
-rw-r--r--winsup/cygwin/devices.cc13
-rw-r--r--winsup/cygwin/devices.h1
-rw-r--r--winsup/cygwin/devices.in13
-rw-r--r--winsup/cygwin/dtable.cc6
-rw-r--r--winsup/cygwin/fhandler_proc.cc56
-rw-r--r--winsup/cygwin/path.cc2
-rw-r--r--winsup/cygwin/pipe.cc2
9 files changed, 83 insertions, 38 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7a0cb6d00..de1ddc329 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,23 @@
+2005-02-01 Christopher Faylor <cgf@timesys.com>
+
+ * cygthread.cc (cygthread::terminate_thread): Wait briefly for
+ notification event in the event that the thread was actually in the
+ process of exiting.
+
+ * pipe.cc (fhandler_pipe::dup): read_state is not supposed to be
+ inheritable. Fix that.
+
+ * path.cc (path_conv::check): Set symlen = 0 to avoid a compiler
+ warning.
+
+ * devices.h (devices::parsedisk): Declare new function.
+ * devices.in (devices::parsedisk): Define new function.
+ * dtable.cc (dtable::init_std_file_from_handle): Use device numbers
+ rather than name.
+ * fhandler_proc.cc (format_proc_partitions): Use parsedisk to generate
+ disk names from numeric codes. (This was broken on two of my
+ systems previously and is still broken now)
+
2005-02-01 Corinna Vinschen <corinna@vinschen.de>
* pipe.cc (fhandler_pipe::open): Allow re-opening of /proc/<pid>/fd
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index adeecb320..3f8286a88 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -73,7 +73,7 @@ cygthread::stub (VOID *arg)
info->func (info->arg == cygself ? info : info->arg);
/* ...so the above should always return */
- /* If stack_ptr is NULL, the above function has set that to indicate
+ /* If func is NULL, the above function has set that to indicate
that it doesn't want to alert anyone with a SetEvent and should
just be marked as no longer inuse. Hopefully the function knows
that it is doing. */
@@ -175,10 +175,6 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
else
{
stack_ptr = NULL;
-#ifdef DEBUGGING
- if (__oldname)
- system_printf ("__oldname %s, terminated %d", __oldname, terminated);
-#endif
h = CreateThread (&sec_none_nih, 0, is_freerange ? simplestub : stub,
this, 0, &id);
if (!h)
@@ -272,6 +268,8 @@ cygthread::terminate_thread ()
(void) TerminateThread (h, 0);
(void) WaitForSingleObject (h, INFINITE);
+ if (ev)
+ WaitForSingleObject (ev, 0);
if (!inuse || exiting)
return;
diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc
index 1c368cdb9..adb197aad 100644
--- a/winsup/cygwin/devices.cc
+++ b/winsup/cygwin/devices.cc
@@ -14850,5 +14850,18 @@ device::tty_to_real_device ()
parse (DEV_TTYS_MAJOR, myself->ctty);
}
+void
+device::parsedisk (int drive, int part)
+{
+ int base;
+ if (drive < ('q' - 'a'))
+ base = DEV_SD_MAJOR;
+ else
+ {
+ base = DEV_SD1_MAJOR;
+ drive -= 'q' - 'q';
+ }
+ parse (base, part + (drive * 16));
+}
diff --git a/winsup/cygwin/devices.h b/winsup/cygwin/devices.h
index f17aeed18..3af7d76b4 100644
--- a/winsup/cygwin/devices.h
+++ b/winsup/cygwin/devices.h
@@ -135,6 +135,7 @@ struct device
void parse (const char *);
void parse (_major_t major, _minor_t minor);
void parse (_dev_t dev);
+ void parsedisk (int, int);
inline bool setunit (unsigned n)
{
minor = n;
diff --git a/winsup/cygwin/devices.in b/winsup/cygwin/devices.in
index cc6040e8c..8c12b558d 100644
--- a/winsup/cygwin/devices.in
+++ b/winsup/cygwin/devices.in
@@ -130,3 +130,16 @@ device::tty_to_real_device ()
parse (DEV_TTYS_MAJOR, myself->ctty);
}
+void
+device::parsedisk (int drive, int part)
+{
+ int base;
+ if (drive < ('q' - 'a'))
+ base = DEV_SD_MAJOR;
+ else
+ {
+ base = DEV_SD1_MAJOR;
+ drive -= 'q' - 'q';
+ }
+ parse (base, part + (drive * 16));
+}
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index a699553c1..22befcdb4 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -273,14 +273,14 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
if (GetConsoleScreenBufferInfo (handle, &buf))
{
if (ISSTATE (myself, PID_USETTY))
- dev.parse ("/dev/tty");
+ dev.parse (FH_TTY);
else
dev = *console_dev;
}
else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf))
{
if (ISSTATE (myself, PID_USETTY))
- dev.parse ("/dev/tty");
+ dev.parse (FH_TTY);
else
dev = *console_dev;
}
@@ -294,7 +294,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
dev = *tcp_dev;
else if (GetCommState (handle, &dcb))
- dev.parse ("/dev/ttyS0");
+ dev.parse (DEV_TTYS_MAJOR, 0);
else
{
name = handle_to_fn (handle, (char *) alloca (CYG_MAX_PATH + 100));
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index 95817b929..bd6ff03bb 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -387,7 +387,7 @@ fhandler_proc::fill_filebuf ()
}
case PROC_SELF:
{
- filebuf = (char *) realloc (filebuf, bufalloc = 32);
+ filebuf = (char *) realloc (filebuf, bufalloc = 32);
filesize = __small_sprintf (filebuf, "%d", getpid ());
}
}
@@ -967,8 +967,6 @@ format_proc_partitions (char *destbuf, size_t maxsize)
{
DWORD dwBytesReturned, dwRetCode;
DISK_GEOMETRY dg;
- int buf_size = 4096;
- char buf[buf_size];
dwRetCode = DeviceIoControl (hDevice,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
@@ -981,49 +979,51 @@ format_proc_partitions (char *destbuf, size_t maxsize)
debug_printf ("DeviceIoControl %E");
else
{
- char devname[16];
- __small_sprintf (devname, "/dev/sd%c", drive_number + 'a');
device dev;
- dev.parse (devname);
+ dev.parsedisk (drive_number, 0);
bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n",
dev.major,
dev.minor,
(long long)((dg.Cylinders.QuadPart * dg.TracksPerCylinder *
dg.SectorsPerTrack * dg.BytesPerSector) >> 10),
- devname + 5);
+ dev.name + 5);
}
- while (dwRetCode = DeviceIoControl (hDevice,
- IOCTL_DISK_GET_DRIVE_LAYOUT,
- NULL,
- 0,
- (DRIVE_LAYOUT_INFORMATION *) buf,
- buf_size,
- &dwBytesReturned,
- NULL),
- !dwRetCode && GetLastError () == ERROR_INSUFFICIENT_BUFFER)
- buf_size *= 2;
- if (!dwRetCode)
- debug_printf ("DeviceIoControl %E");
- else
+ size_t buf_size = 8192;
+ DWORD rc;
+ while (1)
{
+ char buf[buf_size];
+ memset (buf, 0, buf_size);
+ rc = DeviceIoControl (hDevice, IOCTL_DISK_GET_DRIVE_LAYOUT,
+ NULL, 0, (DRIVE_LAYOUT_INFORMATION *) buf,
+ buf_size, &dwBytesReturned, NULL);
+ if (rc)
+ /* fall through */;
+ else if (GetLastError () == ERROR_INSUFFICIENT_BUFFER)
+ {
+ buf_size *= 2;
+ continue;
+ }
+ else
+ {
+ debug_printf ("DeviceIoControl %E");
+ break;
+ }
DRIVE_LAYOUT_INFORMATION *dli = (DRIVE_LAYOUT_INFORMATION *) buf;
for (unsigned partition = 0; partition < dli->PartitionCount; partition++)
{
- if (dli->PartitionEntry[partition].PartitionLength.QuadPart == 0)
+ if (!dli->PartitionEntry[partition].PartitionLength.QuadPart
+ || !dli->PartitionEntry[partition].PartitionType)
continue;
- char devname[16];
- __small_sprintf (devname, "/dev/sd%c%d",
- drive_number + 'a',
- partition + 1);
device dev;
- dev.parse (devname);
+ dev.parsedisk (drive_number, partition + 1);
bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n",
dev.major, dev.minor,
(long long)(dli->PartitionEntry[partition].PartitionLength.QuadPart >> 10),
- devname + 5);
+ dev.name + 5);
}
+ break;
}
-
CloseHandle (hDevice);
}
}
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 9321a9b32..055aa1986 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -572,7 +572,7 @@ path_conv::check (const char *src, unsigned opt,
int component = 0; // Number of translated components
sym.contents[0] = '\0';
- int symlen;
+ int symlen = 0;
for (;;)
{
const suffix_info *suff;
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 6ce540695..7dbd87a5f 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -229,7 +229,7 @@ fhandler_pipe::dup (fhandler_base *child)
if (read_state == NULL)
ftp->read_state = NULL;
else if (!DuplicateHandle (hMainProc, read_state, hMainProc,
- &ftp->read_state, 0, 1,
+ &ftp->read_state, 0, 0,
DUPLICATE_SAME_ACCESS))
{
debug_printf ("couldn't duplicate read_state %p, %E", read_state);