man(1) Manual page archive


     MEMFS(2)                                                 MEMFS(2)

     NAME
          memfs - heap based filesystem

     SYNOPSIS
          include "sys.m";
          include "memfs.m";
          memfs := load MemFS MemFS->PATH;

          init:    fn(): string;
          newfs:   fn(maxsz: int): ref Sys->FD;

     DESCRIPTION
          The MemFS module implements a Styx file server where all
          files and filesystem data structures are stored in the local
          heap, not on disk.

          init()
               The init function should be called once to initialise
               the internal state of MemFS.  Failure to initialise is
               reported by the returned string.  A return value of nil
               indicates success.

          newfs(maxsz)
               The newfs function takes a single argument, maxsz
               defining the maximum number of bytes of the new
               filesystem.  The return value is a file descriptor,
               serving Styx, suitable for passing to mount (see sys-
               bind(2)).

          Multiple filesystems of different sizes can be supported by
          a single instance of the module.  Each filesystem is con-
          strained by maxsz, any filesystem operations that cause the
          limit to be exceeded are failed with the error message:

               `filesystem full'

          File data is allocated in 512 byte blocks.  The actual
          filesystem data limit is always a multiple of this block
          size:

               actualmaxsz := (maxsz / 512) * 512;

     SOURCE
          /appl/lib/memfs.b

     CAVEATS
          Only file data blocks are considered in the determination of
          heap usage, the overhead of internal data structures cannot
          be accounted for.  MemFS could store its own data structures
          in data blocks, but this would impede performance.

     MEMFS(2)                                                 MEMFS(2)

          Newly created and empty files are pre-allocated a data block
          in an attempt to prevent directory entries from using heap
          without regard to the requested maxsz.

     SEE ALSO
          styxlib(2), memfs(4)