Upgrade rust/crates/command-fds to 0.2.1

Test: make
Change-Id: I39ad840264791f20474a0e5b0f9fdb674d1066d9
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 @@
     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 @@
 }
 
 // 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 @@
 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 @@
 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 @@
   }
   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 @@
     // 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 @@
         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 @@
     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 @@
         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);