summaryrefslogtreecommitdiffstats
path: root/winsup/utils/path.cc
Commit message (Collapse)AuthorAgeFilesLines
* Cygwin: Fix remaining warnings building path testsuiteCorinna Vinschen2020-12-021-4/+2
|
* Cygwin: Fix building of utils testsuiteJon Turney2020-12-021-0/+4
| | | | Avoid referencing undefined max_mount_entry.
* Cygwin: utils: MOUNT_BINARY -> MOUNT_TEXTCorinna Vinschen2019-02-181-8/+7
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: path_conv: decouple path_types from mount typesCorinna Vinschen2019-01-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove another unfortunate amalgamation: Mount flags (MOUNT_xxx) are converted to path_types (PATH_xxx) and mixed with non-mount path_types flags in the same storage, leading to a tangled, pell-mell usage of mount flags and path flags in path_conv and symlink_info. - There's also the case of PC_NONULLEMPTY. It's used in exactly one place with a path_conv constructor only used in this single place, just to override the automatic PC_NULLEMPTY addition when calling the other path_conv constructors. Crazily, PC_NONULLEMPTY is a define, no path_types flag, despite its name. - It doesn't help that the binary flag exists as mount and path flag, while the text flag only exists as path flag. This leads to mount code using path flags to set text/binary. Very confusing is the fact that a text mount/path flag is not actually required; the mount code sets the text flag on non binary mounts anyway, so there are only two states. However, to puzzle people a bit more, path_conv::binary wrongly implies there's a third, non-binary/non-text state. Clean up this mess: - Store path flags separately from mount flags in path_conv and symlink_info classes and change all checks and testing inline methods accordingly. - Make PC_NONULLEMPTY a simple path_types flag and drop the redundant path_check constructor. - Clean up the definition of pathconv_arg, path_types, and mount flags. Use _BIT expression, newly define in cygwin/bits.h. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: change 3rd readlink param to size_tCorinna Vinschen2018-08-081-4/+4
| | | | | | Avoid gcc warnings Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix utils path handling in case cygdrive path is just '/'Corinna Vinschen2018-02-161-12/+20
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygcheck: Fix broken test for invalid wcstombs conversion reading symlinksCorinna Vinschen2016-10-221-6/+6
| | | | | | Fixes Coverity CID 66905 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygcheck: Fix check for Cygwin symlinkCorinna Vinschen2016-10-221-1/+1
| | | | | | Fixes Coverity CID 66904 and 66906 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen2016-06-231-3/+0
| | | | | | | | | | | | | | Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Bind mounts require POSIX pathsCorinna Vinschen2015-06-081-2/+7
| | | | | | | * path.cc (from_fstab_line): Don't convert slashes to backslashes for bind mounts. Explain why. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * cygcheck.cc (dll_info): Detect and report on symlinks. Output wrongChristopher Faylor2013-07-071-11/+14
| | | | | | architecture message inline with stdout for clarity. * path.cc (is_symlink): Always reset file pointer to beginning on exit. (readlink): Assume that file pointer is set to the beginning.
* * Merge in cygwin-64bit-branch.Corinna Vinschen2013-04-231-4/+6
|
* Update copyrightsChristopher Faylor2013-01-211-2/+2
|
* * path.cc (vcygpath): Handle cygdrive prefix.Corinna Vinschen2012-11-091-4/+12
|
* * configure.in: Add check for MINGW_CXX. Remove libiconv check.Yaakov Selkowitz2012-10-241-3/+3
| | | | | | | | | | | * configure: Regenerate. * Makefile.in: Remove references to mingw and w32api directories. Use MINGW_CXX instead of mingw script to build MINGW_BINS. Check for libiconv with $CC --print-file-name. * cygcheck.cc: Use relative include paths for Cygwin headers. * path.cc: Ditto. * strace.cc: Ditto * mingw: Remove.
* Clean up whitespace.Christopher Faylor2011-12-171-44/+44
|
* * cygcheck.cc (handle_unique_object_name): Avoid a compiler warning.Corinna Vinschen2011-03-291-2/+4
| | | | | | | | (dump_sysinfo): Ditto. * loadlib.h (_load_sys_library): Mark as used, to avoid a compiler warning. * path.cc (oopt): Gurad with !FSTAB_ONLY to avoid a compiler warning. (read_flags): Ditto.
* * loadlib.h: New header implementing safe LoadLibrary calls.Corinna Vinschen2010-08-281-0/+1
| | | | | | | | | | | | Include throughout files using LoadLibrary function. * cygcheck.cc (dump_sysinfo): Retrieve kernel32.dll handle via GetModuleHandle, rather than using LoadLibrary. * cygpath.cc (get_long_name): Ditto. (do_sysfolders): Append .dll suffix in LoadLibrary call. * ldh.cc (WinMain): Use LoadLibraryExW with DONT_RESOLVE_DLL_REFERENCES to avoid loading malicious library code. * locale.cc (print_locale_with_codeset): Change way to retrieve kernel32.dll path.
* * path.cc: Include sys/cygwin.h if built for mount(1).Corinna Vinschen2010-04-291-1/+10
| | | | | | (struct opt): Add "dos" and "ihash" options. (from_fstab_line): Call cygwin_internal rather than read_flags if built for mount(1).
* * path.cc (read_mounts): Skip unnecessary test if path has beenCorinna Vinschen2009-11-041-6/+10
| | | | fetched from loaded cygwin1.dll.
* * cygcheck.cc (cygwin_dll_path): New global variable.Corinna Vinschen2009-11-041-15/+15
| | | | | | | | (load_cygwin): Fetch cygwin DLL path and store in cygwin_dll_path. * strace.cc: Full ditto. * path.cc (read_mounts): First use the path stored in cygwin_dll_path, if available. Then fall back to fetching own path. Add comment. Drop printing warnings since they look funny in strace output.
* * path.cc (read_mounts): First get installation path from own path.Corinna Vinschen2009-11-041-20/+43
| | | | | Check if cygwin1.dll exists in same directory. Only if not, try to get installation path from setup registry key. Add ample warnings.
* * mount.cc (do_mount): Replace --no-executable flag with notexecCorinna Vinschen2009-07-221-1/+1
| | | | | mount option in hint for remote filesystems. * path.cc (getmntent): Fix typo (noexec -> notexec).
* * Makefile.in (path-mount.o): Add a rule to build stripped down versionCorinna Vinschen2009-07-221-13/+13
| | | | | | | | | | | | | | | | | | | | | | | of path.cc for usage in mount. (mount.exe): Add dependency to path-mount.o. * mount.cc (force): Convert to bool value. Accommodate throughout. (from_fstab): New function. (do_mount_from_fstab): New function. (longopts): Add --all option. (opts): Add -a option. (usage): Document -a/--all option. (main): Handle -a option as well as single parameter. * path.cc: Add FSTAB_ONLY conditional to allow building path-mount.o. (mount_table): Remove static storage class. (max_mount_entry): Ditto. (root_here): Unused. Remove. (from_fstab_line): Remove static. * path.h (struct mnt_t): Define here rather than in path.cc. (from_fstab_line): Declare. (mount_table): Declare. (max_mount_entry): Declare. * utils.sgml (mount): Document -a/--all option and mounting of single path from fstab files.
* * path.cc (oopts): Sort alphabetically, add missing "auto" andCorinna Vinschen2009-06-101-31/+58
| | | | | | | | | | | "override" entries. (from_fstab_line): Handle mount points same as Cygwin itself. Use "cygdrive prefix" as posix name of cygdrive prefix. (from_fstab): Add auto entries for /usr/bin and /usr/lib. Add MOUNT_AUTOMATIC and MOUNT_IMMUTABLE flags to default root dir entry. Use "cygdrive prefix" as posix name of default cygdrive prefix. (getmntent): Allocate smaller buffers. Align output closer to output of mount(1).
* * path.cc (readlink): Accommodate new UTF-16 symlinks.Corinna Vinschen2009-04-071-5/+23
|
* * path.cc (from_fstab): Use wcstombs/mbstowcs instead ofCorinna Vinschen2009-03-141-5/+3
| | | | WideCharToMultiByte/MultiByteToWideChar to accommodate current locale.
* * cygcheck.cc (pathlike::check_existence): Remove class name from declaration.Christopher Faylor2008-09-121-5/+5
| | | | | | | | | | | | | | | | | | | | | (display_internet_error): Use proper format specifier for DWORD. (environ): Remove unneeded declaration. (main): Use brace around nested if to avoid an overly-helpful compiler warning. * dump_setup.cc (parse_filename): Reorganize nested if to avoid an overly-helpful compiler warning. * path.cc (GUID_shortcut): Use braces around part of initializer which needs them. (conv_fstab_spaces): Parenthesize assignment in while loop to avoid a compiler warning. (struct opt): Make static. * ps.cc (main): Reorganize nested if to avoid an overly-helpful compiler warning. * regtool.cc: Make some anonymous structs static to avoid a compiler warning. * ssp.c (lookup_thread_id): Initialize *tix to zero to avoid potential uninitialized use. * strace.cc (add_child): Use proper format specifier for DWORD. (remove_child): Ditto. (proc_child): Ditto.
* * Makefile.in (cygcheck.exe): Link against ntdll.Corinna Vinschen2008-07-221-1/+9
| | | | | | | | | | | | | | | | | | | | * bloda.cc: Use statically linked functions throughout. * cygpath.cc: Drop 9x considerations. * mkgroup.c: Revamp. Redefine -l and -d options to take optional machine and domain parameters. Redefine -c to work always, using token information. Add -L, -D, -C to create unique groupnames in domain\group syntax. Add -S option to define domain\group separator char. Ignore -u and -s options. * mkpasswd.c: Revamp. Redefine -l and -d options to take optional machine and domain parameters. Redefine -c to work always, using token information. Add -L, -D, -C to create unique usernames in domain\user syntax. Add -S option to define domain\user separator char. Ignore -g and -s options. Prefer to take homedir from $HOME over $HOMEDRIVE/$HOMEPATH. * path.cc (oopts): Add "acl", "noacl", "posix=0" and "posix=1" options. (getmntent): Accomodate throughout. * ps.cc: Fix copyright dates. * utils.sgml: Fix text for mkgroup and mkpasswd.
* * mount.cc (do_mount): Remove MOUNT_ENC code.Corinna Vinschen2008-07-171-4/+1
| | | | | | | (oopts): Remove "managed" option. (mount_commands): Drop "managed" handling. * path.cc (oopts): Remove "managed" option. (getmntent): Remove MOUNT_ENC code.
* * cygcheck.cc (dump_sysinfo): Fix multiple Cygwin DLL test.Corinna Vinschen2008-04-221-115/+305
| | | | | | | | | | | | | | | | | | | | | | | | | | | * path.cc: Fetch mount points from fstab files instead of from registry. Use adapted functions copied from Cygwin DLL. (mnt_t): Drop issys member. Define as "mnt_t" instead of "struct mnt_t" subsequently. (max_mount_entry): New variable. (unconvert_slashes): Move to earlier location in file. Make inline. (find2): Remove. (get_cygdrive0): Remove. (get_cygdrive): Remove. (skip_ws): New function. (find_ws): Ditto. (conv_fstab_spaces): Ditto. (read_flags): Ditto. (from_fstab_line): Ditto. (get_user): Ditto. (from_fstab): Ditto. (mnt_sort): Ditto. (read_mounts): Drop old registry code. Fetch "Software\Cygwin\Setup\rootdir" value from HKCU or HKLM key. Use rootdir extracted from module path as fallback. Call from_fstab for nouser and user mount points. (setmntent): Check max_mount_entry to test if read_mounts must be called. (getmntent): Use MOUNT_SYSTEM flag instead of mnt_t's issys member.
* * path.cc: Include malloc.h for alloca.Brian Dessent2008-03-161-48/+46
| | | | | | (is_symlink): Rewrite. Just read the whole file in memory rather than by parts. Account for an ITEMIDLIST if present, as well as the new style of Cygwin shortcut supporting targets > MAX_PATH.
* * cygcheck.cc (dirname): New static function.Brian Dessent2008-03-111-21/+52
| | | | | | | | | | | | | | (find_app_on_path): Use SYMLINK_MAX. Resolve symlink relative to link's location. Adjust to the fact that cygpath already normalizes its return value. * path.cc (rel_vconcat): Add cwd parameter, and use it instead of calling GetCurrentDirectory() if possible. Rename throughout. (vcygpath): Rename from cygpath and accept cwd and va_list. Pass cwd on to rel_vconcat(). (cygpath_rel): New front end for vcygpath. (cygpath): Ditto. * path.h (cygpath_rel): Declare. (SYMLINK_MAX): Define to 4095.
* * Makefile.in: Add a 'check' target that builds and runsBrian Dessent2008-03-091-10/+51
| | | | | | | | | | | | | | | | | | | | | testsuite.exe from path-testsuite.o and testsuite.o. * path.cc: Include testsuite.h. (struct mnt): Change to a mnt_t typedef and don't define mount_table when TESTSUITE is defined. (find2): Don't include when TESTSUITE is defined to avoid warning. (get_cygdrive0): Ditto. (get_cygdrive): Ditto. (read_mounts): Provide empty implementation when TESTSUITE is defined. (vconcat): Use the isslash macro. (unconvert_slashes): New helper to convert to backslashses. (rel_vconcat): Handle relative paths more gracefully. (cygpath): Skip a leading "./" sequence. Avoid double-slashes. Normalize final output to backslashes and remove redundant path sequences. * testsuite.cc: New file implementing testsuite driver. * testsuite.h: New header implementing harness mount table and series of tests.
* * cygcheck.cc (pathlike): New class.Christopher Faylor2007-06-041-18/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (paths): Redefine as type pathlike. (display_error): Declare a few different ways to allow more flexible usage throughout. (display_error_fmt): New function for those cases where C++ just isn't enough. (add_path): Rewrite to allocate pathlike paths. Always tack on a trailing slash since that's what everyone who uses it wants. NULL terminate the path list. Register "it's a system path" field. (init_path): Call add_path with info regarding whether path is a system path or not. (pathlike::check_existence): Move into pathlike class. Accept file and extension arguments to build up path on the fly. Modify other arguments. (find_on_path): Constify return value and appropriate arguments. Eliminate short-circuit for fully-qualified paths. Simplify loop which iterates over path. (already_did): Constify argument. (track_down): Ditto. Regularize some error messages. (find_app_on_path): Ditto. (cygcheck): Constify argument. Use 20th century string handling functions. (dump_sysinfo): Remove odd inclusion of '\\bin' "Just in case". Accommodate change of paths to pathlike. * path.cc (isslash): Rename from SLASH_P and use throughout. (rel_vconcat): Front-end to vconcat which prepends cwd to path before passing along for conversion to native windows. (cygpath): Remove "./" test. Call rel_vconcat if filename appears to be relative.
* * cygcheck.cc (get_word, get_dword): Move to path.cc.Corinna Vinschen2006-10-051-2/+200
| | | | | | | | | | | | | | | | | | | (LINK_EXTENSION): New macro. (check_existence): New static function. (find_on_path): Check for symbolic links if asked. (dll_info): New error handling. (track_down): Only call dll_info() for executables, display an error for symlinks, and print magic number for others. (find_app_on_path): New static function. (cygcheck, dump_sysinfo): Call find_app_on_path() instead of find_on_path(). * path.cc (cmp_shortcut_header): New static function. (get_word, get_dword): Moved from cygcheck.cc. (EXE_MAGIC, SHORTCUT_MAGIC, SYMLINK_COOKIE, SYMLINK_MAGIC): New macros. (is_exe, is_symlink, readlink): New functions. * path.h (is_exe, is_symlink, readlink): Declare. (get_word, get_dword): Ditto.
* * path.cc (vconcat): Don't convert backslahes to slashes.Corinna Vinschen2006-08-031-4/+1
| | | | (cygpath): Return native path with all backslashes.
* * path.cc (getmntent): Add previously-omitted 'noexec' and 'managed'flags toDave Korn2005-04-291-1/+5
| | | | mnt_opts string if present in mount flags.
* * Makefile.in (MINGW_CXX): Define and use for mingw-compiled files.Christopher Faylor2003-09-111-3/+5
| | | | | * path.cc: Include more path info in cygwin-specific includes since the cygwin directory is no longer included by default.
* * Makefile.in (strace.exe): Include mingw_getopt.o in link line.Christopher Faylor2003-03-041-1/+1
| | | | | | | | * cygcheck.cc (print_version): Update copyright. * strace.cc (print_version): Ditto. (main): Allow cygwin paths for -o option. (create_child): Allow cygwin path as argv[0]. * path.cc (path.cc): Allow UNC paths.
* * cygcheck.cc (common_apps): Add some more apps.Christopher Faylor2003-02-071-1/+1
| | | | * path.cc (get_cygdrive): Correctly set system flag.
* * path.cc (cygpath): Change MOUNT_AUTO to MOUNT_CYGDRIVE.Christopher Faylor2002-06-091-3/+3
| | | | (getmntent): Ditto.
* * path.cc (cygpath): Don't consider cygpath stuff when trying to derive nativeChristopher Faylor2001-11-221-0/+3
| | | | paths.
* * cygcheck.cc (scan_registry): Open registry with read-only access.Christopher Faylor2001-11-121-1/+1
| | | | | | (main): Reflect argument change for dump_setup. * dump_setup.cc (dump_setup): Add preliminary extra argument for future use. * path.cc (read_mounts): Open registry with read-only access.
* * dump_setup.cc: New file.Christopher Faylor2001-11-111-15/+12
| | | | | | * Makefile.in: Add info for dump_setup.o. * cygcheck.cc (main): Recognize '-c' option for checking setup installed base. * path.cc (cygpath): Read mount table if not loaded.
* * Makefile.in (cygcheck.exe): Compile as -mno-cygwin executable.Christopher Faylor2001-11-111-0/+350
* path.cc: New file. * cygcheck.cc (init_paths): Use MS-DOS path syntax. (cygwin_info): Properly display cygwin version numbers. Prettify some output. (dump_sysinfo): Calculate max names of posix and ms-dos paths for prettier output.