Skip to content

Commit de294fc

Browse files
committed
fullfs: add runtime state control via ioctl
1 parent e535bfc commit de294fc

17 files changed

Lines changed: 1339 additions & 311 deletions

File tree

distrib/sets/lists/base/mi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@
393393
./sbin/fsck_v7fs base-sysutil-root v7fs
394394
./sbin/fsdb base-sysutil-root
395395
./sbin/fsirand base-sysutil-root
396+
./sbin/fullfsctl base-miscfs-root fullfs
396397
./sbin/gpt base-sysutil-root
397398
./sbin/halt base-sysutil-root
398399
./sbin/ifconfig base-netutil-root

distrib/sets/lists/comp/mi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,7 @@
27882788
./usr/include/miscfs/fdesc/fdesc.h comp-c-include
27892789
./usr/include/miscfs/fifofs/fifo.h comp-c-include
27902790
./usr/include/miscfs/fullfs/full.h comp-c-include
2791+
./usr/include/miscfs/fullfs/full_ioctl.h comp-c-include
27912792
./usr/include/miscfs/genfs/genfs.h comp-c-include
27922793
./usr/include/miscfs/genfs/genfs_node.h comp-c-include
27932794
./usr/include/miscfs/genfs/layer.h comp-c-include

distrib/sets/lists/debug/mi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@
368368
./usr/libdata/debug/sbin/fsck_v7fs.debug comp-sysutil-debug v7fs,debug
369369
./usr/libdata/debug/sbin/fsdb.debug comp-sysutil-debug debug
370370
./usr/libdata/debug/sbin/fsirand.debug comp-sysutil-debug debug
371+
./usr/libdata/debug/sbin/fullfsctl.debug comp-miscfs-debug fullfs,debug
371372
./usr/libdata/debug/sbin/gpt.debug comp-sysutil-debug debug
372373
./usr/libdata/debug/sbin/ifconfig.debug comp-netutil-debug debug
373374
./usr/libdata/debug/sbin/init.debug comp-sysutil-debug debug

distrib/sets/lists/man/mi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,7 @@
28912891
./usr/share/man/cat8/ftp-proxy.0 man-pf-catman pf,.cat
28922892
./usr/share/man/cat8/ftpd.0 man-netutil-catman .cat
28932893
./usr/share/man/cat8/fusermount.0 man-refuse-catman .cat
2894+
./usr/share/man/cat8/fullfsctl.0 man-miscfs-catman fullfs,.cat
28942895
./usr/share/man/cat8/fwctl.0 man-sysutil-catman .cat
28952896
./usr/share/man/cat8/genassym.sh.0 man-obsolete obsolete
28962897
./usr/share/man/cat8/getNAME.0 man-man-catman !makemandb,.cat
@@ -6483,6 +6484,7 @@
64836484
./usr/share/man/man8/fstyp.8 man-sysutil-man .man
64846485
./usr/share/man/man8/ftp-proxy.8 man-pf-man pf,.man
64856486
./usr/share/man/man8/ftpd.8 man-netutil-man .man
6487+
./usr/share/man/man8/fullfsctl.8 man-miscfs-man fullfs,.man
64866488
./usr/share/man/man8/fusermount.8 man-refuse-man .man
64876489
./usr/share/man/man8/fwctl.8 man-sysutil-man .man
64886490
./usr/share/man/man8/genassym.sh.8 man-obsolete obsolete

distrib/sets/lists/manhtml/mi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,7 @@
26122612
./usr/share/man/html8/ftp-proxy.html man-pf-htmlman pf,html
26132613
./usr/share/man/html8/ftpd.html man-netutil-htmlman html
26142614
./usr/share/man/html8/fusermount.html man-refuse-htmlman html
2615+
./usr/share/man/html8/fullfsctl.html man-miscfs-htmlman fullfs,html
26152616
./usr/share/man/html8/fwctl.html man-sysutil-htmlman html
26162617
./usr/share/man/html8/getNAME.html man-man-htmlman !makemandb,html
26172618
./usr/share/man/html8/getencstat.html man-sysutil-htmlman html

sbin/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ SUBDIR+= mount_null
9393
.endif
9494

9595
.if (${MKFULLFS} != "no")
96+
SUBDIR+= fullfsctl
9697
SUBDIR+= mount_full
9798
.endif
9899

sbin/fullfsctl/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# $NetBSD$
2+
3+
.include <bsd.own.mk>
4+
5+
PROG= fullfsctl
6+
MAN= fullfsctl.8
7+
8+
CPPFLAGS+= -I${NETBSDSRCDIR}/sys
9+
LDADD+= -lutil
10+
DPADD+= ${LIBUTIL}
11+
12+
.include <bsd.prog.mk>

sbin/fullfsctl/fullfsctl.8

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
.\" $NetBSD$
2+
.\"
3+
.\"
4+
.Dd March 6, 2026
5+
.Dt FULLFSCTL 8
6+
.Os
7+
.Sh NAME
8+
.Nm fullfsctl
9+
.Nd control fullfs runtime fail state
10+
.Sh SYNOPSIS
11+
.Nm
12+
.Fl m Ar mode
13+
.Op Fl e Ar errno
14+
.Op Fl o Ar ops
15+
.Op Fl d Ar doom
16+
.Op Fl r Ar rate
17+
.Ar path
18+
.Nm
19+
.Fl s
20+
.Ar path
21+
.Sh DESCRIPTION
22+
The
23+
.Nm
24+
utility controls the runtime failure behavior of a mounted
25+
.Em fullfs
26+
filesystem.
27+
By default, a freshly mounted
28+
.Em fullfs
29+
fails all space-allocating operations with
30+
.Er ENOSPC .
31+
.Nm
32+
allows the fail mode, error code, operation mask, and countdown
33+
parameters to be changed at any time without remounting.
34+
.Pp
35+
.Ar path
36+
may be the mountpoint or any file within the fullfs mount.
37+
.Pp
38+
The
39+
.Fl m
40+
flag is required for all set operations.
41+
Flags omitted on the set path take their default values.
42+
.Pp
43+
The second synopsis form,
44+
.Fl s ,
45+
queries and displays the current state in the form:
46+
.Pp
47+
.Dl mode=<mode> error=<n> opmask=0x<mask> doom=<n> rate=<n>
48+
.Pp
49+
It cannot be combined with other flags.
50+
.Sh OPTIONS
51+
.Bl -tag -width "-e errno"
52+
.It Fl m Ar mode
53+
Set the fail mode.
54+
One of:
55+
.Bl -tag -width "random" -compact
56+
.It Cm pass
57+
All operations succeed; transparent passthrough.
58+
.It Cm fail
59+
All masked operations fail with the configured error.
60+
.It Cm count
61+
Allow
62+
.Ar doom
63+
masked operations, then fail subsequent ones.
64+
Operations not in the mask pass through without decrementing the counter.
65+
.It Cm bytes
66+
Allow
67+
.Ar doom
68+
bytes of writes, then fail.
69+
Non-write operations always pass through.
70+
If a write exceeds the remaining budget, it is rejected entirely;
71+
no partial writes occur.
72+
.It Cm random
73+
Each masked operation independently fails with the probability
74+
set by
75+
.Fl r .
76+
Unmasked operations pass through without rolling.
77+
.El
78+
.It Fl e Ar errno
79+
Error code to return on failure.
80+
Accepts a symbolic name
81+
.Po
82+
.Li enospc ,
83+
.Li eio ,
84+
.Li edquot ,
85+
.Li efbig ,
86+
.Li eperm ,
87+
.Li eacces ,
88+
.Li erofs
89+
.Pc
90+
or a positive integer.
91+
Default:
92+
.Er ENOSPC .
93+
.It Fl o Ar ops
94+
Comma-separated list of operations to mask.
95+
Valid names:
96+
.Li write ,
97+
.Li create ,
98+
.Li mkdir ,
99+
.Li mknod ,
100+
.Li symlink ,
101+
.Li link ,
102+
.Li all ,
103+
.Li none .
104+
Default:
105+
.Li all .
106+
.It Fl d Ar doom
107+
Doom counter.
108+
In
109+
.Cm count
110+
mode, the number of masked operations to allow before failing.
111+
In
112+
.Cm bytes
113+
mode, the byte budget for writes.
114+
Must be positive when the mode is
115+
.Cm count
116+
or
117+
.Cm bytes .
118+
Default: 0.
119+
.It Fl r Ar rate
120+
Failure rate percentage for
121+
.Cm random
122+
mode, from 1 to 99.
123+
Boundary values 0 and 100 are rejected; use
124+
.Cm pass
125+
or
126+
.Cm fail
127+
instead.
128+
Default: 0.
129+
.It Fl s
130+
Show the current state of the fullfs mount and exit.
131+
Cannot be combined with
132+
.Fl m
133+
or other flags.
134+
.El
135+
.Sh EXAMPLES
136+
Fail all operations with
137+
.Er ENOSPC :
138+
.Pp
139+
.Dl fullfsctl -m fail /mnt/full
140+
.Pp
141+
Fail all operations with
142+
.Er EIO :
143+
.Pp
144+
.Dl fullfsctl -m fail -e eio /mnt/full
145+
.Pp
146+
Fail only writes, allowing file creation:
147+
.Pp
148+
.Dl fullfsctl -m fail -o write /mnt/full
149+
.Pp
150+
Allow 5 operations, then fail:
151+
.Pp
152+
.Dl fullfsctl -m count -d 5 /mnt/full
153+
.Pp
154+
Allow 1024 bytes of writes, then fail:
155+
.Pp
156+
.Dl fullfsctl -m bytes -d 1024 /mnt/full
157+
.Pp
158+
Fail 50% of masked operations at random:
159+
.Pp
160+
.Dl fullfsctl -m random -r 50 /mnt/full
161+
.Pp
162+
Pass all operations through (disable failure injection):
163+
.Pp
164+
.Dl fullfsctl -m pass /mnt/full
165+
.Pp
166+
Show the current state:
167+
.Pp
168+
.Dl fullfsctl -s /mnt/full
169+
.Sh CAVEATS
170+
Writes performed via
171+
.Xr mmap 2
172+
and
173+
.Xr msync 2
174+
bypass
175+
.Em fullfs
176+
and are not subject to failure injection.
177+
This is a layerfs architectural constraint;
178+
.Fn putpages
179+
operates at the VM page level, not the VOP level.
180+
.Sh SEE ALSO
181+
.Xr mount 8 ,
182+
.Xr mount_full 8
183+
.Sh HISTORY
184+
The
185+
.Nm
186+
utility first appeared in
187+
.Nx 11 .

0 commit comments

Comments
 (0)