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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
.TH CWFS 4
.SH NAME
cwfs, \
cwfs64, \
cwfs64x, \
fs64 - cached-worm file server, dump
.SH SYNOPSIS
.B cwfs
[
.B -csC
] [
.B -n
.I service
] [
.B -a
.I announce-string
] ... [
.B -m
.I device-map
] [
.B -f
.I config-device
]
.SH DESCRIPTION
.I Cwfs
is a cached-worm file server that runs
as a user-mode program and can
maintain file systems created by
.IR fs (4),
the original Plan 9 file server
that had its own kernel and operated
a standalone system with disks and
optical-disc jukebox attached.
Unlike
.IR fs (4),
which could only accept 9P connections over IL/IPv4 on Ethernets
(or over Datakit and Cyclones, long ago),
.I cwfs
accepts 9P connections over any network medium and protocol
that it can announce on,
by default TCP (over IPv4 or IPv6).
Given suitable 9P clients,
one could even run 9P over
.IR aan (8)
or
.IR tls (3).
.PP
The stock
.I cwfs
implements a 16K file system block size
and 32-bit disk addresses,
in order to be compatible with some existing file systems, notably
.IR emelie 's.
These parameters can be changed by recompilation.
.PP
.I Cwfs
places its server 9P connection in
.BI /srv/ name\f1
and its command pipe in
.BI /srv/ name\f1 .cmd,
where
.I name
is the service name.
.PP
Options are:
.TP
.B -f
specify
.IR config-device
other than the default
.LR /dev/sdC0/cwfs .
.TP
.B -a
announce on
.I announce-string
instead of
.LR tcp!*!9fs .
.TP
.B -C
use a newer, faster, and incompatible cache-device layout.
To convert an old file system's cache to the new layout,
dump the file system, note the last superblock number,
halt
.IR cwfs ,
restart
.I cwfs
with
.BR -cC ,
.I recover
the file system, and start
.I cwfs
with
.B -C
thereafter.
.TP
.B -c
enter the file server's configuration mode
before starting normal operation.
.TP
.B -n
overrides the
.I service
name of the file server's configuration.
.TP
.B -s
Post file descriptor zero in
.BI /srv/ service
and read and write protocol messages on file descriptor one.
.TP
.B -m
the file
.I device-map
contains a simple device name
(e.g.,
.LR w9 )
and a replacement per line.
The device name is in the usual
.I filsys
notation of
.IR fsconfig (8).
The replacement can be the name of an existing file
(which
.I cwfs
will not grow)
or another such device name.
For example, the file
.RS
.PD
.IP
.EX
w0 /tmp/w0
h1 w2
.EE
.PP
.PD 0.3v
would map accesses to device
.L w0
to existing file
.LR /tmp/w0
and accesses to device
.L h1
to device
.LR w2 ,
if no file named
.L w2
exists.
.RE
.PD
.PP
The file server normally requires all users except
.L none
to provide authentication tickets on each
.IR attach (5).
This can be disabled using the
.B noauth
configuration command (see
.IR fsconfig (8)).
.PP
The group numbered 9999, normally called
.BR noworld ,
is special
on the file server. Any user belonging to that group has
attenuated access privileges. Specifically, when checking such
a user's access to files, the file's permission bits are first ANDed
with 0770 for normal files or 0771 for directories. The effect is
to deny world access permissions to
.B noworld
users, except
when walking directories.
.PP
The user
.B none
is always allowed to attach to
.B emelie
without authentication but has minimal permissions.
.PP
.B Emelie
maintains three file systems
on a combination of disks and
write-once-read-many (WORM) magneto-optical disks.
.TP
.B other
is a simple disk-based file system not backed by worm.
.TP
.B main
is a worm-based file system with a disk-based
look-aside cache.
The disk cache holds
modified worm blocks
to overcome the write-once property of the worm.
The cache also holds recently accessed
non-modified blocks to
speed up the effective access time of the worm.
Occasionally
(usually daily at 5AM) the modified blocks in the
disk cache are
.IR dumped .
At this time,
traffic to the file system is halted and the
modified blocks are relabeled to the unwritten
portion of the worm.
After the dump,
the file system traffic is continued and
the relabeled blocks are copied to the worm by
a background process.
.TP
.B dump
Each time the main file system is dumped,
its root is appended to a subdirectory of the dump file system.
Since the dump file system is not mirrored with a disk
cache,
it is read-only.
The name of the newly added root is created from the date
of the dump:
.BI / yyyy / mmdds\f1.
Here
.I yyyy
is the full year,
.I mm
is the month number,
.I dd
is the day number and
.I s
is a sequence number if more than
one dump is done in a day.
For the first dump,
.I s
is null.
For the subsequent dumps
.I s
is 1, 2, 3, etc.
.sp
The root of the main file system
that is frozen on the first dump
of March 1, 1992
will be named
.B /1992/0301/
in the dump file system.
.SS "Changes from fs"
.IR fs (4)'s
IP configuration is ignored and the underlying system's is used.
.PP
Various other
.IR fs (4)
commands have been omitted since they (or equivalents) can now be
executed directly on the underlying CPU server,
notably
.I date
and
.I passwd
(see
.IR auth/wrkey ).
.PP
Files can be used directly as wren devices by giving
a file name rooted at
.I /
or using double or single quotes. Such a file name
can be appended to the
.L w
device instead of specifying
.L target
and
.L lun
numbers.
.PP
.IR fs (4)'s
device names
.L h
for IDE disks and
.L m
for Marvell SATA disks are not supported; use
.B -m
to map wren devices to appropriate names under
.BR /dev/sd* .
.PP
The file server kernel seems to have scanned PCI buses
in reverse order from the other Plan 9 kernels,
so systems with multiple SCSI cards may find controller
numbering reversed.
.B -m
can be used to compensate for this if you don't want to change
.I filsys
declarations.
.PP
The file server kernel's
.I config
field in NVRAM was overloaded in recent times to hold a
.IR secstore (1)
key for the CPU hostowner.
Since
.I cwfs
runs on a CPU kernel,
the location of its configuration block must be supplied on the command line.
.PP
Disk labels are now implemented for
.B l
devices.
At the first access of a side,
.I cwfs
will attempt to read the label and verify that it has the correct side
number and byte order; if either is wrong, it will issue a warning.
If the label cannot be read,
.I cwfs
will attempt to write a new label.
.PP
The original file server reserved the rest of the machines RAM for
io buffers. Where
.I cwfs
running under the Plan 9 kernel reserves a settable percentage
of the remaining user pages. The percentage is read from the
environment variable
.B fsmempercent
which when not set is assumed to be 25% (default).
.SH EXAMPLES
Place the root of the
.B dump
file system on
.B /n/dump
and show the modified times of the MIPS C compiler
over all dumps in February, 1992:
.IP
.EX
cwfs w0
9fs dump
ls -l /n/dump/1992/02??/mips/bin/vc
.EE
.PP
To get only one line of output for each version of the compiler:
.IP
.EX
ls -lp /n/dump/1992/02??/mips/bin/vc | uniq
.EE
.SH SOURCE
.B /sys/src/cmd/cwfs
.SH SEE ALSO
.IR yesterday (1),
.IR fs (3),
.IR sd (3),
.IR fs (4),
.IR srv (4),
.IR fs (8),
.IR fsconfig (8)
.br
Sean Quinlan,
``A Cached WORM File System'',
.I
Software \- Practice and Experience,
December, 1991
.br
Ken Thompson,
Geoff Collyer,
``The 64-bit Standalone Plan 9 File Server''
.SH BUGS
For the moment,
the file server serves both the old (9P1) and new (9P2000) versions of 9P,
deciding which to serve by sniffing the first packet on each connection.
.PP
File system block size and disk address size (32- or 64-bit) are fixed
at compilation time, and this is not easily changed.
|