libc icon indicating copy to clipboard operation
libc copied to clipboard

bsd: Add missing minherit system call

Open oherrala opened this issue 1 month ago • 4 comments

Description

Add a missing minherit() system call and constants related to it.

minherit(2) from macOS describes this call as:

The minherit() system call changes the specified pages to have the inheritance characteristic inherit, which can be set to VM_INHERIT_NONE, VM_INHERIT_COPY, or VM_INHERIT_SHARE. Not all implementations will guarantee that the inheritance characteristic can be set on a page basis; the granularity of changes may be as large as an entire region.

Sources

  • OpenBSD:
    • https://man.openbsd.org/minherit
    • https://github.com/openbsd/src/blob/4ae131efb048309284c5ee06d14cc10f03403763/sys/sys/mman.h#L111-L117
  • FreeBSD:
    • https://man.freebsd.org/cgi/man.cgi?query=minherit
    • https://github.com/freebsd/freebsd-src/blob/de1aa3dab23c06fec962a14da3e7b4755c5880cf/sys/sys/mman.h#L42-L48
  • NetBSD:
    • https://man.netbsd.org/minherit.2
    • https://github.com/NetBSD/src/blob/33371e687adff4ba1ef3d243f008a674001b7b51/sys/sys/mman.h#L205-L214
  • DragonFly:
    • https://man.bsd.lv/DragonFly-5.6.1/minherit.2
    • https://github.com/DragonFlyBSD/DragonFlyBSD/blob/fcabea4d653da65056585e7572aa19f7a81583ce/sys/sys/mman.h#L55-L60
  • MacOS:
    • https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/mman.h#L290
    • https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/osfmk/mach/vm_inherit.h#L85-L88

Checklist

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

@rustbot label +stable-nominated

oherrala avatar Nov 27 '25 20:11 oherrala

The arm-linux-androidabi test failed maybe because "The job has exceeded the maximum execution time of 25m0s".

oherrala avatar Nov 28 '25 08:11 oherrala

Reminder, once the PR becomes ready for a review, use @rustbot ready.

rustbot avatar Nov 30 '25 07:11 rustbot

@tgross35 FWIW minherit is not macOS specific. It originates from OpenBSD and is also in FreeBSD, NetBSD and DragonFly:

  • https://man.openbsd.org/minherit
  • https://man.netbsd.org/minherit.2
  • https://man.freebsd.org/cgi/man.cgi?query=minherit
  • https://man.bsd.lv/DragonFly-5.6.1/minherit.2

oherrala avatar Nov 30 '25 19:11 oherrala

Thanks for the links. In that case I think it’s fine here, but would you mind enabling it for those other platforms as well? At least FreeBSD and NetBSD get CI here.

tgross35 avatar Nov 30 '25 21:11 tgross35