readnum, readstr – device read routines
int readstr(ulong off, char *buf, ulong n, char *str)
int readnum(ulong off, char *buf, ulong n, ulong val, int size)
simplify the return of strings and numbers from device
because they deal with any buffering and boundary cases.
Several parameters to the read call are often handed on directly
to these functions:
the file offset, as
the address of the user’s buffer, as
and the number of bytes requested, as
Both functions return the number of bytes they have stored in
and which can often be returned directly from the device read routine.
satisfies a read by copying data into
from the NUL-terminated string in
The data transferred is selected and limited by
and the length of
converts the unsigned integer
to a decimal representation in
The value is right-justified in a field of
places and is followed by a blank.
can be the global constant
for 32-bit integers;
allowed is 64 bytes.