summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* isdrive: fix misuse of isalpha.cygnal-release-3.2.0cygnal-3-1-98-branchKaz Kylheku2024-01-021-1/+1
| | | | | | * winsup/cygwin/path.h (isdrive): This macro is called with a char argument, which it passes to isalpha. It needs to be cast to unsigned char.
* Fix broken handling of drive relative paths.Kaz Kylheku2024-01-021-7/+11
| | | | | | * winsup/cygwin/path.cc (normalize_win32_path): Fix bungled logic for replacing a relative drive reference with the working directory from that drive. We were wrongly copying an extra drive letter character.
* Replace bogus resize-window-to-clear-screen logic.Kaz Kylheku2021-07-262-56/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes (ab)uses of SetConsoleScreenBufferSize which sometimes cause cmd.exe to badly misbehave. It probably doesn't like the closely spaced timing of shrinking the window down to one line followed by a restore of the size. Instead we just output newlines to clear the window. * winsup/cygwin/fhandler.h (dev_console::scroll_window): Member function declaration removed. (dev_console::clear_should_scroll): New member function declared. * winsup/cygwin/fhandler_console.cc (dev_console::scroll_window): Member function removed. (dev_console::clear_should_scroll): New member function. Performs only the test that was performed by scroll_window, not the actual scrolling. The scrolling is now done in the caller in the fhandler_console class. (fhandler_console::clear_screen): Call con.clear_should_scroll instead of con.scroll_window. If this returns false, act as before. Otherwise, clear the screen by scrolling the window. This is done not by making SetConsoleScreenBufferSize calls to shrink and restore the window, but by earnestly emitting a number of carriage returns equal to the vertical screen size and then restoring the cursor position.
* Revert "Fix console clear screen if buffer is full"Kaz Kylheku2021-07-261-23/+14
| | | | | | | | | | | | | | | This reverts commit 99a3f266c15af5bbb9a8cacda63ce11b094c10d1. Unfortunately Corinna's August 3, 2016 is unsatisfactory, and interferes with our patch for the issue cherry picked from cygnal-2.5.2 into cygnal-2.9.0-branch. When the screen-clearing escape sequence ESC[2J is issued material below the cursor is not cleared properly. For instance, in the TXR Lisp listener, the Ctrl-L command fails to clear the screen at all, because it first homes the cursor to the top line of the screen and then issues the clear screen.
* Use Windows values in passwd and HOME env var.Kaz Kylheku2021-07-264-18/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this patch, the path to the Windows command interpreter is reported in the shell field of struct passwd by getpwent by default rather than "/bin/bash". The value of USERPROFILE is used for the home field rather than "/home/<user>". Also, the HOME environment variable is stuffed with a copy of USERPROFILE. The HOME issue solves the following problem: some OSS programs on Windows, such as Vim, respond to a HOME variable. If it has garbage contents that make no sense like "/home/bob", they don't behave well. * winsup/cygwin/grp.cc (pwdgrp::init_grp): Initialize new pwd_sep member. * winsup/cygwin/passwd.cc (pwdgrp::parse_passwd): Use pwd_sep rather than hard-coded colon. (pwdgrp::init_pwd): Initialize pwd_sep. * winsup/cygwin/pwdgrp.h (class pwdgrp): New member, pwd_sep. * winsup/cygwin/uinfo.cc (cygheap_user::ontherange): Copy value of USERPROFILE into HOME. (pwdgrp::next_num, pwdgrp::fetch_account_from_line): Use pwd_sep rather than ':'. (pwdgrp::next_num, pwdgrp::fetch_account_from_windows): Get real Windows shell as default shell field. Get USERPROFILE as home directory. Use '|' as the field separator because these fields contain colons. Set pwd_sep to '|'.
* Remove env var translation; PATH semicolon separated.Kaz Kylheku2021-07-262-99/+9
| | | | | | | | | | | | | | | * winsup/cygwin/environ.cc (conv_envvars): Static array removed. (conv_start_chars): Likewise. (getwinenv): Function gutted to just return NULL. No environment vars require conversion. (match_first_char): Static function removed. (build_env): Removed logic for eliminating those variables that require donversion, since there are no such variables and the needed functions and arrays are gone. * winsup/cygwin/environ.cc (find_exec): Recognize semicolon as PATH separator.
* Arrange for text mode on stdin, stdout and stderr.Kaz Kylheku2021-07-261-0/+20
| | | | | | * newlib/libc/stdio/findfp.c (__sinit): Add the Cygwin-specific __SCLE (stream convert line endings) flag when calling the std function to initializing the reent structure's _stdin, _stdout and _stderr members.
* Console: integrate end-of-line hack with cursor positioning.Kaz Kylheku2021-07-261-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous work for simulating the beyond-right-edge of screen cursor position is incomplete without integrating this into the cursor positioning routines. By making the cursor routines aware of the eat_newline flag, we allow cursor movements to work correctly with regard to this simulated position. * winsup/cygwin/fhandler_console.cc (fhandler_console::cursor_set): If the X position is beyond the right edge of the screen, then set the cursor to the start of the following line, rather than clipping to the right edge, set the eat_newline flag, indicating that the the true position is actually one character beyond the previous line. In all other cases, clear the eat_newline flag. (fhandler_console::cursor_rel): Do not apply the delta vector to the raw Win32 cursor position; call cursor_get and apply it to the virtual cursor position which takes into account the eat_newline flag. (fhandler_console::cursor_get): Take into account the eat_newline flag. If it is set, then report an adjusted position that is one column beyond the end of the previous line.
* Symlink creation defaults to Windows shortcuts.Kaz Kylheku2021-07-261-1/+1
| | | | | * winsup/cygwin/globals.cc (allow_winsymlinks): Change initial value from WSYM_sysfile to WSYM_lnk.
* Respond to CYGNAL environment variable, not CYGWIN.Kaz Kylheku2021-07-261-8/+8
| | | | | | | | | * winsup/cygwin/environ.cc (set_winsymlinks): Refer to CYGNAL variable in diagnostic message. (parse_options): Pass "CYGNAL" to setenv. (_addenv, environ_init): Call parse_options if variable name is "CYGNAL" rather than "CYGWIN". Comments updated. (spenvs): Change CYGWIN_DEBUG to CYGNAL_DEBUG.
* Implement sh -> cmd.exe translation hack.Kaz Kylheku2021-07-261-0/+15
| | | | | * winsup/cygwin/spawn.cc (spawnve): Rewrite /bin/sh -c cmd invocations to use cmd.exe /c cmd instead.
* Default stdio streams to text mode.Kaz Kylheku2021-07-261-0/+4
| | | | | * newlib/libc/stdio/flags.c (__sflags): If mode is not O_BINARY, then add O_TEXT.
* Implement drive-relative paths and per-drive working dir.Kaz Kylheku2021-07-261-1/+40
| | | | | | | | | | | | | | | | | | | | | | * winsup/cygwin/path.cc (normalize_win32_path): When a drive-relative path is normalized, look up the remembered working directory of that drive in the environment. A drive-relative path is, for example, "C:file.txt". Or just "C:", with no component. If there is no path for the drive in the environment, then the root directory is used, and the "C:" part thus becomes "C:\", causing the path to refer to "C:\file.txt". Otherwise the path is inserted, with a backslash, like "C:\users\bob\file.txt". The Windows convention for storing these per-drive paths in the environment is to use environment variables based on drive letters. For instance the path for the C drive is stored in the environment variable "!C:" (bang, letter, colon). The path includes the C:\ prefix. (cwdstuff::override_win32_cwd): Add the behavior of associating the current working directory with its drive (if it is a current working directory based on a drive). For instance if the overriding cwd is "C:\Users", then the "C:\Users" path is stored into the "!C:" environment variable.
* Remove conversion of native paths to POSIX mount points.Kaz Kylheku2021-07-261-74/+1
| | | | | | | | | | | | We don't want the behavior in Cygnal whereby a native path like C:\path\to\app is converted to /app in getcwd and other situations, or C:\random\path is converted to /cygdrive/c/random/path. * winsup/cygwin/mount.cc (mount_info::conv_to_posix_path): Remove entire section of code which scans mount points, mapping native paths to their mount points paths. All we do is "slashify" and exit.
* First steps toward native path handling.Kaz Kylheku2021-07-264-31/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - /proc and /dev are are still available, accessed as proc:/ and dev:/ - All other paths are native, and do not "see" virtual Cygwin items; /cygdrive is just C:\cygdrive (if the current drive is C). - chdir() to a virtual directory like dev:/ or proc:/ results in errno EOPNOTSUPP. * winsup/cygwin/mount.cc (mount_info::conv_to_win32_path): Takes new bool argument, hide_cygwin_virtuals. If true all that the function does is "backslashify" the path. (mount_info::add_item): Special hack inserted here so that we can create the virtual root directory which holds dev and proc and whatnot, and is passed here as "/". We cannot let this go through normalize_posix_path any more because it will turn to C:\. * winsup/cygwin/mount.h (mount_info::conv_to_win32_path): Declaration updated. * winsup/cygwin/path.cc (is_posix_space): New static function: tests for paths in special spaces, currently "dev:/" and "proc:/". Used by normalize_posix_path. (normalize_posix_path): Any path that doesn't satisfy the is_posix_space test is treated as Win32. Since the bulk of the code is now only used for these spaces, the relative path handling is not required and a the corresponding block of code is removed. Paths satisfying is_posix_space are transformed. I.e. the underlying path resolution machine in the path_conv class still recognizes /proc and /dev. It's just that these will not occur, because normalize_posix_path will convert them to references with drive names. (path_conv::check): Pass the is_msdos flag down to mount_info::conv_to_win32_path as the new argument. Thus if normalize_posix_path indicates a native path, this function will hide the virtual spaces. Also, we add MOUNT_NOPOSIX and MOUNT_NOACL to the object's mount_flags. This is used in chdir. (normalize_win32_path): A small piece of logic works against our plan here: it checks for the leading forward slash on the path, and prevents such paths from being converted to Win32 paths with a drive reference. We eliminate this test, and treat paths unconditionally. (chdir): Here, if the path is not native, we return EOPNOTSUPP. Thus it is impossible to chdir into Cygwin virtual directories like /dev (now referenced as dev:/). They can be listed but not turned into the current directory. Eventually we want chdir to actually set the Win32 current directory of the process; that can't work for virtual dirs. * winsup/cygwin/path.h (path_conv::is_native): New inline accessor which tests for the MOUNT_NOPOSIX flag.
* Small fixes in get_cmd_exe_path.Kaz Kylheku2021-07-261-11/+13
| | | | | | | | | | * winsup/cygwin/spawn.cc (init_cmd_exe_path): Restructure code to initialize rather than assign nchars. Include backslash in cmd.exe name; then it can be omitted from the size calculation and sprintf. Do not allocate an excess byte for the string. Thanks to user forsvarir of the code review stackechange. Also reformatted to the GNU style used inside Cygwin. (init_cmd_exe_path): Remove spurious whitespace.
* More secure way of obtaining command interpreter.Kaz Kylheku2021-07-263-4/+30
| | | | | | | | | | | | | | | | | | Instead of relying on the COMSPEC environment variable, what we can do is assume that the program is called "cmd.exe", and then look for it in the directory reported by the GetSystemDirectoryA Win32 function in kernel32.dll. * winsup/cygwin/path.h (get_cmd_exe_path): New function declared. * winsup/cygwin/spawn.cc (av::setup): Use get_cmd_exe_path instead of getenv("COMSPEC"). (cmd_exe_path): New static variable. (init_cmd_exe_path): New static function. (get_cmd_exe_path): New function. * winsup/cygwin/syscalls.cc (system, getusershell, popen): Use get_cmd_exe_path instead of getenv("COMSPEC").
* Use COMSPEC env var, not hard-coded CMD.EXE path.Kaz Kylheku2021-07-263-19/+25
| | | | | | | | | | | | | | | | | | | | It is with some reluctance I make this change, due to the security implications of relying on environment variables. But we can't have a hard-coded path. * winsup/cygwin/include/paths.h (_PATH_CMDEXE): Macro removed. * winsup/cygwin/spawn.cc (av::setup): Use COMSPEC environment variable instead of hard-coded path. If missing, bail with errno set to EOPNOTSUPP. * winsup/cygwin/syscalls.cc (system): Use COMSPEC environment variable. If missing, return -1. (getusershell): Eliminate static array of shell names. If shell_index is zero, return value of COMSPEC env var, if it exists, and increment shell_index to 1. (popen): Use COMSPEC and if that is missing, set errno to EOPNOTSUPP and return NULL.
* Fix previous VT100 fix.Kaz Kylheku2021-07-261-11/+11
| | | | | | | | | We must only set or clear the eat_newline flag if we output something. * winsup/cygwin/fhandler_console.cc (fhandler_console::write_normal): Move the flag setting code inside the if statement which performs output.
* Fix spawned process window not foregrounding.Kaz Kylheku2021-07-262-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | This patch addresses an issue whereby the window of a process created with CreateProcess fails to come to the foreground. This occurs when the calling process itself hasn't run any Windows event processing loop. A repro test case is to make a program with a main, and and call CreateProcess to spawn calc.exe or notepad.exe before doing anything else. It turns out that a dummy call to TranslateMessage makes this issue goes away. If such a call is made before CreateProcess, then the spawned process' window comes up in the foreground as expected. * winsup/cygwin/Makefile.in (DLL_IMPORTS): We need to link in user32.dll to call TranslateMessage. Condense the multiple ${shell ...} call repetition with a foreach. * winsup/cygwin/spawn.cc (child_info_spawn::worker): Do the dummy TranslateMessage call before the section of code that calls CreateProcess or CreateProcessAsUser.
* Console: provide VT100-like end-of-line print behavior.Kaz Kylheku2021-07-262-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On the majority of VT100-like terminals, when you print a character in the last column, the cursor sits in a kind of "limbo", as if the cursor position were one column past the edge of the screen. Thus when a line feed is output next, the cursor is then at the start of the next line. The Win32 console write doesn't do this; the cursor position wraps to the start of the next line. If a newline is put out, it translates to an extra newline going to the next-next line. This spoils the behavior of programs which depend on the VT100 behavior. In this patch, the VT100 behavior is simulated as follows. A new flag in the dev_console structure is set when a character is output to the last column. This flag is then observed in order to discard a newline (or rather any character which is mapped mapped to the DWN action). * winsup/cygwin/fhandler.h (class dev_console): New boolean data member, eat_newline. This indicates that if a character is output which moves down to the next line, it should be discarded rather than sent to the console. * winsup/cygwin/fhandler_console.cc (fhandler_console::write_normal): Set the eat_newline flag if the text output ends up at column zero. Honor the eat_newline flag when processing a DWN character, and clear it when processing certain other control characters.
* Report as CYGNAL in uname syscall.Kaz Kylheku2021-07-261-2/+2
| | | | | | | | This allows applications to distinguish whether they are running on the stock Cygwin or Cygnal. * winsup/cygwin/uname.cc (uname, uname_x): sysname is now filled in with CYGNAL_ prefix rather than CYGWIN_.
* Cygnal apps use cmd.exe, not /bin/sh.Kaz Kylheku2021-07-263-47/+13
| | | | | | | | | | | | | | | | | | | * winsup/cygwin/include/paths.h (_PATH_CMDEXE): New preprocessor symbol. * winsup/cygwin/spawn.cc (av_setup): Use _PATH_CMDEXE rather than "/bin/sh". * winsup/cygwin/syscalls.cc (system): Spawn _PATH_CMDEXE with /c option rather than /bin/sh. (ETC_SHELLS): Preprocessor symbol removed. (shell_fp): Global variable removed. (getusershell): Don't open ETC_SHELLS, just march through static array of shell names. That array contains only one entry: _PATH_CMDEXE. (setusershell, endusershell): Remove references to shell_fp. (popen): Exec _PATH_CMDEXE rather than "/bin/sh", and the option is /c.
* When spawning, don't try to make invisible window.Kaz Kylheku2021-07-261-2/+0
| | | | | | | | | * winsup/cygwin/spawn.cc (child_info_spawn::worker): Do not call fhandler_console::need_invisible. It's not working properly. In an application which has no console because it was compiled -mwindows, calling this funcion causes a visible console window to appear. We don't need this in Cygnal; the Microsoft spawn functions don't pop up such windows.
* Use wShowWindow when calling CreateProcess.Kaz Kylheku2021-07-261-1/+2
| | | | | | * winsup/cygwin/spawn.cc (child_info_spawn::worker): Add STARTF_USESHOWWINDOW to dwFlags of the STARTUPINFOW structure, and set wShowWindow to SW_SHOWNORMAL.
* Cygwin: add "app execution aliases" treatment to release notescygwin-3_2_0-releaseCorinna Vinschen2021-03-232-0/+10
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Treat Windows Store's "app execution aliases" as symbolic linksJohannes Schindelin2021-03-231-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the Windows Store version of Python is installed, so-called "app execution aliases" are put into the `PATH`. These are reparse points under the hood, with an undocumented format. We do know a bit about this format, though, as per the excellent analysis: https://www.tiraniddo.dev/2019/09/overview-of-windows-execution-aliases.html The first 4 bytes is the reparse tag, in this case it's 0x8000001B which is documented in the Windows SDK as IO_REPARSE_TAG_APPEXECLINK. Unfortunately there doesn't seem to be a corresponding structure, but with a bit of reverse engineering we can work out the format is as follows: Version: <4 byte integer> Package ID: <NUL Terminated Unicode String> Entry Point: <NUL Terminated Unicode String> Executable: <NUL Terminated Unicode String> Application Type: <NUL Terminated Unicode String> Let's treat them as symbolic links. For example, in this developer's setup, this will result in the following nice output: $ cd $LOCALAPPDATA/Microsoft/WindowsApps/ $ ls -l python3.exe lrwxrwxrwx 1 me 4096 105 Aug 23 2020 python3.exe -> '/c/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0/python.exe' Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Cygwin: Allow executing Windows Store's "app execution aliases"Johannes Schindelin2021-03-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | The Windows Store version of Python (and apparently other Windows Store applications) install a special reparse point called "app execution alias" into the user's `PATH`. These applications can be executed without any problem, but they cannot be read as if they were files. This trips up Cygwin's beautiful logic that tries to determine whether we're about to execute a Cygwin executable or not: instead of executing the application, it will fail, saying "Permission denied". Let's detect this situation (`NtOpenFile()` helpfully says that this operation is not supported on this reparse point type), and simply skip the logic: Windows Store apps are not Cygwin executables (and even if they were, it is unlikely that they would come with a compatible `cygwin1.dll` or `msys-2.0.dll`). This fixes https://github.com/msys2/MSYS2-packages/issues/1943 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Cygwin: pty: Rename input/output named pipes.Takashi Yano via Cygwin-patches2021-03-231-6/+6
| | | | | | | | - Currently, names of output pipes are "pty%d-to-master" and "pty%d- to-master-cyg" and names of input pipes are "pty%d-to-slave" and "pty%d-from-master". With this patch, these pipes are renamed to "pty%d-to-master-nat", "pty%d-to-master", "pty%d-from-master-nat" and "pty%d-from-master" respectively.
* Cygwin: pty: Transfer input only if the stdin is a pty.Takashi Yano via Cygwin-patches2021-03-092-4/+15
| | | | | - The commit 12325677f73a did not fix enough. With this patch, more transfer_input() calls are skipped if stdin is redirected or piped.
* Cygwin: update release notes for 3.2.0, part 5Corinna Vinschen2021-03-091-0/+3
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: update release notes for 3.2.0, part 4Corinna Vinschen2021-03-092-2/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: pty: Transfer input for native app only if the stdin is pcon.Takashi Yano via Cygwin-patches2021-03-081-8/+10
| | | | | | - Currently, transfer input is triggered even if the stdin of native app is not a pseudo console. With this patch it is triggered only if the stdin is a pseudo console.
* Cygwin: update release notes for 3.2.0Ken Brown2021-03-082-0/+40
|
* Cygwin: pty: Attach to stub process when non-cygwin app inherits pcon.Takashi Yano via Cygwin-patches2021-03-081-1/+1
| | | | | | | | - If two non-cygwin apps are started simultaneously, attaching to pseudo console sometimes fails. This is because the second app trys to attach to the process not started yet. This patch avoids the issue by attaching to the stub process rather than the other non-cygwin app.
* Cygwin: update release notes for 3.2.0, part 2Corinna Vinschen2021-03-082-0/+23
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: update release notes for 3.2.0Corinna Vinschen2021-03-081-0/+7
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: console, pty: Stop ignoring Ctrl-C by IGNBRK.Takashi Yano via Cygwin-patches2021-03-082-4/+4
| | | | | | | - Perhaps current code misunderstand meaning of the IGNBRK. As far as I investigated, IGNBRK is concerned with break signal in serial port but there is no evidence that it has effect to ignore Ctrl-C. This patch stops ignoring Ctrl-C by IGNBRK for non-cygwin apps.
* Cygwin: pty: Discard input already accepted on interrupt.Takashi Yano via Cygwin-patches2021-03-085-1/+31
| | | | | - Currently, input already accepted is not discarded on interrupt by VINTR, VQUIT and VSUSP keys. This patch fixes the issue.
* Revert "Cygwin: Make sure newer apps get uname_x even when loading uname ↵Corinna Vinschen2021-03-082-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | dynamically" This reverts commit 532b91d24e9496c7988b2b1dda7fc0e8b161f782. It turned out that this patch has undesired side effects. To wit, if a newer, post-uname_x executable was linked against or loading an older, pre-uname_x DLL, and this DLL called uname. This call would jump into the old uname with the old struct utsname as parameter, but given the newer executable it would get redirected to uname_x. uname_x in turn would overwrite stack memory it should leave well alone, given it expects the newer, larger struct utsname. For the entire discussion see the thread starting at https://cygwin.com/pipermail/cygwin/2021-February/247870.html and continuing in March at https://cygwin.com/pipermail/cygwin/2021-March/247930.html For a description where we're coming from, see https://cygwin.com/pipermail/cygwin/2021-March/247959.html While we *could* make the scenario in question work by patching dlsym, the problem would actually be the same, just for dynamic loading. In the end, we're missing the information, which Cygwin version has been used when building DLLs. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Regenerate lib/posix/Makefile.inJeff Johnston2021-03-051-3/+16
|
* Cygwin: console: Fix restoring console mode failure.Takashi Yano via Cygwin-patches2021-03-052-4/+11
| | | | | | | - Restoring console mode fails in the following scenario. 1) Start cygwin shell in command prompt. 2) Run 'exec chcp.com'. This patch fixes the issue.
* Cygwin: pty: Fix a race issue in startup of pseudo console.Takashi Yano via Cygwin-patches2021-03-051-4/+12
| | | | | | | | - If two non-cygwin apps are started simultaneously and this is the first execution of non-cygwin apps in the pty, these occasionally hang up. The cause is the race issue between term_has_pcon_cap(), reset_switch_to_pcon() and setup_pseudoconsole(). This patch fixes the issue.
* Cygwin: simplify linkat with AT_EMPTY_PATHKen Brown2021-02-251-8/+16
| | | | | | | | | | | | | | linkat(olddirfd, oldpath, oldname, newdirfd, newname, AT_EMPTY_PATH) is supposed to create a link to the file referenced by olddirfd if oldname is the empty string. Currently this is done via the /proc filesystem by converting the call to linkat(AT_FDCWD, "/proc/self/fd/<olddirfd>", newdirfd, newname, AT_SYMLINK_FOLLOW), which ultimately leads to a call to the appropriate fhandler's link method. Simplify this by using cygheap_fdget to obtain the fhandler directly.
* Cygwin: fix linkat(2) on sockets that are not socket filesKen Brown2021-02-252-4/+12
| | | | | | | | | | | | | | | If linkat(2) is called with AT_EMPTY_PATH on an AF_LOCAL or AF_UNIX socket that is not a socket file, the current code calls fhandler_disk_file::link in most cases. The latter expects to be operating on a disk file and uses the socket's io_handle, which is not a file handle. Fix this by calling fhandler_disk_file::link only if the fhandler_socket object is a file (determined by testing dev().isfs()). Also fix the case of a socket file opened with O_PATH by setting the fhandler_disk_file's io_handle.
* Cygwin: fix facl on sockets that are not socket filesKen Brown2021-02-252-4/+10
| | | | | | | | | | If facl(2) is called on an AF_LOCAL or AF_UNIX socket that is not a socket file, the current code calls fhandler_disk_file::facl in most cases. The latter expects to be operating on a disk file and uses the socket's io_handle, which is not a file handle. Fix this by calling fhandler_disk_file::facl only if the fhandler_socket object is a file (determined by testing dev().isfs()).
* Cygwin: fix fchown on sockets that are not socket filesKen Brown2021-02-252-4/+10
| | | | | | | | | | If fchown(2) is called on an AF_LOCAL or AF_UNIX socket that is not a socket file, the current code calls fhandler_disk_file::fchown in most cases. The latter expects to be operating on a disk file and uses the socket's io_handle, which is not a file handle. Fix this by calling fhandler_disk_file::fchown only if the fhandler_socket object is a file (determined by testing dev().isfs()).
* Cygwin: fix fchmod on sockets that are not socket filesKen Brown2021-02-252-4/+10
| | | | | | | | | | If fchmod(2) is called on an AF_LOCAL or AF_UNIX socket that is not a socket file, the current code calls fhandler_disk_file::fchmod in most cases. The latter expects to be operating on a disk file and uses the socket's io_handle, which is not a file handle. Fix this by calling fhandler_disk_file::fchmod only if the fhandler_socket object is a file (determined by testing dev().isfs()).
* Cygwin: fix fstatvfs on sockets that are not socket filesKen Brown2021-02-252-4/+15
| | | | | | | | | | | If fstatvfs(2) is called on an AF_LOCAL or AF_UNIX socket that is not a socket file, the current code calls fhandler_disk_file::fstatvfs in most cases. The latter expects to be operating on a disk file and uses the socket's io_handle, which is not a file handle. Fix this by calling fhandler_disk_file::fstatvfs only if the fhandler_socket object is a socket file (determined by testing dev().isfs()).
* Cygwin: fix fstat on sockets that are not socket filesKen Brown2021-02-252-10/+10
| | | | | | | | | | If fstat(2) is called on an AF_LOCAL or AF_UNIX socket that is not a socket file, the current code calls fstat_fs. The latter expects to be operating on a disk file and uses the socket's io_handle, which is not a file handle. Fix this by calling fstat_fs only if the fhandler_socket object is a file (determined by testing dev().isfs()).