OpenBSD does not support extended file attributes

This commit is contained in:
Björn Ketelaars 2023-03-25 07:58:23 +01:00
parent e6404f6a45
commit 3d72aee1b2
4 changed files with 20 additions and 11 deletions

View File

@ -91,6 +91,8 @@ rhai = {version = "1.13", features = ["sync", "serde", "no_optimize", "no_module
[target.'cfg(not(windows))'.dependencies] [target.'cfg(not(windows))'.dependencies]
users = "0.11" users = "0.11"
[target.'cfg(not(any(windows, target_os="openbsd")))'.dependencies]
xattr = "1" xattr = "1"
[dev-dependencies] [dev-dependencies]

View File

@ -3,5 +3,6 @@ Changes in version x.x.x:
Breaking changes: Breaking changes:
Bugs fixed: Bugs fixed:
- Fixed compiliation on OpenBSD.
New features: New features:

View File

@ -17,7 +17,7 @@ use serde_with::{serde_as, DisplayFromStr};
#[cfg(not(windows))] #[cfg(not(windows))]
use users::{Groups, Users, UsersCache}; use users::{Groups, Users, UsersCache};
#[cfg(not(windows))] #[cfg(not(any(windows, target_os = "openbsd")))]
use super::node::ExtendedAttribute; use super::node::ExtendedAttribute;
use super::node::{Metadata, NodeType}; use super::node::{Metadata, NodeType};
use super::{Node, ReadSource, ReadSourceEntry, ReadSourceOpen}; use super::{Node, ReadSource, ReadSourceEntry, ReadSourceOpen};
@ -325,15 +325,21 @@ fn map_entry(
let device_id = if ignore_devid { 0 } else { m.dev() }; let device_id = if ignore_devid { 0 } else { m.dev() };
let links = if m.is_dir() { 0 } else { m.nlink() }; let links = if m.is_dir() { 0 } else { m.nlink() };
let path = entry.path(); #[cfg(target_os = "openbsd")]
let extended_attributes = xattr::list(path)? let extended_attributes = vec![];
.map(|name| {
Ok(ExtendedAttribute { #[cfg(not(target_os = "openbsd"))]
name: name.to_string_lossy().to_string(), let extended_attributes = {
value: xattr::get(path, name)?.unwrap(), let path = entry.path();
xattr::list(path)?
.map(|name| {
Ok(ExtendedAttribute {
name: name.to_string_lossy().to_string(),
value: xattr::get(path, name)?.unwrap(),
})
}) })
}) .collect::<Result<_>>()?
.collect::<Result<_>>()?; };
let meta = Metadata { let meta = Metadata {
size, size,

View File

@ -324,7 +324,7 @@ impl LocalDestination {
Ok(()) Ok(())
} }
#[cfg(windows)] #[cfg(any(windows, target_os = "openbsd"))]
pub fn set_extended_attributes( pub fn set_extended_attributes(
&self, &self,
_item: impl AsRef<Path>, _item: impl AsRef<Path>,
@ -333,7 +333,7 @@ impl LocalDestination {
Ok(()) Ok(())
} }
#[cfg(not(windows))] #[cfg(not(any(windows, target_os = "openbsd")))]
pub fn set_extended_attributes( pub fn set_extended_attributes(
&self, &self,
item: impl AsRef<Path>, item: impl AsRef<Path>,