]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/proto
nusb(2): remove startdevs() reference, document getdev() (thanks BurnZeZ)
[plan9front.git] / sys / man / 2 / proto
1 .TH PROTO 2
2 .SH NAME
3 rdproto \- 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
13 typedef void Protoenum(char *new, char *old, Dir *d, void *a)
14 .PP
15 .B
16 typedef void Protowarn(char *msg, void *a)
17 .PP
18 .B
19 int rdproto(char *proto, char *root, Protoenum *enm,
20 .br
21 .B
22                          Protowarn *warn, void *a)
23 .SH DESCRIPTION
24 .I Rdproto
25 reads and interprets the named
26 .I proto
27 file relative to the 
28 root directory
29 .IR root .
30 .PP
31 Each line of the
32 .I proto
33 file specifies a file to copy except lines in the form of
34 .IB attr = val
35 which sets an attribute (see below).
36 Blank lines and lines beginning with
37 .B #
38 are ignored.
39 Indentation (usually tabs) is significant,
40 with each level of indentation corresponding to a level in the file tree.
41 Fields within a line are separated by white space.
42 The first field is the last path element in the destination file tree.
43 The second field specifies the permissions.
44 The third field is the owner of the file,
45 and the fourth is the group owning the file.
46 The fifth field is the name of the file from which to copy;
47 this file is read from the current name space,
48 not the source file tree.
49 All fields except the first are optional.
50 Specifying 
51 .B -
52 for permissions, owner, or group 
53 causes
54 .I rdproto
55 to fetch the corresponding information
56 from the file rather than override it.
57 (This is the default behavior when the fields
58 are not present; explicitly specifying
59 .B -
60 is useful when one wishes to set, say,
61 the file owner without setting the permissions.)
62 .PP
63 Names beginning with a
64 .L $
65 are expanded as environment variables.
66 If the first file specified in a directory is
67 .LR * ,
68 all of the files in that directory are considered listed.
69 If the first file is
70 .LR + ,
71 all of the files are copied, and all subdirectories
72 are recursively considered listed.
73 All files are considered relative to
74 .IR root .
75 .PP
76 Attributes, lines in the form of
77 .IB attr = val,
78 apply to all files in the current
79 indention level after the attribute line.
80 Attributes are inherited to deeper levels but
81 each level can override them individualy.
82 The attribute
83 .BI skip= regexp
84 skips all file names matching the regular expression
85 .I regexp
86 for
87 .B *
88 and
89 .B +
90 operations using
91 .IR regexp (2).
92 If owner or group is left unspecified on a file, the attributes
93 .BI uid= owner
94 and
95 .BI gid= group
96 will override these fields.
97 The
98 .BI mode= mode
99 attribute adds, sets or masks file permission bits if permissions
100 where not explicitly specified on the file. If multiple
101 .B mode=
102 lines are given and
103 .I mode
104 is not a set operation (forced by
105 .B !
106 character)
107 the modes are combined.
108 Except for the special
109 .B !
110 character,
111 .I mode
112 has the same syntax as in
113 .IR chmod (1).
114 .PP
115 For each file named by the
116 .IR proto ,
117 .I enm
118 is called with
119 .I new
120 pointing at the name of the file (without the root prefix),
121 .I old
122 pointing at the name of the source file (with the root prefix,
123 when applicable),
124 and
125 .I Dir
126 at the desired directory information for the new file.
127 Only the
128 .BR name ,
129 .BR uid ,
130 .BR gid ,
131 .BR mode ,
132 .BR mtime ,
133 and
134 .B length
135 fields are guaranteed to be valid.
136 The argument 
137 .I a
138 is the same argument passed to
139 .IR rdproto ;
140 typically it points at some extra state
141 used by the enumeration function.
142 .PP
143 When files or directories do not exist or 
144 cannot be read by 
145 .IR rdproto ,
146 it formats a warning message, calls 
147 .IR warn ,
148 and continues processing; 
149 if
150 .I warn
151 is nil, 
152 .I rdproto
153 prints the warning message to standard error.
154 .PP
155 .I Rdproto
156 returns zero
157 if
158 .I proto 
159 was processed, \-1 if it could not be opened.
160 .SH FILES
161 .TF /sys/lib/sysconfig/proto/portproto
162 .TP
163 .B /sys/lib/sysconfig/proto/
164 directory of prototype files.
165 .TP
166 .B /sys/lib/sysconfig/proto/portproto
167 generic prototype file.
168 .SH SOURCE
169 .B /sys/src/libdisk/proto.c
170 .SH SEE ALSO
171 .IR mk9660 (8),
172 .IR mkfs (8),
173 .IR regexp (2),
174 .IR chmod (1).