summaryrefslogtreecommitdiff
path: root/file.c
AgeCommit message (Collapse)Author
3 daysThe device numbers in `struct statx` may be larger than `dev_t`Nobuyoshi Nakada
`dev_t` is already 64-bit in glibc, but on some platforms like Alpine Linux and Android NDK, `makedev` is defined as more than 32-bit ( promoting to `unsigned long long` then left-shifting by 32bit), while `dev_t` is still 32-bit. Notes: Merged: https://github.com/ruby/ruby/pull/13607
7 daysFix build on alpine with statx changeEarlopain
Since https://github.com/ruby/ruby/commit/18a036a6133bd141dfc25cd48ced9a2b78826af6 building on alpine fails because usage of `__u32`, which is not portable. > file.c: In function 'rb_stat_new': > file.c:546:33: error: '__u32' undeclared (first use in this function) > # define CP_32(m) .stx_ ## m = (__u32)st->st_ ## m Notes: Merged: https://github.com/ruby/ruby/pull/13562
2025-05-30[Feature #21205] Define File::Stat#birthtime by statxNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13474
2025-04-19Ensure `struct rb_io` is passed through to `thread.c`. (#13134)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2025-04-18[wasm] Fallback to emulated realpath on wasi-libc realpath `ENOTSUP`Yuta Saito
wasi-libc 22 and later support realpath(3) (https://github.com/WebAssembly/wasi-libc/pull/463) but the underlying host syscall may return ENOTSUP. This is typically the case when using incomplete WASI polyfills on web browsers. For such cases, we should fallback to the emulated realpath. Notes: Merged: https://github.com/ruby/ruby/pull/13124
2025-04-01GCC defines __linux__, not __LINUX__Alan Wu
Fixes: 2c6512fe67a275ce4d251f3c5d304bc523597f42 Notes: Merged: https://github.com/ruby/ruby/pull/13032
2025-03-13[Feature #20971] Deprecate `rb_path_check`Earlopain
https://bugs.ruby-lang.org/issues/20971 Notes: Merged: https://github.com/ruby/ruby/pull/12542
2025-01-29[DOC] Fix wrong call-seq format (#12662)tomoya ishida
Notes: Merged-By: tompng <[email protected]>
2025-01-02[DOC] Exclude 'Class' and 'Module' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12496
2024-10-10[Bug #20631] Workaround for macOS 15.0 fork crashYuta Saito
macOS 15.0 24A5331b seems to have a weird issue that `CFStringCreateWithBytesNoCopy` does not return `NSTaggedPointerString` instance for the first call. This issue is fixed in macOS 15.1 but we need to workaround it for macOS 15.0. Notes: Merged: https://github.com/ruby/ruby/pull/11849
2024-10-09Fix spellingJohn Bampton
Notes: Merged: https://github.com/ruby/ruby/pull/11835
2024-10-05Introduce `rb_io_blocking_region` which takes `struct rb_io` argument. (#11795)Samuel Williams
This does not change any actual behaviour, but provides a choke point for blocking IO operations. * Update `IO::Buffer` to use `rb_io_blocking_region`. * Update `File` to use `rb_io_blocking_region`. * Update `IO` to use `rb_io_blocking_region`. Notes: Merged-By: ioquatix <[email protected]>
2024-09-30Free a buffer allocated by realpathYusuke Endoh
8350b48cfa7d344d9e2dc9748c26607c1b89d7df introduced a memory leak bug. Will fix [Bug #20773] `loop { File.realpath("foo") }` caused memory leak. Notes: Merged: https://github.com/ruby/ruby/pull/11736
2024-09-26Extract `mutable_CFString_new`Nobuyoshi Nakada
From duplicate code in `rb_CFString_class_initialize_before_fork` and `rb_str_append_normalized_ospath`. Notes: Merged: https://github.com/ruby/ruby/pull/11695
2024-09-26Import patches for old macOS from MacPortsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11690
2024-09-12Release GVL for get{pwnam,pwuid,grgid,grnam}_r calls in process.cJeremy Evans
Do not release GVL around get{pwuid,pwnam,grgid,grnam} calls, as doing so is not thread-safe. Another C extension could have a concurrent call, and derefencing the returned pointer from these calls could result in a segfault. Have rb_home_dir_of call rb_getpwdirnam_for_login if available, so it can use getpwnam_r and release GVL in a thread-safe manner. This is related to GVL releasing work in [Bug #20587]. Notes: Merged: https://github.com/ruby/ruby/pull/11202
2024-08-22Check getlogin return value before passing to strcasecmpJeremy Evans
getlogin can return NULL, and this can avoid a segfault in that case. Mentioned as an issue in comment to bug 20586. Notes: Merged: https://github.com/ruby/ruby/pull/11427
2024-07-18Fix `utimesat` availability conditionNobuyoshi Nakada
As `__has_attribute` macro is always defined in internal/compilers.h, gcc warns `-Wunguarded-availability-new` as unknown option. Check if the warning option is usable instead.
2024-07-14Release GVL around system calls in dir.cJeremy Evans
* Release GVL for fdopendir calls * Release GVL for readdir calls * Release GVL for chdir call in dir_chdir0 * Release GVL for fchdir call in dir_fchdir * Release GVL for chroot calls * Release GVL for lstat calls * Release GVL for stat calls * Release GVL for fstatat calls * Release GVL for getpwnam call in rb_home_dir_of (technically in file.c, but called from dir.c) This does not release GVL for readdir/stat/lstat on Windows, as that causes issues because the emulation functions that are called in win32.c require the GVL. This also removes some explicit casts either to or from void *, which are allowed implicitly. The remaining casts to or from void * are part of function pointer casts, which are not allowed implicitly and will generate a warning.
2024-07-08Doc fixesBurdetteLamar
2024-03-05[DOC] fix some commentscui fliter
Signed-off-by: cui fliter <[email protected]>
2024-03-02Make `File#chown` unblockingNobuyoshi Nakada
2024-03-02Make `File#chmod` unblockingNobuyoshi Nakada
2024-02-23Remove unneeded RUBY_FUNC_EXPORTEDPeter Zhu
2024-02-20[DOC] Fix links in doc (#9970)Burdette Lamar
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2024-02-01[DOC] Pretty tables for Kernel#test doc (#9751)Burdette Lamar
2024-01-30Fix memory leak in File.expand_pathPeter Zhu
File.expand_path leaks the dir if the encodings are not compatible. For example: Encoding.default_external = Encoding::UTF_16BE 10.times do 100_000.times do File.expand_path("./a") rescue end puts `ps -o rss= -p #{$$}` end Before: 12288 15488 18656 21872 25056 28240 31392 34688 37856 41056 After: 9680 9728 9728 9792 9792 9792 9792 9792 9792
2024-01-24Define `IO_WITHOUT_GVL` macroNobuyoshi Nakada
2024-01-08[DOC] Escape File in documentationPeter Zhu
2023-12-25Markdown table for #flockBurdetteLamar
2023-12-24[DOC] Fix markup in HTMLNobuyoshi Nakada
Inside HTML is not markdown.
2023-12-23[DOC] Clean up doc for File#flock (#9332)Burdette Lamar
2023-12-18[DOC] Add links from `File::Constants` to `File` constantsNobuyoshi Nakada
2023-12-06[DOC] Fixed document positionNobuyoshi Nakada
Method documentation must be placed immediately before each implementation, without any other functions or preprocessor directives.
2023-11-22Embed File::Stat objectsJean Boussier
They are very short lived and fit in a 160B slot.
2023-11-17Fix File.directory? doc hidding File::Stat#directory? docDana Sherson
Now the documentation that was already in the codebase for `File::Stat#directory?` shows up.
2023-09-27[DOC] Missing comment markersNobuyoshi Nakada
2023-09-24[DOC] Correction for doc guide + TOC fix in File (#8505)Burdette Lamar
2023-08-31[DOC] Link fix (#8340)Burdette Lamar
Notes: Merged-By: peterzhu2118 <[email protected]>
2023-08-26Introduce `at_char_boundary` functionNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8296
2023-08-12[DOC] Don't suppress autolinksBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/8213
2023-07-24[rubygems/rubygems] Bundler: Update bundle-outdated(1) manKentaro Takeyama
Updated output examples to current format since the output format has changed since version 2.2.0.dev https://github.com/rubygems/rubygems/commit/48d98f906a
2023-07-23[DOC] RDoc for File::Constants (#8103)Burdette Lamar
Notes: Merged-By: peterzhu2118 <[email protected]>
2023-07-10Use `File::NULL` instead of hard coded null device namesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8050
2023-06-28[DOC] Fixes for link fragments (#7981)Burdette Lamar
Notes: Merged-By: peterzhu2118 <[email protected]>
2023-06-01Hide the usage of `rb_io_t` where possible. (#7880)Samuel Williams
This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility. Notes: Merged-By: ioquatix <[email protected]>
2023-06-01Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui
This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
2023-05-30Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams
* Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <[email protected]> Notes: Merged-By: ioquatix <[email protected]>
2023-03-22Should not reach end of non-void functionNobuyoshi Nakada