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