13a7d8294SWarner Losh.\" Copyright (c) Michael Smith 23a7d8294SWarner Losh.\" All rights reserved. 33a7d8294SWarner Losh.\" 43a7d8294SWarner Losh.\" Redistribution and use in source and binary forms, with or without 53a7d8294SWarner Losh.\" modification, are permitted provided that the following conditions 63a7d8294SWarner Losh.\" are met: 73a7d8294SWarner Losh.\" 1. Redistributions of source code must retain the above copyright 83a7d8294SWarner Losh.\" notice, this list of conditions and the following disclaimer. 93a7d8294SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 103a7d8294SWarner Losh.\" notice, this list of conditions and the following disclaimer in the 113a7d8294SWarner Losh.\" documentation and/or other materials provided with the distribution. 123a7d8294SWarner Losh.\" 133a7d8294SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 143a7d8294SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 153a7d8294SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 163a7d8294SWarner Losh.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 173a7d8294SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 183a7d8294SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 193a7d8294SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 203a7d8294SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 213a7d8294SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 223a7d8294SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 233a7d8294SWarner Losh.\" SUCH DAMAGE. 243a7d8294SWarner Losh.\" 253a7d8294SWarner Losh.\" $FreeBSD$ 263a7d8294SWarner Losh.\" 2745ad9557SWarner Losh.Dd September 9, 2022 28f6b2a429SKyle Evans.Dt LIBSA 3 293a7d8294SWarner Losh.Os 303a7d8294SWarner Losh.Sh NAME 31f6b2a429SKyle Evans.Nm libsa 323a7d8294SWarner Losh.Nd support library for standalone executables 333a7d8294SWarner Losh.Sh SYNOPSIS 343a7d8294SWarner Losh.In stand.h 353a7d8294SWarner Losh.Sh DESCRIPTION 363a7d8294SWarner LoshThe 373a7d8294SWarner Losh.Nm 383a7d8294SWarner Loshlibrary provides a set of supporting functions for standalone 393a7d8294SWarner Loshapplications, mimicking where possible the standard 403a7d8294SWarner Losh.Bx 413a7d8294SWarner Loshprogramming 423a7d8294SWarner Loshenvironment. 433a7d8294SWarner LoshThe following sections group these functions by kind. 443a7d8294SWarner LoshUnless specifically described here, see the corresponding section 3 453a7d8294SWarner Loshmanpages for the given functions. 463a7d8294SWarner Losh.Sh STRING FUNCTIONS 473a7d8294SWarner LoshString functions are available as documented in 483a7d8294SWarner Losh.Xr string 3 493a7d8294SWarner Loshand 503a7d8294SWarner Losh.Xr bstring 3 . 513a7d8294SWarner Losh.Sh MEMORY ALLOCATION 523a7d8294SWarner Losh.Bl -hang -width 10n 533a7d8294SWarner Losh.It Xo 543a7d8294SWarner Losh.Ft "void *" 553a7d8294SWarner Losh.Fn malloc "size_t size" 563a7d8294SWarner Losh.Xc 573a7d8294SWarner Losh.Pp 583a7d8294SWarner LoshAllocate 593a7d8294SWarner Losh.Fa size 603a7d8294SWarner Loshbytes of memory from the heap using a best-fit algorithm. 613a7d8294SWarner Losh.It Xo 623a7d8294SWarner Losh.Ft void 633a7d8294SWarner Losh.Fn free "void *ptr" 643a7d8294SWarner Losh.Xc 653a7d8294SWarner Losh.Pp 663a7d8294SWarner LoshFree the allocated object at 673a7d8294SWarner Losh.Fa ptr . 683a7d8294SWarner Losh.It Xo 693a7d8294SWarner Losh.Ft void 703a7d8294SWarner Losh.Fn setheap "void *start" "void *limit" 713a7d8294SWarner Losh.Xc 723a7d8294SWarner Losh.Pp 733a7d8294SWarner LoshInitialise the heap. 743a7d8294SWarner LoshThis function must be called before calling 753a7d8294SWarner Losh.Fn alloc 763a7d8294SWarner Loshfor the first time. 773a7d8294SWarner LoshThe region between 783a7d8294SWarner Losh.Fa start 793a7d8294SWarner Loshand 803a7d8294SWarner Losh.Fa limit 813a7d8294SWarner Loshwill be used for the heap; attempting to allocate beyond this will result 823a7d8294SWarner Loshin a panic. 833a7d8294SWarner Losh.It Xo 843a7d8294SWarner Losh.Ft "char *" 853a7d8294SWarner Losh.Fn sbrk "int junk" 863a7d8294SWarner Losh.Xc 873a7d8294SWarner Losh.Pp 883a7d8294SWarner LoshProvides the behaviour of 893a7d8294SWarner Losh.Fn sbrk 0 , 903a7d8294SWarner Loshi.e., returns the highest point that the heap has reached. 913a7d8294SWarner LoshThis value can 923a7d8294SWarner Loshbe used during testing to determine the actual heap usage. 933a7d8294SWarner LoshThe 943a7d8294SWarner Losh.Fa junk 953a7d8294SWarner Loshargument is ignored. 963a7d8294SWarner Losh.El 973a7d8294SWarner Losh.Sh ENVIRONMENT 983a7d8294SWarner LoshA set of functions are provided for manipulating a flat variable space similar 993a7d8294SWarner Loshto the traditional shell-supported environment. 1003a7d8294SWarner LoshMajor enhancements are support 1013a7d8294SWarner Loshfor set/unset hook functions. 1023a7d8294SWarner Losh.Bl -hang -width 10n 1033a7d8294SWarner Losh.It Xo 1043a7d8294SWarner Losh.Ft "char *" 1053a7d8294SWarner Losh.Fn getenv "const char *name" 1063a7d8294SWarner Losh.Xc 1073a7d8294SWarner Losh.It Xo 1083a7d8294SWarner Losh.Ft int 1093a7d8294SWarner Losh.Fn setenv "const char *name" "const char *value" "int overwrite" 1103a7d8294SWarner Losh.Xc 1113a7d8294SWarner Losh.It Xo 1123a7d8294SWarner Losh.Ft int 1133a7d8294SWarner Losh.Fn putenv "char *string" 1143a7d8294SWarner Losh.Xc 1153a7d8294SWarner Losh.It Xo 1163a7d8294SWarner Losh.Ft int 1173a7d8294SWarner Losh.Fn unsetenv "const char *name" 1183a7d8294SWarner Losh.Xc 1193a7d8294SWarner Losh.Pp 1203a7d8294SWarner LoshThese functions behave similarly to their standard library counterparts. 1213a7d8294SWarner Losh.It Xo 1223a7d8294SWarner Losh.Ft "struct env_var *" 1233a7d8294SWarner Losh.Fn env_getenv "const char *name" 1243a7d8294SWarner Losh.Xc 1253a7d8294SWarner Losh.Pp 1263a7d8294SWarner LoshLooks up a variable in the environment and returns its entire 1273a7d8294SWarner Loshdata structure. 1283a7d8294SWarner Losh.It Xo 1293a7d8294SWarner Losh.Ft int 1303a7d8294SWarner Losh.Fn env_setenv "const char *name" "int flags" "const void *value" "ev_sethook_t sethook" "ev_unsethook_t unsethook" 1313a7d8294SWarner Losh.Xc 1323a7d8294SWarner Losh.Pp 1333a7d8294SWarner LoshCreates a new or sets an existing environment variable called 1343a7d8294SWarner Losh.Fa name . 1353a7d8294SWarner LoshIf creating a new variable, the 1363a7d8294SWarner Losh.Fa sethook 1373a7d8294SWarner Loshand 1383a7d8294SWarner Losh.Fa unsethook 1393a7d8294SWarner Losharguments may be specified. 1403a7d8294SWarner Losh.Pp 1413a7d8294SWarner LoshThe set hook is invoked whenever an attempt 1423a7d8294SWarner Loshis made to set the variable, unless the EV_NOHOOK flag is set. 1433a7d8294SWarner LoshTypically 1443a7d8294SWarner Losha set hook will validate the 1453a7d8294SWarner Losh.Fa value 1463a7d8294SWarner Loshargument, and then call 1473a7d8294SWarner Losh.Fn env_setenv 1483a7d8294SWarner Loshagain with EV_NOHOOK set to actually save the value. 1493a7d8294SWarner LoshThe predefined function 1503a7d8294SWarner Losh.Fn env_noset 1513a7d8294SWarner Loshmay be specified to refuse all attempts to set a variable. 1523a7d8294SWarner Losh.Pp 1533a7d8294SWarner LoshThe unset hook is invoked when an attempt is made to unset a variable. 1543a7d8294SWarner LoshIf it 1553a7d8294SWarner Loshreturns zero, the variable will be unset. 1563a7d8294SWarner LoshThe predefined function 1573a7d8294SWarner Losh.Fa env_nounset 1583a7d8294SWarner Loshmay be used to prevent a variable being unset. 1593a7d8294SWarner Losh.El 1603a7d8294SWarner Losh.Sh STANDARD LIBRARY SUPPORT 1613a7d8294SWarner Losh.Bl -hang -width 10n 1623a7d8294SWarner Losh.It Xo 1633a7d8294SWarner Losh.Ft int 1643a7d8294SWarner Losh.Fn abs "int i" 1653a7d8294SWarner Losh.Xc 1663a7d8294SWarner Losh.It Xo 1673a7d8294SWarner Losh.Ft int 1683a7d8294SWarner Losh.Fn getopt "int argc" "char * const *argv" "const char *optstring" 1693a7d8294SWarner Losh.Xc 1703a7d8294SWarner Losh.It Xo 1713a7d8294SWarner Losh.Ft long 1723a7d8294SWarner Losh.Fn strtol "const char *nptr" "char **endptr" "int base" 1733a7d8294SWarner Losh.Xc 1743a7d8294SWarner Losh.It Xo 1753a7d8294SWarner Losh.Ft long long 1763a7d8294SWarner Losh.Fn strtoll "const char *nptr" "char **endptr" "int base" 1773a7d8294SWarner Losh.Xc 1783a7d8294SWarner Losh.It Xo 1793a7d8294SWarner Losh.Ft long 1803a7d8294SWarner Losh.Fn strtoul "const char *nptr" "char **endptr" "int base" 1813a7d8294SWarner Losh.Xc 1823a7d8294SWarner Losh.It Xo 1833a7d8294SWarner Losh.Ft long long 1843a7d8294SWarner Losh.Fn strtoull "const char *nptr" "char **endptr" "int base" 1853a7d8294SWarner Losh.Xc 1863a7d8294SWarner Losh.It Xo 1873a7d8294SWarner Losh.Ft void 1883a7d8294SWarner Losh.Fn srandom "unsigned int seed" 1893a7d8294SWarner Losh.Xc 1903a7d8294SWarner Losh.It Xo 1913a7d8294SWarner Losh.Ft "long" 1923a7d8294SWarner Losh.Fn random void 1933a7d8294SWarner Losh.Xc 1943a7d8294SWarner Losh.It Xo 1953a7d8294SWarner Losh.Ft "char *" 1963a7d8294SWarner Losh.Fn strerror "int error" 1973a7d8294SWarner Losh.Xc 1983a7d8294SWarner Losh.Pp 1993a7d8294SWarner LoshReturns error messages for the subset of errno values supported by 2003a7d8294SWarner Losh.Nm . 2013a7d8294SWarner Losh.It Fn assert expression 2023a7d8294SWarner Losh.Pp 2033a7d8294SWarner LoshRequires 2043a7d8294SWarner Losh.In assert.h . 2053a7d8294SWarner Losh.It Xo 2063a7d8294SWarner Losh.Ft int 2073a7d8294SWarner Losh.Fn setjmp "jmp_buf env" 2083a7d8294SWarner Losh.Xc 2093a7d8294SWarner Losh.It Xo 2103a7d8294SWarner Losh.Ft void 2113a7d8294SWarner Losh.Fn longjmp "jmp_buf env" "int val" 2123a7d8294SWarner Losh.Xc 2133a7d8294SWarner Losh.Pp 2143a7d8294SWarner LoshDefined as 2153a7d8294SWarner Losh.Fn _setjmp 2163a7d8294SWarner Loshand 2173a7d8294SWarner Losh.Fn _longjmp 2183a7d8294SWarner Loshrespectively as there is no signal state to manipulate. 2193a7d8294SWarner LoshRequires 2203a7d8294SWarner Losh.In setjmp.h . 2213a7d8294SWarner Losh.El 2223a7d8294SWarner Losh.Sh CHARACTER I/O 2233a7d8294SWarner Losh.Bl -hang -width 10n 2243a7d8294SWarner Losh.It Xo 2253a7d8294SWarner Losh.Ft void 2263a7d8294SWarner Losh.Fn gets "char *buf" 2273a7d8294SWarner Losh.Xc 2283a7d8294SWarner Losh.Pp 2293a7d8294SWarner LoshRead characters from the console into 2303a7d8294SWarner Losh.Fa buf . 2313a7d8294SWarner LoshAll of the standard cautions apply to this function. 2323a7d8294SWarner Losh.It Xo 2333a7d8294SWarner Losh.Ft void 2343a7d8294SWarner Losh.Fn ngets "char *buf" "int size" 2353a7d8294SWarner Losh.Xc 2363a7d8294SWarner Losh.Pp 2373a7d8294SWarner LoshRead at most 2383a7d8294SWarner Losh.Fa size 2393a7d8294SWarner Losh- 1 characters from the console into 2403a7d8294SWarner Losh.Fa buf . 2413a7d8294SWarner LoshIf 2423a7d8294SWarner Losh.Fa size 2433a7d8294SWarner Loshis less than 1, the function's behaviour is as for 2443a7d8294SWarner Losh.Fn gets . 2453a7d8294SWarner Losh.It Xo 2463a7d8294SWarner Losh.Ft int 2473a7d8294SWarner Losh.Fn fgetstr "char *buf" "int size" "int fd" 2483a7d8294SWarner Losh.Xc 2493a7d8294SWarner Losh.Pp 2503a7d8294SWarner LoshRead a line of at most 2513a7d8294SWarner Losh.Fa size 2523a7d8294SWarner Loshcharacters into 2533a7d8294SWarner Losh.Fa buf . 2543a7d8294SWarner LoshLine terminating characters are stripped, and the buffer is always 2553a7d8294SWarner Losh.Dv NUL 2563a7d8294SWarner Loshterminated. 2573a7d8294SWarner LoshReturns the number of characters in 2583a7d8294SWarner Losh.Fa buf 2593a7d8294SWarner Loshif successful, or -1 if a read error occurs. 2603a7d8294SWarner Losh.It Xo 2613a7d8294SWarner Losh.Ft int 2623a7d8294SWarner Losh.Fn printf "const char *fmt" "..." 2633a7d8294SWarner Losh.Xc 2643a7d8294SWarner Losh.It Xo 2653a7d8294SWarner Losh.Ft void 2663a7d8294SWarner Losh.Fn vprintf "const char *fmt" "va_list ap" 2673a7d8294SWarner Losh.Xc 2683a7d8294SWarner Losh.It Xo 2693a7d8294SWarner Losh.Ft int 2703a7d8294SWarner Losh.Fn sprintf "char *buf" "const char *fmt" "..." 2713a7d8294SWarner Losh.Xc 2723a7d8294SWarner Losh.It Xo 2733a7d8294SWarner Losh.Ft void 2743a7d8294SWarner Losh.Fn vsprintf "char *buf" "const char *fmt" "va_list ap" 2753a7d8294SWarner Losh.Xc 2763a7d8294SWarner Losh.Pp 2773a7d8294SWarner LoshThe *printf functions implement a subset of the standard 2783a7d8294SWarner Losh.Fn printf 2793a7d8294SWarner Loshfamily functionality and some extensions. 2803a7d8294SWarner LoshThe following standard conversions 2813a7d8294SWarner Loshare supported: c,d,n,o,p,s,u,x. 2823a7d8294SWarner LoshThe following modifiers are supported: 2833a7d8294SWarner Losh+,-,#,*,0,field width,precision,l. 2843a7d8294SWarner Losh.Pp 2853a7d8294SWarner LoshThe 2863a7d8294SWarner Losh.Li b 2873a7d8294SWarner Loshconversion is provided to decode error registers. 2883a7d8294SWarner LoshIts usage is: 2893a7d8294SWarner Losh.Bd -ragged -offset indent 2903a7d8294SWarner Loshprintf( 2913a7d8294SWarner Losh.Qq reg=%b\en , 2923a7d8294SWarner Loshregval, 2933a7d8294SWarner Losh.Qq <base><arg>* 2943a7d8294SWarner Losh); 2953a7d8294SWarner Losh.Ed 2963a7d8294SWarner Losh.Pp 2973a7d8294SWarner Loshwhere <base> is the output expressed as a control character, e.g.\& \e10 gives 2983a7d8294SWarner Loshoctal, \e20 gives hex. 2993a7d8294SWarner LoshEach <arg> is a sequence of characters, the first of 3003a7d8294SWarner Loshwhich gives the bit number to be inspected (origin 1) and the next characters 3013a7d8294SWarner Losh(up to a character less than 32) give the text to be displayed if the bit is set. 3023a7d8294SWarner LoshThus 3033a7d8294SWarner Losh.Bd -ragged -offset indent 3043a7d8294SWarner Loshprintf( 3053a7d8294SWarner Losh.Qq reg=%b\en , 3063a7d8294SWarner Losh3, 3073a7d8294SWarner Losh.Qq \e10\e2BITTWO\e1BITONE 3083a7d8294SWarner Losh); 3093a7d8294SWarner Losh.Ed 3103a7d8294SWarner Losh.Pp 3113a7d8294SWarner Loshwould give the output 3123a7d8294SWarner Losh.Bd -ragged -offset indent 3133a7d8294SWarner Loshreg=3<BITTWO,BITONE> 3143a7d8294SWarner Losh.Ed 3153a7d8294SWarner Losh.Pp 3163a7d8294SWarner LoshThe 3173a7d8294SWarner Losh.Li D 3183a7d8294SWarner Loshconversion provides a hexdump facility, e.g. 3193a7d8294SWarner Losh.Bd -ragged -offset indent 3203a7d8294SWarner Loshprintf( 3213a7d8294SWarner Losh.Qq %6D , 3223a7d8294SWarner Loshptr, 3233a7d8294SWarner Losh.Qq \&: 3243a7d8294SWarner Losh); gives 3253a7d8294SWarner Losh.Qq XX:XX:XX:XX:XX:XX 3263a7d8294SWarner Losh.Ed 3273a7d8294SWarner Losh.Bd -ragged -offset indent 3283a7d8294SWarner Loshprintf( 3293a7d8294SWarner Losh.Qq %*D , 3303a7d8294SWarner Loshlen, 3313a7d8294SWarner Loshptr, 3323a7d8294SWarner Losh.Qq "\ " 3333a7d8294SWarner Losh); gives 3343a7d8294SWarner Losh.Qq XX XX XX ... 3353a7d8294SWarner Losh.Ed 3363a7d8294SWarner Losh.El 3373a7d8294SWarner Losh.Sh CHARACTER TESTS AND CONVERSIONS 3383a7d8294SWarner Losh.Bl -hang -width 10n 3393a7d8294SWarner Losh.It Xo 3403a7d8294SWarner Losh.Ft int 3413a7d8294SWarner Losh.Fn isupper "int c" 3423a7d8294SWarner Losh.Xc 3433a7d8294SWarner Losh.It Xo 3443a7d8294SWarner Losh.Ft int 3453a7d8294SWarner Losh.Fn islower "int c" 3463a7d8294SWarner Losh.Xc 3473a7d8294SWarner Losh.It Xo 3483a7d8294SWarner Losh.Ft int 3493a7d8294SWarner Losh.Fn isspace "int c" 3503a7d8294SWarner Losh.Xc 3513a7d8294SWarner Losh.It Xo 3523a7d8294SWarner Losh.Ft int 3533a7d8294SWarner Losh.Fn isdigit "int c" 3543a7d8294SWarner Losh.Xc 3553a7d8294SWarner Losh.It Xo 3563a7d8294SWarner Losh.Ft int 3573a7d8294SWarner Losh.Fn isxdigit "int c" 3583a7d8294SWarner Losh.Xc 3593a7d8294SWarner Losh.It Xo 3603a7d8294SWarner Losh.Ft int 3613a7d8294SWarner Losh.Fn isascii "int c" 3623a7d8294SWarner Losh.Xc 3633a7d8294SWarner Losh.It Xo 3643a7d8294SWarner Losh.Ft int 3653a7d8294SWarner Losh.Fn isalpha "int c" 3663a7d8294SWarner Losh.Xc 3673a7d8294SWarner Losh.It Xo 3683a7d8294SWarner Losh.Ft int 3693a7d8294SWarner Losh.Fn isalnum "int c" 3703a7d8294SWarner Losh.Xc 3713a7d8294SWarner Losh.It Xo 3723a7d8294SWarner Losh.Ft int 3733a7d8294SWarner Losh.Fn iscntrl "int c" 3743a7d8294SWarner Losh.Xc 3753a7d8294SWarner Losh.It Xo 3763a7d8294SWarner Losh.Ft int 3773a7d8294SWarner Losh.Fn isgraph "int c" 3783a7d8294SWarner Losh.Xc 3793a7d8294SWarner Losh.It Xo 3803a7d8294SWarner Losh.Ft int 3813a7d8294SWarner Losh.Fn ispunct "int c" 3823a7d8294SWarner Losh.Xc 3833a7d8294SWarner Losh.It Xo 3843a7d8294SWarner Losh.Ft int 3853a7d8294SWarner Losh.Fn toupper "int c" 3863a7d8294SWarner Losh.Xc 3873a7d8294SWarner Losh.It Xo 3883a7d8294SWarner Losh.Ft int 3893a7d8294SWarner Losh.Fn tolower "int c" 3903a7d8294SWarner Losh.Xc 3913a7d8294SWarner Losh.El 3923a7d8294SWarner Losh.Sh FILE I/O 3933a7d8294SWarner Losh.Bl -hang -width 10n 3943a7d8294SWarner Losh.It Xo 3953a7d8294SWarner Losh.Ft int 3963a7d8294SWarner Losh.Fn open "const char *path" "int flags" 3973a7d8294SWarner Losh.Xc 3983a7d8294SWarner Losh.Pp 3993a7d8294SWarner LoshSimilar to the behaviour as specified in 4003a7d8294SWarner Losh.Xr open 2 , 4013a7d8294SWarner Loshexcept that file creation is not supported, so the mode parameter is not 4023a7d8294SWarner Loshrequired. 4033a7d8294SWarner LoshThe 4043a7d8294SWarner Losh.Fa flags 405f6b2a429SKyle Evansargument may be one of O_RDONLY, O_WRONLY and O_RDWR. 406f6b2a429SKyle EvansOnly UFS currently supports writing. 4073a7d8294SWarner Losh.It Xo 4083a7d8294SWarner Losh.Ft int 4093a7d8294SWarner Losh.Fn close "int fd" 4103a7d8294SWarner Losh.Xc 4113a7d8294SWarner Losh.It Xo 4123a7d8294SWarner Losh.Ft void 4133a7d8294SWarner Losh.Fn closeall void 4143a7d8294SWarner Losh.Xc 4153a7d8294SWarner Losh.Pp 4163a7d8294SWarner LoshClose all open files. 4173a7d8294SWarner Losh.It Xo 4183a7d8294SWarner Losh.Ft ssize_t 4193a7d8294SWarner Losh.Fn read "int fd" "void *buf" "size_t len" 4203a7d8294SWarner Losh.Xc 4213a7d8294SWarner Losh.It Xo 4223a7d8294SWarner Losh.Ft ssize_t 4233a7d8294SWarner Losh.Fn write "int fd" "void *buf" "size_t len" 4243a7d8294SWarner Losh.Xc 4253a7d8294SWarner Losh.Pp 4263a7d8294SWarner Losh(No file systems currently support writing.) 4273a7d8294SWarner Losh.It Xo 4283a7d8294SWarner Losh.Ft off_t 4293a7d8294SWarner Losh.Fn lseek "int fd" "off_t offset" "int whence" 4303a7d8294SWarner Losh.Xc 4313a7d8294SWarner Losh.Pp 4323a7d8294SWarner LoshFiles being automatically uncompressed during reading cannot seek backwards 4333a7d8294SWarner Loshfrom the current point. 4343a7d8294SWarner Losh.It Xo 4353a7d8294SWarner Losh.Ft int 4363a7d8294SWarner Losh.Fn stat "const char *path" "struct stat *sb" 4373a7d8294SWarner Losh.Xc 4383a7d8294SWarner Losh.It Xo 4393a7d8294SWarner Losh.Ft int 4403a7d8294SWarner Losh.Fn fstat "int fd" "struct stat *sb" 4413a7d8294SWarner Losh.Xc 4423a7d8294SWarner Losh.Pp 4433a7d8294SWarner LoshThe 4443a7d8294SWarner Losh.Fn stat 4453a7d8294SWarner Loshand 4463a7d8294SWarner Losh.Fn fstat 4473a7d8294SWarner Loshfunctions only fill out the following fields in the 4483a7d8294SWarner Losh.Fa sb 4493a7d8294SWarner Loshstructure: st_mode,st_nlink,st_uid,st_gid,st_size. 4503a7d8294SWarner LoshThe 4513a7d8294SWarner Losh.Nm tftp 4523a7d8294SWarner Loshfile system cannot provide meaningful values for this call, and the 4533a7d8294SWarner Losh.Nm cd9660 4543a7d8294SWarner Loshfile system always reports files having uid/gid of zero. 4553a7d8294SWarner Losh.El 4563a7d8294SWarner Losh.Sh PAGER 4573a7d8294SWarner LoshThe 4583a7d8294SWarner Losh.Nm 4593a7d8294SWarner Loshlibrary supplies a simple internal pager to ease reading the output of large 4603a7d8294SWarner Loshcommands. 4613a7d8294SWarner Losh.Bl -hang -width 10n 4623a7d8294SWarner Losh.It Xo 4633a7d8294SWarner Losh.Ft void 4643a7d8294SWarner Losh.Fn pager_open 4653a7d8294SWarner Losh.Xc 4663a7d8294SWarner Losh.Pp 4673a7d8294SWarner LoshInitialises the pager and tells it that the next line output will be the top of the 4683a7d8294SWarner Loshdisplay. 4693a7d8294SWarner LoshThe environment variable LINES is consulted to determine the number of 4703a7d8294SWarner Loshlines to be displayed before pausing. 4713a7d8294SWarner Losh.It Xo 4723a7d8294SWarner Losh.Ft void 4733a7d8294SWarner Losh.Fn pager_close void 4743a7d8294SWarner Losh.Xc 4753a7d8294SWarner Losh.Pp 4763a7d8294SWarner LoshCloses the pager. 4773a7d8294SWarner Losh.It Xo 4783a7d8294SWarner Losh.Ft int 4793a7d8294SWarner Losh.Fn pager_output "const char *lines" 4803a7d8294SWarner Losh.Xc 4813a7d8294SWarner Losh.Pp 4823a7d8294SWarner LoshSends the lines in the 4833a7d8294SWarner Losh.Dv NUL Ns 4843a7d8294SWarner Losh-terminated buffer at 4853a7d8294SWarner Losh.Fa lines 4863a7d8294SWarner Loshto the pager. 4873a7d8294SWarner LoshNewline characters are counted in order to determine the number 4883a7d8294SWarner Loshof lines being output (wrapped lines are not accounted for). 4893a7d8294SWarner LoshThe 4903a7d8294SWarner Losh.Fn pager_output 4913a7d8294SWarner Loshfunction will return zero when all of the lines have been output, or nonzero 4923a7d8294SWarner Loshif the display was paused and the user elected to quit. 4933a7d8294SWarner Losh.It Xo 4943a7d8294SWarner Losh.Ft int 4953a7d8294SWarner Losh.Fn pager_file "const char *fname" 4963a7d8294SWarner Losh.Xc 4973a7d8294SWarner Losh.Pp 4983a7d8294SWarner LoshAttempts to open and display the file 4993a7d8294SWarner Losh.Fa fname . 5003a7d8294SWarner LoshReturns -1 on error, 0 at EOF, or 1 if the user elects to quit while reading. 5013a7d8294SWarner Losh.El 5023a7d8294SWarner Losh.Sh MISC 5033a7d8294SWarner Losh.Bl -hang -width 10n 5043a7d8294SWarner Losh.It Xo 50545ad9557SWarner Losh.Ft char * 50645ad9557SWarner Losh.Fn devformat "struct devdesc *" 50745ad9557SWarner Losh.Xc 50845ad9557SWarner Losh.Pp 50945ad9557SWarner LoshFormat the specified device as a string. 51045ad9557SWarner Losh.It Xo 511781ca0afSWarner Losh.Ft int 512781ca0afSWarner Losh.Fn devparse "struct devdesc **dev" "const char *devdesc" "const char **path" 513781ca0afSWarner Losh.Xc 514781ca0afSWarner Losh.Pp 515781ca0afSWarner LoshParse the 516781ca0afSWarner Losh.Dv devdesc 517781ca0afSWarner Loshstring of the form 518781ca0afSWarner Losh.Sq device:[/path/to/file] . 519781ca0afSWarner LoshThe 520781ca0afSWarner Losh.Dv devsw 521781ca0afSWarner Loshtable is used to match the start of the 522781ca0afSWarner Losh.Sq device 523781ca0afSWarner Loshstring with 524781ca0afSWarner Losh.Fa dv_name . 525781ca0afSWarner LoshIf 526781ca0afSWarner Losh.Fa dv_parsedev 527781ca0afSWarner Loshis non-NULL, then it will be called to parse the rest of the string and allocate 528781ca0afSWarner Loshthe 529781ca0afSWarner Losh.Dv struct devdesc 530781ca0afSWarner Loshfor this path. 531781ca0afSWarner LoshIf NULL, then a default routine will be called that will allocate a simple 532781ca0afSWarner Losh.Dv struct devdesc , 533781ca0afSWarner Loshparse a unit number and ensure there's no trailing characters. 534781ca0afSWarner LoshIf 535781ca0afSWarner Losh.Dv path 536781ca0afSWarner Loshis non-NULL, then a pointer to the remainder of the 537781ca0afSWarner Losh.Dv devdesc 538781ca0afSWarner Loshstring after the device specification is written. 539781ca0afSWarner Losh.It Xo 540*66012c8fSWarner Losh.Ft int 541*66012c8fSWarner Losh.Fn devinit void 542*66012c8fSWarner LoshCalls all the 543*66012c8fSWarner Losh.Fa dv_init 544*66012c8fSWarner Loshroutines in the 545*66012c8fSWarner Losh.Dv devsw 546*66012c8fSWarner Losharray, returning the number of routines that returned an error. 547*66012c8fSWarner Losh.It Xo 5483a7d8294SWarner Losh.Ft void 5493a7d8294SWarner Losh.Fn twiddle void 5503a7d8294SWarner Losh.Xc 5513a7d8294SWarner Losh.Pp 5523a7d8294SWarner LoshSuccessive calls emit the characters in the sequence |,/,-,\\ followed by a 5533a7d8294SWarner Loshbackspace in order to provide reassurance to the user. 5543a7d8294SWarner Losh.El 5553a7d8294SWarner Losh.Sh REQUIRED LOW-LEVEL SUPPORT 5563a7d8294SWarner LoshThe following resources are consumed by 5573a7d8294SWarner Losh.Nm 5583a7d8294SWarner Losh- stack, heap, console and devices. 5593a7d8294SWarner Losh.Pp 5603a7d8294SWarner LoshThe stack must be established before 5613a7d8294SWarner Losh.Nm 5623a7d8294SWarner Loshfunctions can be invoked. 5633a7d8294SWarner LoshStack requirements vary depending on the functions 5643a7d8294SWarner Loshand file systems used by the consumer and the support layer functions detailed 5653a7d8294SWarner Loshbelow. 5663a7d8294SWarner Losh.Pp 5673a7d8294SWarner LoshThe heap must be established before calling 5683a7d8294SWarner Losh.Fn alloc 5693a7d8294SWarner Loshor 5703a7d8294SWarner Losh.Fn open 5713a7d8294SWarner Loshby calling 5723a7d8294SWarner Losh.Fn setheap . 5733a7d8294SWarner LoshHeap usage will vary depending on the number of simultaneously open files, 5743a7d8294SWarner Loshas well as client behaviour. 5753a7d8294SWarner LoshAutomatic decompression will allocate more 5763a7d8294SWarner Loshthan 64K of data per open file. 5773a7d8294SWarner Losh.Pp 5783a7d8294SWarner LoshConsole access is performed via the 5793a7d8294SWarner Losh.Fn getchar , 5803a7d8294SWarner Losh.Fn putchar 5813a7d8294SWarner Loshand 5823a7d8294SWarner Losh.Fn ischar 5833a7d8294SWarner Loshfunctions detailed below. 5843a7d8294SWarner Losh.Pp 5853a7d8294SWarner LoshDevice access is initiated via 5863a7d8294SWarner Losh.Fn devopen 5873a7d8294SWarner Loshand is performed through the 5883a7d8294SWarner Losh.Fn dv_strategy , 5893a7d8294SWarner Losh.Fn dv_ioctl 5903a7d8294SWarner Loshand 5913a7d8294SWarner Losh.Fn dv_close 5923a7d8294SWarner Loshfunctions in the device switch structure that 5933a7d8294SWarner Losh.Fn devopen 5943a7d8294SWarner Loshreturns. 5953a7d8294SWarner Losh.Pp 5963a7d8294SWarner LoshThe consumer must provide the following support functions: 5973a7d8294SWarner Losh.Bl -hang -width 10n 5983a7d8294SWarner Losh.It Xo 5993a7d8294SWarner Losh.Ft int 6003a7d8294SWarner Losh.Fn getchar void 6013a7d8294SWarner Losh.Xc 6023a7d8294SWarner Losh.Pp 6033a7d8294SWarner LoshReturn a character from the console, used by 6043a7d8294SWarner Losh.Fn gets , 6053a7d8294SWarner Losh.Fn ngets 6063a7d8294SWarner Loshand pager functions. 6073a7d8294SWarner Losh.It Xo 6083a7d8294SWarner Losh.Ft int 6093a7d8294SWarner Losh.Fn ischar void 6103a7d8294SWarner Losh.Xc 6113a7d8294SWarner Losh.Pp 6123a7d8294SWarner LoshReturns nonzero if a character is waiting from the console. 6133a7d8294SWarner Losh.It Xo 6143a7d8294SWarner Losh.Ft void 6153a7d8294SWarner Losh.Fn putchar int 6163a7d8294SWarner Losh.Xc 6173a7d8294SWarner Losh.Pp 6183a7d8294SWarner LoshWrite a character to the console, used by 6193a7d8294SWarner Losh.Fn gets , 6203a7d8294SWarner Losh.Fn ngets , 6213a7d8294SWarner Losh.Fn *printf , 6223a7d8294SWarner Losh.Fn panic 6233a7d8294SWarner Loshand 6243a7d8294SWarner Losh.Fn twiddle 6253a7d8294SWarner Loshand thus by many other functions for debugging and informational output. 6263a7d8294SWarner Losh.It Xo 6273a7d8294SWarner Losh.Ft int 6283a7d8294SWarner Losh.Fn devopen "struct open_file *of" "const char *name" "const char **file" 6293a7d8294SWarner Losh.Xc 6303a7d8294SWarner Losh.Pp 6313a7d8294SWarner LoshOpen the appropriate device for the file named in 6323a7d8294SWarner Losh.Fa name , 6333a7d8294SWarner Loshreturning in 6343a7d8294SWarner Losh.Fa file 6353a7d8294SWarner Losha pointer to the remaining body of 6363a7d8294SWarner Losh.Fa name 6373a7d8294SWarner Loshwhich does not refer to the device. 6383a7d8294SWarner LoshThe 6393a7d8294SWarner Losh.Va f_dev 6403a7d8294SWarner Loshfield in 6413a7d8294SWarner Losh.Fa of 6423a7d8294SWarner Loshwill be set to point to the 6433a7d8294SWarner Losh.Vt devsw 6443a7d8294SWarner Loshstructure for the opened device if successful. 6453a7d8294SWarner LoshDevice identifiers must 6463a7d8294SWarner Loshalways precede the path component, but may otherwise be arbitrarily formatted. 6473a7d8294SWarner LoshUsed by 6483a7d8294SWarner Losh.Fn open 6493a7d8294SWarner Loshand thus for all device-related I/O. 6503a7d8294SWarner Losh.It Xo 6513a7d8294SWarner Losh.Ft int 6523a7d8294SWarner Losh.Fn devclose "struct open_file *of" 6533a7d8294SWarner Losh.Xc 6543a7d8294SWarner Losh.Pp 6553a7d8294SWarner LoshClose the device allocated for 6563a7d8294SWarner Losh.Fa of . 6573a7d8294SWarner LoshThe device driver itself will already have been called for the close; this call 6583a7d8294SWarner Loshshould clean up any allocation made by devopen only. 6593a7d8294SWarner Losh.It Xo 6603a7d8294SWarner Losh.Ft void 66145ad9557SWarner Losh.Fn __abort 6623a7d8294SWarner Losh.Xc 6633a7d8294SWarner Losh.Pp 6643a7d8294SWarner LoshCalls 6653a7d8294SWarner Losh.Fn panic 6663a7d8294SWarner Loshwith a fixed string. 6673a7d8294SWarner Losh.It Xo 6683a7d8294SWarner Losh.Ft void 6693a7d8294SWarner Losh.Fn panic "const char *msg" "..." 6703a7d8294SWarner Losh.Xc 6713a7d8294SWarner Losh.Pp 6723a7d8294SWarner LoshSignal a fatal and unrecoverable error condition. 6733a7d8294SWarner LoshThe 6743a7d8294SWarner Losh.Fa msg ... 6753a7d8294SWarner Losharguments are as for 6763a7d8294SWarner Losh.Fn printf . 6773a7d8294SWarner Losh.El 6783a7d8294SWarner Losh.Sh INTERNAL FILE SYSTEMS 6793a7d8294SWarner LoshInternal file systems are enabled by the consumer exporting the array 6803a7d8294SWarner Losh.Vt struct fs_ops *file_system[] , 6813a7d8294SWarner Loshwhich should be initialised with pointers 6823a7d8294SWarner Loshto 6833a7d8294SWarner Losh.Vt struct fs_ops 6843a7d8294SWarner Loshstructures. 6853a7d8294SWarner LoshThe following file system handlers are supplied by 6863a7d8294SWarner Losh.Nm , 6873a7d8294SWarner Loshthe consumer may supply other file systems of their own: 6883a7d8294SWarner Losh.Bl -hang -width ".Va cd9660_fsops" 6893a7d8294SWarner Losh.It Va ufs_fsops 6903a7d8294SWarner LoshThe 6913a7d8294SWarner Losh.Bx 6923a7d8294SWarner LoshUFS. 6933a7d8294SWarner Losh.It Va ext2fs_fsops 6943a7d8294SWarner LoshLinux ext2fs file system. 6953a7d8294SWarner Losh.It Va tftp_fsops 6963a7d8294SWarner LoshFile access via TFTP. 6973a7d8294SWarner Losh.It Va nfs_fsops 6983a7d8294SWarner LoshFile access via NFS. 6993a7d8294SWarner Losh.It Va cd9660_fsops 7003a7d8294SWarner LoshISO 9660 (CD-ROM) file system. 7013a7d8294SWarner Losh.It Va gzipfs_fsops 7023a7d8294SWarner LoshStacked file system supporting gzipped files. 7033a7d8294SWarner LoshWhen trying the gzipfs file system, 7043a7d8294SWarner Losh.Nm 7053a7d8294SWarner Loshappends 7063a7d8294SWarner Losh.Li .gz 7073a7d8294SWarner Loshto the end of the filename, and then tries to locate the file using the other 7083a7d8294SWarner Loshfile systems. 7093a7d8294SWarner LoshPlacement of this file system in the 7103a7d8294SWarner Losh.Va file_system[] 7113a7d8294SWarner Losharray determines whether gzipped files will be opened in preference to non-gzipped 7123a7d8294SWarner Loshfiles. 7133a7d8294SWarner LoshIt is only possible to seek a gzipped file forwards, and 7143a7d8294SWarner Losh.Fn stat 7153a7d8294SWarner Loshand 7163a7d8294SWarner Losh.Fn fstat 7173a7d8294SWarner Loshon gzipped files will report an invalid length. 7183a7d8294SWarner Losh.It Va bzipfs_fsops 7193a7d8294SWarner LoshThe same as 7203a7d8294SWarner Losh.Va gzipfs_fsops , 7213a7d8294SWarner Loshbut for 7223a7d8294SWarner Losh.Xr bzip2 1 Ns -compressed 7233a7d8294SWarner Loshfiles. 7243a7d8294SWarner Losh.El 7253a7d8294SWarner Losh.Pp 7263a7d8294SWarner LoshThe array of 7273a7d8294SWarner Losh.Vt struct fs_ops 7283a7d8294SWarner Loshpointers should be terminated with a NULL. 7293a7d8294SWarner Losh.Sh DEVICES 7303a7d8294SWarner LoshDevices are exported by the supporting code via the array 7313a7d8294SWarner Losh.Vt struct devsw *devsw[] 7323a7d8294SWarner Loshwhich is a NULL terminated array of pointers to device switch structures. 73345ad9557SWarner Losh.Sh DRIVER INTERFACE 73445ad9557SWarner LoshThe driver needs to provide a common set of entry points that are 73545ad9557SWarner Loshused by 73645ad9557SWarner Losh.Nm libsa 73745ad9557SWarner Loshto interface with the device. 73845ad9557SWarner Losh.Bd -literal 73945ad9557SWarner Loshstruct devsw { 74045ad9557SWarner Losh const char dv_name[DEV_NAMLEN]; 74145ad9557SWarner Losh int dv_type; 74245ad9557SWarner Losh int (*dv_init)(void); 74345ad9557SWarner Losh int (*dv_strategy)(void *devdata, int rw, daddr_t blk, 74445ad9557SWarner Losh size_t size, char *buf, size_t *rsize); 74545ad9557SWarner Losh int (*dv_open)(struct open_file *f, ...); 74645ad9557SWarner Losh int (*dv_close)(struct open_file *f); 74745ad9557SWarner Losh int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data); 74845ad9557SWarner Losh int (*dv_print)(int verbose); 74945ad9557SWarner Losh void (*dv_cleanup)(void); 750a0aad69fSWarner Losh char * (*dv_fmtdev)(struct devdesc *); 751a0aad69fSWarner Losh int (*dv_parsedev)(struct devdesc **dev, const char *devpart, 752a0aad69fSWarner Losh const char **path); 75345ad9557SWarner Losh}; 75445ad9557SWarner Losh.Ed 75545ad9557SWarner Losh.Bl -tag -width ".Fn dv_strategy" 75645ad9557SWarner Losh.It Fn dv_name 75745ad9557SWarner LoshThe device's name. 75845ad9557SWarner Losh.It Fn dv_type 75945ad9557SWarner LoshType of device. 76045ad9557SWarner LoshThe supported types are: 76145ad9557SWarner Losh.Bl -tag -width "DEVT_NONE" 76245ad9557SWarner Losh.It DEVT_NONE 76345ad9557SWarner Losh.It DEVT_DISK 76445ad9557SWarner Losh.It DEVT_NET 76545ad9557SWarner Losh.It DEVT_CD 76645ad9557SWarner Losh.It DEVT_ZFS 76745ad9557SWarner Losh.It DEVT_FD 76845ad9557SWarner Losh.El 76945ad9557SWarner LoshEach type may have its own associated (struct type_devdesc), 77045ad9557SWarner Loshwhich has the generic (struct devdesc) as its first member. 77145ad9557SWarner Losh.It Fn dv_init 77245ad9557SWarner LoshDriver initialization routine. 77345ad9557SWarner LoshThis routine should probe for available units. 77445ad9557SWarner LoshDrivers are responsible for maintaining lists of units for later enumeration. 77545ad9557SWarner LoshNo other driver routines may be called before 77645ad9557SWarner Losh.Fn dv_init 77745ad9557SWarner Loshreturns. 77845ad9557SWarner Losh.It Fn dv_open 77945ad9557SWarner LoshThe driver open routine. 78045ad9557SWarner Losh.It Fn dv_close 78145ad9557SWarner LoshThe driver close routine. 78245ad9557SWarner Losh.It Fn dv_ioctl 78345ad9557SWarner LoshThe driver ioctl routine. 78445ad9557SWarner Losh.It Fn dv_print 78545ad9557SWarner LoshPrints information about the available devices. 78645ad9557SWarner LoshInformation should be presented with 78745ad9557SWarner Losh.Fn pager_output . 78845ad9557SWarner Losh.It Fn dv_cleanup 78945ad9557SWarner LoshCleans up any memory used by the device before the next stage is run. 79045ad9557SWarner Losh.It Fn dv_fmtdev 79145ad9557SWarner LoshConverts the specified devdesc to the canonical string representation 79245ad9557SWarner Loshfor that device. 793a0aad69fSWarner Losh.It Fn dv_parsedev 794a0aad69fSWarner LoshParses the device portion of a file path. 795a0aad69fSWarner LoshThe 796a0aad69fSWarner Losh.Dv devpart 797a0aad69fSWarner Loshwill point to the 798a0aad69fSWarner Losh.Sq tail 799a0aad69fSWarner Loshof device name, possibly followed by a colon and a path within the device. 800a0aad69fSWarner LoshThe 801a0aad69fSWarner Losh.Sq tail 802a0aad69fSWarner Loshis, by convention, the part of the device specification that follows the 803a0aad69fSWarner Losh.Fa dv_name 804a0aad69fSWarner Loshpart of the string. 805781ca0afSWarner LoshSo when 806781ca0afSWarner Losh.Fa devparse 807781ca0afSWarner Loshis parsing the string 808781ca0afSWarner Losh.Dq disk3p5:/xxx , 809a0aad69fSWarner Losh.Dv devpart 810a0aad69fSWarner Loshwill point to the 811a0aad69fSWarner Losh.Sq 3 812a0aad69fSWarner Loshin that string. 813a0aad69fSWarner LoshThe parsing routine is expected to allocate a new 814a0aad69fSWarner Losh.Dv struct devdesc 815a0aad69fSWarner Loshor subclass and return it in 816a0aad69fSWarner Losh.Dv dev 817a0aad69fSWarner Loshwhen successful. 818a0aad69fSWarner LoshThis routine should set 819a0aad69fSWarner Losh.Dv path 820a0aad69fSWarner Loshto point to the portion of the string after device specification, or 821a0aad69fSWarner Losh.Dq /xxx 822a0aad69fSWarner Loshin the earlier example. 823781ca0afSWarner LoshGenerally, code needing to parse a path will use 824781ca0afSWarner Losh.Fa devparse 825781ca0afSWarner Loshinstead of calling this routine directly. 82645ad9557SWarner Losh.El 8273a7d8294SWarner Losh.Sh HISTORY 8283a7d8294SWarner LoshThe 8293a7d8294SWarner Losh.Nm 8303a7d8294SWarner Loshlibrary contains contributions from many sources, including: 8313a7d8294SWarner Losh.Bl -bullet -compact 8323a7d8294SWarner Losh.It 8333a7d8294SWarner Losh.Nm libsa 8343a7d8294SWarner Loshfrom 8353a7d8294SWarner Losh.Nx 8363a7d8294SWarner Losh.It 8373a7d8294SWarner Losh.Nm libc 8383a7d8294SWarner Loshand 8393a7d8294SWarner Losh.Nm libkern 8403a7d8294SWarner Loshfrom 8413a7d8294SWarner Losh.Fx 3.0 . 8423a7d8294SWarner Losh.It 8433a7d8294SWarner Losh.Nm zalloc 8443a7d8294SWarner Loshfrom 8453a7d8294SWarner Losh.An Matthew Dillon Aq Mt dillon@backplane.com 8463a7d8294SWarner Losh.El 8473a7d8294SWarner Losh.Pp 8483a7d8294SWarner LoshThe reorganisation and port to 8493a7d8294SWarner Losh.Fx 3.0 , 8503a7d8294SWarner Loshthe environment functions and this manpage were written by 8513a7d8294SWarner Losh.An Mike Smith Aq Mt msmith@FreeBSD.org . 8523a7d8294SWarner Losh.Sh BUGS 8533a7d8294SWarner LoshThe lack of detailed memory usage data is unhelpful. 854