Throughout, change 'cygwin_shared.mount' to 'mount_table'.
* child_info.h (child_info): Move shared_h, console_h to cygheap. Add mount_h. * cygheap.h (init_cygheap): Add shared_h, console_h. * cygheap.cc (init_cheap): Initialize heap at a fixed location after the shared memory regions. Initialize cygheap->user name here. * dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants. Remove cygheap_init since it is done in shared_init now. (_dll_crt0): Initialize mount_h, remove shared_h and console_h initialization. * fhandler_console.cc (console_shared_h): Eliminate. (get_tty_stuff): Use cygheap->console_h rather than console_shared_h. * heap.cc (heap_init): Use page size constant calculated earlier in initialization. * shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h. (mount_table_init): New function for initializing a user mount table. (open_shared_file_map): Use constant for shared memory region. Initialize cygheap and mount table here. (open_shared): Improve debugging output. (shared_info::initialize): Eliminate call to mount.init. (shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h. (open_shared_file_map): Eliminate. * shared_info.h (mount_info): Add a version field. (shared_align_past): New macro for calculating location for shared memory regions. * sigproc.cc (init_child_info): Eliminate shared_h, console_h. * spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different user. * syscalls.cc (system_info): New global holding system memory defaults. (getpagesize): Use system_info. * uinfo.cc (internal_getlogin): Only fill in user name if nonexistent. * winsup.h: Declare system_info. * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than retrieving the name again.
This commit is contained in:
parent
022ce214de
commit
2a6fc028ba
@ -1,3 +1,36 @@
|
||||
Sun Jan 28 00:28:30 2001 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
Throughout, change 'cygwin_shared.mount' to 'mount_table'.
|
||||
* child_info.h (child_info): Move shared_h, console_h to cygheap. Add
|
||||
mount_h.
|
||||
* cygheap.h (init_cygheap): Add shared_h, console_h.
|
||||
* cygheap.cc (init_cheap): Initialize heap at a fixed location after
|
||||
the shared memory regions. Initialize cygheap->user name here.
|
||||
* dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants.
|
||||
Remove cygheap_init since it is done in shared_init now.
|
||||
(_dll_crt0): Initialize mount_h, remove shared_h and console_h
|
||||
initialization.
|
||||
* fhandler_console.cc (console_shared_h): Eliminate.
|
||||
(get_tty_stuff): Use cygheap->console_h rather than console_shared_h.
|
||||
* heap.cc (heap_init): Use page size constant calculated earlier in initialization.
|
||||
* shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h.
|
||||
(mount_table_init): New function for initializing a user mount table.
|
||||
(open_shared_file_map): Use constant for shared memory region. Initialize cygheap and mount table here.
|
||||
(open_shared): Improve debugging output.
|
||||
(shared_info::initialize): Eliminate call to mount.init.
|
||||
(shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h.
|
||||
(open_shared_file_map): Eliminate.
|
||||
* shared_info.h (mount_info): Add a version field.
|
||||
(shared_align_past): New macro for calculating location for shared memory regions.
|
||||
* sigproc.cc (init_child_info): Eliminate shared_h, console_h.
|
||||
* spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different user.
|
||||
* syscalls.cc (system_info): New global holding system memory defaults.
|
||||
(getpagesize): Use system_info.
|
||||
* uinfo.cc (internal_getlogin): Only fill in user name if nonexistent.
|
||||
* winsup.h: Declare system_info.
|
||||
|
||||
* passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than retrieving the name again.
|
||||
|
||||
Sat Jan 27 10:18:02 2001 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
* path.cc (path_conv::check): Detect when path has symlinks.
|
||||
|
@ -12,7 +12,7 @@ details. */
|
||||
|
||||
enum
|
||||
{
|
||||
PROC_MAGIC = 0xaf0bf000,
|
||||
PROC_MAGIC = 0xaf0cf000,
|
||||
PROC_FORK = PROC_MAGIC + 1,
|
||||
PROC_EXEC = PROC_MAGIC + 2,
|
||||
PROC_SPAWN = PROC_MAGIC + 3,
|
||||
@ -34,8 +34,7 @@ public:
|
||||
DWORD type; // type of record
|
||||
int cygpid; // cygwin pid of child process
|
||||
HANDLE subproc_ready; // used for synchronization with parent
|
||||
HANDLE shared_h;
|
||||
HANDLE console_h;
|
||||
HANDLE mount_h;
|
||||
HANDLE parent;
|
||||
HANDLE pppid_handle;
|
||||
init_cygheap *cygheap;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "heap.h"
|
||||
#include "cygerrno.h"
|
||||
#include "sync.h"
|
||||
#include "shared_info.h"
|
||||
|
||||
init_cygheap NO_COPY *cygheap;
|
||||
void NO_COPY *cygheap_max = NULL;
|
||||
@ -26,10 +27,19 @@ static NO_COPY muto *cygheap_protect = NULL;
|
||||
inline static void
|
||||
init_cheap ()
|
||||
{
|
||||
cygheap = (init_cygheap *) VirtualAlloc (NULL, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS);
|
||||
void *addr = cygheap_address;
|
||||
cygheap = (init_cygheap *) VirtualAlloc (addr, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS);
|
||||
if (!cygheap)
|
||||
api_fatal ("Couldn't reserve space for cygwin's heap, %E");
|
||||
cygheap_max = cygheap + 1;
|
||||
|
||||
char username[MAX_USER_NAME];
|
||||
DWORD username_len = MAX_USER_NAME;
|
||||
|
||||
if (!GetUserName (username, &username_len))
|
||||
cygheap->user.set_name ("unknown");
|
||||
else
|
||||
cygheap->user.set_name (username);
|
||||
}
|
||||
|
||||
#define pagetrunc(x) ((void *) (((DWORD) (x)) & ~(4096 - 1)))
|
||||
|
@ -103,6 +103,8 @@ struct init_cygheap
|
||||
cygheap_root root;
|
||||
cygheap_user user;
|
||||
mode_t umask;
|
||||
HANDLE shared_h;
|
||||
HANDLE console_h;
|
||||
};
|
||||
|
||||
extern init_cygheap *cygheap;
|
||||
|
@ -632,9 +632,7 @@ dll_crt0_1 ()
|
||||
/* FIXME: Verify forked children get their exception handler set up ok. */
|
||||
exception_list cygwin_except_entry;
|
||||
|
||||
/* Initialize SIGSEGV handling, etc... Because the exception handler
|
||||
references data in the shared area, this must be done after
|
||||
shared_init. */
|
||||
/* Initialize SIGSEGV handling, etc. */
|
||||
init_exceptions (&cygwin_except_entry);
|
||||
|
||||
do_global_ctors (&__CTOR_LIST__, 1);
|
||||
@ -656,6 +654,7 @@ dll_crt0_1 ()
|
||||
|
||||
threadname_init ();
|
||||
debug_init ();
|
||||
(void) getpagesize (); /* initialize page size constant */
|
||||
|
||||
regthread ("main", GetCurrentThreadId ());
|
||||
mainthread.init ("mainthread"); // For use in determining if signals
|
||||
@ -735,9 +734,6 @@ dll_crt0_1 ()
|
||||
/* Initialize events. */
|
||||
events_init ();
|
||||
|
||||
if (!child_proc_info)
|
||||
cygheap_init ();
|
||||
|
||||
cygcwd.init ();
|
||||
|
||||
cygbench ("pre-forkee");
|
||||
@ -918,9 +914,8 @@ _dll_crt0 ()
|
||||
case PROC_EXEC:
|
||||
{
|
||||
child_proc_info = fork_info;
|
||||
cygwin_mount_h = child_proc_info->mount_h;
|
||||
mypid = child_proc_info->cygpid;
|
||||
cygwin_shared_h = child_proc_info->shared_h;
|
||||
console_shared_h = child_proc_info->console_h;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -299,7 +299,7 @@ static int NO_COPY keep_looping = 0;
|
||||
extern "C" int
|
||||
try_to_debug ()
|
||||
{
|
||||
debug_printf ("debugger_command %s", debugger_command);
|
||||
debug_printf ("debugger_command '%s'", debugger_command);
|
||||
if (*debugger_command == '\0')
|
||||
return 0;
|
||||
|
||||
|
@ -91,8 +91,7 @@ static DWORD
|
||||
get_cygdrive_info (char *user, char *system, char *user_flags,
|
||||
char *system_flags)
|
||||
{
|
||||
shared_info *info = cygwin_getshared();
|
||||
int res = info->mount.get_cygdrive_info (user, system, user_flags,
|
||||
int res = mount_table->get_cygdrive_info (user, system, user_flags,
|
||||
system_flags);
|
||||
return (res == ERROR_SUCCESS) ? 1 : 0;
|
||||
}
|
||||
@ -138,7 +137,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
|
||||
|
||||
case CW_READ_V1_MOUNT_TABLES:
|
||||
/* Upgrade old v1 registry mounts to new location. */
|
||||
cygwin_shared->mount.import_v1_mounts ();
|
||||
mount_table->import_v1_mounts ();
|
||||
return 0;
|
||||
|
||||
case CW_USER_DATA:
|
||||
|
@ -20,6 +20,7 @@ details. */
|
||||
#include <wincon.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/cygwin.h>
|
||||
#include "cygheap.h"
|
||||
#include "cygerrno.h"
|
||||
#include "fhandler.h"
|
||||
#include "sync.h"
|
||||
@ -49,8 +50,6 @@ const char * get_nonascii_key (INPUT_RECORD&, char *);
|
||||
|
||||
static BOOL use_mouse = FALSE;
|
||||
|
||||
HANDLE console_shared_h;
|
||||
|
||||
static tty_min NO_COPY *shared_console_info = NULL;
|
||||
|
||||
/* Allocate and initialize the shared record for the current console.
|
||||
@ -61,10 +60,10 @@ get_tty_stuff (int force = 0)
|
||||
if (shared_console_info && !force)
|
||||
return shared_console_info;
|
||||
|
||||
shared_console_info = (tty_min *) open_shared (NULL, console_shared_h,
|
||||
shared_console_info = (tty_min *) open_shared (NULL, cygheap->console_h,
|
||||
sizeof (*shared_console_info),
|
||||
NULL);
|
||||
ProtectHandle (console_shared_h);
|
||||
ProtectHandle (cygheap->console_h);
|
||||
shared_console_info->setntty (TTY_CONSOLE);
|
||||
shared_console_info->setsid (myself->sid);
|
||||
return shared_console_info;
|
||||
|
@ -31,7 +31,7 @@ heap_init ()
|
||||
/* If we're the forkee, we must allocate the heap at exactly the same place
|
||||
as our parent. If not, we don't care where it ends up. */
|
||||
|
||||
page_const = getpagesize ();
|
||||
page_const = system_info.dwPageSize;
|
||||
if (brkbase)
|
||||
{
|
||||
DWORD chunk = brkchunk; /* allocation chunk */
|
||||
|
@ -140,14 +140,7 @@ read_etc_passwd ()
|
||||
else
|
||||
{
|
||||
debug_printf ("Emulating /etc/passwd");
|
||||
char user_name [ MAX_USER_NAME ];
|
||||
DWORD user_name_len = MAX_USER_NAME;
|
||||
if (! GetUserNameA (user_name, &user_name_len))
|
||||
{
|
||||
strncpy (user_name, "Administrator", MAX_USER_NAME);
|
||||
debug_printf ("Failed to get current user name. %E");
|
||||
}
|
||||
snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", user_name,
|
||||
snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", cygheap->user.name (),
|
||||
DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?: "/");
|
||||
add_pwd_line (linebuf);
|
||||
passwd_state = emulated;
|
||||
|
@ -102,12 +102,12 @@ cwdstuff cygcwd; /* The current working directory. */
|
||||
|
||||
/* Determine if path prefix matches current cygdrive */
|
||||
#define iscygdrive(path) \
|
||||
(path_prefix_p (cygwin_shared->mount.cygdrive, (path), cygwin_shared->mount.cygdrive_len))
|
||||
(path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len))
|
||||
|
||||
#define iscygdrive_device(path) \
|
||||
(iscygdrive(path) && isalpha(path[cygwin_shared->mount.cygdrive_len]) && \
|
||||
(isdirsep(path[cygwin_shared->mount.cygdrive_len + 1]) || \
|
||||
!path[cygwin_shared->mount.cygdrive_len + 1]))
|
||||
(iscygdrive(path) && isalpha(path[mount_table->cygdrive_len]) && \
|
||||
(isdirsep(path[mount_table->cygdrive_len + 1]) || \
|
||||
!path[mount_table->cygdrive_len + 1]))
|
||||
|
||||
#define ischrootpath(p) \
|
||||
(cygheap->root.length () && \
|
||||
@ -214,9 +214,8 @@ path_conv::check (const char *src, unsigned opt,
|
||||
(p[1] == '\0' || strcmp (p, "\\.") == 0))
|
||||
need_directory = 1;
|
||||
/* Must look up path in mount table, etc. */
|
||||
error = cygwin_shared->mount.conv_to_win32_path (src, rel_path,
|
||||
full_path,
|
||||
devn, unit, &path_flags);
|
||||
error = mount_table->conv_to_win32_path (src, rel_path, full_path, devn,
|
||||
unit, &path_flags);
|
||||
MALLOC_CHECK;
|
||||
if (error)
|
||||
return;
|
||||
@ -360,7 +359,7 @@ path_conv::check (const char *src, unsigned opt,
|
||||
p = sym.contents - headlen;
|
||||
memcpy (p, path_copy, headlen);
|
||||
MALLOC_CHECK;
|
||||
error = cygwin_shared->mount.conv_to_posix_path (p, tmp_buf, 1);
|
||||
error = mount_table->conv_to_posix_path (p, tmp_buf, 1);
|
||||
MALLOC_CHECK;
|
||||
if (error)
|
||||
return;
|
||||
@ -949,8 +948,6 @@ conv_path_list (const char *src, char *dst, int to_posix_p)
|
||||
while (s != NULL);
|
||||
}
|
||||
|
||||
/************************* mount_info class ****************************/
|
||||
|
||||
/* init: Initialize the mount table. */
|
||||
|
||||
void
|
||||
@ -1035,7 +1032,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
|
||||
{
|
||||
char posix_path[MAX_PATH + 1];
|
||||
|
||||
rc = cygwin_shared->mount.conv_to_posix_path (dst, posix_path, 0);
|
||||
rc = mount_table->conv_to_posix_path (dst, posix_path, 0);
|
||||
if (rc)
|
||||
{
|
||||
debug_printf ("conv_to_posix_path failed, rc %d", rc);
|
||||
@ -1397,7 +1394,7 @@ mount_info::read_mounts (reg_key& r)
|
||||
mount_flags = subkey.get_int ("flags", 0);
|
||||
|
||||
/* Add mount_item corresponding to registry mount point. */
|
||||
res = cygwin_shared->mount.add_item (native_path, posix_path, mount_flags, FALSE);
|
||||
res = mount_table->add_item (native_path, posix_path, mount_flags, FALSE);
|
||||
if (res && get_errno () == EMFILE)
|
||||
break; /* The number of entries exceeds MAX_MOUNTS */
|
||||
}
|
||||
@ -1625,11 +1622,11 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign
|
||||
1. setting user path prefix, or
|
||||
2. overwriting (a previous) system path prefix */
|
||||
if ((flags & MOUNT_SYSTEM) == 0 ||
|
||||
(cygwin_shared->mount.cygdrive_flags & MOUNT_SYSTEM) != 0)
|
||||
(mount_table->cygdrive_flags & MOUNT_SYSTEM) != 0)
|
||||
{
|
||||
slashify (cygdrive_prefix, cygwin_shared->mount.cygdrive, 1);
|
||||
cygwin_shared->mount.cygdrive_flags = flags;
|
||||
cygwin_shared->mount.cygdrive_len = strlen(cygwin_shared->mount.cygdrive);
|
||||
slashify (cygdrive_prefix, mount_table->cygdrive, 1);
|
||||
mount_table->cygdrive_flags = flags;
|
||||
mount_table->cygdrive_len = strlen(mount_table->cygdrive);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1962,7 +1959,7 @@ mount_info::read_v1_mounts (reg_key r, unsigned which)
|
||||
we're reading. */
|
||||
mountflags |= which;
|
||||
|
||||
int res = cygwin_shared->mount.add_item (win32path, unixpath, mountflags, TRUE);
|
||||
int res = mount_table->add_item (win32path, unixpath, mountflags, TRUE);
|
||||
if (res && get_errno () == EMFILE)
|
||||
break; /* The number of entries exceeds MAX_MOUNTS */
|
||||
}
|
||||
@ -2010,42 +2007,42 @@ mount_item::getmntent ()
|
||||
static NO_COPY struct mntent ret;
|
||||
#endif
|
||||
|
||||
/* Pass back pointers to mount_info strings reserved for use by
|
||||
/* Pass back pointers to mount_table strings reserved for use by
|
||||
getmntent rather than pointers to strings in the internal mount
|
||||
table because the mount table might change, causing weird effects
|
||||
from the getmntent user's point of view. */
|
||||
|
||||
strcpy (cygwin_shared->mount.mnt_fsname, native_path);
|
||||
ret.mnt_fsname = cygwin_shared->mount.mnt_fsname;
|
||||
strcpy (cygwin_shared->mount.mnt_dir, posix_path);
|
||||
ret.mnt_dir = cygwin_shared->mount.mnt_dir;
|
||||
strcpy (mount_table->mnt_fsname, native_path);
|
||||
ret.mnt_fsname = mount_table->mnt_fsname;
|
||||
strcpy (mount_table->mnt_dir, posix_path);
|
||||
ret.mnt_dir = mount_table->mnt_dir;
|
||||
|
||||
if (!(flags & MOUNT_SYSTEM)) /* user mount */
|
||||
strcpy (cygwin_shared->mount.mnt_type, (char *) "user");
|
||||
strcpy (mount_table->mnt_type, (char *) "user");
|
||||
else /* system mount */
|
||||
strcpy (cygwin_shared->mount.mnt_type, (char *) "system");
|
||||
strcpy (mount_table->mnt_type, (char *) "system");
|
||||
|
||||
if ((flags & MOUNT_AUTO)) /* cygdrive */
|
||||
strcat (cygwin_shared->mount.mnt_type, (char *) ",auto");
|
||||
strcat (mount_table->mnt_type, (char *) ",auto");
|
||||
|
||||
ret.mnt_type = cygwin_shared->mount.mnt_type;
|
||||
ret.mnt_type = mount_table->mnt_type;
|
||||
|
||||
/* mnt_opts is a string that details mount params such as
|
||||
binary or textmode, or exec. We don't print
|
||||
`silent' here; it's a magic internal thing. */
|
||||
|
||||
if (! (flags & MOUNT_BINARY))
|
||||
strcpy (cygwin_shared->mount.mnt_opts, (char *) "textmode");
|
||||
strcpy (mount_table->mnt_opts, (char *) "textmode");
|
||||
else
|
||||
strcpy (cygwin_shared->mount.mnt_opts, (char *) "binmode");
|
||||
strcpy (mount_table->mnt_opts, (char *) "binmode");
|
||||
|
||||
if (flags & MOUNT_CYGWIN_EXEC)
|
||||
strcat (cygwin_shared->mount.mnt_opts, (char *) ",cygexec");
|
||||
strcat (mount_table->mnt_opts, (char *) ",cygexec");
|
||||
else if (flags & MOUNT_EXEC)
|
||||
strcat (cygwin_shared->mount.mnt_opts, (char *) ",exec");
|
||||
strcat (mount_table->mnt_opts, (char *) ",exec");
|
||||
|
||||
|
||||
ret.mnt_opts = cygwin_shared->mount.mnt_opts;
|
||||
ret.mnt_opts = mount_table->mnt_opts;
|
||||
|
||||
ret.mnt_freq = 1;
|
||||
ret.mnt_passno = 1;
|
||||
@ -2086,11 +2083,11 @@ mount (const char *win32_path, const char *posix_path, unsigned flags)
|
||||
/* When flags include MOUNT_AUTO, take this to mean that
|
||||
we actually want to change the cygdrive prefix and flags
|
||||
without actually mounting anything. */
|
||||
res = cygwin_shared->mount.write_cygdrive_info_to_registry (posix_path, flags);
|
||||
res = mount_table->write_cygdrive_info_to_registry (posix_path, flags);
|
||||
win32_path = NULL;
|
||||
}
|
||||
else
|
||||
res = cygwin_shared->mount.add_item (win32_path, posix_path, flags, TRUE);
|
||||
res = mount_table->add_item (win32_path, posix_path, flags, TRUE);
|
||||
|
||||
syscall_printf ("%d = mount (%s, %s, %p)", res, win32_path, posix_path, flags);
|
||||
return res;
|
||||
@ -2123,11 +2120,11 @@ cygwin_umount (const char *path, unsigned flags)
|
||||
/* When flags include MOUNT_AUTO, take this to mean that we actually want
|
||||
to remove the cygdrive prefix and flags without actually unmounting
|
||||
anything. */
|
||||
res = cygwin_shared->mount.remove_cygdrive_info_from_registry (path, flags);
|
||||
res = mount_table->remove_cygdrive_info_from_registry (path, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = cygwin_shared->mount.del_item (path, flags, TRUE);
|
||||
res = mount_table->del_item (path, flags, TRUE);
|
||||
}
|
||||
|
||||
syscall_printf ("%d = cygwin_umount (%s, %d)", res, path, flags);
|
||||
@ -2152,7 +2149,7 @@ extern "C"
|
||||
struct mntent *
|
||||
getmntent (FILE *)
|
||||
{
|
||||
return cygwin_shared->mount.getmntent (iteration++);
|
||||
return mount_table->getmntent (iteration++);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@ -2643,7 +2640,7 @@ cygwin_conv_to_posix_path (const char *path, char *posix_path)
|
||||
{
|
||||
if (check_null_empty_path_errno (path))
|
||||
return -1;
|
||||
cygwin_shared->mount.conv_to_posix_path (path, posix_path, 1);
|
||||
mount_table->conv_to_posix_path (path, posix_path, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2653,7 +2650,7 @@ cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
|
||||
{
|
||||
if (check_null_empty_path_errno (path))
|
||||
return -1;
|
||||
cygwin_shared->mount.conv_to_posix_path (path, posix_path, 0);
|
||||
mount_table->conv_to_posix_path (path, posix_path, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2671,7 +2668,7 @@ realpath (const char *path, char *resolved)
|
||||
err = real_path.error;
|
||||
else
|
||||
{
|
||||
err = cygwin_shared->mount.conv_to_posix_path (real_path.get_win32 (), resolved, 0);
|
||||
err = mount_table->conv_to_posix_path (real_path.get_win32 (), resolved, 0);
|
||||
if (err == 0)
|
||||
return resolved;
|
||||
}
|
||||
@ -2728,11 +2725,11 @@ conv_path_list_buf_size (const char *path_list, int to_posix_p)
|
||||
++p;
|
||||
|
||||
/* 7: strlen ("//c") + slop, a conservative initial value */
|
||||
for (max_mount_path_len = 7, i = 0; i < cygwin_shared->mount.nmounts; ++i)
|
||||
for (max_mount_path_len = 7, i = 0; i < mount_table->nmounts; ++i)
|
||||
{
|
||||
int mount_len = (to_posix_p
|
||||
? cygwin_shared->mount.mount[i].posix_pathlen
|
||||
: cygwin_shared->mount.mount[i].native_pathlen);
|
||||
? mount_table->mount[i].posix_pathlen
|
||||
: mount_table->mount[i].native_pathlen);
|
||||
if (max_mount_path_len < mount_len)
|
||||
max_mount_path_len = mount_len;
|
||||
}
|
||||
@ -2944,7 +2941,7 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd)
|
||||
}
|
||||
|
||||
if (!posix_cwd)
|
||||
cygwin_shared->mount.conv_to_posix_path (win32, pathbuf, 0);
|
||||
mount_table->conv_to_posix_path (win32, pathbuf, 0);
|
||||
else
|
||||
(void) normalize_posix_path (posix_cwd, pathbuf);
|
||||
|
||||
|
@ -86,7 +86,7 @@ reg_key::build_reg (HKEY top, REGSAM access, va_list av)
|
||||
be created and set had_to_create appropriately. */
|
||||
if (strcmp (name, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME) == 0)
|
||||
if (disp == REG_CREATED_NEW_KEY)
|
||||
cygwin_shared->mount.had_to_create_mount_areas++;
|
||||
mount_table->had_to_create_mount_areas++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,8 @@ details. */
|
||||
cygwin_version.api_minor)
|
||||
|
||||
shared_info NO_COPY *cygwin_shared = NULL;
|
||||
|
||||
/* The handle of the shared data area. */
|
||||
HANDLE cygwin_shared_h = NULL;
|
||||
mount_info NO_COPY *mount_table = NULL;
|
||||
HANDLE cygwin_mount_h = NULL;
|
||||
|
||||
/* General purpose security attribute objects for global use. */
|
||||
SECURITY_ATTRIBUTES NO_COPY sec_none;
|
||||
@ -49,15 +48,24 @@ shared_name (const char *str, int num)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Open the shared memory map. */
|
||||
static void __stdcall
|
||||
open_shared_file_map ()
|
||||
static void
|
||||
mount_table_init ()
|
||||
{
|
||||
cygwin_shared = (shared_info *) open_shared ("shared",
|
||||
cygwin_shared_h,
|
||||
sizeof (*cygwin_shared),
|
||||
(void *)0xa000000);
|
||||
ProtectHandle (cygwin_shared);
|
||||
void *addr = mount_table_address;
|
||||
debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (),
|
||||
mount_table_address);
|
||||
mount_table = (mount_info *) open_shared (cygheap->user.name (),
|
||||
cygwin_mount_h, sizeof (mount_info),
|
||||
addr);
|
||||
ProtectHandle (cygwin_mount_h);
|
||||
|
||||
debug_printf ("mount table version %x at %p", mount_table->version, mount_table);
|
||||
if (!mount_table->version)
|
||||
{
|
||||
mount_table->version = MOUNT_VERSION;
|
||||
debug_printf ("initializing mount table");
|
||||
mount_table->init (); /* Initialize the mount table. */
|
||||
}
|
||||
}
|
||||
|
||||
void * __stdcall
|
||||
@ -99,9 +107,9 @@ open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr)
|
||||
}
|
||||
|
||||
if (!shared)
|
||||
api_fatal ("MapViewOfFileEx, %E. Terminating.");
|
||||
api_fatal ("MapViewOfFileEx '%s'(%p), %E. Terminating.", name, shared_h);
|
||||
|
||||
debug_printf ("name %s, shared %p, h %p", name, shared, shared_h);
|
||||
debug_printf ("name %s, shared %p (wanted %p), h %p", name, shared, addr, shared_h);
|
||||
|
||||
/* FIXME: I couldn't find anywhere in the documentation a note about
|
||||
whether the memory is initialized to zero. The code assumes it does
|
||||
@ -124,9 +132,6 @@ shared_info::initialize ()
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the mount table. */
|
||||
mount.init ();
|
||||
|
||||
/* Initialize the queue of deleted files. */
|
||||
delqueue.init ();
|
||||
|
||||
@ -155,16 +160,28 @@ shared_info::initialize ()
|
||||
void __stdcall
|
||||
shared_init ()
|
||||
{
|
||||
open_shared_file_map ();
|
||||
HANDLE shared_h = cygheap ? cygheap->shared_h : NULL;
|
||||
cygwin_shared = (shared_info *) open_shared ("shared",
|
||||
shared_h,
|
||||
sizeof (*cygwin_shared),
|
||||
cygwin_shared_address);
|
||||
if (!cygheap)
|
||||
cygheap_init ();
|
||||
|
||||
mount_table_init ();
|
||||
|
||||
cygheap->shared_h = shared_h;
|
||||
ProtectHandle (cygheap->shared_h);
|
||||
cygwin_shared->initialize ();
|
||||
}
|
||||
|
||||
void __stdcall
|
||||
shared_terminate ()
|
||||
{
|
||||
if (cygwin_shared_h)
|
||||
ForceCloseHandle (cygwin_shared_h);
|
||||
if (cygheap->shared_h)
|
||||
ForceCloseHandle (cygheap->shared_h);
|
||||
if (cygwin_mount_h)
|
||||
ForceCloseHandle (cygwin_mount_h);
|
||||
}
|
||||
|
||||
unsigned
|
||||
@ -292,4 +309,3 @@ sec_user_nih (PVOID sa_buf, PSID sid2)
|
||||
{
|
||||
return sec_user (sa_buf, sid2, FALSE);
|
||||
}
|
||||
|
||||
|
@ -40,12 +40,13 @@ public:
|
||||
scheme should be satisfactory for a long while yet. */
|
||||
#define MAX_MOUNTS 30
|
||||
|
||||
#define MOUNT_VERSION 0x01010102
|
||||
|
||||
class reg_key;
|
||||
class mount_info
|
||||
{
|
||||
int posix_sorted[MAX_MOUNTS];
|
||||
int native_sorted[MAX_MOUNTS];
|
||||
public:
|
||||
DWORD version;
|
||||
int nmounts;
|
||||
mount_item mount[MAX_MOUNTS];
|
||||
|
||||
@ -61,7 +62,11 @@ public:
|
||||
char cygdrive[MAX_PATH];
|
||||
size_t cygdrive_len;
|
||||
unsigned cygdrive_flags;
|
||||
private:
|
||||
int posix_sorted[MAX_MOUNTS];
|
||||
int native_sorted[MAX_MOUNTS];
|
||||
|
||||
public:
|
||||
/* Increment when setting up a reg_key if mounts area had to be
|
||||
created so we know when we need to import old mount tables. */
|
||||
int had_to_create_mount_areas;
|
||||
@ -135,9 +140,6 @@ class shared_info
|
||||
DWORD inited;
|
||||
|
||||
public:
|
||||
/* FIXME: Doesn't work if more than one user on system. */
|
||||
mount_info mount;
|
||||
|
||||
int heap_chunk_in_mb;
|
||||
unsigned heap_chunk_size (void);
|
||||
|
||||
@ -147,11 +149,20 @@ public:
|
||||
};
|
||||
|
||||
extern shared_info *cygwin_shared;
|
||||
extern HANDLE cygwin_shared_h;
|
||||
extern HANDLE console_shared_h;
|
||||
extern mount_info *mount_table;
|
||||
extern HANDLE cygwin_mount_h;
|
||||
|
||||
void __stdcall shared_init (void);
|
||||
void __stdcall shared_terminate (void);
|
||||
|
||||
#define shared_align_past(p) \
|
||||
((char *) (system_info.dwAllocationGranularity * \
|
||||
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
|
||||
system_info.dwAllocationGranularity)))
|
||||
|
||||
#define cygwin_shared_address ((void *) 0xa000000)
|
||||
#define mount_table_address shared_align_past (cygwin_shared)
|
||||
#define cygheap_address shared_align_past ((mount_info *) shared_align_past (cygwin_shared))
|
||||
|
||||
char *__stdcall shared_name (const char *, int);
|
||||
void *__stdcall open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr);
|
||||
|
@ -821,8 +821,6 @@ init_child_info (DWORD chtype, child_info *ch, pid_t pid, HANDLE subproc_ready)
|
||||
ch->cb = sizeof *ch;
|
||||
ch->type = chtype;
|
||||
ch->cygpid = pid;
|
||||
ch->shared_h = cygwin_shared_h;
|
||||
ch->console_h = console_shared_h;
|
||||
ch->subproc_ready = subproc_ready;
|
||||
ch->pppid_handle = myself->ppid_handle;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ details. */
|
||||
#include "sigproc.h"
|
||||
#include "cygheap.h"
|
||||
#include "child_info.h"
|
||||
#include "shared_info.h"
|
||||
#include "pinfo.h"
|
||||
#define NEED_VFORK
|
||||
#include "perthread.h"
|
||||
@ -592,6 +593,9 @@ skip_arg_parsing:
|
||||
if (!hToken)
|
||||
{
|
||||
ciresrv.moreinfo->uid = getuid ();
|
||||
/* FIXME: This leaks a handle in the CreateProcessAsUser case since the
|
||||
child process doesn't know about cygwin_mount_h. */
|
||||
ciresrv.mount_h = cygwin_mount_h;
|
||||
rc = CreateProcess (runpath, /* image name - with full path */
|
||||
one_line.buf, /* what was passed to exec */
|
||||
/* process security attrs */
|
||||
|
@ -38,6 +38,8 @@ details. */
|
||||
#include "security.h"
|
||||
#include "cygheap.h"
|
||||
|
||||
SYSTEM_INFO system_info;
|
||||
|
||||
/* Close all files and process any queued deletions.
|
||||
Lots of unix style applications will open a tmp file, unlink it,
|
||||
but never call close. This function is called by _exit to
|
||||
@ -1360,15 +1362,9 @@ getdtablesize ()
|
||||
extern "C" size_t
|
||||
getpagesize ()
|
||||
{
|
||||
static DWORD sys_page_size = 0;
|
||||
|
||||
if (!sys_page_size)
|
||||
{
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
sys_page_size = si.dwPageSize;
|
||||
}
|
||||
return (int)sys_page_size;
|
||||
if (!system_info.dwPageSize)
|
||||
GetSystemInfo(&system_info);
|
||||
return (int) system_info.dwPageSize;
|
||||
}
|
||||
|
||||
/* FIXME: not all values are correct... */
|
||||
@ -1952,8 +1948,7 @@ chroot (const char *newroot)
|
||||
goto done;
|
||||
}
|
||||
char buf[MAX_PATH + 1];
|
||||
ret = cygwin_shared->mount.conv_to_posix_path (path.get_win32 (),
|
||||
buf, 0);
|
||||
ret = mount_table->conv_to_posix_path (path.get_win32 (), buf, 0);
|
||||
if (ret)
|
||||
{
|
||||
set_errno (ret);
|
||||
|
@ -31,10 +31,12 @@ internal_getlogin (cygheap_user &user)
|
||||
char username[MAX_USER_NAME];
|
||||
DWORD username_len = MAX_USER_NAME;
|
||||
|
||||
if (!user.name ())
|
||||
if (!GetUserName (username, &username_len))
|
||||
user.set_name ("unknown");
|
||||
else
|
||||
user.set_name (username);
|
||||
|
||||
if (os_being_run == winNT)
|
||||
{
|
||||
LPWKSTA_USER_INFO_1 wui;
|
||||
|
@ -234,6 +234,7 @@ extern DWORD binmode;
|
||||
extern char _data_start__, _data_end__, _bss_start__, _bss_end__;
|
||||
extern void (*__CTOR_LIST__) (void);
|
||||
extern void (*__DTOR_LIST__) (void);
|
||||
extern SYSTEM_INFO system_info;
|
||||
};
|
||||
|
||||
/*************************** Unsorted ******************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user