Skip to content
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

Add TCGETS2 and TCSETS2 (and variants) ioctl constants for Linux. #2508

Merged
merged 1 commit into from Nov 6, 2021

Conversation

de-vri-es
Copy link
Contributor

@de-vri-es de-vri-es commented Nov 3, 2021

I noticed that the termios2 struct is already exposed, but the ioctl constants to use it are not. This PR adds the TCGETS2, TCSETS2, TCSETSW2 and TCSETSF2 on Linux so that you can actually do something with the termios2 struct.

The powerpc architecture is notably missing, because it does not seem to support the TCGETS2/TCSETS2 ioctls.

I think the constants are correct for all platforms, but I'm also not 100% sure. Do the unit tests verify the values for all supported platforms, by any chance?

@rust-highfive
Copy link

r? @Amanieu

(rust-highfive has picked a reviewer for you, use r? to override)

@de-vri-es

This comment has been minimized.

@de-vri-es de-vri-es force-pushed the tcgets2-and-friends branch 4 times, most recently from 05b4bdf to 75b7725 Compare November 3, 2021 19:09
@Amanieu
Copy link
Member

Amanieu commented Nov 4, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Nov 4, 2021

📌 Commit 1338e2e has been approved by Amanieu

@de-vri-es
Copy link
Contributor Author

@bors r+

Oops, I pushed a new commit to fix mips after the r+.

@Amanieu
Copy link
Member

Amanieu commented Nov 4, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Nov 4, 2021

📌 Commit 8c9bfe0 has been approved by Amanieu

bors added a commit that referenced this pull request Nov 4, 2021
Add TCGETS2 and TCSETS2 (and variants) ioctl constants for Linux.

I noticed that the `termios2` struct is already exposed, but the ioctl constants to use it are not. This PR adds the `TCGETS2`, `TCSETS2`, `TCSETSW2` and `TCSETSF2` on Linux so that you can actually do something with the `termios2` struct.

The `powerpc` architecture is notably missing, because it does not seem to support the `TCGETS2`/`TCSETS2` ioctls.

I *think* the constants are correct for all platforms, but I'm also not 100% sure. Do the unit tests verify the values for all supported platforms, by any chance?
@bors
Copy link
Contributor

bors commented Nov 4, 2021

⌛ Testing commit 8c9bfe0 with merge 598674a...

@bors
Copy link
Contributor

bors commented Nov 4, 2021

💔 Test failed - checks-actions

@de-vri-es
Copy link
Contributor Author

de-vri-es commented Nov 4, 2021

Ugh, the termios2 struct is 4 bytes larger on mips. Updated the constants again.

Yay for the test suite though <3

@Amanieu
Copy link
Member

Amanieu commented Nov 5, 2021

Yea the tests here are a lifesaver.

@bors r+

@bors
Copy link
Contributor

bors commented Nov 5, 2021

📌 Commit 447e868 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Nov 5, 2021

⌛ Testing commit 447e868 with merge da0c585...

bors added a commit that referenced this pull request Nov 5, 2021
Add TCGETS2 and TCSETS2 (and variants) ioctl constants for Linux.

I noticed that the `termios2` struct is already exposed, but the ioctl constants to use it are not. This PR adds the `TCGETS2`, `TCSETS2`, `TCSETSW2` and `TCSETSF2` on Linux so that you can actually do something with the `termios2` struct.

The `powerpc` architecture is notably missing, because it does not seem to support the `TCGETS2`/`TCSETS2` ioctls.

I *think* the constants are correct for all platforms, but I'm also not 100% sure. Do the unit tests verify the values for all supported platforms, by any chance?
@bors
Copy link
Contributor

bors commented Nov 5, 2021

💔 Test failed - checks-actions

@de-vri-es
Copy link
Contributor Author

de-vri-es commented Nov 5, 2021

I had a typo in TCSETSF2 for sparc 😢 Fixed it now.

Also, I noticed that the constants are all ulong, even though ioctl takes an int for the request parameter. I could turn these new ones from this PR into uint, which would have made the typo impossible. But I guess that the existing ones should stay ulong for backwards compatibility.

Or I can just leave them as ulong for consistency with the other constants.

@Amanieu
Copy link
Member

Amanieu commented Nov 6, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Nov 6, 2021

📌 Commit 58a015c has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Nov 6, 2021

⌛ Testing commit 58a015c with merge 3124475...

@bors
Copy link
Contributor

bors commented Nov 6, 2021

☀️ Test successful - checks-actions, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13
Approved by: Amanieu
Pushing 3124475 to master...

@bors bors merged commit 3124475 into rust-lang:master Nov 6, 2021
@de-vri-es
Copy link
Contributor Author

\o/

Thanks for the reviews!

bors added a commit that referenced this pull request Nov 6, 2021
Move termios2 struct and ioctl constants to linux::arch::*.

When trying to use the newly added ioctls from #2508 I noticed that the `termios2` struct was not defined for musl or uclibc, except interestingly for the hexagon+musl target

However, the `termios2` struct and ioctls are part of the Linux headers, not part of the libc headers. So the libc flavour doesn't matter for these definitions.

This PR moves the definitions to the `linux::arch::*` modules, to make them available for all libc flavours and reduce code duplication as a bonus.
bors added a commit that referenced this pull request Nov 6, 2021
Move termios2 struct and ioctl constants to linux::arch::*.

When trying to use the newly added ioctls from #2508 I noticed that the `termios2` struct was not defined for musl or uclibc, except interestingly for the hexagon+musl target

However, the `termios2` struct and ioctls are part of the Linux headers, not part of the libc headers. So the libc flavour doesn't matter for these definitions.

This PR moves the definitions to the `linux::arch::*` modules, to make them available for all libc flavours and reduce code duplication as a bonus.
bors added a commit that referenced this pull request Nov 18, 2021
Use libc specific type for architecture specific ioctl defines on Linux.

This PR should fix the type change of some ioctl constants on Linux introduced by #2530.

It does this by adding a `#[doc(hidden)]` type called `Ioctl`, which is defined in libc specific modules and used in arch specific modules.

However, when doing this I noticed that when I added `TCGETS2`, `TCSETS2`, ... in #2508, I unconditionally used `c_ulong`. This is inconsistent with the other ioctl constants for `musl` and `uclibc`. This PR also changes those to use the libc specific types. However, PR #2508 has already been released in 0.2.107, so technically that is also a semver incompatible change. The impact is limited to new constants introduced in the last release, and only on `musl` and `uclibc` targets.

So what is more important here? Consistency in the type of ioctl constants, or being very strict with backwards compatibility? If it is the latter, I'll revert `TCGETS2` etc to `c_ulong`  for this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants