Skip to content

Commit 25f9b81

Browse files
committed
etc-merge: Minor cleanups to lsetxattr
- Use &Path and not &PathBuf per general style - Include info about which xattr failed - Consistently use with_context + format! Signed-off-by: Colin Walters <[email protected]>
1 parent b010983 commit 25f9b81

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

crates/etc-merge/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,11 @@ fn collect_xattrs(etc_fd: &CapStdDir, rel_path: impl AsRef<Path>) -> anyhow::Res
418418
}
419419

420420
#[context("Copying xattrs")]
421-
fn copy_xattrs(xattrs: &Xattrs, new_etc_fd: &CapStdDir, file: &PathBuf) -> anyhow::Result<()> {
421+
fn copy_xattrs(xattrs: &Xattrs, new_etc_fd: &CapStdDir, path: &Path) -> anyhow::Result<()> {
422422
for (attr, value) in xattrs.borrow().iter() {
423-
let path = Path::new(&format!("/proc/self/fd/{}", new_etc_fd.as_raw_fd())).join(file);
424-
425-
lsetxattr(path, attr.as_ref(), value, XattrFlags::empty())
426-
.context(format!("setxattr for {file:?}"))?;
423+
let fdpath = &Path::new(&format!("/proc/self/fd/{}", new_etc_fd.as_raw_fd())).join(path);
424+
lsetxattr(fdpath, attr.as_ref(), value, XattrFlags::empty())
425+
.with_context(|| format!("setxattr {attr:?} for {fdpath:?}"))?;
427426
}
428427

429428
Ok(())

0 commit comments

Comments
 (0)