xref: /freebsd/sbin/tunefs/tunefs.c (revision 907db4dd231cf25071be576ba701a32b1ccf9634)
18fae3551SRodney W. Grimes /*
28fae3551SRodney W. Grimes  * Copyright (c) 1983, 1993
38fae3551SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
48fae3551SRodney W. Grimes  *
58fae3551SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
68fae3551SRodney W. Grimes  * modification, are permitted provided that the following conditions
78fae3551SRodney W. Grimes  * are met:
88fae3551SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
98fae3551SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
108fae3551SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
118fae3551SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
128fae3551SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
138fae3551SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
148fae3551SRodney W. Grimes  *    must display the following acknowledgement:
158fae3551SRodney W. Grimes  *	This product includes software developed by the University of
168fae3551SRodney W. Grimes  *	California, Berkeley and its contributors.
178fae3551SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
188fae3551SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
198fae3551SRodney W. Grimes  *    without specific prior written permission.
208fae3551SRodney W. Grimes  *
218fae3551SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
228fae3551SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
238fae3551SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
248fae3551SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
258fae3551SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
268fae3551SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
278fae3551SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
288fae3551SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
298fae3551SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
308fae3551SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
318fae3551SRodney W. Grimes  * SUCH DAMAGE.
328fae3551SRodney W. Grimes  */
338fae3551SRodney W. Grimes 
348fae3551SRodney W. Grimes #ifndef lint
358679b1b4SPhilippe Charnier static const char copyright[] =
368fae3551SRodney W. Grimes "@(#) Copyright (c) 1983, 1993\n\
378fae3551SRodney W. Grimes 	The Regents of the University of California.  All rights reserved.\n";
388fae3551SRodney W. Grimes #endif /* not lint */
398fae3551SRodney W. Grimes 
408fae3551SRodney W. Grimes #ifndef lint
418679b1b4SPhilippe Charnier #if 0
428fae3551SRodney W. Grimes static char sccsid[] = "@(#)tunefs.c	8.2 (Berkeley) 4/19/94";
438679b1b4SPhilippe Charnier #endif
448679b1b4SPhilippe Charnier static const char rcsid[] =
457f3dea24SPeter Wemm   "$FreeBSD$";
468fae3551SRodney W. Grimes #endif /* not lint */
478fae3551SRodney W. Grimes 
488fae3551SRodney W. Grimes /*
498fae3551SRodney W. Grimes  * tunefs: change layout parameters to an existing file system.
508fae3551SRodney W. Grimes  */
518fae3551SRodney W. Grimes #include <sys/param.h>
527382c45aSLuoqi Chen #include <sys/mount.h>
5375766e17SPoul-Henning Kamp #include <sys/disklabel.h>
548fae3551SRodney W. Grimes #include <sys/stat.h>
558fae3551SRodney W. Grimes 
567382c45aSLuoqi Chen #include <ufs/ufs/ufsmount.h>
571c85e6a3SKirk McKusick #include <ufs/ufs/dinode.h>
581c85e6a3SKirk McKusick #include <ufs/ffs/fs.h>
598fae3551SRodney W. Grimes 
608fae3551SRodney W. Grimes #include <err.h>
618fae3551SRodney W. Grimes #include <fcntl.h>
628fae3551SRodney W. Grimes #include <fstab.h>
63b1f0fda0SJuli Mallett #include <libufs.h>
648fae3551SRodney W. Grimes #include <paths.h>
658679b1b4SPhilippe Charnier #include <stdio.h>
668fae3551SRodney W. Grimes #include <stdlib.h>
67060ac658SSheldon Hearn #include <string.h>
688fae3551SRodney W. Grimes #include <unistd.h>
698fae3551SRodney W. Grimes 
708fae3551SRodney W. Grimes /* the optimization warning string template */
718fae3551SRodney W. Grimes #define	OPTWARN	"should optimize for %s with minfree %s %d%%"
728fae3551SRodney W. Grimes 
73b1f0fda0SJuli Mallett struct uufsd disk;
74b1f0fda0SJuli Mallett #define	sblock disk.d_fs
758fae3551SRodney W. Grimes 
76d476a036SWarner Losh void usage(void);
77d476a036SWarner Losh void printfs(void);
788fae3551SRodney W. Grimes 
798fae3551SRodney W. Grimes int
80b1f0fda0SJuli Mallett main(int argc, char *argv[])
818fae3551SRodney W. Grimes {
82907db4ddSJuli Mallett 	const char *special, *on;
83c33fa91fSDima Dorfman 	const char *name;
84289e09eeSRobert Watson 	int Aflag = 0, active = 0, aflag = 0;
85289e09eeSRobert Watson 	int eflag = 0, fflag = 0, lflag = 0, mflag = 0;
86a61ab64aSKirk McKusick 	int nflag = 0, oflag = 0, pflag = 0, sflag = 0;
87a9098c89SPoul-Henning Kamp 	int evalue = 0, fvalue = 0;
88a61ab64aSKirk McKusick 	int mvalue = 0, ovalue = 0, svalue = 0;
89289e09eeSRobert Watson 	char *avalue = NULL, *lvalue = NULL, *nvalue = NULL;
90c33fa91fSDima Dorfman 	const char *chg[2];
917382c45aSLuoqi Chen 	struct ufs_args args;
927382c45aSLuoqi Chen 	struct statfs stfs;
932af14b60SPhilippe Charnier 	int found_arg, ch;
948fae3551SRodney W. Grimes 
952af14b60SPhilippe Charnier         if (argc < 3)
968fae3551SRodney W. Grimes                 usage();
9777edab90SPhilippe Charnier 	found_arg = 0; /* at least one arg is required */
98a2325efeSRobert Watson 	while ((ch = getopt(argc, argv, "Aa:e:f:l:m:n:o:ps:")) != -1)
9977edab90SPhilippe Charnier 	  switch (ch) {
100a2325efeSRobert Watson 	  case 'A':
101a2325efeSRobert Watson 		found_arg = 1;
102a2325efeSRobert Watson 		Aflag++;
103a2325efeSRobert Watson 		break;
104289e09eeSRobert Watson 	  case 'a':
105289e09eeSRobert Watson 		found_arg = 1;
106289e09eeSRobert Watson 		name = "ACLs";
107289e09eeSRobert Watson 		avalue = optarg;
108289e09eeSRobert Watson 		if (strcmp(avalue, "enable") && strcmp(avalue, "disable")) {
109289e09eeSRobert Watson 			errx(10, "bad %s (options are %s)", name,
110289e09eeSRobert Watson 			    "`enable' or `disable'");
111289e09eeSRobert Watson 		}
112289e09eeSRobert Watson 		aflag = 1;
113289e09eeSRobert Watson 		break;
11477edab90SPhilippe Charnier 	  case 'e':
11577edab90SPhilippe Charnier 		found_arg = 1;
11677edab90SPhilippe Charnier 		name = "maximum blocks per file in a cylinder group";
11777edab90SPhilippe Charnier 		evalue = atoi(optarg);
11877edab90SPhilippe Charnier 		if (evalue < 1)
11977edab90SPhilippe Charnier 			errx(10, "%s must be >= 1 (was %s)", name, optarg);
12077edab90SPhilippe Charnier 		eflag = 1;
12177edab90SPhilippe Charnier 		break;
122a61ab64aSKirk McKusick 	  case 'f':
123a61ab64aSKirk McKusick 		found_arg = 1;
124a61ab64aSKirk McKusick 		name = "average file size";
125a61ab64aSKirk McKusick 		fvalue = atoi(optarg);
126a61ab64aSKirk McKusick 		if (fvalue < 1)
127a61ab64aSKirk McKusick 			errx(10, "%s must be >= 1 (was %s)", name, optarg);
128a61ab64aSKirk McKusick 		fflag = 1;
129a61ab64aSKirk McKusick 		break;
130289e09eeSRobert Watson 	  case 'l':
131289e09eeSRobert Watson 		found_arg = 1;
132289e09eeSRobert Watson 		name = "multilabel MAC file system";
133289e09eeSRobert Watson 		lvalue = optarg;
134289e09eeSRobert Watson 		if (strcmp(lvalue, "enable") && strcmp(lvalue, "disable")) {
135289e09eeSRobert Watson 			errx(10, "bad %s (options are %s)", name,
136289e09eeSRobert Watson 			    "`enable' or `disable'");
137289e09eeSRobert Watson 		}
138289e09eeSRobert Watson 		lflag = 1;
139289e09eeSRobert Watson 		break;
14077edab90SPhilippe Charnier 	  case 'm':
14177edab90SPhilippe Charnier 		found_arg = 1;
14277edab90SPhilippe Charnier 		name = "minimum percentage of free space";
14377edab90SPhilippe Charnier 		mvalue = atoi(optarg);
14477edab90SPhilippe Charnier 		if (mvalue < 0 || mvalue > 99)
14577edab90SPhilippe Charnier 			errx(10, "bad %s (%s)", name, optarg);
14677edab90SPhilippe Charnier 		mflag = 1;
14777edab90SPhilippe Charnier 		break;
14877edab90SPhilippe Charnier 	  case 'n':
14977edab90SPhilippe Charnier 		found_arg = 1;
15077edab90SPhilippe Charnier  		name = "soft updates";
15177edab90SPhilippe Charnier  		nvalue = optarg;
15277edab90SPhilippe Charnier                 if (strcmp(nvalue, "enable") && strcmp(nvalue, "disable")) {
15377edab90SPhilippe Charnier  			errx(10, "bad %s (options are %s)",
15477edab90SPhilippe Charnier  			    name, "`enable' or `disable'");
15577edab90SPhilippe Charnier  		}
15677edab90SPhilippe Charnier 		nflag = 1;
15777edab90SPhilippe Charnier  		break;
15877edab90SPhilippe Charnier 	  case 'o':
15977edab90SPhilippe Charnier 		found_arg = 1;
16077edab90SPhilippe Charnier 		name = "optimization preference";
16177edab90SPhilippe Charnier 		chg[FS_OPTSPACE] = "space";
16277edab90SPhilippe Charnier 		chg[FS_OPTTIME] = "time";
16377edab90SPhilippe Charnier 		if (strcmp(optarg, chg[FS_OPTSPACE]) == 0)
16477edab90SPhilippe Charnier 			ovalue = FS_OPTSPACE;
16577edab90SPhilippe Charnier 		else if (strcmp(optarg, chg[FS_OPTTIME]) == 0)
16677edab90SPhilippe Charnier 			ovalue = FS_OPTTIME;
16777edab90SPhilippe Charnier 		else
16877edab90SPhilippe Charnier 			errx(10, "bad %s (options are `space' or `time')",
16977edab90SPhilippe Charnier 					    name);
17077edab90SPhilippe Charnier 		oflag = 1;
17177edab90SPhilippe Charnier 		break;
17277edab90SPhilippe Charnier 	  case 'p':
173e50fa3d2SBen Smithurst 		found_arg = 1;
17477edab90SPhilippe Charnier 		pflag = 1;
17577edab90SPhilippe Charnier 		break;
176a61ab64aSKirk McKusick 	  case 's':
177a61ab64aSKirk McKusick 		found_arg = 1;
178a61ab64aSKirk McKusick 		name = "expected number of files per directory";
179a61ab64aSKirk McKusick 		svalue = atoi(optarg);
180a61ab64aSKirk McKusick 		if (svalue < 1)
181a61ab64aSKirk McKusick 			errx(10, "%s must be >= 1 (was %s)", name, optarg);
182a61ab64aSKirk McKusick 		sflag = 1;
183a61ab64aSKirk McKusick 		break;
18477edab90SPhilippe Charnier 	  default:
18577edab90SPhilippe Charnier 		usage();
18677edab90SPhilippe Charnier 	  }
18777edab90SPhilippe Charnier 	argc -= optind;
18877edab90SPhilippe Charnier 	argv += optind;
18977edab90SPhilippe Charnier 
19077edab90SPhilippe Charnier 	if (found_arg == 0 || argc != 1)
19177edab90SPhilippe Charnier 	  usage();
19277edab90SPhilippe Charnier 
193907db4ddSJuli Mallett 	on = special = argv[0];
194907db4ddSJuli Mallett 	if (ufs_disk_fillout(&disk, special) == -1)
195907db4ddSJuli Mallett 		goto err;
196907db4ddSJuli Mallett 	if (disk.d_name != special) {
197907db4ddSJuli Mallett 		special = disk.d_name;
1989ea6e95eSLuoqi Chen 		if (statfs(special, &stfs) == 0 &&
199907db4ddSJuli Mallett 		    strcmp(special, stfs.f_mntonname) == 0)
2007382c45aSLuoqi Chen 			active = 1;
201b20ae6a0SLuoqi Chen 	}
2028fae3551SRodney W. Grimes 
20377edab90SPhilippe Charnier 	if (pflag) {
20477edab90SPhilippe Charnier 		printfs();
20577edab90SPhilippe Charnier 		exit(0);
20677edab90SPhilippe Charnier 	}
207289e09eeSRobert Watson 	if (aflag) {
208289e09eeSRobert Watson 		name = "ACLs";
209289e09eeSRobert Watson 		if (strcmp(avalue, "enable") == 0) {
210289e09eeSRobert Watson 			if (sblock.fs_flags & FS_ACLS) {
211289e09eeSRobert Watson 				warnx("%s remains unchanged as enabled", name);
212289e09eeSRobert Watson 			} else {
213289e09eeSRobert Watson 				sblock.fs_flags |= FS_ACLS;
214289e09eeSRobert Watson 				warnx("%s set", name);
215289e09eeSRobert Watson 			}
216289e09eeSRobert Watson 		} else if (strcmp(avalue, "disable") == 0) {
217289e09eeSRobert Watson 			if ((~sblock.fs_flags & FS_ACLS) ==
218289e09eeSRobert Watson 			    FS_ACLS) {
219289e09eeSRobert Watson 				warnx("%s remains unchanged as disabled",
220289e09eeSRobert Watson 				    name);
221289e09eeSRobert Watson 			} else {
222289e09eeSRobert Watson 				sblock.fs_flags &= ~FS_ACLS;
223273500c2SRobert Watson 				warnx("%s cleared", name);
224289e09eeSRobert Watson 			}
225289e09eeSRobert Watson 		}
226289e09eeSRobert Watson 	}
22777edab90SPhilippe Charnier 	if (eflag) {
2282af14b60SPhilippe Charnier 		name = "maximum blocks per file in a cylinder group";
22977edab90SPhilippe Charnier 		if (sblock.fs_maxbpg == evalue) {
23077edab90SPhilippe Charnier 			warnx("%s remains unchanged as %d", name, evalue);
2312af14b60SPhilippe Charnier 		}
23277edab90SPhilippe Charnier 		else {
23377edab90SPhilippe Charnier 			warnx("%s changes from %d to %d",
23477edab90SPhilippe Charnier 					name, sblock.fs_maxbpg, evalue);
23577edab90SPhilippe Charnier 			sblock.fs_maxbpg = evalue;
23677edab90SPhilippe Charnier 		}
23777edab90SPhilippe Charnier 	}
238a61ab64aSKirk McKusick 	if (fflag) {
239a61ab64aSKirk McKusick 		name = "average file size";
240a61ab64aSKirk McKusick 		if (sblock.fs_avgfilesize == fvalue) {
241a61ab64aSKirk McKusick 			warnx("%s remains unchanged as %d", name, fvalue);
242a61ab64aSKirk McKusick 		}
243a61ab64aSKirk McKusick 		else {
244a61ab64aSKirk McKusick 			warnx("%s changes from %d to %d",
245a61ab64aSKirk McKusick 					name, sblock.fs_avgfilesize, fvalue);
246a61ab64aSKirk McKusick 			sblock.fs_avgfilesize = fvalue;
247a61ab64aSKirk McKusick 		}
248a61ab64aSKirk McKusick 	}
249289e09eeSRobert Watson 	if (lflag) {
250289e09eeSRobert Watson 		name = "multilabel";
251289e09eeSRobert Watson 		if (strcmp(lvalue, "enable") == 0) {
252289e09eeSRobert Watson 			if (sblock.fs_flags & FS_MULTILABEL) {
253289e09eeSRobert Watson 				warnx("%s remains unchanged as enabled", name);
254289e09eeSRobert Watson 			} else {
255289e09eeSRobert Watson 				sblock.fs_flags |= FS_MULTILABEL;
256289e09eeSRobert Watson 				warnx("%s set", name);
257289e09eeSRobert Watson 			}
258289e09eeSRobert Watson 		} else if (strcmp(lvalue, "disable") == 0) {
259289e09eeSRobert Watson 			if ((~sblock.fs_flags & FS_MULTILABEL) ==
260289e09eeSRobert Watson 			    FS_MULTILABEL) {
261289e09eeSRobert Watson 				warnx("%s remains unchanged as disabled",
262289e09eeSRobert Watson 				    name);
263289e09eeSRobert Watson 			} else {
264289e09eeSRobert Watson 				sblock.fs_flags &= ~FS_MULTILABEL;
265273500c2SRobert Watson 				warnx("%s cleared", name);
266289e09eeSRobert Watson 			}
267289e09eeSRobert Watson 		}
268289e09eeSRobert Watson 	}
26977edab90SPhilippe Charnier 	if (mflag) {
2708fae3551SRodney W. Grimes 		name = "minimum percentage of free space";
27177edab90SPhilippe Charnier 		if (sblock.fs_minfree == mvalue) {
27277edab90SPhilippe Charnier 			warnx("%s remains unchanged as %d%%", name, mvalue);
2732af14b60SPhilippe Charnier 		}
27477edab90SPhilippe Charnier 		else {
2758fae3551SRodney W. Grimes 			warnx("%s changes from %d%% to %d%%",
27677edab90SPhilippe Charnier 				    name, sblock.fs_minfree, mvalue);
27777edab90SPhilippe Charnier 			sblock.fs_minfree = mvalue;
27877edab90SPhilippe Charnier 			if (mvalue >= MINFREE && sblock.fs_optim == FS_OPTSPACE)
2798fae3551SRodney W. Grimes 				warnx(OPTWARN, "time", ">=", MINFREE);
28077edab90SPhilippe Charnier 			if (mvalue < MINFREE && sblock.fs_optim == FS_OPTTIME)
2818fae3551SRodney W. Grimes 				warnx(OPTWARN, "space", "<", MINFREE);
282b1897c19SJulian Elischer 		}
28377edab90SPhilippe Charnier 	}
28477edab90SPhilippe Charnier 	if (nflag) {
28577edab90SPhilippe Charnier  		name = "soft updates";
28677edab90SPhilippe Charnier  		if (strcmp(nvalue, "enable") == 0) {
28777edab90SPhilippe Charnier 			if (sblock.fs_flags & FS_DOSOFTDEP) {
28877edab90SPhilippe Charnier 				warnx("%s remains unchanged as enabled", name);
2891c2665d8SKirk McKusick 			} else if (sblock.fs_clean == 0) {
2901c2665d8SKirk McKusick 				warnx("%s cannot be enabled until fsck is run",
2911c2665d8SKirk McKusick 				    name);
29277edab90SPhilippe Charnier 			} else {
29377edab90SPhilippe Charnier  				sblock.fs_flags |= FS_DOSOFTDEP;
29477edab90SPhilippe Charnier  				warnx("%s set", name);
29577edab90SPhilippe Charnier 			}
29677edab90SPhilippe Charnier  		} else if (strcmp(nvalue, "disable") == 0) {
29777edab90SPhilippe Charnier 			if ((~sblock.fs_flags & FS_DOSOFTDEP) == FS_DOSOFTDEP) {
29877edab90SPhilippe Charnier 				warnx("%s remains unchanged as disabled", name);
29977edab90SPhilippe Charnier 			} else {
30077edab90SPhilippe Charnier  				sblock.fs_flags &= ~FS_DOSOFTDEP;
30177edab90SPhilippe Charnier  				warnx("%s cleared", name);
30277edab90SPhilippe Charnier 			}
30377edab90SPhilippe Charnier  		}
30477edab90SPhilippe Charnier 	}
30577edab90SPhilippe Charnier 	if (oflag) {
3068fae3551SRodney W. Grimes 		name = "optimization preference";
3078fae3551SRodney W. Grimes 		chg[FS_OPTSPACE] = "space";
3088fae3551SRodney W. Grimes 		chg[FS_OPTTIME] = "time";
30977edab90SPhilippe Charnier 		if (sblock.fs_optim == ovalue) {
31077edab90SPhilippe Charnier 			warnx("%s remains unchanged as %s", name, chg[ovalue]);
3118fae3551SRodney W. Grimes 		}
31277edab90SPhilippe Charnier 		else {
3138fae3551SRodney W. Grimes 			warnx("%s changes from %s to %s",
31477edab90SPhilippe Charnier 				    name, chg[sblock.fs_optim], chg[ovalue]);
31577edab90SPhilippe Charnier 			sblock.fs_optim = ovalue;
31677edab90SPhilippe Charnier 			if (sblock.fs_minfree >= MINFREE &&
31777edab90SPhilippe Charnier 					ovalue == FS_OPTSPACE)
3188fae3551SRodney W. Grimes 				warnx(OPTWARN, "time", ">=", MINFREE);
31977edab90SPhilippe Charnier 			if (sblock.fs_minfree < MINFREE &&
32077edab90SPhilippe Charnier 					ovalue == FS_OPTTIME)
3218fae3551SRodney W. Grimes 				warnx(OPTWARN, "space", "<", MINFREE);
3228fae3551SRodney W. Grimes 		}
32377edab90SPhilippe Charnier 	}
324a61ab64aSKirk McKusick 	if (sflag) {
325a61ab64aSKirk McKusick 		name = "expected number of files per directory";
326a61ab64aSKirk McKusick 		if (sblock.fs_avgfpdir == svalue) {
327a61ab64aSKirk McKusick 			warnx("%s remains unchanged as %d", name, svalue);
328a61ab64aSKirk McKusick 		}
329a61ab64aSKirk McKusick 		else {
330a61ab64aSKirk McKusick 			warnx("%s changes from %d to %d",
331a61ab64aSKirk McKusick 					name, sblock.fs_avgfpdir, svalue);
332a61ab64aSKirk McKusick 			sblock.fs_avgfpdir = svalue;
333a61ab64aSKirk McKusick 		}
334a61ab64aSKirk McKusick 	}
3352af14b60SPhilippe Charnier 
336907db4ddSJuli Mallett 	if (sbwrite(&disk, Aflag) == -1)
337907db4ddSJuli Mallett 		goto err;
338907db4ddSJuli Mallett 	ufs_disk_close(&disk);
3397382c45aSLuoqi Chen 	if (active) {
3407382c45aSLuoqi Chen 		bzero(&args, sizeof(args));
341907db4ddSJuli Mallett 		if (mount("ufs", on,
3427382c45aSLuoqi Chen 		    stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0)
3437382c45aSLuoqi Chen 			err(9, "%s: reload", special);
3447382c45aSLuoqi Chen 		warnx("file system reloaded");
3457382c45aSLuoqi Chen 	}
3468fae3551SRodney W. Grimes 	exit(0);
347907db4ddSJuli Mallett err:
348907db4ddSJuli Mallett 	if (disk.d_error != NULL)
349907db4ddSJuli Mallett 		errx(11, "%s: %s", special, disk.d_error);
350907db4ddSJuli Mallett 	else
351907db4ddSJuli Mallett 		err(12, "%s", special);
3528fae3551SRodney W. Grimes }
3538fae3551SRodney W. Grimes 
3548fae3551SRodney W. Grimes void
355b1f0fda0SJuli Mallett usage(void)
3568fae3551SRodney W. Grimes {
3578679b1b4SPhilippe Charnier 	fprintf(stderr, "%s\n%s\n%s\n",
358a2325efeSRobert Watson "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]",
359289e09eeSRobert Watson "              [-l enable | disable] [-m minfree] [-n enable | disable]",
360289e09eeSRobert Watson "              [-o space | time] [-p] [-s avgfpdir] special | filesystem");
3618fae3551SRodney W. Grimes 	exit(2);
3628fae3551SRodney W. Grimes }
3638fae3551SRodney W. Grimes 
3648fae3551SRodney W. Grimes void
365b1f0fda0SJuli Mallett printfs(void)
36616a7269eSJoerg Wunsch {
36781dc101cSRobert Watson 	warnx("ACLs: (-a)                                         %s",
36881dc101cSRobert Watson 		(sblock.fs_flags & FS_ACLS)? "enabled" : "disabled");
36981dc101cSRobert Watson 	warnx("MAC multilabel: (-l)                               %s",
37081dc101cSRobert Watson 		(sblock.fs_flags & FS_MULTILABEL)? "enabled" : "disabled");
371b1897c19SJulian Elischer 	warnx("soft updates: (-n)                                 %s",
372b1897c19SJulian Elischer 		(sblock.fs_flags & FS_DOSOFTDEP)? "enabled" : "disabled");
37316a7269eSJoerg Wunsch 	warnx("maximum blocks per file in a cylinder group: (-e)  %d",
37416a7269eSJoerg Wunsch 	      sblock.fs_maxbpg);
375a61ab64aSKirk McKusick 	warnx("average file size: (-f)                            %d",
376a61ab64aSKirk McKusick 	      sblock.fs_avgfilesize);
377a61ab64aSKirk McKusick 	warnx("average number of files in a directory: (-s)       %d",
378a61ab64aSKirk McKusick 	      sblock.fs_avgfpdir);
37916a7269eSJoerg Wunsch 	warnx("minimum percentage of free space: (-m)             %d%%",
38016a7269eSJoerg Wunsch 	      sblock.fs_minfree);
38116a7269eSJoerg Wunsch 	warnx("optimization preference: (-o)                      %s",
38216a7269eSJoerg Wunsch 	      sblock.fs_optim == FS_OPTSPACE ? "space" : "time");
38316a7269eSJoerg Wunsch 	if (sblock.fs_minfree >= MINFREE &&
38416a7269eSJoerg Wunsch 	    sblock.fs_optim == FS_OPTSPACE)
38516a7269eSJoerg Wunsch 		warnx(OPTWARN, "time", ">=", MINFREE);
38616a7269eSJoerg Wunsch 	if (sblock.fs_minfree < MINFREE &&
38716a7269eSJoerg Wunsch 	    sblock.fs_optim == FS_OPTTIME)
38816a7269eSJoerg Wunsch 		warnx(OPTWARN, "space", "<", MINFREE);
38916a7269eSJoerg Wunsch }
390