aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-08-17 21:09:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-08-17 21:09:41 +0000
commitd7c4e7deaf6c7143bc38b3ea3046469a1cfc95c0 (patch)
tree95f7f0dd3c17718f17bccd6cf62a31b5cc95fd41
parentbf9eff4d9b683344456d37f9ccbd16ca69938102 (diff)
parent937e66d2899061b5b2d34c8c98a32144ee48de47 (diff)
downloadcommand-fds-d7c4e7deaf6c7143bc38b3ea3046469a1cfc95c0.tar.gz
Upgrade rust/crates/command-fds to 0.2.1 am: 937e66d289
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/command-fds/+/1796669 Change-Id: Id4ec4dd1adc472ac1d019d8c0a0a4b3a590c74e7
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp16
-rw-r--r--Cargo.toml4
-rw-r--r--Cargo.toml.orig4
-rw-r--r--METADATA8
-rw-r--r--src/lib.rs22
6 files changed, 25 insertions, 31 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 111ab26..eb2050d 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "5fe7a67415bd0559fee13392880fd6e4aceeb922"
+ "sha1": "cb5819f26b7e1b2eab75994bdd73309ef2859df7"
}
}
diff --git a/Android.bp b/Android.bp
index 42b61df..dc2ad2d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -22,6 +22,8 @@ rust_library {
name: "libcommand_fds",
host_supported: true,
crate_name: "command_fds",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.2.1",
srcs: ["src/lib.rs"],
edition: "2018",
rustlibs: [
@@ -35,13 +37,15 @@ rust_library {
}
// dependent_library ["feature_list"]
+// autocfg-1.0.1
// bitflags-1.2.1 "default"
// cfg-if-1.0.0
-// libc-0.2.97 "default,extra_traits,std"
-// nix-0.20.0
-// proc-macro2-1.0.27 "default,proc-macro"
+// libc-0.2.99 "default,extra_traits,std"
+// memoffset-0.6.4 "default"
+// nix-0.22.1
+// proc-macro2-1.0.28 "default,proc-macro"
// quote-1.0.9 "default,proc-macro"
-// syn-1.0.73 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
-// thiserror-1.0.25
-// thiserror-impl-1.0.25
+// syn-1.0.74 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+// thiserror-1.0.26
+// thiserror-impl-1.0.26
// unicode-xid-0.2.2 "default"
diff --git a/Cargo.toml b/Cargo.toml
index f6f0c8c..1d72a8c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "command-fds"
-version = "0.2.0"
+version = "0.2.1"
authors = ["Andrew Walbran <qwandor@google.com>"]
description = "A library for passing arbitrary file descriptors when spawning child processes."
keywords = ["command", "process", "child", "subprocess", "fd"]
@@ -21,7 +21,7 @@ categories = ["os::unix-apis"]
license = "Apache-2.0"
repository = "https://github.com/google/command-fds/"
[dependencies.nix]
-version = "0.20.0"
+version = "0.22.0"
[dependencies.thiserror]
version = "1.0.24"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 9de1d83..15a6874 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "command-fds"
-version = "0.2.0"
+version = "0.2.1"
edition = "2018"
authors = ["Andrew Walbran <qwandor@google.com>"]
license = "Apache-2.0"
@@ -10,5 +10,5 @@ keywords = ["command", "process", "child", "subprocess", "fd"]
categories = ["os::unix-apis"]
[dependencies]
-nix = "0.20.0"
+nix = "0.22.0"
thiserror = "1.0.24"
diff --git a/METADATA b/METADATA
index 35b27e9..9ed08b1 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/command-fds/command-fds-0.2.0.crate"
+ value: "https://static.crates.io/crates/command-fds/command-fds-0.2.1.crate"
}
- version: "0.2.0"
+ version: "0.2.1"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 6
- day: 21
+ month: 8
+ day: 16
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 2435983..2dfb63f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -51,7 +51,7 @@
use nix::fcntl::{fcntl, FcntlArg, FdFlag};
use nix::unistd::dup2;
use std::cmp::max;
-use std::io::{self, ErrorKind};
+use std::io;
use std::os::unix::io::RawFd;
use std::os::unix::process::CommandExt;
use std::process::Command;
@@ -142,8 +142,7 @@ fn map_fds(mappings: &mut [FdMapping], child_fds: &[RawFd]) -> io::Result<()> {
// removing the FD_CLOEXEC flag from the existing (parent) FD.
for mapping in mappings.iter_mut() {
if child_fds.contains(&mapping.parent_fd) && mapping.parent_fd != mapping.child_fd {
- mapping.parent_fd = fcntl(mapping.parent_fd, FcntlArg::F_DUPFD_CLOEXEC(first_safe_fd))
- .map_err(nix_to_io_error)?;
+ mapping.parent_fd = fcntl(mapping.parent_fd, FcntlArg::F_DUPFD_CLOEXEC(first_safe_fd))?;
}
}
@@ -152,12 +151,11 @@ fn map_fds(mappings: &mut [FdMapping], child_fds: &[RawFd]) -> io::Result<()> {
if mapping.child_fd == mapping.parent_fd {
// Remove the FD_CLOEXEC flag, so the FD will be kept open when exec is called for the
// child.
- fcntl(mapping.parent_fd, FcntlArg::F_SETFD(FdFlag::empty()))
- .map_err(nix_to_io_error)?;
+ fcntl(mapping.parent_fd, FcntlArg::F_SETFD(FdFlag::empty()))?;
} else {
// This closes child_fd if it is already open as something else, and clears the
// FD_CLOEXEC flag on child_fd.
- dup2(mapping.parent_fd, mapping.child_fd).map_err(nix_to_io_error)?;
+ dup2(mapping.parent_fd, mapping.child_fd)?;
}
}
@@ -168,21 +166,12 @@ fn preserve_fds(fds: &[RawFd]) -> io::Result<()> {
for fd in fds {
// Remove the FD_CLOEXEC flag, so the FD will be kept open when exec is called for the
// child.
- fcntl(*fd, FcntlArg::F_SETFD(FdFlag::empty())).map_err(nix_to_io_error)?;
+ fcntl(*fd, FcntlArg::F_SETFD(FdFlag::empty()))?;
}
Ok(())
}
-/// Convert a [`nix::Error`] to a [`std::io::Error`].
-fn nix_to_io_error(error: nix::Error) -> io::Error {
- if let nix::Error::Sys(errno) = error {
- io::Error::from_raw_os_error(errno as i32)
- } else {
- io::Error::new(ErrorKind::Other, error)
- }
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -287,6 +276,7 @@ mod tests {
let file = File::open("testdata/file1.txt").unwrap();
let file_fd = file.as_raw_fd();
command.preserved_fds(vec![file_fd]);
+ assert!(file_fd > 3);
let output = command.output().unwrap();
expect_fds(&output, &[0, 1, 2, 3, file_fd], 0);