Extended attribute library for rust.

Related tags

Filesystem xattr
Overview

xattr

Build Status Build Status

A small library for setting, getting, and listing extended attributes.

Supported Platforms: Linux, MacOS, FreeBSD, and NetBSD.

API Documentation: https://stebalien.github.com/xattr/xattr/

Unsupported Platforms

This library includes no-op support for unsupported platforms. That is, it will build on all platforms but always fail on unsupported platforms.

  1. You can turn this off by disabling the default unsupported feature. If you do so, this library will fail to compile on unsupported platforms.
  2. Alternatively, you can detect unsupported platforms at runtime by checking the xattr::SUPPORTED_PLATFORM boolean.
Comments
  • tests are failing (selinux?)

    tests are failing (selinux?)

    test test_multi ... FAILED
    test test_fd ... FAILED
    test test_path ... FAILED
    
    failures:
    
    ---- test_multi stdout ----
    	thread 'test_multi' panicked at 'assertion failed: items.remove(&*it)', tests/main.rs:59
    
    ---- test_fd stdout ----
    	thread 'test_fd' panicked at 'assertion failed: `(left == right)` (left: `Some("security.selinux")`, right: `None`)', tests/main.rs:16
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    
    ---- test_path stdout ----
    	thread 'test_path' panicked at 'assertion failed: `(left == right)` (left: `Some("security.selinux")`, right: `None`)', tests/main.rs:33
    
    opened by ignatenkobrain 6
  • Build failure with 0.1.8 on NetBSD

    Build failure with 0.1.8 on NetBSD

    I don't actually use NetBSD but this happened recently with rustup:

    + cargo build --release --target x86_64-unknown-netbsd
    
        Updating registry `https://github.com/rust-lang/crates.io-index`
    
        Updating git repository `https://github.com/ctz/rustls.git`
    
        Updating git repository `https://github.com/sfackler/rust-native-tls.git`
    
        Updating git repository `https://github.com/Diggsey/markdown.rs.git`
    
        Updating git repository `https://github.com/ctz/ring`
    
        Updating git repository `https://github.com/ctz/webpki`
    
        Updating git repository `https://github.com/sfackler/schannel-rs`
    
     Downloading term v0.4.4
    
     Downloading clap v2.10.2
    
     Downloading tempfile v2.1.4
    
     Downloading error-chain v0.4.2
    
     Downloading sha2 v0.1.2
    
     Downloading rand v0.3.14
    
     Downloading regex v0.1.73
    
     Downloading rustc-serialize v0.3.19
    
     Downloading scopeguard v0.1.2
    
     Downloading tempdir v0.3.4
    
     Downloading toml v0.1.30
    
     Downloading time v0.1.35
    
     Downloading itertools v0.4.18
    
     Downloading url v1.1.1
    
     Downloading libc v0.2.14
    
     Downloading winapi v0.2.8
    
     Downloading kernel32-sys v0.2.2
    
     Downloading winapi-build v0.1.1
    
     Downloading unicode-width v0.1.3
    
     Downloading ansi_term v0.8.0
    
     Downloading bitflags v0.7.0
    
     Downloading vec_map v0.6.0
    
     Downloading term_size v0.1.0
    
     Downloading strsim v0.4.1
    
     Downloading rustc_version v0.1.7
    
     Downloading semver v0.1.20
    
     Downloading backtrace v0.2.3
    
     Downloading dbghelp-sys v0.2.0
    
     Downloading rustc-demangle v0.1.1
    
     Downloading backtrace-sys v0.1.4
    
     Downloading cfg-if v0.1.0
    
     Downloading gcc v0.3.32
    
     Downloading curl v0.3.0
    
     Downloading env_proxy v0.1.1
    
     Downloading hyper v0.9.10
    
     Downloading curl-sys v0.2.0
    
     Downloading libz-sys v1.0.4
    
     Downloading pkg-config v0.3.8
    
     Downloading idna v0.1.0
    
     Downloading matches v0.1.2
    
     Downloading unicode-bidi v0.2.3
    
     Downloading unicode-normalization v0.1.2
    
     Downloading httparse v1.1.2
    
     Downloading log v0.3.6
    
     Downloading cookie v0.2.5
    
     Downloading typeable v0.1.2
    
     Downloading traitobject v0.0.1
    
     Downloading num_cpus v0.2.13
    
     Downloading solicit v0.4.4
    
     Downloading language-tags v0.2.2
    
     Downloading mime v0.2.1
    
     Downloading unicase v1.4.0
    
     Downloading hpack v0.2.0
    
     Downloading utf8-ranges v0.1.3
    
     Downloading memchr v0.1.11
    
     Downloading regex-syntax v0.3.4
    
     Downloading aho-corasick v0.5.2
    
     Downloading thread_local v0.2.6
    
     Downloading thread-id v2.0.0
    
     Downloading tar v0.4.8
    
     Downloading walkdir v0.1.5
    
     Downloading ole32-sys v0.2.0
    
     Downloading flate2 v0.2.14
    
     Downloading filetime v0.1.10
    
     Downloading lazy_static v0.1.16
    
     Downloading wait-timeout v0.1.3
    
     Downloading miniz-sys v0.1.7
    
     Downloading pipeline v0.5.0
    
     Downloading openssl-sys v0.7.14
    
     Downloading openssl v0.7.14
    
     Downloading openssl-verify v0.1.0
    
     Downloading lazy_static v0.2.1
    
     Downloading openssl-sys-extras v0.7.14
    
     Downloading xattr v0.1.8
    
       Compiling itertools v0.4.18
    
       Compiling backtrace v0.2.3
    
       Compiling typeable v0.1.2
    
       Compiling utf8-ranges v0.1.3
    
       Compiling libc v0.2.14
    
       Compiling xattr v0.1.8
    
    error[E0432]: unresolved import `sys::XAttrs`. There is no `XAttrs` in `sys`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:15:9
    
       |
    
    15 | pub use sys::XAttrs;
    
       |         ^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::get_path`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:22:5
    
       |
    
    22 |     sys::get_path(path.as_ref(), name.as_ref())
    
       |     ^^^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::set_path`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:30:5
    
       |
    
    30 |     sys::set_path(path.as_ref(), name.as_ref(), value)
    
       |     ^^^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::remove_path`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:38:5
    
       |
    
    38 |     sys::remove_path(path.as_ref(), name.as_ref())
    
       |     ^^^^^^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::list_path`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:48:5
    
       |
    
    48 |     sys::list_path(path.as_ref())
    
       |     ^^^^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::get_fd`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:56:9
    
       |
    
    56 |         sys::get_fd(self.as_raw_fd(), name.as_ref())
    
       |         ^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::set_fd`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:63:9
    
       |
    
    63 |         sys::set_fd(self.as_raw_fd(), name.as_ref(), value)
    
       |         ^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::remove_fd`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:70:9
    
       |
    
    70 |         sys::remove_fd(self.as_raw_fd(), name.as_ref())
    
       |         ^^^^^^^^^^^^^^
    
    error[E0425]: unresolved name `sys::list_fd`
    
      --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/xattr-0.1.8/src/lib.rs:78:9
    
       |
    
    78 |         sys::list_fd(self.as_raw_fd())
    
       |         ^^^^^^^^^^^^
    
    error: aborting due to 9 previous errors
    
    Build failed, waiting for other jobs to finish...
    
    error: Could not compile `xattr`.
    
    opened by brson 6
  • way to check if xattrs are supported on an FS

    way to check if xattrs are supported on an FS

    would there be any way to check if the underlying fs on linux supports xattrs? using the C fns directly one could check for ENOTSUP but I'm wondering how to check the same with this library https://man7.org/linux/man-pages/man2/getxattr.2.html

    opened by runcom 4
  • lib: please expose list/get/set-xattr methods taking RawFd

    lib: please expose list/get/set-xattr methods taking RawFd

    On linux platforms, I'd need to list/get/set xattr using the file descriptor instead of the fs-path as the object identifier. That is, having access to safe wrappers for flistxattr/fgetxattr/fsetxattr. The usecase is xattr inspection/manipulation of already-opened File objects, when writing library code and when using fd-passing across processes.

    Looking at the source, I just realized those are already implemented internally under sys::linux_macos, but not exported. Would you please consider exposing them as part of this library public API?

    opened by lucab 4
  • name clash with use std::os::unix::fs::FileExt

    name clash with use std::os::unix::fs::FileExt

    if a rust file needs to use both FileExt::write_at/read_at and the raw fd interface in this crate, you get a use clash:

    8  | use std::os::unix::fs::FileExt;
       |     -------------------------- previous import of `FileExt` here
    ...
    13 | use self::xattr::FileExt;
       |     ^^^^^^^^^^^^^^^^^^^^ `FileExt` already imported
    
    opened by kahing 3
  • Run tests on MacOS and fix new get

    Run tests on MacOS and fix new get

    On MacOS getxattr and fgetxattr return ENOATTR as the error code not ENODATA when the attribute is not found. This fixes the problem.

    I also noticed that the tests were disabled on MacOS but they run just fine on my mac so I have enabled them.

    opened by griff 3
  • add Android as supported platform

    add Android as supported platform

    This doesn't get most the tests working, since they rely on paths android doesn't have, but I confirmed locally that if /var/tmp were replaced with a path that exists (and android added to the relevant cfg statements), all the tests do pass.

    opened by jtracey 1
  • Solaris ENOATTR build failure

    Solaris ENOATTR build failure

    The commit https://github.com/Stebalien/xattr/commit/0d637ae981645ac6ae441b42d782aa95cd9b71cf switches to ENOATTR in preference to ENODATA, however this causes the build to fail on Solaris which does not provide ENOATTR. I assume the same will be true of all unsupported platforms.

    error[E0432]: unresolved import `libc::ENOATTR`
     --> vendor/xattr/src/util.rs:8:20
      |
    8 | use libc::{ERANGE, ENOATTR, ssize_t};
      |                    ^^^^^^^ no `ENOATTR` in the root. Did you mean to use `ENOTTY`?
    

    Is the correct fix here to work around it in the module, or add a dummy libc::ENOATTR alias for libc::NODATA to rust?

    opened by jperkin 1
  • Method for optionally getting an attribute

    Method for optionally getting an attribute

    Currently to get an attribute that might not be set on the file i have to either iterate through all the attributes with list or depend on the libc crate and manually handle ENODATA.

    Neither of these options appeal to me and given that rust has the Option type wouldn't it be better if get returned an io::Result<Option<Vec>? Or at least that there was a version of get that returned this type?

    opened by griff 1
  • Add

    Add "support" for unsupported platforms.

    This patch adds a dummy (mock) interface for unsupported platforms that always returns errors. It also allows both compile-time (optional) and runtime detection of unsupported platforms.

    /cc @brson

    opened by Stebalien 1
  • XAttrs keeps iterating eternally when a file has more than one attribute

    XAttrs keeps iterating eternally when a file has more than one attribute

    When calling xattr::list() on a file that has more than one attribute and iterating over the resulting XAttrs object, it stays in the loop for all eternity, stuck on the first entry. Depending on the length of the attribute name, every other iteration may lack the first character.

    The cause of this is in the implementation of the next() function of the Iterator trait for XAttrs. Every time it's called and the end of the list data hasn't been reached yet, it changes the offset like this:

    self.offset = end + 1;
    

    But end here is a position in array that after the first iteration has already been offsetted, so when applied to the array containing the full list data, it ends up going back to an earlier point in the list. This can be fixed by replacing that line with this one:

    self.offset += end + 1;
    
    opened by HetareKing 1
Owner
Steven Allen
Steven Allen
A POSIX select I/O Multiplexing Rust library.

A POSIX select I/O Multiplexing Rust library.

b23r0 4 Jul 6, 2022
Expanding opportunities standard library std::fs and std::io

fs_extra A Rust library that provides additional functionality not present in std::fs. Documentation Migrations to 1.x.x version Key features: Copy fi

Denis Kurilenko 163 Dec 30, 2022
Minty is an amazingly fast file deduplication app built in rust with a rust user interface.

minty Project Minty has a new look and feel!!! Minty is an amazingly fast file deduplication app built in rust with a rust user interface. I say super

null 26 Nov 20, 2022
High level FFI binding around the sys mount & umount2 calls, for Rust

sys-mount High level FFI bindings to the mount and umount2 system calls, for Rust. Examples Mount This is how the mount command could be written with

Pop!_OS 31 Dec 9, 2022
ergonomic paths and files in rust

path_abs: ergonomic paths and files in rust. This library aims to provide ergonomic path and file operations to rust with reasonable performance. See

Rett Berg 45 Oct 29, 2022
Temporary directory management for Rust

tempdir A Rust library for creating a temporary directory and deleting its entire contents when the directory is dropped. Documentation Deprecation No

null 132 Jan 7, 2023
Rust implemention of Ascon

Ascon Pure Rust implementation of the lightweight Authenticated Encryption and Associated Data (AEAD) Ascon-128 and Ascon-128a. Security Notes This cr

Sebastian Ramacher 4 May 28, 2022
Lightweight Google Cloud Storage sync Rust Client with better performance than gsutil rsync

gcs-rsync Lightweight and efficient Rust gcs rsync for Google Cloud Storage. gcs-sync is faster than gsutil rsync when files change a lot while perfor

@cboudereau 4 Sep 8, 2022
Supertag is a tag-based filesystem, written in Rust, for Linux and MacOS

Supertag is a tag-based filesystem, written in Rust, for Linux and MacOS. It provides a tag-based view of your files by removing the hierarchy constraints typically imposed on files and folders. In other words, it allows you to think about your files not as objects stored in folders, but as objects that can be filtered by folders.

Andrew Moffat 539 Dec 24, 2022
🦀 How to minimize Rust binary size 📦

Minimizing Rust Binary Size To help this project reach more users, consider upvoting the min-sized-rust Stack Overflow answer. This repository demonst

null 4.9k Jan 8, 2023
Spacedrive is an open source cross-platform file explorer, powered by a virtual distributed filesystem written in Rust.

Spacedrive A file explorer from the future. spacedrive.com » Download for macOS · Windows · Linux · iOS · watchOS · Android ~ Links will be added once

Spacedrive 16.2k Jan 7, 2023
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Rust Attribute-Based Encryption library rabe's C FFI binding , support CP-ABE and KP-ABE encrypt and decrypt, submodule of Rabe.Core c# library.

Rabe-ffi Rust Attribute-Based Encryption library rabe's C FFI binding , support CP-ABE and KP-ABE encrypt and decrypt, submodule of Rabe.Core c# libra

Aya0wind 2 Oct 10, 2022
rabe is an Attribute Based Encryption library, written in Rust

Rabe rabe is a rust library implementing several Attribute Based Encryption (ABE) schemes using a modified version of the bn library of zcash (type-3

Fraunhofer AISEC 52 Dec 15, 2022
Rust library for HTTP authentication. Parses challenge lists, responds to Basic and Digest challenges. Likely to be extended with server support and additional auth schemes.

Rust library for HTTP authentication. Parses challenge lists, responds to Basic and Digest challenges. Likely to be extended with server support and a

Scott Lamb 3 Jun 10, 2022
"Crates for Cheese" is a Rust collection library of those crates I consider a useful "extended standard".

cfc The purpose of this library is to provide a minimal list of currated crates which enhance the std library. In addition, most or all crates in this

null 0 Dec 23, 2021
Extended precision integer Rust library. Provides signed/unsigned integer 256 to 2048.

Extended precision integer Rust library. Provides signed/unsigned integer 256 to 2048.

Mohanson 4 Jul 28, 2022
A Rust attribute macro to limit a function's number of runs over a specified period of time

throttle_my_fn: A Rust attribute macro to throttle the execution of functions throttle_my_fn is a Rust attribute macro to limit a function's number of

Fred Morcos 8 Dec 3, 2022
A Rust attribute macro that adds memoization to a function (rhymes with Mickey)

michie (sounds like Mickey) — an attribute macro that adds memoization to a function. Table of contents Features Non-features key_expr key_type store_

Mobus Operandi 16 Dec 20, 2022