xref: /inferno-os/man/2/fsproto (revision 6e425a9de8c003b5a733621a6b6730ec3cc902b8)
FSPROTO 2
NAME
FSproto: readprotofile, readprotostring - read file system prototype file
SYNOPSIS
.EX include "fsproto.m"; fsproto := load FSproto FSproto->PATH; Direntry: type (string, string, ref Sys->Dir); init: fn(): string; readprotofile: fn(proto: string, root: string, entries: chan of Direntry, warnings: chan of (string, string)): string; readprotostring: fn(proto: string, root: string, entries: chan of Direntry, warnings: chan of (string, string));
DESCRIPTION
FSproto provides an interface to read a file system prototype file, as defined by proto (6).

Init must be called before any other function in the module.

Readprotofile reads a file system prototype from the file proto . It traverses the file system, starting at the given root , and each file or directory encountered that is mentioned in the prototype causes readprotofile to send a Direntry tuple on the channel entries . The tuple has the form ( old , new , dir\f5) where old is the name of the current file or directory, rooted at root , new is the same file's name relative to root , and dir is a reference to the Sys->Dir directory information for old , as produced by sys-stat (2). When all files in root have been examined, readprotofile sends a single tuple with all nil components on entries . For each error that occurs during processing (eg, unable to open a directory) readprotofile sends a tuple ( old , diag ) on the channel warnings , naming the file and giving a diagnostic string, but processing continues.

Readprotostring reads a file system prototype from the string proto itself. Otherwise, its operation is the same as readprotofile .

SOURCE
/appl/lib/fsproto.b
SEE ALSO
fs (1), proto (6), mkfs (8)