aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/fs.c
Commit message (Collapse)AuthorAge
* vim-patch:partial:9.1.1050: too many strlen() calls in os_unix.c (#32188)zeertzjq2025-01-24
| | | | | | | | | | | | | | Problem: too many strlen() calls in os_unix.c Solution: refactor os_unix.c and remove calls to strlen() (John Marriott) closes: vim/vim#16496 https://github.com/vim/vim/commit/efc41a5958bf25b352e0916af5f57dafbbb44f17 Omit os_expand_wildcards() change: Nvim's code is more complicated and harder to refactor. Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:8.2.4860: MS-Windows: always uses current directory for executableszeertzjq2024-08-09
| | | | | | | | | | | | Problem: MS-Windows: always uses current directory for executables. Solution: Check the NoDefaultCurrentDirectoryInExePath environment variable. (Yasuhiro Matsumoto, closes vim/vim#10341) https://github.com/vim/vim/commit/05cf63e9bdca1ac070df3e7d9c6dfc45e68ac916 Omit doc change: override in later doc update. Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
* fixup: apply the change on more filesJames Tirta Halim2024-06-04
|
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* fix(path): avoid chdir() when resolving path (#28799)zeertzjq2024-05-17
| | | | | | | | | | | | | | | | | | | | | | Use uv_fs_realpath() instead. It seems that uv_fs_realpath() has some problems on non-Linux platforms: - macOS and other BSDs: this function will fail with UV_ELOOP if more than 32 symlinks are found while resolving the given path. This limit is hardcoded and cannot be sidestepped. - Windows: while this function works in the common case, there are a number of corner cases where it doesn't: - Paths in ramdisk volumes created by tools which sidestep the Volume Manager (such as ImDisk) cannot be resolved. - Inconsistent casing when using drive letters. - Resolved path bypasses subst'd drives. Ref: https://docs.libuv.org/en/v1.x/fs.html#c.uv_fs_realpath I don't know if the old implementation that uses uv_chdir() and uv_cwd() also suffers from the same problems. - For the ELOOP case, chdir() seems to have the same limitations. - On Windows, Vim doesn't use anything like chdir() either. It uses _wfullpath(), while libuv uses GetFinalPathNameByHandleW().
* refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq2024-04-20
| | | | | | Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
* fix(path): check return value of append_path() (#28309)Joey Gouly2024-04-13
| | | | | | | | | | | | | | | | | | | | | | | If the filename passed to vim_FullName() is a relative directory, and does not exist, it is appended to the current working directory. Since the return value of append_path() was ignored, and if the buffer length was too small to fit getcwd() + dirname(filename), it would still try to append the basename(filename). This was manifesting as a failure in test/unit/path_spec.lua in: itp('fails and uses filename if given filename contains non-existing directory', .. This failure occurs when running the tests from directory with a short path such as: /work/src/nv test/unit/path_spec.lua:420: Expected objects to be the same. Passed in: (string) '/work/src/nv/test.file' Expected: (string) 'non_existing_dir/test.file' This return value for the second call to append_path() to append basename(filename) was checked, and this is where it would fail for normal / longer getcwd()s.
* vim-patch:9.1.0162: problem with writing extended attributes on failure (#27800)zeertzjq2024-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: problem with writing extended attributes on failure Solution: Change return type to ssize_t and check listxattr's return value correctly on failure (Paul Tagliamonte) The existing logic will return when the listxattr call returns with the errno set to ENOTSUP (or a size of 0 bytes), without checking to see if listxattr actually failed. listxattr can fail with at least E2BIG, ENOTSUP, ERANGE, or anything that `stat(2)` can fail with (in my case; ENOENT from stat). The returned size is stored to a size_t, but the return type is a ssize_t. On failure, listxattr returns -1, which will get translated to size_t's MAX. If the listxattr call failed with anything other than ENOTSUP, this triggers a request for size_t MAX bytes. This means that, if the listxattr call fails with anything other than ENOTSUP on save, vim will error with `E342: Out of memory! (allocating 18446744073709551615 bytes)` (keen observers will note 18446744073709551615 is 0xffffffffffffffff) In reality, this is likely masking a different (usually filesystem?) error -- but at least it's an error being pushed to the user now, and we don't try to allocate size_t MAX bytes. I've opted to change the type that we store listxattr to from size_t to ssize_t, to match listxattr(2)'s signature, and to check for the -1 return value. Additionally, I've removed the errno check -- if we get a listxattr failure for any reason, we may as well bail without trying; it's not like we can even recover. closes: vim/vim#14169 https://github.com/vim/vim/commit/14759ded57447345ba11c11a99fd84344797862c Co-authored-by: Paul R. Tagliamonte <paultag@gmail.com>
* refactor(api): make cstr_as_string accept "const char*"bfredl2024-02-09
| | | | | In the context a String inside an Object/Dictionary etc is consumed, it is considered to be read-only.
* feat(quickfix): support -q - to read 'errorfile' from stdin (#27303)zeertzjq2024-02-02
| | | Note that this only works when stdin is a pipe.
* feat(ui): add chdir UI event (#27093)Gregory Anders2024-01-19
| | | | | | When an embedded Nvim instance changes its current directory a "chdir" UI event is emitted. Attached UIs can use this information however they wish. In the TUI it is used to synchronize the cwd of the TUI process with the cwd of the embedded Nvim process.
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* refactor: move function macros out of vim_defs.h (#26300)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* build: enable IWYU on macdundargoc2023-11-27
|
* build(IWYU): replace most private mappings with pragmas (#26247)zeertzjq2023-11-27
|
* build: rework IWYU mapping filesdundargoc2023-11-25
| | | | | Create mapping to most of the C spec and some POSIX specific functions. This is more robust than relying files shipped with IWYU.
* fix: missing case in setxattr error handling (#26176)Nik Klassen2023-11-24
| | | ENOTSUP case is present in vim, but doesn't appear to have included here.
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* vim-patch:dbf749bd5aae (#25665)zeertzjq2023-10-16
| | | | | | | | | | | runtime: Fix more typos (vim/vim#13354) * Fix more typos * Fix typos in ignored runtime/ directory https://github.com/vim/vim/commit/dbf749bd5aaef6ea2d28bce081349785d174d96a Co-authored-by: Viktor Szépe <viktor@szepe.net>
* vim-patch:9.0.1975: xattr: permission-denied errors on write (#25478)zeertzjq2023-10-03
| | | | | | | | | | | | | | Problem: xattr: permission-denied errors on write Solution: ignore those errors closes: vim/vim#13246 https://github.com/vim/vim/commit/993b17569b5acffe2d8941d1709a55da4e439755 N/A patches: vim-patch:9.0.1965: wrong auto/configure script vim-patch:9.0.1966: configure prints stray 6 when checking libruby Co-authored-by: Gene C <arch@sapience.com>
* vim-patch:9.0.1967: xattr errors not translated (#25454)zeertzjq2023-10-01
| | | | | | | | | Problem: xattr errors not translated Solution: mark for translation, consistently capitalize first letter. closes: vim/vim#13236 https://github.com/vim/vim/commit/7ece036d72cf639b05d3936183220bec7179bf63
* vim-patch:9.0.1964: xattr support fails to build on MacOS X (#25448)zeertzjq2023-10-01
| | | | | | | | | | | | | | | | Problem: xattr support fails to build on MacOS X Solution: Disable xattr support for MacOS X MacOS X uses the same headers and functions sys/xattr.h but the function signatures for xattr support are much different, so building fails. So let's for now disable xattr support there. closes: vim/vim#13230 closes: vim/vim#13232 https://github.com/vim/vim/commit/a4dfbfed89e26a766e30cca62c18e710eec81c3f Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:9.0.1963: Configure script may not detect xattrzeertzjq2023-09-30
| | | | | | | | | | | | | | Problem: Configure script may not detect xattr correctly Solution: include sys/xattr instead of attr/xattr, make Test_write_with_xattr_support() test xattr feature correctly This also applies to the Smack security feature, so change the include and configure script for it as well. closes: vim/vim#13229 https://github.com/vim/vim/commit/6de4e58cf27a3bb6e81653ca63b77e29d1bb46f2
* vim-patch:9.0.1962: No support for writing extended attributeszeertzjq2023-09-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: No support for writing extended attributes Solution: Add extended attribute support for linux It's been a long standing issue, that if you write a file with extended attributes and backupcopy is set to no, the file will loose the extended attributes. So this patch adds support for retrieving the extended attributes and copying it to the new file. It currently only works on linux, mainly because I don't know the different APIs for other systems (BSD, MacOSX and Solaris). On linux, this should be supported since Kernel 2.4 or something, so this should be pretty safe to use now. Enable the extended attribute support with normal builds. I also added it explicitly to the :version output as well as make it able to check using `:echo has("xattr")`, to have users easily check that this is available. In contrast to the similar support for SELINUX and SMACK support (which also internally uses extended attributes), I have made this a FEAT_XATTR define, instead of the similar HAVE_XATTR. Add a test and change CI to include relevant packages so that CI can test that extended attributes are correctly written. closes: vim/vim#306 closes: vim/vim#13203 https://github.com/vim/vim/commit/e085dfda5d8dde064b0332464040959479696d1c Co-authored-by: Christian Brabandt <cb@256bit.org>
* refactor: reorganize option header files (#25437)zeertzjq2023-09-30
| | | | | | - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* refactor(message): smsg_attr -> smsgbfredl2023-09-29
|
* refactor: adjust headers according to the style guide (#23934)dundargoc2023-06-06
| | | System headers should be included first to prevent naming conflicts.
* refactor: uncrustifydundargoc2023-04-26
| | | | Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.
* refactor(fs): now it is time to get rid of fs_loop and fs_loop_mutexbfredl2023-04-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here's the headline: when run in sync mode (last argument cb=NULL), these functions don't actually use the uv_loop_t. An earlier version of this patch instead replaced fs_loop with using main_loop.uv on the main thread and luv_loop() on luv worker threads. However this made the code more complicated for no reason. Also arbitrarily, half of these functions would attempt to handle UV_ENOMEM by try_to_free_memory(). This would mostly happen on windows because it needs to allocate a converted WCHAR buffer. This should be a quite rare situation. Your system is pretty much hosed already if you cannot allocate like 50 WCHAR:s. Therefore, take the liberty of simply removing this fallback. In addition, we tried to "recover" from ENOMEM in read()/readv() this way which doesn't make any sense. The read buffer(s) are already allocated at this point. This would also be an issue when using these functions on a worker thread, as try_to_free_memory() is not thread-safe. Currently os_file_is_readable() and os_is_dir() is used by worker threads (as part of nvim__get_runtime(), to implement require from 'rtp' in threads). In the end, these changes makes _all_ os/fs.c functions thread-safe, and we thus don't need to document and maintain a thread-safe subset.
* vim-patch:9.0.0411: only created files can be cleaned up with one callzeertzjq2023-04-16
| | | | | | | | | | | | | | | | | | | | | | Problem: Only created files can be cleaned up with one call. Solution: Add flags to mkdir() to delete with a deferred function. Expand the writefile() name to a full path to handle changing directory. https://github.com/vim/vim/commit/6f14da15ac900589f2f413d77898b9bff3b31ece vim-patch:8.2.3742: dec mouse test fails without gnome terminfo entry Problem: Dec mouse test fails without gnome terminfo entry. Solution: Check if there is a gnome entry. Also fix 'acd' test on MS-Windows. (Dominique Pellé, closes vim/vim#9282) https://github.com/vim/vim/commit/f589fd3e1047cdf90566b68aaf9a13389e54d26a Cherry-pick test_autochdir.vim changes from patch 9.0.0313. Cherry-pick test_autocmd.vim changes from patch 9.0.0323. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: remove use of reserved c++ keywordsii142023-04-06
| | | | | | libnvim couldn't be easily used in C++ due to the use of reserved keywords. Additionally, add explicit casts to *alloc function calls used in inline functions, as C++ doesn't allow implicit casts from void pointers.
* Merge pull request #22056 from lewis6991/refactor/fileio_moreLewis Russell2023-02-15
|\ | | | | refactor `fileio.c`
| * refactor(fileio.c): remove HAVE_ACL ifdefsLewis Russell2023-02-01
| |
* | build: enable MSVC level 3 warnings (#21934)dundargoc2023-02-11
| | | | | | | | | | | | MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag.
* | fix(lua): mark some eval functions that can run in API-fastLewis Russell2023-02-02
|/
* refactor: replace char_u with char 24 (#21823)dundargoc2023-01-18
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* refactor: replace char_u with char 22 (#21786)dundargoc2023-01-17
| | | Work on https://github.com/neovim/neovim/issues/459
* fix(exepath)!: prefers extensionless for powershellAnton Kriese2023-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PROBLEM: exepath("test") should prefer ".bat" when shell=powershell. Current behavior differs from Vim 8.2.3071. TEST CASE: 1. in a folder which is in $PATH, create files "test" "test.bat". - "(Get-Command test).Path test" returns "test.bat". 2. compare nvim: nvim --clean :set shell=powershell :echo exepath("test") 3. should returns "path\to\test.bat" (before this patch it returns "path\to\test"). SOLUTION: After this patch, the binary files "text.exe", "test.bat", "test.com" will be found, but the file "test" (without any extension) will not be found (matches Vim 8.2.3071). But powershell's `where` and `Get-Command` _do_ find the extensionless 'test' file. But Nvim with ":set shell=cmd.exe", doesn't find "test" either (before and after this patch), even though `where test` returns correct path in cmd. - `where` is a program to find files in general, not just executable files. -`Get-Command` returning extensionless (and thus non-executable) file is puzzling even to Chris Dent, [PowerShell expert][1] (asked on Discord). [1]: https://www.amazon.com/Mastering-PowerShell-Scripting-Automate-environment-ebook/dp/B0971MG88X Co-authored-by: Enan Ajmain <3nan.ajmain@gmail.com> Helped-by: erw7 <erw7.github@gmail.com> Fixes #21045
* refactor: replace char_u with char 21 (#21779)dundargoc2023-01-14
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* refactor: replace char_u with char 17 - remove STRLCPY (#21235)dundargoc2023-01-09
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* refactor: eliminate os_unix.c #21621Justin M. Keyes2023-01-02
|
* refactor: replace char_u with chardundargoc2022-11-28
| | | | Work on https://github.com/neovim/neovim/issues/459
* fix: pvs warnings (#21145)dundargoc2022-11-22
| | | | | | | | | | | * fix(PVS/V009): start file with special comment * fix(PVS/V501): identical sub-expressions for comparison * fix(PVS/V560): part of conditional expression is always true/false * fix(PVS/V593): review expression of type A = B < C * fix(PVS/V614): potentially uninitialized variable used
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* Merge pull request #20821 from dundargoc/refactor/clang-tidybfredl2022-11-08
|\ | | | | refactor: fix clang-tidy warnings