diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d8f88b6..fe26eaab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,38 +7,52 @@ on: - '!gh-pages' pull_request: +env: + # rust 1.68 + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + jobs: build: runs-on: windows-latest env: RUST_BACKTRACE: 1 - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse - MINGW_URL: https://ci-mirrors.rust-lang.org/rustc MIRIFLAGS: -Zmiri-disable-isolation + # taken from . + MIRRORS_BASE: https://ci-mirrors.rust-lang.org/rustc strategy: matrix: - target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, x86_64-pc-windows-gnu, i686-pc-windows-gnu] + target: + - x86_64-pc-windows-msvc + - i686-pc-windows-msvc + - x86_64-pc-windows-gnu + - i686-pc-windows-gnu include: - target: x86_64-pc-windows-gnu - archive: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z + archive: x86_64-12.2.0-release-posix-seh-rt_v10-rev0.7z mingw_dir: mingw64 - target: i686-pc-windows-gnu - archive: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z + archive: i686-12.2.0-release-posix-dwarf-rt_v10-rev0.7z mingw_dir: mingw32 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | + rustup set auto-self-update disable rustup toolchain install stable-${{ matrix.target }} rustup default stable-${{ matrix.target }} - name: Check out MinGW toolchain + # NOTE: The self-contained rust-mingw is enough for linking to Windows. + # Full MinGW toolchain is only needed when compiling C code. + #if: matrix.mingw_dir + if: false run: | set -x - curl -sSf -O "${MINGW_URL}/${{ matrix.archive }}" + curl -sSf -O "$MIRRORS_BASE/${{ matrix.archive }}" 7z x -y "${{ matrix.archive }}" -o/c/mingw rm "${{ matrix.archive }}" + ls -l "/c/mingw/${{ matrix.mingw_dir }}/bin" echo "C:\mingw\${{ matrix.mingw_dir }}\bin" >> $GITHUB_PATH shell: bash - if: matrix.mingw_dir + - run: cargo fetch - run: cargo build - run: cargo build --features nightly - run: cargo build --all-targets @@ -67,16 +81,15 @@ jobs: runs-on: windows-latest # needs: [build] env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse - # add_of_mut! requires for soundness - MSRV: 1.56.0 + # assert! in consts + MSRV: 1.57.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | + rustup set auto-self-update disable rustup toolchain install ${{ env.MSRV }} rustup default ${{ env.MSRV }} - run: | - rustup run stable cargo generate-lockfile rustup run stable cargo fetch - run: | cargo build --locked @@ -84,57 +97,52 @@ jobs: rustfmt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: cargo fmt -- --check rustdoc: runs-on: windows-latest - env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse - if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master' - needs: [build] steps: - name: Before checking out source and change \n -> \r\n run: | git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | + rustup set auto-self-update disable rustup toolchain install nightly rustup default nightly - run: cargo doc --all --no-deps # --document-private-items - run: echo '' > target/doc/index.html - - name: Commit docs to gh-pages branch - working-directory: target/doc - run: | - # Bypassing Jekyll on GitHub Pages - touch .nojekyll - REV=$(git rev-parse --short HEAD) - git init - git config user.name "Actions" - git config user.email "" - git add -A . - # git add --renormalize . - git commit -qm "Documentation for ${{github.repository}}@${REV}" - shell: bash - - name: Push gh-pages to GitHub - working-directory: target/doc - run: | - git remote add upstream https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} - git push -q upstream HEAD:gh-pages --force + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: target/doc + retention-days: 1 + + deploy: + if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/main' + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + needs: [rustdoc] + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 clippy: runs-on: windows-latest needs: [build] - env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | + rustup set auto-self-update disable rustup toolchain install nightly -c clippy rustup default nightly - - run: cargo clippy --all-targets --all-features -- -Dwarnings -A clippy::assertions-on-constants - + - run: cargo fetch + - run: cargo clippy --all-targets --all-features -- -Dwarnings # Use static analyzer Rudra . # FIXME: Disable for now since it's very costly to run. @@ -142,14 +150,13 @@ jobs: if: false runs-on: ubuntu-latest env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse MSRV: nightly-2021-08-20 WIN_TARGET: x86_64-pc-windows-gnu steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: junction - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: sslab-gatech/Rudra path: Rudra @@ -157,6 +164,7 @@ jobs: shell: bash run: | # Toolchain setup + rustup set auto-self-update disable rustup toolchain install ${{ env.MSRV }} -c rustc-dev -c miri rustup default ${{ env.MSRV }} rustup target add ${{ env.WIN_TARGET }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f72b162..45558331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `Fixed` for any bug fixes. * `Security` in case of vulnerabilities. --> +## [v1.2.0] - 2024-09-08 +### Change MSRV from 1.56 to 1.57 +Minor refactorings to abuse assertions in constants that Rust 1.57.0 allows. + ## [v1.1.0] - 2024-04-30 ### Change MSRV from 1.51 to 1.56 @@ -62,7 +66,8 @@ It signals that the API is mature enough to be stable for a long time. First release -[v1.0.0]: https://github.com/lzutao/junction/compare/v1.0.0...v1.1.0 +[v1.2.0]: https://github.com/lzutao/junction/compare/v1.1.0...v1.2.0 +[v1.1.0]: https://github.com/lzutao/junction/compare/v1.0.0...v1.1.0 [v1.0.0]: https://github.com/lzutao/junction/compare/v0.2.1...v1.0.0 [v0.2.1]: https://github.com/lzutao/junction/compare/v0.2.0...v0.2.1 [v0.2.0]: https://github.com/lzutao/junction/compare/v0.1.0...v0.2.0 diff --git a/Cargo.lock b/Cargo.lock index c29dd169..617e5054 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "cfg-if" @@ -22,9 +22,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -32,13 +32,13 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "junction" -version = "1.1.0" +version = "1.2.0" dependencies = [ "rustix", "scopeguard", @@ -48,15 +48,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "redox_syscall" @@ -73,7 +73,7 @@ version = "0.38.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -114,7 +114,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -134,18 +134,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -156,9 +156,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -168,9 +168,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -180,15 +180,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -198,9 +198,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -210,9 +210,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -222,9 +222,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -234,6 +234,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index fd6a592c..bc97f453 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,10 @@ [package] name = "junction" -version = "1.1.0" # Also update `html_root_url` in lib.rs +version = "1.2.0" # Also update `html_root_url` in lib.rs authors = ["Lzu Tao "] categories = ["api-bindings", "os::windows-apis"] -documentation = "https://docs.rs/junction/*/x86_64-pc-windows-msvc/junction/" -edition = "2018" # edition 2021 released in 1.56.0 -rust-version = "1.56" +edition = "2021" +rust-version = "1.57" exclude = [ "/.github", "/HOW-TO-RELEASE.md", @@ -13,11 +12,13 @@ exclude = [ keywords = ["junction", "symlink"] license = "MIT" readme = "README.md" -repository = "https://github.com/lzutao/junction" +repository = "https://github.com/tesuji/junction" description = "library for working with NTFS junctions" [features] default = ["unstable_admin"] +# # Unstable flag +# # Flag for trying out new rust language features nightly = [] # # Unstable flag diff --git a/README.md b/README.md index 411e8aee..5623c349 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Library for working with [NTFS junctions][junction]. -As opposed to symlinks, junction does not require administrator privileges during creation.[perm] +As opposed to symlinks, junction does not require [administrator privileges during creation][perm]. (*However starting with Windows 10 Insiders build 14972, symlinks can be created without needing to elevate the console as administrator*)[^1][improvement]. @@ -22,7 +22,7 @@ Quoted from [Computer Hope](https://www.computerhope.com/jargon/j/junction.htm): ### Minimal Supported Rust versions -1.56.0 +1.57.0 ## All relevant references diff --git a/src/internals.rs b/src/internals.rs index 6fe7dbd0..1ec68b7c 100644 --- a/src/internals.rs +++ b/src/internals.rs @@ -60,21 +60,17 @@ pub fn create(target: &Path, junction: &Path) -> io::Result<()> { addr_of_mut!((*rdb).ReparseBuffer.PrintNameOffset).write(target_len_in_bytes + UNICODE_NULL_SIZE); addr_of_mut!((*rdb).ReparseBuffer.PrintNameLength).write(0); + let mut path_buffer_ptr: *mut u16 = addr_of_mut!((*rdb).ReparseBuffer.PathBuffer).cast(); // Safe because we checked `MAX_AVAILABLE_PATH_BUFFER` copy_nonoverlapping( NON_INTERPRETED_PATH_PREFIX.as_ptr(), - addr_of_mut!((*rdb).ReparseBuffer.PathBuffer).cast::(), + path_buffer_ptr, NON_INTERPRETED_PATH_PREFIX.len(), ); // TODO: Do we need to write the NULL-terminator byte? // It looks like libuv does that. - copy_nonoverlapping( - target.as_ptr(), - addr_of_mut!((*rdb).ReparseBuffer.PathBuffer) - .cast::() - .add(NON_INTERPRETED_PATH_PREFIX.len()), - target.len(), - ); + path_buffer_ptr = path_buffer_ptr.add(NON_INTERPRETED_PATH_PREFIX.len()); + copy_nonoverlapping(target.as_ptr(), path_buffer_ptr, target.len()); // Set the total size of the data buffer let size = target_len_in_bytes.wrapping_add(c::MOUNT_POINT_REPARSE_BUFFER_HEADER_SIZE + 2 * UNICODE_NULL_SIZE); diff --git a/src/internals/c.rs b/src/internals/c.rs index 30deb605..77dba339 100644 --- a/src/internals/c.rs +++ b/src/internals/c.rs @@ -30,14 +30,12 @@ pub use windows_sys::Win32::System::IO::DeviceIoControl; // Makes sure layout of RawHandle and windows-sys's HANDLE are the same // for pointer casts between them. -// CLIPPY: nonsense suggestions for assert! #[allow(clippy::unnecessary_operation)] const _: () = { let std_layout = Layout::new::(); let win_sys_layout = Layout::new::(); - // MSVR(Rust v1.57): use assert! instead - [(); 1][!(std_layout.size() == win_sys_layout.size()) as usize]; - [(); 1][!(std_layout.align() == win_sys_layout.align()) as usize]; + assert!(std_layout.size() == win_sys_layout.size()); + assert!(std_layout.align() == win_sys_layout.align()); }; // NOTE: to use `size_of` operator, below structs should be packed. @@ -49,6 +47,7 @@ pub const REPARSE_GUID_DATA_BUFFER_HEADER_SIZE: u16 = 24; pub const MOUNT_POINT_REPARSE_BUFFER_HEADER_SIZE: u16 = 8; #[cfg(feature = "nightly")] +#[allow(clippy::assertions_on_constants)] const _: () = { assert!(REPARSE_DATA_BUFFER_HEADER_SIZE == nightly::REPARSE_DATA_BUFFER_HEADER_SIZE); assert!(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE == nightly::REPARSE_GUID_DATA_BUFFER_HEADER_SIZE); diff --git a/src/internals/c/nightly.rs b/src/internals/c/nightly.rs index 90591e5a..0b4d9503 100644 --- a/src/internals/c/nightly.rs +++ b/src/internals/c/nightly.rs @@ -1,4 +1,4 @@ -#![allow(unused)] +#![expect(unused)] use std::mem::offset_of; diff --git a/src/internals/helpers.rs b/src/internals/helpers.rs index 7b74c538..c2ce23d0 100644 --- a/src/internals/helpers.rs +++ b/src/internals/helpers.rs @@ -50,7 +50,7 @@ fn set_privilege(write: bool) -> io::Result<()> { c::SE_BACKUP_NAME } } else { - // FSCTL_SET_REPARSE_POINT requires SE_CREATE_SYMBOLIC_LINK_NAME privilege + // FSCTL_SET_REPARSE_POINT requires below privilege. // Ref c::SE_CREATE_SYMBOLIC_LINK_NAME }; diff --git a/src/lib.rs b/src/lib.rs index fa518329..8552d9b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ an application accessing `D:\SYMLINK\DRIVERS` would in reality be accessing */ #![doc(html_root_url = "https://docs.rs/junction/~1")] #![cfg(windows)] -#![deny(rust_2018_idioms)] +#![deny(rust_2021_compatibility)] mod internals;