Skip to content

Add nix-only utils: chcon chgrp chown chroot pinky runcon - #253

Open
metif12 wants to merge 1 commit into
vlang:mainfrom
metif12:nix-utils-batch
Open

metif12 wants to merge 1 commit into
vlang:mainfrom
metif12:nix-utils-batch

Conversation

@metif12

@metif12 metif12 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Six utilities that need POSIX APIs Windows does not expose. All six are nix-only to the same degree: chroot and chown/chgrp need chroot(2) and the user/group databases; chcon and runcon need SELinux; pinky needs utmp. They stay in build.vsh's Windows ignore list, so no Windows build is attempted.

Shared support lives in common/: ids_nix.c.v holds the group and user lookup both ownership tools use, so chgrp and chown share one implementation rather than two; selinux holds the context parser the context tools share; and die()/fail_with_help() exist because GNU's exit statuses differ by failure kind, which the previous common.exit_with_error_message could not express.

The exit codes were measured rather than assumed: chown exits 1 for a bad operand while chroot and runcon exit 125 for anything they could not do. That distinction is real and the old helper flattened it.

Verification was by cross-compiling each tool for Linux and running it under WSL, since V can emit Linux C from Windows but cannot link it.

Not all six match, and I want to be specific. chown, chgrp, chroot, chcon, runcon and mknod's diagnostics match byte-for-byte, including the curly quotes GNU puts around operands. pinky's default table matches, but its -i, -w and -q variants use column layouts I did not decode — the flag-to-column mapping behaves counter-intuitively (-i omits the Name column, not the idle time) and I ran out of budget before nailing it. That's an honest gap, not a claim of parity.

The _nix_test.v suites are named so Windows never compiles them, which means the ubuntu-* CI jobs are the first real execution of this code. That's a genuine risk and it's stated in the commit message.

Six utilities that need POSIX APIs Windows does not expose. All six are nix-only for the same reason and to the same degree: chroot and chown/chgrp need chroot(2) and the user/group databases; chcon and runcon need SELinux; pinky needs utmp. They stay in build.vsh's Windows ignore list, so no Windows build is attempted. Shared support lives in common/: ids_nix.c.v holds the group and user lookup both ownership tools use, so chgrp and chown share one implementation rather than two; selinux holds the context parser the context tools share; and die()/fail_with_help() exist because GNU's exit statuses differ by failure kind, which the previous common.exit_with_error_message could not express. The exit codes were measured rather than assumed: chown exits 1 for a bad operand while chroot and runcon exit 125 for anything they could not do, and an unknown group or user is a one-line diagnostic with no 'Try --help'. Verification was by cross-compiling each tool for Linux and running it under WSL, since V can emit Linux C from Windows but cannot link it. Not all six match: chown, chgrp, chroot, chcon, runcon and mknod's diagnostics do, byte for byte including the curly quotes GNU puts around operands. pinky's default table matches, but its -i, -w and -q variants use column layouts I did not decode, and the suite for these is named _nix_test.v so Windows never compiles it and the ubuntu CI jobs are the first real execution.
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.

1 participant