silk.platform.linux.process_inputs.
The arguments, environment and page size of a raw Linux process, read from the initial stack.
When to use#
Call ProcessInputs.decode once at a raw process entry, as silk.platform.linux.start does. The
application then gets a &ProcessInputs.
Details#
The kernel puts argc, the argv and envp vectors, and the auxiliary vector on the stack.
ProcessInputs.decode reads them without allocation or copies. Arguments and environment
entries stay NUL-terminated byte strings. The page size comes from AT_PAGESZ.
Errors#
decode returns error 22 (EINVAL) if argv has no null terminator, or if AT_PAGESZ is
missing, is repeated, or is not a power of two.
Gotchas#
The decoder needs a complete, readable kernel stack image. It does not check arbitrary memory. The returned pointers own nothing. They stay valid only while that image is live.
Import as ProcessInputs with import silk.platform.linux.process_inputs { ProcessInputs }.
Public declarations: 1.
ProcessInputs#
pub struct ProcessInputsBorrowed argument and environment vectors, and a checked page size, of a raw Linux process.
Details#
ProcessInputs.decode reads them from the initial stack without allocation or copies.
Arguments and environment entries stay NUL-terminated byte strings. The page size comes from
AT_PAGESZ.
Gotchas#
The pointers own nothing. They stay valid only while the kernel stack image is live.
Implementation ProcessInputs#
impl ProcessInputsAssociated function decode#
pub unsafe fn decode(stack: [*]const usize) -> Result<ProcessInputs, usize>Decodes one complete kernel stack image. It does not allocate.
Details#
Unknown auxiliary-vector keys are ignored. No input is copied or changed.
Errors#
Error 22 if argv has no terminator, or AT_PAGESZ is missing, repeated, or not a power
of two.
Gotchas#
stack must point to aligned, readable words up to both vector terminators and AT_NULL.
Each address in argv and envp that is not zero must point to a live NUL-terminated
string.
Method pageSize#
pub fn pageSize(self: &ProcessInputs) -> usizeReturns the page size from AT_PAGESZ. It is always a power of two.
Method argc#
pub fn argc(self: &ProcessInputs) -> usizeReturns the number of arguments. The program name is argument 0.
Method envc#
pub fn envc(self: &ProcessInputs) -> usizeReturns the number of environment entries.
Method argument#
pub unsafe fn argument(self: &ProcessInputs, index: usize) -> ?[*]const u8Returns a pointer to argument index as a NUL-terminated string, or null if index is not
less than ProcessInputs.argc.
Gotchas#
The original stack and strings must stay live. The pointer owns no storage.
Method variable#
pub unsafe fn variable(self: &ProcessInputs, index: usize) -> ?[*]const u8Returns a pointer to environment entry index (a NAME=value string), or null if index
is not less than ProcessInputs.envc.
Gotchas#
The original stack and strings must stay live. The pointer owns no storage.
Category: Native platform.
Profiles: aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu-no-libc.