Conversation
|
The underlying issue is addressed in a more robust way in #14652. |
|
GNU testsuite comparison: |
|
@xtqqczze I think excluding it at compile time might introduce some technical debt.
Here is why:
Ruling out an entire operating system outright during compilation is too rigid an approach. The problem isn’t OpenBSD itself, but the lack of a specific feature. If OpenBSD were to add support for extended attributes in the future, or if another system had the same limitation, a hardcoded block at compile-time would force us to revisit the code to update the exceptions.
Handling the error at runtime, on the other hand, is the more robust approach and is in line with the philosophy of classic Unix tools: the program attempts to perform the operation, and if the OS responds with “not supported,” it handles the situation cleanly and moves on. Filling the code with conditional flags to disable parts of the program based on the operating system’s name is merely a shortcut that creates technical debt; not a true architectural solution.
|
|
@krosci The issue is that OpenBSD is not supported by the See also: #14642 |
|
That's fair context, and I see where you're coming from regarding the current limitations of the xattr crate. However, from an architectural standpoint, this is still a workaround that conflates an upstream dependency limitation with our own design decisions. |
|
Just to clarify, with |
|
Yes, exactly! That's precisely the behavior we want. Having the crate unconditionally return io::ErrorKind::Unsupported is perfect: it ensures the build doesn't break on OpenBSD and allows us to handle the missing feature cleanly and predictably in the calling code, all while keeping the API consistent |
|
I completely understand the frustration with runtime failures, and looking at those past issues, it makes sense why you'd want to catch things at compile-time, but returning io::ErrorKind::Unsupported is fundamentally different from a silent failure or an unexpected runtime panic. By doing this, we are actually following the Rust standard library precedent, just like std::os::unix::fs::chown handles unsupported platform features by returning an unsupported error rather than breaking the build. Because the operation returns a Result, we aren't introducing an unhandled exception; the caller is forced by the compiler to acknowledge the outcome and can easily match against ErrorKind::Unsupported to implement a clean fallback, like logging a skip message instead of crashing. Most importantly, forcing a compile-time failure has a massive blast radius: if xattr fails to compile, every downstream crate in the dependency tree instantly fails to build on OpenBSD, even if extended attributes are just a minor, optional feature for their specific use case. By returning a well-typed runtime error instead, we allow the broader ecosystem to actually compile on OpenBSD, leaving the final decision to the downstream application on whether to gracefully ignore the missing feature or handle the lack of support safely |
|
+1 for build time error. There is no benefit to include gabage to binaries. |
|
Upon further investigation, OpenBSD does not support extended file attributes, and there is no corresponding API for |
|
OK. Then we can close this PR and just guard building it. |
On platforms without extended attribute support such as OpenBSD, the xattr crate returns io::ErrorKind::Unsupported and BSD systems use distinct errno codes. The optional attribute preservation check in cp and uucore now recognizes io::ErrorKind::Unsupported along with ENOTSUP, EOPNOTSUPP, and ENOSYS to match GNU behavior. This prevents cp -a and --preserve=all from failing with spurious error diagnostics on unsupported platforms.