Skip to content

Define more ioctl codes on riscv32gc-unknown-linux-gnu #4382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

sunfishcode
Copy link
Member

Description

Define ioctl codes including FICLONE and FS_IOC32_GETVERSION on riscv32gc-unknown-linux-gnu.

Sources

The values match the values in the linux-raw-sys crate, which is autogenerated from Linux sources:

https://github.com/sunfishcode/linux-raw-sys/blob/21a3b3b1fada619179810ca92404690d45890f29/src/riscv32/ioctl.rs#L248

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Copy link
Contributor

@kraj kraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why these are gated in the first place? All of the constants are in https://github.com/torvalds/linux/blob/bec7dcbc242c6c087cede1a6fdfaeb5d6eaf25bf/include/uapi/linux/fs.h, I don't know why any platforms wouldn't have them unless they have no fs support.

In any case LGTM, blocked on CI issues.

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Apr 8, 2025
@kraj
Copy link
Contributor

kraj commented Apr 8, 2025

Any idea why these are gated in the first place? All of the constants are in https://github.com/torvalds/linux/blob/bec7dcbc242c6c087cede1a6fdfaeb5d6eaf25bf/include/uapi/linux/fs.h, I don't know why any platforms wouldn't have them unless they have no fs support.

they all do exist but values are different sadly

In any case LGTM, blocked on CI issues.

@tgross35
Copy link
Contributor

tgross35 commented Apr 8, 2025

they all do exist but values are different sadly

Oh, from differences in sizes passed to _IOR and _IOW? We actually have these functions now, the cfg could probably just be deleted and replaced with calls

/// Build an ioctl number, analogous to the C macro of the same name.
const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> u32 {
// FIXME(ctest) the `garando_syntax` crate (used by ctest in the CI test suite)
// cannot currently parse these `debug_assert!`s
//
// debug_assert!(dir <= _IOC_DIRMASK);
// debug_assert!(ty <= _IOC_TYPEMASK);
// debug_assert!(nr <= _IOC_NRMASK);
// debug_assert!(size <= (_IOC_SIZEMASK as usize));
(dir << _IOC_DIRSHIFT)
| (ty << _IOC_TYPESHIFT)
| (nr << _IOC_NRSHIFT)
| ((size as u32) << _IOC_SIZESHIFT)
}
/// Build an ioctl number for an argumentless ioctl.
pub const fn _IO(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_NONE, ty, nr, 0)
}
/// Build an ioctl number for an read-only ioctl.
pub const fn _IOR<T>(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_READ, ty, nr, size_of::<T>())
}
/// Build an ioctl number for an write-only ioctl.
pub const fn _IOW<T>(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_WRITE, ty, nr, size_of::<T>())
}
/// Build an ioctl number for a read-write ioctl.
pub const fn _IOWR<T>(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::<T>())
}
.

@tgross35
Copy link
Contributor

tgross35 commented Apr 8, 2025

Actually @sunfishcode would you mind just changing the relevant blocks to make use of those instead? I think we may as well use this as an excuse to get rid of some pre-const fn cruft.

Define ioctl codes including `FICLONE` and `FS_IOC32_GETVERSION` using
`_IOR` and `_IOW` so that they're automatically supported on all
architectures, including riscv32gc-unknown-linux-gnu.
@sunfishcode sunfishcode force-pushed the sunfishcode/riscv32-ioctls branch from 20a1dff to 4b439b0 Compare April 9, 2025 12:59
@sunfishcode
Copy link
Member Author

@tgross35 Done.

Copy link
Contributor

@kraj kraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great cleanup, thanks!

@tgross35 tgross35 added this pull request to the merge queue Apr 9, 2025
Merged via the queue into rust-lang:main with commit 057bb14 Apr 9, 2025
44 of 45 checks passed
@sunfishcode sunfishcode deleted the sunfishcode/riscv32-ioctls branch April 9, 2025 18:12
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Apr 11, 2025
Define ioctl codes including `FICLONE` and `FS_IOC32_GETVERSION` using
`_IOR` and `_IOW` so that they're automatically supported on all
architectures, including riscv32gc-unknown-linux-gnu.

(backport <rust-lang#4382>)
(cherry picked from commit 4b439b0)
@tgross35 tgross35 mentioned this pull request Apr 11, 2025
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Apr 11, 2025
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 14, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: bf0be4ef8afa5031a9151f19ebcdcf58722a6238)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Apr 14, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 14, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: 3a81240c93fd230e45082ef391730927916944c4)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 14, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: a1e6e02abd27edf7101189b0bac8c776861d909c)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Apr 14, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 14, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: a1e6e02abd27edf7101189b0bac8c776861d909c)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 15, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: a1e6e02abd27edf7101189b0bac8c776861d909c)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 15, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: a1e6e02abd27edf7101189b0bac8c776861d909c)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 16, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: 6f72a9ca498e4c18b6e6bfb6f10547641b0c3daa)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 16, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: 6f72a9ca498e4c18b6e6bfb6f10547641b0c3daa)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 16, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: d34f49cc604733c7d714a72b3a3d66a99aa65c79)

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Apr 16, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

Signed-off-by: Yoann Congal <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 16, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: d34f49cc604733c7d714a72b3a3d66a99aa65c79)

Signed-off-by: Yoann Congal <yoann.congalsmile.fr>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 19, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: d34f49cc604733c7d714a72b3a3d66a99aa65c79)

Signed-off-by: Yoann Congal <yoann.congalsmile.fr>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 20, 2025
rust-lang/libc#4382 was merge as
rust-lang/libc@4b439b0

(From OE-Core rev: d34f49cc604733c7d714a72b3a3d66a99aa65c79)

Signed-off-by: Yoann Congal <yoann.congalsmile.fr>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-linux O-unix S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants