Skip to content

Conversation

@sxyazi
Copy link
Owner

@sxyazi sxyazi commented Jan 5, 2026

Try to fix #3497

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a build error on NetBSD where the O_SYMLINK constant is unavailable in the libc crate. The fix relocates NetBSD from using the BSD/macOS-style implementation to the Linux-style implementation for path case folding, as NetBSD doesn't support the same BSD system calls but does support the Linux-style /proc filesystem access.

  • Moved NetBSD from BSD/macOS implementation group to Linux/Android implementation group
  • Added NetBSD-specific /proc/curproc/fd/ path support (NetBSD equivalent of Linux's /proc/self/fd/)
  • Removed NetBSD from final_path function that requires unsupported O_SYMLINK flag

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sxyazi sxyazi force-pushed the pr-41a7e778 branch 3 times, most recently from d060084 to 990074a Compare January 16, 2026 07:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +117 to +119
if let fd = unsafe { libc::open(cstr.as_ptr(), O_RDONLY | O_NOFOLLOW) }
&& fd >= 0
&& let file = unsafe { File::from_raw_fd(fd) }
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential file descriptor leak when fd >= 0 but try_from_fd() and path.canonicalize() both fail. If the open succeeds (fd >= 0) but the conditions at lines 121 and 123 both fail, the function returns early at line 126 without closing the file descriptor. The file is wrapped in a File but never gets used after line 122 returns None and line 123 fails. Consider using a match expression on the open result similar to the Linux implementation at line 55-58, or ensure the file is properly dropped before the early return.

Copilot uses AI. Check for mistakes.
};

// Fast path: if it's not a symlink
if let fd = unsafe { libc::open(cstr.as_ptr(), O_RDONLY | O_NOFOLLOW) }
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The irrefutable let pattern if let fd = ... is used but fd is not an Option or Result type. This pattern always matches and makes the code unnecessarily complex. The #[allow(irrefutable_let_patterns)] attribute at line 104 suggests this is intentional, but it would be clearer to use a regular let binding followed by an if condition let fd = unsafe { libc::open(...) }; if fd >= 0 { ... }.

Copilot uses AI. Check for mistakes.
@sxyazi sxyazi merged commit 756964b into main Jan 17, 2026
16 checks passed
@sxyazi sxyazi deleted the pr-41a7e778 branch January 17, 2026 05:11
@sxyazi sxyazi mentioned this pull request Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2025.12.19 fails to build on NetBSD

2 participants