Snap for 9856111 from e9224f1ec417fd8eb4b3d965d1a27c14fed0196e to udc-d1-release

Change-Id: I4e8860208646a90b94160e2506a8a649a446ae40
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
new file mode 100644
index 0000000..c054044
--- /dev/null
+++ b/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+  "git": {
+    "sha1": "cb2cd6d359b715e24144242e4580679897268ffd"
+  },
+  "path_in_vcs": ""
+}
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/blank-issue.md b/.github/ISSUE_TEMPLATE/blank-issue.md
new file mode 100755
index 0000000..8651c00
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/blank-issue.md
@@ -0,0 +1,9 @@
+---
+name: Blank Issue
+about: Create a blank issue.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..7631965
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,39 @@
+name: Rust
+
+on:
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ main ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Build
+      run: cargo build --verbose
+
+    # The github ubuntu-latest is now on linux 5.11 kernel,
+    # so we can test the crate with support for each of the
+    # kernel featuresets:
+
+    - name: Run tests (Linux 4.11 support)
+      run: cargo test --verbose
+    - name: Run tests (Linux 4.14 support)
+      run: cargo test --verbose --features linux4_14
+    - name: Run tests (Linux 5.7 support)
+      run: cargo test --verbose --features linux5_7
+
+  audit:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Install Cargo Audit
+      run: cargo install cargo-audit
+    - name: Audit
+      run: cargo audit
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..954917e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+target/
+**/*.rs.bk
+.google.json
+TAGS
+package
+*.pyc
+core.*
+Cargo.lock
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index e6c9660..b1133c8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -29,7 +29,7 @@
     host_supported: true,
     crate_name: "userfaultfd",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.5.0",
+    cargo_pkg_version: "0.5.1",
     srcs: ["src/lib.rs"],
     edition: "2018",
     features: ["default"],
diff --git a/Cargo.toml b/Cargo.toml
index a188797..c2f042a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,14 +10,14 @@
 # See Cargo.toml.orig for the original contents.
 
 [package]
-name = "userfaultfd"
-version = "0.5.0"
-authors = ["Adam C. Foltzer <acfoltzer@fastly.com>"]
 edition = "2018"
-license = "MIT OR Apache-2.0"
+name = "userfaultfd"
+version = "0.5.1"
+authors = ["The Wasmtime Project Developers"]
 description = "Rust bindings for the Linux userfaultfd functionality"
-repository = "https://github.com/fastly/userfaultfd-rs"
 readme = "README.md"
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/bytecodealliance/userfaultfd-rs"
 
 [dependencies.bitflags]
 version = "1.0"
@@ -29,7 +29,7 @@
 version = "0.2.65"
 
 [dependencies.nix]
-version = "0.23"
+version = "0.26"
 
 [dependencies.thiserror]
 version = "1.0.4"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 153efe6..04c8ca4 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,18 +1,18 @@
 [package]
 name = "userfaultfd"
-version = "0.5.0"
-authors = ["Adam C. Foltzer <acfoltzer@fastly.com>"]
+version = "0.5.1"
+authors = ["The Wasmtime Project Developers"]
 edition = "2018"
 license = "MIT OR Apache-2.0"
 description = "Rust bindings for the Linux userfaultfd functionality"
-repository = "https://github.com/fastly/userfaultfd-rs"
+repository = "https://github.com/bytecodealliance/userfaultfd-rs"
 readme = "README.md"
 
 [dependencies]
 bitflags = "1.0"
 cfg-if = "^1.0.0"
 libc = "0.2.65"
-nix = "0.23"
+nix = "0.26"
 thiserror = "1.0.4"
 userfaultfd-sys = { path = "userfaultfd-sys", version = "^0.4.0" }
 
diff --git a/METADATA b/METADATA
index 9ffa4db..e2181c8 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/userfaultfd
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
 name: "userfaultfd"
 description: "Rust bindings for the Linux userfaultfd functionality"
 third_party {
@@ -7,14 +11,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/userfaultfd/userfaultfd-0.5.0.crate"
+    value: "https://static.crates.io/crates/userfaultfd/userfaultfd-0.5.1.crate"
   }
-  version: "0.5.0"
-  # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same.
+  version: "0.5.1"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2022
-    month: 11
-    day: 16
+    year: 2023
+    month: 3
+    day: 30
   }
 }
diff --git a/examples/manpage.rs b/examples/manpage.rs
index f8d6848..29cccd0 100644
--- a/examples/manpage.rs
+++ b/examples/manpage.rs
@@ -3,9 +3,8 @@
 use nix::poll::{poll, PollFd, PollFlags};
 use nix::sys::mman::{mmap, MapFlags, ProtFlags};
 use nix::unistd::{sysconf, SysconfVar};
-use std::env;
 use std::os::unix::io::AsRawFd;
-use std::ptr;
+use std::{convert::TryInto, env};
 use userfaultfd::{Event, Uffd, UffdBuilder};
 
 fn fault_handler_thread(uffd: Uffd) {
@@ -15,8 +14,8 @@
 
     let page = unsafe {
         mmap(
-            ptr::null_mut(),
-            page_size,
+            None,
+            page_size.try_into().unwrap(),
             ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
             MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS,
             -1,
@@ -64,7 +63,7 @@
             }
             fault_cnt += 1;
 
-            let dst = (addr as usize & !(page_size as usize - 1)) as *mut c_void;
+            let dst = (addr as usize & !(page_size - 1)) as *mut c_void;
             let copy = unsafe { uffd.copy(page, dst, page_size, true).expect("uffd copy") };
 
             println!("        (uffdio_copy.copy returned {})", copy);
@@ -98,8 +97,8 @@
 
     let addr = unsafe {
         mmap(
-            ptr::null_mut(),
-            len,
+            None,
+            len.try_into().unwrap(),
             ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
             MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS,
             -1,