uutils / uutils/coreutils

proposal: consolidate `libc::mode_t` abstraction

Open
#7,751 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

I was hacking on #7728, trying to get rid of numerous suspiscious u32 casts, and realized that many of them have to do with libc::mode_t alias. In most unix-like OS, it uses u32, but some use u16 and Redux uses i32, making this somewhat problematic.

Coreutils code constantly casts from mode_t to u32 and back. I think a better paradigm might be to introduce a dedicated type, probably based on bitflags? In general, a strongly typed flag type should be better than a generic u32 passed around. My only reservation is that maybe this should be part of libc itself?

See also https://github.com/rust-lang/libc/discussions/4404

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #7728, the libc::mode_t documentation, and the linked libc discussion #4404. Then inventory the existing mode_t-to-u32 casts in the coreutils codebase and determine whether a dedicated bitflags-based type belongs here or in libc. Done means an agreed design and a consistent abstraction that handles the differing Unix-like representations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.