* thread.h (struct _winsup_t): Remove obsolete elements. Add available_drives

element.
* path.cc (mount_info::getmntent): Report "/cygdrive" drives when mounted
drives are exhausted.
(fillout_mntent): New function.
(mount_item::getmntent): Use fillout_mntent.
(cygdrives_mntent): New function.  Returns next available "/cygdrive".
(setmntent): Initialize available "/cygdrives".
* syscalls.cc: Remove some if 0'ed code.
* times.cc (timezone): Use more descriptive variable name.
This commit is contained in:
Christopher Faylor 2001-04-01 03:06:02 +00:00
parent f611148366
commit f2aeff27f0
5 changed files with 130 additions and 135 deletions

View File

@ -1,3 +1,16 @@
Sat Mar 31 21:56:19 2001 Christopher Faylor <cgf@cygnus.com>
* thread.h (struct _winsup_t): Remove obsolete elements. Add
available_drives element.
* path.cc (mount_info::getmntent): Report "/cygdrive" drives when
mounted drives are exhausted.
(fillout_mntent): New function.
(mount_item::getmntent): Use fillout_mntent.
(cygdrives_mntent): New function. Returns next available "/cygdrive".
(setmntent): Initialize available "/cygdrives".
* syscalls.cc: Remove some if 0'ed code.
* times.cc (timezone): Use more descriptive variable name.
Sat Mar 31 18:59:52 2001 Christopher Faylor <cgf@cygnus.com>
* sigproc.h (class sigframe): Implement 'unregister()' method.

View File

@ -77,6 +77,14 @@ details. */
#include <assert.h>
#include "shortcut.h"
#ifdef _MT_SAFE
#define iteration _reent_winsup ()->_iteration
#define available_drives _reent_winsup ()->available_drives
#else
static int iteration;
static DWORD available_drives;
#endif
static int normalize_win32_path (const char *src, char *dst);
static void slashify (const char *src, char *dst, int trailing_slash_p);
static void backslashify (const char *src, char *dst, int trailing_slash_p);
@ -1720,15 +1728,6 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags,
return (res != ERROR_SUCCESS) ? res : res2;
}
struct mntent *
mount_info::getmntent (int x)
{
if (x < 0 || x >= nmounts)
return NULL;
return mount[native_sorted[x]].getmntent ();
}
static mount_item *mounts_for_sort;
/* sort_by_posix_name: qsort callback to sort the mount entries. Sort
@ -2028,11 +2027,11 @@ mount_info::import_v1_mounts ()
/************************* mount_item class ****************************/
struct mntent *
mount_item::getmntent ()
static mntent *
fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
{
#ifdef _MT_SAFE
struct mntent &ret=_reent_winsup()->_ret;
struct mntent &ret=_reent_winsup()->mntbuf;
#else
static NO_COPY struct mntent ret;
#endif
@ -2053,7 +2052,7 @@ mount_item::getmntent ()
strcpy (mount_table->mnt_type, (char *) "system");
if ((flags & MOUNT_AUTO)) /* cygdrive */
strcat (mount_table->mnt_type, (char *) ",auto");
strcat (mount_table->mnt_type, (char *) ",noumount");
ret.mnt_type = mount_table->mnt_type;
@ -2079,6 +2078,42 @@ mount_item::getmntent ()
return &ret;
}
struct mntent *
mount_item::getmntent ()
{
return fillout_mntent (native_path, posix_path, flags);
}
static struct mntent *
cygdrive_getmntent ()
{
if (!available_drives)
return NULL;
DWORD mask, drive;
for (mask = 1, drive = 'a'; drive <= 'z'; mask <<= 1, drive++)
if (available_drives & mask)
{
available_drives &= ~mask;
break;
}
char native_path[3];
char posix_path[MAX_PATH];
__small_sprintf (native_path, "%c:", drive);
__small_sprintf (posix_path, "%s%c", mount_table->cygdrive, drive);
return fillout_mntent (native_path, posix_path, mount_table->cygdrive_flags);
}
struct mntent *
mount_info::getmntent (int x)
{
if (x < 0 || x >= nmounts)
return cygdrive_getmntent ();
return mount[native_sorted[x]].getmntent ();
}
/* Fill in the fields of a mount table entry. */
void
@ -2161,17 +2196,12 @@ cygwin_umount (const char *path, unsigned flags)
return res;
}
#ifdef _MT_SAFE
#define iteration _reent_winsup()->_iteration
#else
static int iteration;
#endif
extern "C"
FILE *
setmntent (const char *filep, const char *)
{
iteration = 0;
available_drives = GetLogicalDrives ();
return (FILE *) filep;
}

View File

@ -665,38 +665,6 @@ done:
return res;
}
#if 0
static BOOL
rel2abssd (PSECURITY_DESCRIPTOR psd_rel, PSECURITY_DESCRIPTOR psd_abs,
DWORD abslen)
{
#ifdef _MT_SAFE
struct _winsup_t *r=_reent_winsup ();
char *dacl_buf=r->_dacl_buf;
char *sacl_buf=r->_sacl_buf;
char *ownr_buf=r->_ownr_buf;
char *grp_buf=r->_grp_buf;
#else
static char dacl_buf[1024];
static char sacl_buf[1024];
static char ownr_buf[1024];
static char grp_buf[1024];
#endif
DWORD dacl_len = 1024;
DWORD sacl_len = 1024;
DWORD ownr_len = 1024;
DWORD grp_len = 1024;
BOOL res = MakeAbsoluteSD (psd_rel, psd_abs, &abslen, (PACL) dacl_buf,
&dacl_len, (PACL) sacl_buf, &sacl_len,
(PSID) ownr_buf, &ownr_len, (PSID) grp_buf,
&grp_len);
syscall_printf ("%d = rel2abssd (...)", res);
return res;
}
#endif
/* chown: POSIX 5.6.5.1 */
/*
* chown () is only implemented for Windows NT. Under other operating

View File

@ -26,9 +26,9 @@ details. */
extern "C"
{
#if defined (_CYG_THREAD_FAILSAFE) && defined (_MT_SAFE)
void AssertResourceOwner (int, int);
void AssertResourceOwner (int, int);
#else
# define AssertResourceOwner(i,ii)
#define AssertResourceOwner(i,ii)
#endif
}
@ -63,73 +63,64 @@ extern "C"
extern "C"
{
struct _winsup_t
{
/*
Needed for the group functions
*/
struct group _grp;
char *_namearray[2];
char _linebuf[100];
int _grp_pos;
struct _winsup_t
{
/*
Needed for the group functions
*/
struct group _grp;
char *_namearray[2];
int _grp_pos;
/* console.cc */
unsigned _rarg;
/* console.cc */
unsigned _rarg;
/* dlfcn.cc */
int _dl_error;
char _dl_buffer[256];
/* dlfcn.cc */
int _dl_error;
char _dl_buffer[256];
/* passwd.cc */
struct passwd _res;
char _tmpbuf[100];
char _pass[_PASSWORD_LEN];
int _pw_pos;
/* passwd.cc */
struct passwd _res;
char _pass[_PASSWORD_LEN];
int _pw_pos;
/* path.cc */
struct mntent _ret;
int _iteration;
/* path.cc */
struct mntent mntbuf;
int _iteration;
DWORD available_drives;
/* strerror */
char _strerror_buf[20];
/* strerror */
char _strerror_buf[20];
/* syscalls.cc */
char _dacl_buf[1024];
char _sacl_buf[1024];
char _ownr_buf[1024];
char _grp_buf[1024];
/* sysloc.cc */
char *_process_ident;
int _process_logopt;
int _process_facility;
int _process_logmask;
/* sysloc.cc */
char *_process_ident;
int _process_logopt;
int _process_facility;
int _process_logmask;
/* times.cc */
char timezone_buf[20];
struct tm _localtime_buf;
/* times.cc */
char _b[20];
struct tm _localtime_buf;
char _buf1[33];
char _buf2[33];
/* uinfo.cc */
char _username[MAX_USER_NAME];
};
/* uinfo.cc */
char _username[MAX_USER_NAME];
};
struct __reent_t
{
struct _reent *_clib;
struct _winsup_t *_winsup;
};
struct __reent_t
{
struct _reent *_clib;
struct _winsup_t *_winsup;
};
_reent *_reent_clib ();
_winsup_t *_reent_winsup ();
void SetResourceLock (int, int, const char *) __attribute__ ((regparm (3)));
void ReleaseResourceLock (int, int, const char *)
__attribute__ ((regparm (3)));
_reent *_reent_clib ();
_winsup_t *_reent_winsup ();
void SetResourceLock (int, int, const char *) __attribute__ ((regparm (3)));
void ReleaseResourceLock (int, int, const char *)
__attribute__ ((regparm (3)));
#ifdef _CYG_THREAD_FAILSAFE
void AssertResourceOwner (int, int);
void AssertResourceOwner (int, int);
#else
#define AssertResourceOwner(i,ii)
#endif
@ -141,9 +132,7 @@ class pinfo;
class ResourceLocks
{
public:
ResourceLocks ()
{
};
ResourceLocks () {}
LPCRITICAL_SECTION Lock (int);
void Init ();
void Delete ();
@ -170,8 +159,8 @@ class verifyable_object
public:
long magic;
verifyable_object (long);
~verifyable_object ();
verifyable_object (long);
~verifyable_object ();
};
int verifyable_object_isvalid (verifyable_object *, long);
@ -182,8 +171,8 @@ public:
int joinable;
size_t stacksize;
pthread_attr ();
~pthread_attr ();
pthread_attr ();
~pthread_attr ();
};
class pthread:public verifyable_object
@ -211,18 +200,16 @@ public:
LONG *sigtodo;
void create (void *(*)(void *), pthread_attr *, void *);
pthread ();
~pthread ();
pthread ();
~pthread ();
private:
DWORD thread_id;
DWORD thread_id;
};
class pthread_mutexattr:public verifyable_object
{
public:
pthread_mutexattr ();
~pthread_mutexattr ();
};
@ -237,8 +224,8 @@ public:
int TryLock ();
int UnLock ();
pthread_mutex (pthread_mutexattr *);
~pthread_mutex ();
pthread_mutex (pthread_mutexattr *);
~pthread_mutex ();
};
class pthread_key:public verifyable_object
@ -249,8 +236,8 @@ public:
int set (const void *);
void *get ();
pthread_key ();
~pthread_key ();
pthread_key ();
~pthread_key ();
};
class pthread_condattr:public verifyable_object
@ -258,8 +245,8 @@ class pthread_condattr:public verifyable_object
public:
int shared;
pthread_condattr ();
~pthread_condattr ();
pthread_condattr ();
~pthread_condattr ();
};
class pthread_cond:public verifyable_object
@ -273,8 +260,8 @@ public:
void BroadCast ();
void Signal ();
pthread_cond (pthread_condattr *);
~pthread_cond ();
pthread_cond (pthread_condattr *);
~pthread_cond ();
};
/* shouldn't be here */
@ -287,8 +274,8 @@ public:
void Post ();
int TryWait ();
semaphore (int, unsigned int);
~semaphore ();
semaphore (int, unsigned int);
~semaphore ();
};
typedef class pthread *pthread_t;
@ -318,15 +305,13 @@ public:
void Init (int);
MTinterface ():reent_index (0), indexallocated (0)
{
}
MTinterface ():reent_index (0), indexallocated (0)
{}
};
extern "C"
{
void *thread_init_wrapper (void *);
/* ThreadCreation */
@ -400,7 +385,6 @@ __pthread_attr_getstackaddr(...);
int __sem_wait (sem_t * sem);
int __sem_trywait (sem_t * sem);
int __sem_post (sem_t * sem);
};
#endif // MT_SAFE

View File

@ -123,7 +123,7 @@ extern "C" char *
timezone ()
{
#ifdef _MT_SAFE
char *b=_reent_winsup()->_b;
char *b=_reent_winsup()->timezone_buf;
#else
static NO_COPY char b[20] = {0};
#endif