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
AgeCommit message (Collapse)Author
2023-09-08Cygwin: unlink_nt: declare in winsup.hCorinna Vinschen
unlink_nt is used more than once so declare it in a header. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20Cygwin: unlink: drop unlink_nt/unlink_nt_shareable wrappersCorinna Vinschen
Useless indirection. Rename _unlink_nt back to unlink_nt and call the function directly with `sharable' flag as needed. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-12Cygwin: wincap.h: clarify NO_COPY_RO usageCorinna Vinschen
...and drop one unnecessary usage of NO_COPY_RO. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-06-03Cygwin: dll_list: no recursive use of nt_max_path_bufMichael Haubenwallner
Querying the ntlength and existence of the /var/run/cygfork directory in the very first Cygwin process should not use nt_max_path_buf, as that one is used by dll_list::alloc already.
2019-06-03Cygwin: dll_list: stat_real_file_once with ntnameMichael Haubenwallner
NtQueryVirtualMemory for MemorySectionName may return some old path even if the process was just started, for when some directory in between was renamed - maybe because the NT file cache is hot for the old path still. This was seen during gcc bootstrap, returning a MemorySectionName of ".../gcc/xgcc.exe" even if started as ".../prev-gcc/xgcc.exe", where the directory rename from "gcc" to "prev-gcc" was done the moment before. As we stat the module's real file right after loading now, there is no point in using NtQueryVirtualMemory with MemorySectionName any more, and we can use what GetModuleFileName returned instead.
2019-05-05Cygwin: dll_list: drop unused read_fbi methodMichael Haubenwallner
2019-04-30Cygwin: dll_list: query dll file id at load timeMichael Haubenwallner
NtQueryVirtualMemory for MemorySectionName does not reliable return the changed dll file name when another process does move the file around, and we may end up creating forkable hardlinks to wrong dll files. So query the file id when loading the dll rather than before fork.
2019-04-30Cygwin: dll_list: stat_real_file_once as dll methodMichael Haubenwallner
Make stat_real_file_once a method of struct dll, to be more flexible on where to use. Also, debug print memory section name queried for a dll. This is a preparation to query the file id when loading the dll.
2019-04-30Cygwin: dll_list: drop FILE_BASIC_INFORMATIONMichael Haubenwallner
Querying FILE_BASIC_INFORMATION is needless since using win pid+threadid for forkables dirname rather than newest last write time.
2019-04-12Cygwin: use win pid+threadid for forkables dirnameMichael Haubenwallner
Rather than newest last write time of all dlls loaded, use the forking process' windows pid and windows thread id as directory name to create the forkable hardlinks into. While this may create hardlinks more often, it does avoid conflicts between dlls not having the newest last write time.
2019-02-25Cygwin: use NULL security descriptor in InitializeObjectAttributesCorinna Vinschen
Using sec_none{_nih} is just a roundabout way to specify a NULL SD. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-07forkables: hardlink without WRITE_ATTRIBUTES firstMichael Haubenwallner
When the current process has renamed (to bin) a readonly dll, we get STATUS_TRANSACTION_NOT_ACTIVE for unknown reason when subsequently creating the forkable hardlink. A workaround is to open the original file with FILE_WRITE_ATTRIBUTES access, but that fails with permission denied for users not owning the original file. * forkable.cc (dll::create_forkable): Retry hardlink creation using the original file's handle opened with FILE_WRITE_ATTRIBUTES access when the first attempt fails with STATUS_TRANSACTION_NOT_ACTIVE.
2019-02-07forkables: inline dll_list::forkables_supportedMichael Haubenwallner
And LONG fits better for shared_info member forkable_hardlink_support.
2019-02-07forkables: simplify disabling via shmMichael Haubenwallner
* Rename cygwin_shared->prefer_forkable_hardlinks to forkable_hardlink_support, with values 0 for Unknown, 1 for Supported, -1 for Unsupported. Upon first dll loaded ever, dll_list::forkable_ntnamesize checks the /var/run/cygfork directory to both exist and reside on NTFS, setting cygwin_shared->forkable_hardlink_support accordingly. * Replace enum forkables_needs by bool forkables_created: Set to True by request_forkables after creating forkable hardlinks.
2019-02-07forkables: use dynloaded dll's IndexNumber as dirnameMichael Haubenwallner
2019-02-07forkables: Keep hardlinks disabled via shared mem.Michael Haubenwallner
To avoid the need for each process to check the filesystem to detect that hardlink creation is impossible or disabled, cache this fact in shared memory. Removing cygfork directory while in use does disable hardlinks creation. To (re-)enable hardlinks creation, the cygfork directory has to exist before the first cygwin process does fork. * forkable.cc (dll_list::forkable_ntnamesize): Short cut forkables needs to impossible when disabled via shared memory. (dll_list::update_forkables_needs): When detecting hardlink creation as impossible (not on NTFS) while still (we are the first one checking) enabled via shared memory, disable the shared memory value. (dll_list::request_forkables): Disable the shared memory value when hardlinks creation became disabled, that is when the cygfork directory was removed. * include/cygwin/version.h: Bump CYGWIN_VERSION_SHARED_DATA 6. * shared_info.h (struct shared_info): Add member prefer_forkable_hardlinks. Update CURR_SHARED_MAGIC. * shared.cc (shared_info::initialize): Initialize prefer_forkable_hardlinks to 1 (Yes).
2019-02-07forkables: Create forkable hardlinks, yet unused.Michael Haubenwallner
In preparation to protect fork() against dll- and exe-updates, create hardlinks to the main executable and each loaded dll in subdirectories of /var/run/cygfork/, if that one exists on the NTFS file system. The directory names consist of the user sid, the main executable's NTFS IndexNumber, and the most recent LastWriteTime of all involved binaries (dlls and main executable). Next to the main.exe hardlink we create the empty file main.exe.local to enable dll redirection. The name of the mutex to synchronize hardlink creation/cleanup also is assembled from these directory names, to allow for synchronized cleanup of even orphaned hardlink directories. The hardlink to each dynamically loaded dll goes into another directory, named using the NTFS IndexNumber of the dll's original directory. * Makefile.in (DLL_OFILES): Add forkable.o. * dll_init.h (struct dll): Declare member variables fbi, fii, forkable_ntname. Declare methods nominate_forkable, create_forkable. (struct dll_list): Declare enum forkables_needs. Declare member variables forkables_dirx_size, forkables_dirx_ntname, forkables_mutex_name, forkables_mutex. Declare private methods forkable_ntnamesize, prepare_forkables_nomination, update_forkables_needs, update_forkables, create_forkables, denominate_forkables, close_mutex, try_remove_forkables, set_forkables_inheritance, request_forkables. Declare public static methods ntopenfile, read_fii, read_fbi. Declare public methods release_forkables, cleanup_forkables. Define public inline method setup_forkables. * dll_init.cc (dll_list::alloc): Allocate memory to hold the name of the hardlink in struct dll member forkable_ntname. Initialize struct dll members fbi, fii. (dll_list::load_after_fork): Call release_forkables method. * fork.cc: Rename public fork function to static dofork, add with_forkables as bool pointer parameter. Add new fork function calling dofork. (struct frok): Add bool pointer member with_forkables, add as constructor parameter. (frok::parent): Call dlls.setup_forkables before CreateProcessW, dlls.release_forkables afterwards. * pinfo.cc (pinfo::exit): Call dlls.cleanup_forkables. * syscalls.cc (_unlink_nt): Rename public unlink_nt function to static _unlink_nt, with 'shareable' as additional argument. (unlink_nt): New, wrap _unlink_nt for original behaviour. (unlink_nt_shareable): New, wrap _unlink_nt to keep a binary file still loadable while removing one of its hardlinks. * forkable.cc: New file. Implement static functions mkdirs, rmdirs, rmdirs_synchronized, stat_real_file_once, format_IndexNumber, rootname, sidname, exename, lwtimename. Define static array forkable_nameparts. (struct dll): Implement nominate_forkable, create_forkable. (struct dll_list): Implement static methods ntopenfile, read_fii, read_fbi. Implement forkable_ntnamesize,