next up previous contents index
Next: 10.21 Signals Up: 10.20 Boot Module Filesystem Previous: 10.20.3 oskit_bmod_unlock: unlock BMOD

10.20.4 oskit_bmod_file_set_contents: replace contents of a BMOD file

 

SYNOPSIS

#include <oskit/fs/bmodfs.h>

oskit_error_t oskit_bmod_file_set_contents(oskit_file_t *file, void *data, oskit_off_t size, oskit_off_t allocsize, oskit_bool_t can_sfree, oskit_bool_t inhibit_resize);

DESCRIPTION

This function changes the indicated BMOD file to use the memory from [data - data+size-1] as its contents. File must be a regular BMOD file and not a directory.

Allocsize indicates the total amount of memory available for the file to use when growing and must be greater than or equal to size. If an attempt is made to grow the file to a size greater than allocsize, new memory will be allocated with smemalign and the file contents copied to the new memory.

If inhibit_resize is true, attempts to change the size of the file hereafter will fail with OSKIT_EPERM.

If can_sfree is true, sfree is called on the data buffer if the file grows beyond allocsize, is truncated to zero-length or is removed.

PARAMETERS

file
File in the bmod filesystem whose contents are being replaced.
data
Pointer to memory to be used as the new file contents.
size
The new size of the file.
allocsize
Size of writable memory available for the file.
can_sfree
If true, indicates that the memory pointed to by data can be released with sfree when the file grows beyond allocsize, is truncated to zero-length, or is removed.
inhibit_resize
If true, fails any attempt to change the size of the file.

RETURNS

Returns zero on success, an error code otherwise.

DEPENDENCIES

smemalign
9.5.10
sfree
9.5.11
memset
9.4.18



University of Utah Flux Research Group