Skip to content

Add ENOATTR for Linux #594

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

Merged
merged 1 commit into from
May 18, 2017
Merged

Add ENOATTR for Linux #594

merged 1 commit into from
May 18, 2017

Conversation

PlasmaPower
Copy link
Contributor

It's defined differently for OSX and *BSD, so having a Linux definition is helpful for cross-platform code.

@@ -171,6 +171,7 @@ fn main() {
if !uclibc {
// optionally included in uclibc
cfg.header("sys/xattr.h");
cfg.header("attr/xattr.h");
Copy link
Contributor Author

@PlasmaPower PlasmaPower May 15, 2017

Choose a reason for hiding this comment

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

Not sure about this, but we test uclibc right?

@PlasmaPower
Copy link
Contributor Author

The #include <attr/xattr.h> seems more complicated than expected. It's defined by libattr, which we don't have on all platforms. That's not necessary for the definition itself though, just the tests. How should I handle this? Just disable the tests for the constant?

@PlasmaPower
Copy link
Contributor Author

Also, this change is failing the linter as the constant definition comes at the end, but I think it needs to be there to use the platform specific ENODATA definition. Once again, how should I handle this?

@alexcrichton
Copy link
Member

Oh right now we don't actually test uclibc on CI yet, so it's ok to back out those changes if you'd like. Also no need to worry about definition order, it doesn't have to literally come after ENODATA, the definitions can be in either order.

@PlasmaPower
Copy link
Contributor Author

How should I deal with needing the attr headers for tests? They aren't present on some test systems.

@alexcrichton
Copy link
Member

Whatever gets past CI is fine by me, I don't particularly have opinions how it gets past CI

@PlasmaPower PlasmaPower force-pushed the linux-enoattr branch 2 times, most recently from 1166da2 to 19e03f8 Compare May 15, 2017 21:51
@PlasmaPower
Copy link
Contributor Author

Do you mind if I just ignore the constant in the tests? The setxattr and getxattr man pages on linux specifically say EATTR == ENODATA.

@alexcrichton
Copy link
Member

Hm man pages typically tend to be right for one architecture and I've seen they don't always tend to be right across all of them. Do you know why this header can't be found?

@PlasmaPower
Copy link
Contributor Author

It comes from libattr, which we don't have for a lot of Linux platforms.

@PlasmaPower
Copy link
Contributor Author

Because of that, maybe it shouldn't be in this Rust crate, but I think it's very important as other platforms define it and it's explicitly mentioned in the man page.

@PlasmaPower
Copy link
Contributor Author

From the libattr source: http://download.savannah.gnu.org/releases/attr/attr-2.4.47.src.tar.gz

include/xattr.h:

#include <errno.h>
#ifndef ENOATTR
# define ENOATTR ENODATA        /* No such attribute */
#endif

If defined, ENOATTR will always be an alias for ENODATA on Linux.

@alexcrichton
Copy link
Member

If this constant is only available on architecture, perhaps it could just be included there? The package should be installable via the various docker images we've got.

@PlasmaPower
Copy link
Contributor Author

Okay, I'll see if I can install them in docker.

ENOATTR is available for all architectures. It's just that libattr isn't installed by default on all platforms.

@alexcrichton
Copy link
Member

Hm if this isn't actually available in libc itself but requires an extra package to be installed, should it be included in the libc crate itself?

@PlasmaPower
Copy link
Contributor Author

PlasmaPower commented May 17, 2017

I'm not sure. It is in libc for other platforms, so it's useful for cross-platform code. It's also mentioned in the setxattr and getxattr man pages (which don't come from libattr but Linux itself).

@alexcrichton
Copy link
Member

Ok, well it sounds like the story here is fishy enough that it seems safe to just skip the constant, mind adding these comments to a comment as to why we're skipping it?

@PlasmaPower
Copy link
Contributor Author

Done. I'm assuming we don't want rustdoc comments for the constant definition? We don't have them for any other constants.

@alexcrichton
Copy link
Member

Nah that's ok, we typically don't have lots of rustdoc docs in libc (we rely on libc itself documentation for that)

@bors: r+

@bors
Copy link
Contributor

bors commented May 18, 2017

📌 Commit 98889cf has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented May 18, 2017

⌛ Testing commit 98889cf with merge a3e79eb...

bors added a commit that referenced this pull request May 18, 2017
Add ENOATTR for Linux

It's defined differently for OSX and *BSD, so having a Linux definition is helpful for cross-platform code.
@bors
Copy link
Contributor

bors commented May 18, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing a3e79eb to master...

@bors bors merged commit 98889cf into rust-lang:master May 18, 2017
@mati865 mati865 mentioned this pull request Jul 4, 2018
bors added a commit that referenced this pull request Jul 5, 2018
Add ENOATTR for Android

PR based on #594

It's defined in Android sysroot so it should work without test workaround (CI should catch it otherwise?).
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.

3 participants