Skip to content

mkfifo: fix build where mode_t is not u32 - #13775

Open
pkubaj wants to merge 1 commit into
uutils:mainfrom
pkubaj:patch-1
Open

mkfifo: fix build where mode_t is not u32#13775
pkubaj wants to merge 1 commit into
uutils:mainfrom
pkubaj:patch-1

Conversation

@pkubaj

@pkubaj pkubaj commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

rustix::fs::Mode is a bitflags over rustix::fs::RawMode, which aliases libc::mode_t. That is u32 on Linux but u16 on the BSDs, so handing the u32 mode straight to Mode::from_bits_truncate() fails to compile there:

error[E0308]: mismatched types
   --> src/uu/mkfifo/src/mkfifo.rs:146:50
    |
146 |     mkfifoat(CWD, path, Mode::from_bits_truncate(mode))
    |                         ------------------------ ^^^^ expected `u16`, found `u32`

Cast to RawMode first, which is a no-op on Linux and matches what mkdir already does in src/uu/mkdir/src/mkdir.rs.

Comment thread src/uu/mkfifo/src/mkfifo.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Aug 6, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 22.81%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 346 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation df_with_path 704.6 µs 573.7 µs +22.81%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing pkubaj:patch-1 (959d6e0) with main (98dd261)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@pkubaj
pkubaj force-pushed the patch-1 branch 2 times, most recently from 39ba52d to 192e71b Compare August 6, 2026 12:30
@sylvestre

Copy link
Copy Markdown
Contributor

on which bsd? thanks

@pkubaj

pkubaj commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

FreeBSD.

Comment thread src/uu/mkfifo/src/mkfifo.rs Outdated
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/mv/dir2dir is no longer failing!
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

`rustix::fs::Mode` is a bitflags over `rustix::fs::RawMode`, which aliases
`libc::mode_t`.  That is `u32` on Linux but `u16` on the BSDs, so handing the
`u32` mode straight to `Mode::from_bits_truncate()` fails to compile there:

    error[E0308]: mismatched types
        |     fs::mkfifoat(fs::CWD, path, Mode::from_bits_truncate(mode))
        |                                 ------------------------ ^^^^
        |                                 expected `u16`, found `u32`

Type `create_fifo` in terms of `RawMode` so the conversion happens once at the
call site, where the parsed `u32` becomes a platform mode.  The cast is a no-op
on Linux, matching what `mkdir` already does in src/uu/mkdir/src/mkdir.rs.  The
Apple arm keeps its explicit `as libc::mode_t`: `RawMode` is defined as
`c::mode_t` so the cast is an identity there, but keeping it compiles either way
and that arm cannot be exercised by CI on Linux.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants