From 6a4878cf1617f051e4706ce30f7c8607ebf2e85d Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 29 Jan 2001 00:46:25 +0000 Subject: * syscalls.cc (_link): Make sure that newpath does not exist. Set errno if it does. * cygheap.cc (init_cheap): Don't specify a load address for the heap. It doesn't work on #!*& Windows 9x. (cygheap_init): Move GetUserName to memory_init. * dcrt0.cc (dll_crt0_1): Call new memory_init functin, eliminate call to heap_init. * heap.cc (heap_init): Improve error output. * heap.h: Correct some declarations. * shared.cc (mount_table_init): Remove. (memory_init): Renamed from shared_init. Reorganize to accomodate strange Windows 9x problems with cygheap/heap interaction. * shared_info.h: Rename shared_init to memory_init. --- winsup/cygwin/ChangeLog | 49 +++++++++++++++++++++++++++-------- winsup/cygwin/cygheap.cc | 11 +------- winsup/cygwin/dcrt0.cc | 7 ++--- winsup/cygwin/heap.cc | 4 +-- winsup/cygwin/heap.h | 4 +-- winsup/cygwin/shared.cc | 63 +++++++++++++++++++++++++-------------------- winsup/cygwin/shared_info.h | 2 +- winsup/cygwin/syscalls.cc | 7 +++++ 8 files changed, 88 insertions(+), 59 deletions(-) (limited to 'winsup/cygwin') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index da1a33ce0..63f4c560b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,22 @@ +Sun Jan 28 19:40:40 2001 Christopher Faylor + + * syscalls.cc (_link): Make sure that newpath does not exist. Set + errno if it does. + +Sun Jan 28 19:29:08 2001 Christopher Faylor + + * cygheap.cc (init_cheap): Don't specify a load address for the heap. + It doesn't work on #!*& Windows 9x. + (cygheap_init): Move GetUserName to memory_init. + * dcrt0.cc (dll_crt0_1): Call new memory_init functin, eliminate call + to heap_init. + * heap.cc (heap_init): Improve error output. + * heap.h: Correct some declarations. + * shared.cc (mount_table_init): Remove. + (memory_init): Renamed from shared_init. Reorganize to accomodate + strange Windows 9x problems with cygheap/heap interaction. + * shared_info.h: Rename shared_init to memory_init. + Sun Jan 28 01:25:33 2001 Christopher Faylor * include/cygwin/version.h: Bump API version. @@ -30,24 +49,29 @@ Sun Jan 28 00:28:30 2001 Christopher Faylor 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. + * 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_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. + (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. + * 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. + * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than + retrieving the name again. Sat Jan 27 10:18:02 2001 Christopher Faylor @@ -176,11 +200,13 @@ Fri Jan 12 00:35:15 2001 Christopher Faylor * signal.cc (sigaction): Don't treat SIGCONT specially. - * exceptions.cc (interrupt_setup): Save sa_flags of interrupted signal for later use. + * exceptions.cc (interrupt_setup): Save sa_flags of interrupted signal + for later use. (sig_handler): Default any stopping signal to SIGSTOP. (call_signal_handler): New function. (sigdelayed0): New function. - * sigproc.cc (sigproc_init): Initialize SIGSTOP sigaction for special behavior. + * sigproc.cc (sigproc_init): Initialize SIGSTOP sigaction for special + behavior. * sigproc.h: Define call_signal_handler. * syscalls.cc (_read): Allow restartable signal behavior. @@ -192,14 +218,15 @@ Thu Jan 11 13:17:00 2001 Corinna Vinschen * fhandler_mem.cc (fhandler_dev_mem::open): Set OBJ_INHERIT attribute for device\physicalmemory handle. (fhandler_dev_mem::mmap): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): New method. - * mmap.cc (mmap_record): Add private `fdesc_' member. Change constructor - accordingly. + * fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): New + method. + * mmap.cc (mmap_record): Add private `fdesc_' member. Change + constructor accordingly. (get_fd): New method. (mmap): Use new mmap_record constructor. (fhandler_base::fixup_mmap_after_fork): New method. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. - (fixup_mmaps_after_fork): Call `fixup_mmap_after_fork' of appropriate + (fixup_mmaps_after_fork): Call `fixup_mmap_after_fork' of appropriate fhandler class. Wed Jan 10 22:08:30 2001 Kazuhiro Fujieda diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 10c16d1a2..49a819a65 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -27,8 +27,7 @@ static NO_COPY muto *cygheap_protect = NULL; inline static void init_cheap () { - void *addr = cygheap_address; - cygheap = (init_cygheap *) VirtualAlloc (addr, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS); + cygheap = (init_cygheap *) VirtualAlloc (NULL, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS); if (!cygheap) api_fatal ("Couldn't reserve space for cygwin's heap, %E"); cygheap_max = cygheap + 1; @@ -67,14 +66,6 @@ cygheap_init () { cygheap_protect = new_muto (FALSE, "cygheap_protect"); _csbrk (0); - - 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); } /* Copyright (C) 1997, 2000 DJ Delorie */ diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 52605f0b7..1e1aeaf62 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -723,14 +723,11 @@ dll_crt0_1 () host_dependent.init (); /* Initialize the cygwin subsystem if this is the first process, - or attach to the shared data structure if it's already running. */ - shared_init (); + or attach to shared data structures if it's already running. */ + memory_init (); (void) SetErrorMode (SEM_FAILCRITICALERRORS); - /* Initialize the heap. */ - heap_init (); - /* Initialize events. */ events_init (); diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index 6a35b9c8f..43ece46b6 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -52,8 +52,8 @@ heap_init () break; } if (p == NULL) - api_fatal ("1. unable to allocate heap, heap_chunk_size %d, pid %d, %E", - brkchunk, myself->pid); + api_fatal ("1. unable to allocate heap %p, heap_chunk_size %d, pid %d, %E", + brkbase, brkchunk, myself->pid); if (p != brkbase) api_fatal ("heap allocated but not at %p", brkbase); if (! VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE)) diff --git a/winsup/cygwin/heap.h b/winsup/cygwin/heap.h index 110e03763..848be5735 100644 --- a/winsup/cygwin/heap.h +++ b/winsup/cygwin/heap.h @@ -11,8 +11,8 @@ details. */ #include "perprocess.h" /* Heap management. */ -void heap_init (void); -void malloc_init (void); +void heap_init (); +void malloc_init (); #define inheap(s) (brk && ((char *) (s) >= (char *) brkbase) && ((char *) (s) <= (char *) brktop)) diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 71255da8c..43c4893ef 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -18,6 +18,7 @@ details. */ #include "sigproc.h" #include "pinfo.h" #include "cygheap.h" +#include "heap.h" #include "shared_info.h" #include "registry.h" #include "cygwin_version.h" @@ -48,26 +49,6 @@ shared_name (const char *str, int num) return buf; } -static void -mount_table_init () -{ - 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 open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr) { @@ -143,11 +124,11 @@ shared_info::initialize () reg_key reg (KEY_READ, NULL); /* Note that reserving a huge amount of heap space does not result in - swapping since we are not committing it. */ + the use of swap since we are not committing it. */ /* FIXME: We should not be restricted to a fixed size heap no matter what the fixed size is. */ - heap_chunk_in_mb = reg.get_int ("heap_chunk_in_mb", 128); + heap_chunk_in_mb = reg.get_int ("heap_chunk_in_mb", 1024); if (heap_chunk_in_mb < 4) { heap_chunk_in_mb = 4; @@ -158,21 +139,47 @@ shared_info::initialize () } void __stdcall -shared_init () +memory_init () { + /* Initialize general shared memory */ 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 (); + cygwin_shared->initialize (); + heap_init (); + + /* Allocate memory for the per-user mount table */ + char user_name[MAX_USER_NAME]; + DWORD user_name_len = MAX_USER_NAME; + + if (!GetUserName (user_name, &user_name_len)) + strcpy (user_name, "unknown"); + mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h, + sizeof (mount_info), 0); + debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (), + mount_table_address); + ProtectHandle (cygwin_mount_h); + debug_printf ("mount table version %x at %p", mount_table->version, mount_table); + + /* Initialize the Cygwin heap, if necessary */ + if (!cygheap) + { + cygheap_init (); + cygheap->user.set_name (user_name); + } cygheap->shared_h = shared_h; ProtectHandle (cygheap->shared_h); - cygwin_shared->initialize (); + + /* Initialize the Cygwin per-user mount table, if necessary */ + if (!mount_table->version) + { + mount_table->version = MOUNT_VERSION; + debug_printf ("initializing mount table"); + mount_table->init (); /* Initialize the mount table. */ + } } void __stdcall diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index 13388a4d1..cdaacebda 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -153,7 +153,7 @@ extern shared_info *cygwin_shared; extern mount_info *mount_table; extern HANDLE cygwin_mount_h; -void __stdcall shared_init (void); +void __stdcall memory_init (void); void __stdcall shared_terminate (void); #define shared_align_past(p) \ diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 3945912f3..c7d70fdbc 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -531,6 +531,13 @@ _link (const char *a, const char *b) set_errno (real_b.error); goto done; } + + if (real_b.file_attributes () != (DWORD)-1) + { + syscall_printf ("file '%s' exists?", (char *)real_b); + set_errno (EEXIST); + goto done; + } if (real_b.get_win32 ()[strlen (real_b.get_win32 ()) - 1] == '.') { syscall_printf ("trailing dot, bailing out"); -- cgit v1.2.3