From 5291f8c053223797abc77e9f2d6f70fd027decc0 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Tue, 30 Apr 2024 21:28:31 +0700 Subject: [PATCH 01/20] readme: typo linkify --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 411e8aee..37a76d00 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]. From bb2b3c4174ba4632561d751f44417bd871bafed5 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 1 May 2024 22:34:38 +0700 Subject: [PATCH 02/20] Migrate to 2021 edition --- Cargo.toml | 5 ++--- src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd6a592c..65bfe230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,7 @@ name = "junction" version = "1.1.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 +edition = "2021" rust-version = "1.56" exclude = [ "/.github", @@ -13,7 +12,7 @@ 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] diff --git a/src/lib.rs b/src/lib.rs index fa518329..23951c5a 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_idioms)] mod internals; From 2a2bf9b87492ed70670d1797d04b84db13ae66cd Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 09:29:43 +0700 Subject: [PATCH 03/20] bupmp actions checkout to v4 --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d8f88b6..35fc6b15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: archive: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z mingw_dir: mingw32 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | rustup toolchain install stable-${{ matrix.target }} rustup default stable-${{ matrix.target }} @@ -71,7 +71,7 @@ jobs: # add_of_mut! requires for soundness MSRV: 1.56.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | rustup toolchain install ${{ env.MSRV }} rustup default ${{ env.MSRV }} @@ -84,7 +84,7 @@ jobs: rustfmt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: cargo fmt -- --check rustdoc: @@ -98,7 +98,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | rustup toolchain install nightly rustup default nightly @@ -129,7 +129,7 @@ jobs: env: CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | rustup toolchain install nightly -c clippy rustup default nightly @@ -146,10 +146,10 @@ jobs: 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 From 57405227cf8ed047d1899bd760123b267e1fe0aa Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 09:45:34 +0700 Subject: [PATCH 04/20] ci: env cargo sparse only once --- .github/workflows/ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35fc6b15..933efa59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,15 @@ on: - '!gh-pages' pull_request: +# rust 1.68 +env: + 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 strategy: @@ -67,7 +70,6 @@ jobs: runs-on: windows-latest # needs: [build] env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse # add_of_mut! requires for soundness MSRV: 1.56.0 steps: @@ -126,8 +128,6 @@ jobs: clippy: runs-on: windows-latest needs: [build] - env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse steps: - uses: actions/checkout@v4 - run: | @@ -142,7 +142,6 @@ 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: From 61aec70a72f4de11b5547069fd6169839de3028a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 10:07:06 +0700 Subject: [PATCH 05/20] ci: windows ci: no self update --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 933efa59..7d388507 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - rustup toolchain install stable-${{ matrix.target }} + rustup toolchain install --no-self-update stable-${{ matrix.target }} rustup default stable-${{ matrix.target }} - name: Check out MinGW toolchain run: | @@ -75,7 +75,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - rustup toolchain install ${{ env.MSRV }} + rustup toolchain install --no-self-update ${{ env.MSRV }} rustup default ${{ env.MSRV }} - run: | rustup run stable cargo generate-lockfile @@ -102,7 +102,7 @@ jobs: git config --global core.eol lf - uses: actions/checkout@v4 - run: | - rustup toolchain install nightly + rustup toolchain install --no-self-update nightly rustup default nightly - run: cargo doc --all --no-deps # --document-private-items - run: echo '' > target/doc/index.html @@ -131,7 +131,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - rustup toolchain install nightly -c clippy + rustup toolchain install --no-self-update nightly -c clippy rustup default nightly - run: cargo clippy --all-targets --all-features -- -Dwarnings -A clippy::assertions-on-constants @@ -156,7 +156,7 @@ jobs: shell: bash run: | # Toolchain setup - rustup toolchain install ${{ env.MSRV }} -c rustc-dev -c miri + rustup toolchain install --no-self-update ${{ env.MSRV }} -c rustc-dev -c miri rustup default ${{ env.MSRV }} rustup target add ${{ env.WIN_TARGET }} From f918c52e59a93e4e40497058a97a0b50679fec75 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 10:08:42 +0700 Subject: [PATCH 06/20] deny 2021 compability lints --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 23951c5a..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_2021_idioms)] +#![deny(rust_2021_compatibility)] mod internals; From f7c043bd4372bfe0076eaa0841a8a45e7653d8d5 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 11:30:24 +0700 Subject: [PATCH 07/20] ci: use actions/deploy pages --- .github/workflows/ci.yml | 47 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d388507..a10ebee3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,10 +91,6 @@ jobs: 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: | @@ -106,24 +102,31 @@ jobs: 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: + name: github-pages + path: target/doc + retention-days: 1 + + deploy: + if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master' + # 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 + # Deploy to the github-pages environment + # environment: + # name: github-pages + # url: ${{ steps.deployment.outputs.page_url }} + needs: [rustdoc] + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + with: + artifact_name: github-pages clippy: runs-on: windows-latest From d37396c3bdc8b5d89b7aafeb8eca0668d0dc0396 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 19:39:52 +0700 Subject: [PATCH 08/20] simplifying const asserts --- src/internals/c.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internals/c.rs b/src/internals/c.rs index 30deb605..7ddfc798 100644 --- a/src/internals/c.rs +++ b/src/internals/c.rs @@ -36,8 +36,8 @@ 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]; + [(); 1][std_layout.size() - win_sys_layout.size()]; + [(); 1][std_layout.align() - win_sys_layout.align()]; }; // NOTE: to use `size_of` operator, below structs should be packed. From 37b3e6325edf7d8d9fac8bd4e4d0f939a18e1bc4 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 19:53:56 +0700 Subject: [PATCH 09/20] ci: fetch before build --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a10ebee3..c05f5d6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,7 @@ jobs: 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 From 317e1086fe1400eb0d1398668c9ff05cf16e428a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 12 May 2024 19:54:23 +0700 Subject: [PATCH 10/20] ci: pages: rm unused parts --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c05f5d6c..de9a8bef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,6 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - name: github-pages path: target/doc retention-days: 1 @@ -116,18 +115,11 @@ jobs: permissions: pages: write # to deploy to Pages id-token: write # to verify the deployment originates from an appropriate source - # Deploy to the github-pages environment - # environment: - # name: github-pages - # url: ${{ steps.deployment.outputs.page_url }} needs: [rustdoc] runs-on: ubuntu-latest steps: - name: Deploy to GitHub Pages - id: deployment uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages clippy: runs-on: windows-latest From fce87aac889bbaa774fe7ef9a472eff3ba4f3694 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Tue, 14 May 2024 01:02:22 +0700 Subject: [PATCH 11/20] no rustup self-update --- .github/workflows/ci.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de9a8bef..dd293666 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,8 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - rustup toolchain install --no-self-update stable-${{ matrix.target }} + rustup set auto-self-update disable + rustup toolchain install stable-${{ matrix.target }} rustup default stable-${{ matrix.target }} - name: Check out MinGW toolchain run: | @@ -76,10 +77,10 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - rustup toolchain install --no-self-update ${{ env.MSRV }} + 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 @@ -99,7 +100,8 @@ jobs: git config --global core.eol lf - uses: actions/checkout@v4 - run: | - rustup toolchain install --no-self-update nightly + 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 @@ -127,7 +129,8 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - rustup toolchain install --no-self-update nightly -c clippy + 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 @@ -152,7 +155,8 @@ jobs: shell: bash run: | # Toolchain setup - rustup toolchain install --no-self-update ${{ env.MSRV }} -c rustc-dev -c miri + 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 }} From c3d6518a2980178541020f0b7eeff1886dc64f95 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 19 May 2024 01:29:08 +0700 Subject: [PATCH 12/20] ci: update mingw from 6.3.0 to 12.2.0 --- .github/workflows/ci.yml | 19 +++++++++++++------ Cargo.toml | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd293666..1039eab4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,8 @@ on: - '!gh-pages' pull_request: -# rust 1.68 env: + # rust 1.68 CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse jobs: @@ -16,17 +16,22 @@ jobs: runs-on: windows-latest env: RUST_BACKTRACE: 1 - 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: i686-12.2.0-release-posix-dwarf-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: x86_64-12.2.0-release-posix-seh-rt_v10-rev0.7z mingw_dir: mingw32 steps: - uses: actions/checkout@v4 @@ -37,8 +42,9 @@ jobs: - name: Check out MinGW toolchain 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 + ls -l "/c/mingw/${{ matrix.mingw_dir }}/bin" rm "${{ matrix.archive }}" echo "C:\mingw\${{ matrix.mingw_dir }}\bin" >> $GITHUB_PATH shell: bash @@ -132,6 +138,7 @@ jobs: rustup set auto-self-update disable rustup toolchain install nightly -c clippy rustup default nightly + - run: cargo fetch - run: cargo clippy --all-targets --all-features -- -Dwarnings -A clippy::assertions-on-constants diff --git a/Cargo.toml b/Cargo.toml index 65bfe230..7fc6481e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,8 @@ description = "library for working with NTFS junctions" [features] default = ["unstable_admin"] +# # Unstable flag +# # Flag for trying out new rust language features nightly = [] # # Unstable flag From 408f562381d25daca5b7a17aa76fab397b29f32f Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 19 May 2024 01:50:50 +0700 Subject: [PATCH 13/20] chore: edit more comments about clippy --- .github/workflows/ci.yml | 3 +-- src/internals/c.rs | 4 ++-- src/internals/helpers.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1039eab4..6bc227f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,8 +139,7 @@ jobs: rustup toolchain install nightly -c clippy rustup default nightly - run: cargo fetch - - run: cargo clippy --all-targets --all-features -- -Dwarnings -A clippy::assertions-on-constants - + - run: cargo clippy --all-targets --all-features -- -Dwarnings # Use static analyzer Rudra . # FIXME: Disable for now since it's very costly to run. diff --git a/src/internals/c.rs b/src/internals/c.rs index 7ddfc798..3cd1ee1f 100644 --- a/src/internals/c.rs +++ b/src/internals/c.rs @@ -30,12 +30,11 @@ 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 + // MSRV(Rust v1.57): use assert! instead [(); 1][std_layout.size() - win_sys_layout.size()]; [(); 1][std_layout.align() - win_sys_layout.align()]; }; @@ -49,6 +48,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/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 }; From 3dfac3a3220e63b1e5a908d1f5dcddd1da5c77b2 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 31 May 2024 09:36:46 +0700 Subject: [PATCH 14/20] ci: Fix wrong order of mingw artifacts --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bc227f8..1e17af2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,10 @@ jobs: - i686-pc-windows-gnu include: - target: x86_64-pc-windows-gnu - archive: i686-12.2.0-release-posix-dwarf-rt_v10-rev0.7z + archive: x86_64-12.2.0-release-posix-seh-rt_v10-rev0.7z mingw_dir: mingw64 - target: i686-pc-windows-gnu - archive: x86_64-12.2.0-release-posix-seh-rt_v10-rev0.7z + archive: i686-12.2.0-release-posix-dwarf-rt_v10-rev0.7z mingw_dir: mingw32 steps: - uses: actions/checkout@v4 @@ -44,8 +44,8 @@ jobs: set -x curl -sSf -O "$MIRRORS_BASE/${{ matrix.archive }}" 7z x -y "${{ matrix.archive }}" -o/c/mingw - ls -l "/c/mingw/${{ matrix.mingw_dir }}/bin" 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 From b97670f92eb5e5a0fd0fb80c0bfe12b6e9da836e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 31 May 2024 09:46:31 +0700 Subject: [PATCH 15/20] lock file maintenance --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c29dd169..8a633159 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", @@ -48,15 +48,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[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" From 3e9e2fbe5f5fa6fce1e715d009a337ddba60f620 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 31 May 2024 09:57:05 +0700 Subject: [PATCH 16/20] ci: mingw: use rust-mingw --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e17af2f..1c697d46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,10 @@ jobs: 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 "$MIRRORS_BASE/${{ matrix.archive }}" @@ -48,7 +52,6 @@ jobs: 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 From 29c738249e09ff815204b58be57f6387d5cea80b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 31 May 2024 10:00:25 +0700 Subject: [PATCH 17/20] ci/deploy-pages: typo after renaming branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c697d46..cc8956db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,7 @@ jobs: retention-days: 1 deploy: - if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master' + 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 From d93617db134bbb89014139135df609a0a23bda28 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 8 Sep 2024 02:15:15 +0700 Subject: [PATCH 18/20] chore: Minor refactoring for pointers --- src/internals.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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); From 4b28cfa57df1cac29be20ff99207f66e16599f6e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 8 Sep 2024 02:17:42 +0700 Subject: [PATCH 19/20] use assert! in const --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 7 ++++++- Cargo.lock | 2 +- Cargo.toml | 4 ++-- README.md | 2 +- src/internals/c.rs | 5 ++--- src/internals/c/nightly.rs | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc8956db..fe26eaab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,8 +81,8 @@ jobs: runs-on: windows-latest # needs: [build] env: - # add_of_mut! requires for soundness - MSRV: 1.56.0 + # assert! in consts + MSRV: 1.57.0 steps: - uses: actions/checkout@v4 - run: | 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 8a633159..56e89546 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "junction" -version = "1.1.0" +version = "1.2.0" dependencies = [ "rustix", "scopeguard", diff --git a/Cargo.toml b/Cargo.toml index 7fc6481e..bc97f453 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +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"] edition = "2021" -rust-version = "1.56" +rust-version = "1.57" exclude = [ "/.github", "/HOW-TO-RELEASE.md", diff --git a/README.md b/README.md index 37a76d00..5623c349 100644 --- a/README.md +++ b/README.md @@ -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/c.rs b/src/internals/c.rs index 3cd1ee1f..77dba339 100644 --- a/src/internals/c.rs +++ b/src/internals/c.rs @@ -34,9 +34,8 @@ pub use windows_sys::Win32::System::IO::DeviceIoControl; const _: () = { let std_layout = Layout::new::(); let win_sys_layout = Layout::new::(); - // MSRV(Rust v1.57): use assert! instead - [(); 1][std_layout.size() - win_sys_layout.size()]; - [(); 1][std_layout.align() - win_sys_layout.align()]; + 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. 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; From bc38fdef745af6ac34332db3d4e7bad82d4ec8d0 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 8 Sep 2024 02:23:31 +0700 Subject: [PATCH 20/20] bump devs --- Cargo.lock | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56e89546..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" @@ -32,9 +32,9 @@ 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" @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "linux-raw-sys" @@ -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"