blob: 2d5da3afc7968f9f15c77a396a599cae5e0fc2a8 [file] [log] [blame]
rsc058b0112005-01-03 06:40:20 +00001.TH PROTO 3
2.SH NAME
3rdproto \- parse and process a proto file listing
4.SH SYNOPSIS
5.nf
6.ft L
7#include <u.h>
8#include <libc.h>
9#include <disk.h>
10.ft
11.PP
12.B
13typedef void Protoenum(char *new, char *old, Dir *d, void *a)
14.PP
15.B
16typedef void Protowarn(char *msg, void *a)
17.PP
18.B
19int rdproto(char *proto, char *root, Protoenum *enm,
20.br
21.B
22 Protowarn *warn, void *a)
23.SH DESCRIPTION
24.I Rdproto
25reads and interprets the named
26.I proto
27file relative to the
28root directory
29.IR root .
30.PP
31Each line of the
32.I proto
33file specifies a file to copy.
34Blank lines and lines beginning with
35.B #
36are ignored.
37Indentation (usually tabs) is significant,
38with each level of indentation corresponding to a level in the file tree.
39Fields within a line are separated by white space.
40The first field is the last path element in the destination file tree.
41The second field specifies the permissions.
42The third field is the owner of the file,
43and the fourth is the group owning the file.
44The fifth field is the name of the file from which to copy;
45this file is read from the current name space,
46not the source file tree.
47All fields except the first are optional.
48Specifying
49.B -
50for permissions, owner, or group
51causes
52.I rdproto
53to fetch the corresponding information
54from the file rather than override it.
55(This is the default behavior when the fields
56are not present; explicitly specifying
57.B -
58is useful when one wishes to set, say,
59the file owner without setting the permissions.)
60.PP
61Names beginning with a
62.L $
63are expanded as environment variables.
64If the first file specified in a directory is
65.LR * ,
66all of the files in that directory are considered listed.
67If the first file is
68.LR + ,
69all of the files are copied, and all subdirectories
70are recursively considered listed.
71All files are considered relative to
72.IR root .
73.PP
74For each file named by the
75.IR proto ,
76.I enm
77is called with
78.I new
79pointing at the name of the file (without the root prefix),
80.I old
81pointing at the name of the source file (with the root prefix,
82when applicable),
83and
84.I Dir
85at the desired directory information for the new file.
86Only the
87.BR name ,
88.BR uid ,
89.BR gid ,
90.BR mode ,
91.BR mtime ,
92and
93.B length
94fields are guaranteed to be valid.
95The argument
96.I a
97is the same argument passed to
98.IR rdproto ;
99typically it points at some extra state
100used by the enumeration function.
101.PP
102When files or directories do not exist or
103cannot be read by
104.IR rdproto ,
105it formats a warning message, calls
106.IR warn ,
107and continues processing;
108if
109.I warn
110is nil,
111.I rdproto
112prints the warning message to standard error.
113.PP
114.I Rdproto
115returns zero
116if
117.I proto
118was processed, \-1 if it could not be opened.
119.SH FILES
120.TF /sys/lib/sysconfig/proto/portproto
121.TP
122.B /sys/lib/sysconfig/proto/
123directory of prototype files.
124.TP
125.B /sys/lib/sysconfig/proto/portproto
126generic prototype file.
127.SH SOURCE
rscc3674de2005-01-11 17:37:33 +0000128.B \*9/src/libdisk/proto.c
rsc058b0112005-01-03 06:40:20 +0000129.SH SEE ALSO
rscadc93f62005-01-14 17:37:50 +0000130.IR mk9660 (1),
rsc058b0112005-01-03 06:40:20 +0000131Plan 9's \fImkfs\fR(8)