* 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)
This commit is contained in:
parent
01a94cf866
commit
74d8e12e16
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
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;
|
||||
if (!dwRetCode)
|
||||
debug_printf ("DeviceIoControl %E");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue