-
Notifications
You must be signed in to change notification settings - Fork 698
fix: build error on NetBSD #3506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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_pathfunction that requires unsupportedO_SYMLINKflag
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d060084 to
990074a
Compare
There was a problem hiding this 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.
| if let fd = unsafe { libc::open(cstr.as_ptr(), O_RDONLY | O_NOFOLLOW) } | ||
| && fd >= 0 | ||
| && let file = unsafe { File::from_raw_fd(fd) } |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| }; | ||
|
|
||
| // Fast path: if it's not a symlink | ||
| if let fd = unsafe { libc::open(cstr.as_ptr(), O_RDONLY | O_NOFOLLOW) } |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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 { ... }.
Try to fix #3497