2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 static const char copyright[] =
33 "@(#) Copyright (c) 1983, 1993\n\
34 The Regents of the University of California. All rights reserved.\n";
38 static char sccsid[] = "@(#)tunefs.c 8.2 (Berkeley) 4/19/94";
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD$");
45 * tunefs: change layout parameters to an existing file system.
47 #include <sys/param.h>
48 #include <sys/mount.h>
49 #include <sys/disklabel.h>
52 #include <ufs/ufs/ufsmount.h>
53 #include <ufs/ufs/dinode.h>
54 #include <ufs/ffs/fs.h>
55 #include <ufs/ufs/dir.h>
69 /* the optimization warning string template */
70 #define OPTWARN "should optimize for %s with minfree %s %d%%"
73 #define sblock disk.d_fs
77 int journal_alloc(int64_t size);
78 void journal_clear(void);
82 main(int argc, char *argv[])
84 char *avalue, *jvalue, *Jvalue, *Lvalue, *lvalue, *Nvalue, *nvalue;
85 const char *special, *on;
88 int Aflag, aflag, eflag, evalue, fflag, fvalue, jflag, Jflag, Lflag;
89 int lflag, mflag, mvalue, Nflag, nflag, oflag, ovalue, pflag, sflag;
90 int svalue, Sflag, Svalue;
98 Aflag = aflag = eflag = fflag = jflag = Jflag = Lflag = lflag = 0;
99 mflag = Nflag = nflag = oflag = pflag = sflag = 0;
100 avalue = jvalue = Jvalue = Lvalue = lvalue = Nvalue = nvalue = NULL;
101 evalue = fvalue = mvalue = ovalue = svalue = Svalue = 0;
103 found_arg = 0; /* At least one arg is required. */
104 while ((ch = getopt(argc, argv, "Aa:e:f:j:J:L:l:m:N:n:o:ps:S:")) != -1)
114 name = "POSIX.1e ACLs";
116 if (strcmp(avalue, "enable") &&
117 strcmp(avalue, "disable")) {
118 errx(10, "bad %s (options are %s)",
119 name, "`enable' or `disable'");
126 name = "maximum blocks per file in a cylinder group";
127 evalue = atoi(optarg);
129 errx(10, "%s must be >= 1 (was %s)",
136 name = "average file size";
137 fvalue = atoi(optarg);
139 errx(10, "%s must be >= 1 (was %s)",
146 name = "softdep journaled file system";
148 if (strcmp(jvalue, "enable") &&
149 strcmp(jvalue, "disable")) {
150 errx(10, "bad %s (options are %s)",
151 name, "`enable' or `disable'");
158 name = "gjournaled file system";
160 if (strcmp(Jvalue, "enable") &&
161 strcmp(Jvalue, "disable")) {
162 errx(10, "bad %s (options are %s)",
163 name, "`enable' or `disable'");
171 name = "volume label";
174 while (isalnum(Lvalue[++i]));
175 if (Lvalue[i] != '\0') {
177 "bad %s. Valid characters are alphanumerics.",
180 if (strlen(Lvalue) >= MAXVOLLEN) {
181 errx(10, "bad %s. Length is longer than %d.",
182 name, MAXVOLLEN - 1);
189 name = "multilabel MAC file system";
191 if (strcmp(lvalue, "enable") &&
192 strcmp(lvalue, "disable")) {
193 errx(10, "bad %s (options are %s)",
194 name, "`enable' or `disable'");
201 name = "minimum percentage of free space";
202 mvalue = atoi(optarg);
203 if (mvalue < 0 || mvalue > 99)
204 errx(10, "bad %s (%s)", name, optarg);
212 if (strcmp(Nvalue, "enable") &&
213 strcmp(Nvalue, "disable")) {
214 errx(10, "bad %s (options are %s)",
215 name, "`enable' or `disable'");
222 name = "soft updates";
224 if (strcmp(nvalue, "enable") != 0 &&
225 strcmp(nvalue, "disable") != 0) {
226 errx(10, "bad %s (options are %s)",
227 name, "`enable' or `disable'");
234 name = "optimization preference";
235 if (strcmp(optarg, "space") == 0)
236 ovalue = FS_OPTSPACE;
237 else if (strcmp(optarg, "time") == 0)
241 "bad %s (options are `space' or `time')",
253 name = "expected number of files per directory";
254 svalue = atoi(optarg);
256 errx(10, "%s must be >= 1 (was %s)",
263 name = "Softdep Journal Size";
264 Svalue = atoi(optarg);
265 if (Svalue < SUJ_MIN)
266 errx(10, "%s must be >= %d (was %s)",
267 name, SUJ_MIN, optarg);
276 if (found_arg == 0 || argc != 1)
279 on = special = argv[0];
280 if (ufs_disk_fillout(&disk, special) == -1)
282 if (disk.d_name != special) {
283 if (statfs(special, &stfs) != 0)
284 warn("Can't stat %s", special);
285 if (strcmp(special, stfs.f_mntonname) == 0)
294 name = "volume label";
295 strlcpy(sblock.fs_volname, Lvalue, MAXVOLLEN);
298 name = "POSIX.1e ACLs";
299 if (strcmp(avalue, "enable") == 0) {
300 if (sblock.fs_flags & FS_ACLS) {
301 warnx("%s remains unchanged as enabled", name);
302 } else if (sblock.fs_flags & FS_NFS4ACLS) {
303 warnx("%s and NFSv4 ACLs are mutually "
306 sblock.fs_flags |= FS_ACLS;
307 warnx("%s set", name);
309 } else if (strcmp(avalue, "disable") == 0) {
310 if ((~sblock.fs_flags & FS_ACLS) ==
312 warnx("%s remains unchanged as disabled",
315 sblock.fs_flags &= ~FS_ACLS;
316 warnx("%s cleared", name);
321 name = "maximum blocks per file in a cylinder group";
322 if (sblock.fs_maxbpg == evalue)
323 warnx("%s remains unchanged as %d", name, evalue);
325 warnx("%s changes from %d to %d",
326 name, sblock.fs_maxbpg, evalue);
327 sblock.fs_maxbpg = evalue;
331 name = "average file size";
332 if (sblock.fs_avgfilesize == (unsigned)fvalue) {
333 warnx("%s remains unchanged as %d", name, fvalue);
336 warnx("%s changes from %d to %d",
337 name, sblock.fs_avgfilesize, fvalue);
338 sblock.fs_avgfilesize = fvalue;
342 name = "soft updates journaling";
343 if (strcmp(jvalue, "enable") == 0) {
344 if ((sblock.fs_flags & (FS_DOSOFTDEP | FS_SUJ)) ==
345 (FS_DOSOFTDEP | FS_SUJ)) {
346 warnx("%s remains unchanged as enabled", name);
347 } else if (sblock.fs_clean == 0) {
348 warnx("%s cannot be enabled until fsck is run",
350 } else if (journal_alloc(Svalue) != 0) {
351 warnx("%s can not be enabled", name);
353 sblock.fs_flags |= FS_DOSOFTDEP | FS_SUJ;
354 warnx("%s set", name);
356 } else if (strcmp(jvalue, "disable") == 0) {
357 if ((~sblock.fs_flags & FS_SUJ) == FS_SUJ) {
358 warnx("%s remains unchanged as disabled", name);
361 sblock.fs_flags &= ~(FS_DOSOFTDEP | FS_SUJ);
362 sblock.fs_sujfree = 0;
364 "remove .sujournal to reclaim space", name);
370 if (strcmp(Jvalue, "enable") == 0) {
371 if (sblock.fs_flags & FS_GJOURNAL) {
372 warnx("%s remains unchanged as enabled", name);
374 sblock.fs_flags |= FS_GJOURNAL;
375 warnx("%s set", name);
377 } else if (strcmp(Jvalue, "disable") == 0) {
378 if ((~sblock.fs_flags & FS_GJOURNAL) ==
380 warnx("%s remains unchanged as disabled",
383 sblock.fs_flags &= ~FS_GJOURNAL;
384 warnx("%s cleared", name);
390 if (strcmp(lvalue, "enable") == 0) {
391 if (sblock.fs_flags & FS_MULTILABEL) {
392 warnx("%s remains unchanged as enabled", name);
394 sblock.fs_flags |= FS_MULTILABEL;
395 warnx("%s set", name);
397 } else if (strcmp(lvalue, "disable") == 0) {
398 if ((~sblock.fs_flags & FS_MULTILABEL) ==
400 warnx("%s remains unchanged as disabled",
403 sblock.fs_flags &= ~FS_MULTILABEL;
404 warnx("%s cleared", name);
409 name = "minimum percentage of free space";
410 if (sblock.fs_minfree == mvalue)
411 warnx("%s remains unchanged as %d%%", name, mvalue);
413 warnx("%s changes from %d%% to %d%%",
414 name, sblock.fs_minfree, mvalue);
415 sblock.fs_minfree = mvalue;
416 if (mvalue >= MINFREE && sblock.fs_optim == FS_OPTSPACE)
417 warnx(OPTWARN, "time", ">=", MINFREE);
418 if (mvalue < MINFREE && sblock.fs_optim == FS_OPTTIME)
419 warnx(OPTWARN, "space", "<", MINFREE);
424 if (strcmp(Nvalue, "enable") == 0) {
425 if (sblock.fs_flags & FS_NFS4ACLS) {
426 warnx("%s remains unchanged as enabled", name);
427 } else if (sblock.fs_flags & FS_ACLS) {
428 warnx("%s and POSIX.1e ACLs are mutually "
431 sblock.fs_flags |= FS_NFS4ACLS;
432 warnx("%s set", name);
434 } else if (strcmp(Nvalue, "disable") == 0) {
435 if ((~sblock.fs_flags & FS_NFS4ACLS) ==
437 warnx("%s remains unchanged as disabled",
440 sblock.fs_flags &= ~FS_NFS4ACLS;
441 warnx("%s cleared", name);
446 name = "soft updates";
447 if (strcmp(nvalue, "enable") == 0) {
448 if (sblock.fs_flags & FS_DOSOFTDEP)
449 warnx("%s remains unchanged as enabled", name);
450 else if (sblock.fs_clean == 0) {
451 warnx("%s cannot be enabled until fsck is run",
454 sblock.fs_flags |= FS_DOSOFTDEP;
455 warnx("%s set", name);
457 } else if (strcmp(nvalue, "disable") == 0) {
458 if ((~sblock.fs_flags & FS_DOSOFTDEP) == FS_DOSOFTDEP)
459 warnx("%s remains unchanged as disabled", name);
461 sblock.fs_flags &= ~FS_DOSOFTDEP;
462 warnx("%s cleared", name);
467 name = "optimization preference";
468 chg[FS_OPTSPACE] = "space";
469 chg[FS_OPTTIME] = "time";
470 if (sblock.fs_optim == ovalue)
471 warnx("%s remains unchanged as %s", name, chg[ovalue]);
473 warnx("%s changes from %s to %s",
474 name, chg[sblock.fs_optim], chg[ovalue]);
475 sblock.fs_optim = ovalue;
476 if (sblock.fs_minfree >= MINFREE &&
477 ovalue == FS_OPTSPACE)
478 warnx(OPTWARN, "time", ">=", MINFREE);
479 if (sblock.fs_minfree < MINFREE && ovalue == FS_OPTTIME)
480 warnx(OPTWARN, "space", "<", MINFREE);
484 name = "expected number of files per directory";
485 if (sblock.fs_avgfpdir == (unsigned)svalue) {
486 warnx("%s remains unchanged as %d", name, svalue);
489 warnx("%s changes from %d to %d",
490 name, sblock.fs_avgfpdir, svalue);
491 sblock.fs_avgfpdir = svalue;
495 if (sbwrite(&disk, Aflag) == -1)
497 ufs_disk_close(&disk);
499 bzero(&args, sizeof(args));
501 stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0)
502 err(9, "%s: reload", special);
503 warnx("file system reloaded");
507 if (disk.d_error != NULL)
508 errx(11, "%s: %s", special, disk.d_error);
510 err(12, "%s", special);
516 disk.d_fs.fs_flags |= FS_UNCLEAN | FS_NEEDSFSCK;
517 disk.d_fs.fs_clean = 0;
521 static char clrbuf[MAXBSIZE];
529 static int contig = 1;
533 blk = cgballoc(&disk);
537 * If we failed to allocate a block from this cg, move to
540 if (cgwrite(&disk) < 0) {
541 warn("Failed to write updated cg");
544 while ((valid = cgread(&disk)) == 1) {
546 * Try to minimize fragmentation by requiring a minimum
547 * number of blocks present.
549 if (cgp->cg_cs.cs_nbfree > 128 * 1024 * 1024)
551 if (contig == 0 && cgp->cg_cs.cs_nbfree)
557 * Try once through looking only for large contiguous regions
558 * and again taking any space we can find.
563 warnx("Journal file fragmented.");
566 warnx("Failed to find sufficient free blocks for the journal");
569 if (bwrite(&disk, fsbtodb(&sblock, blk), clrbuf,
570 sblock.fs_bsize) <= 0) {
571 warn("Failed to initialize new block");
578 * Search a directory block for the SUJ_FILE.
581 dir_search(ufs2_daddr_t blk, int bytes)
583 char block[MAXBSIZE];
587 if (bread(&disk, fsbtodb(&sblock, blk), block, bytes) <= 0) {
588 warn("Failed to read dir block");
591 for (off = 0; off < bytes; off += dp->d_reclen) {
592 dp = (struct direct *)&block[off];
593 if (dp->d_reclen == 0)
597 if (dp->d_namlen != strlen(SUJ_FILE))
599 if (bcmp(dp->d_name, SUJ_FILE, dp->d_namlen) != 0)
608 * Search in the ROOTINO for the SUJ_FILE. If it exists we can not enable
612 journal_findfile(void)
614 struct ufs1_dinode *dp1;
615 struct ufs2_dinode *dp2;
621 if (getino(&disk, &ip, ROOTINO, &mode) != 0) {
622 warn("Failed to get root inode");
627 if (sblock.fs_magic == FS_UFS1_MAGIC) {
628 if ((off_t)dp1->di_size >= lblktosize(&sblock, NDADDR)) {
629 warnx("ROOTINO extends beyond direct blocks.");
632 for (i = 0; i < NDADDR; i++) {
633 if (dp1->di_db[i] == 0)
635 if ((ino = dir_search(dp1->di_db[i],
636 sblksize(&sblock, (off_t)dp1->di_size, i))) != 0)
640 if ((off_t)dp1->di_size >= lblktosize(&sblock, NDADDR)) {
641 warnx("ROOTINO extends beyond direct blocks.");
644 for (i = 0; i < NDADDR; i++) {
645 if (dp2->di_db[i] == 0)
647 if ((ino = dir_search(dp2->di_db[i],
648 sblksize(&sblock, (off_t)dp2->di_size, i))) != 0)
657 * Insert the journal at inode 'ino' into directory blk 'blk' at the first
658 * free offset of 'off'. DIRBLKSIZ blocks after off are initialized as
662 dir_insert(ufs2_daddr_t blk, off_t off, ino_t ino)
665 char block[MAXBSIZE];
667 if (bread(&disk, fsbtodb(&sblock, blk), block, sblock.fs_bsize) <= 0) {
668 warn("Failed to read dir block");
671 bzero(&block[off], sblock.fs_bsize - off);
672 dp = (struct direct *)&block[off];
674 dp->d_reclen = DIRBLKSIZ;
676 dp->d_namlen = strlen(SUJ_FILE);
677 bcopy(SUJ_FILE, &dp->d_name, strlen(SUJ_FILE));
679 for (; off < sblock.fs_bsize; off += DIRBLKSIZ) {
680 dp = (struct direct *)&block[off];
682 dp->d_reclen = DIRBLKSIZ;
683 dp->d_type = DT_UNKNOWN;
685 if (bwrite(&disk, fsbtodb(&sblock, blk), block, sblock.fs_bsize) <= 0) {
686 warn("Failed to write dir block");
693 * Extend a directory block in 'blk' by copying it to a full size block
694 * and inserting the new journal inode into .sujournal.
697 dir_extend(ufs2_daddr_t blk, ufs2_daddr_t nblk, off_t size, ino_t ino)
699 char block[MAXBSIZE];
701 if (bread(&disk, fsbtodb(&sblock, blk), block, size) <= 0) {
702 warn("Failed to read dir block");
705 if (bwrite(&disk, fsbtodb(&sblock, nblk), block, size) <= 0) {
706 warn("Failed to write dir block");
710 return dir_insert(nblk, size, ino);
714 * Insert the journal file into the ROOTINO directory. We always extend the
718 journal_insertfile(ino_t ino)
720 struct ufs1_dinode *dp1;
721 struct ufs2_dinode *dp2;
730 if (getino(&disk, &ip, ROOTINO, &mode) != 0) {
731 warn("Failed to get root inode");
739 nblk = journal_balloc();
743 * For simplicity sake we aways extend the ROOTINO into a new
744 * directory block rather than searching for space and inserting
745 * into an existing block. However, if the rootino has frags
746 * have to free them and extend the block.
748 if (sblock.fs_magic == FS_UFS1_MAGIC) {
749 lbn = lblkno(&sblock, dp1->di_size);
750 off = blkoff(&sblock, dp1->di_size);
751 blk = dp1->di_db[lbn];
752 size = sblksize(&sblock, (off_t)dp1->di_size, lbn);
754 lbn = lblkno(&sblock, dp2->di_size);
755 off = blkoff(&sblock, dp2->di_size);
756 blk = dp2->di_db[lbn];
757 size = sblksize(&sblock, (off_t)dp2->di_size, lbn);
760 if (dir_extend(blk, nblk, off, ino) == -1)
764 if (dir_insert(nblk, 0, ino) == -1)
767 if (sblock.fs_magic == FS_UFS1_MAGIC) {
768 dp1->di_blocks += (sblock.fs_bsize - size) / DEV_BSIZE;
769 dp1->di_db[lbn] = nblk;
770 dp1->di_size = lblktosize(&sblock, lbn+1);
772 dp2->di_blocks += (sblock.fs_bsize - size) / DEV_BSIZE;
773 dp2->di_db[lbn] = nblk;
774 dp2->di_size = lblktosize(&sblock, lbn+1);
776 if (putino(&disk) < 0) {
777 warn("Failed to write root inode");
780 if (cgwrite(&disk) < 0) {
781 warn("Failed to write updated cg");
786 if (cgbfree(&disk, blk, size) < 0) {
787 warn("Failed to write cg");
796 indir_fill(ufs2_daddr_t blk, int level, int *resid)
798 char indirbuf[MAXBSIZE];
806 bzero(indirbuf, sizeof(indirbuf));
807 bap1 = (ufs1_daddr_t *)indirbuf;
810 for (i = 0; i < NINDIR(&sblock) && *resid != 0; i++) {
811 nblk = journal_balloc();
815 if (sblock.fs_magic == FS_UFS1_MAGIC)
820 ncnt = indir_fill(nblk, level - 1, resid);
827 if (bwrite(&disk, fsbtodb(&sblock, blk), indirbuf,
828 sblock.fs_bsize) <= 0) {
829 warn("Failed to write indirect");
836 * Clear the flag bits so the journal can be removed.
841 struct ufs1_dinode *dp1;
842 struct ufs2_dinode *dp2;
847 ino = journal_findfile();
848 if (ino == (ino_t)-1 || ino == 0) {
849 warnx("Journal file does not exist");
852 printf("Clearing journal flags from inode %d\n", ino);
853 if (getino(&disk, &ip, ino, &mode) != 0) {
854 warn("Failed to get journal inode");
859 if (sblock.fs_magic == FS_UFS1_MAGIC)
863 if (putino(&disk) < 0) {
864 warn("Failed to write journal inode");
870 journal_alloc(int64_t size)
872 struct ufs1_dinode *dp1;
873 struct ufs2_dinode *dp2;
887 * If the journal file exists we can't allocate it.
889 ino = journal_findfile();
890 if (ino == (ino_t)-1)
893 warnx("Journal file %s already exists, please remove.",
898 * If the user didn't supply a size pick one based on the filesystem
899 * size constrained with hardcoded MIN and MAX values. We opt for
900 * 1/1024th of the filesystem up to MAX but not exceeding one CG and
901 * not less than the MIN.
904 size = (sblock.fs_size * sblock.fs_bsize) / 1024;
905 size = MIN(SUJ_MAX, size);
906 if (size / sblock.fs_fsize > sblock.fs_fpg)
907 size = sblock.fs_fpg * sblock.fs_fsize;
908 size = MAX(SUJ_MIN, size);
910 resid = blocks = size / sblock.fs_bsize;
911 if (sblock.fs_cstotal.cs_nbfree < blocks) {
912 warn("Insufficient free space for %jd byte journal", size);
916 * Find a cg with enough blocks to satisfy the journal
917 * size. Presently the journal does not span cgs.
919 while (cgread(&disk) == 1) {
920 if (cgp->cg_cs.cs_nifree == 0)
922 ino = cgialloc(&disk);
925 printf("Using inode %d in cg %d for %jd byte journal\n",
926 ino, cgp->cg_cgx, size);
927 if (getino(&disk, &ip, ino, &mode) != 0) {
928 warn("Failed to get allocated inode");
933 * We leave fields unrelated to the number of allocated
934 * blocks and size uninitialized. This causes legacy
935 * fsck implementations to clear the inode.
939 if (sblock.fs_magic == FS_UFS1_MAGIC) {
940 bzero(dp1, sizeof(*dp1));
942 dp1->di_mode = IFREG | IREAD;
944 dp1->di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP;
946 bzero(dp2, sizeof(*dp2));
948 dp2->di_mode = IFREG | IREAD;
950 dp2->di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP;
952 for (i = 0; i < NDADDR && resid; i++, resid--) {
953 blk = journal_balloc();
956 if (sblock.fs_magic == FS_UFS1_MAGIC) {
964 for (i = 0; i < NIADDR && resid; i++) {
965 blk = journal_balloc();
968 blks = indir_fill(blk, i, &resid) + 1;
973 if (sblock.fs_magic == FS_UFS1_MAGIC) {
975 dp1->di_blocks += blks;
978 dp2->di_blocks += blks;
981 if (sblock.fs_magic == FS_UFS1_MAGIC)
982 dp1->di_blocks *= sblock.fs_bsize / disk.d_bsize;
984 dp2->di_blocks *= sblock.fs_bsize / disk.d_bsize;
985 if (putino(&disk) < 0) {
986 warn("Failed to write inode");
990 if (cgwrite(&disk) < 0) {
991 warn("Failed to write updated cg");
995 if (journal_insertfile(ino) < 0) {
999 sblock.fs_sujfree = 0;
1002 warnx("Insufficient free space for the journal.");
1010 fprintf(stderr, "%s\n%s\n%s\n%s\n",
1011 "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]",
1012 " [-J enable | disable ] [-L volname] [-l enable | disable]",
1013 " [-m minfree] [-N enable | disable] [-n enable | disable]",
1014 " [-o space | time] [-p] [-s avgfpdir] special | filesystem");
1021 warnx("POSIX.1e ACLs: (-a) %s",
1022 (sblock.fs_flags & FS_ACLS)? "enabled" : "disabled");
1023 warnx("NFSv4 ACLs: (-N) %s",
1024 (sblock.fs_flags & FS_NFS4ACLS)? "enabled" : "disabled");
1025 warnx("MAC multilabel: (-l) %s",
1026 (sblock.fs_flags & FS_MULTILABEL)? "enabled" : "disabled");
1027 warnx("soft updates: (-n) %s",
1028 (sblock.fs_flags & FS_DOSOFTDEP)? "enabled" : "disabled");
1029 warnx("soft update journaling: (-j) %s",
1030 (sblock.fs_flags & FS_SUJ)? "enabled" : "disabled");
1031 warnx("gjournal: (-J) %s",
1032 (sblock.fs_flags & FS_GJOURNAL)? "enabled" : "disabled");
1033 warnx("maximum blocks per file in a cylinder group: (-e) %d",
1035 warnx("average file size: (-f) %d",
1036 sblock.fs_avgfilesize);
1037 warnx("average number of files in a directory: (-s) %d",
1038 sblock.fs_avgfpdir);
1039 warnx("minimum percentage of free space: (-m) %d%%",
1041 warnx("optimization preference: (-o) %s",
1042 sblock.fs_optim == FS_OPTSPACE ? "space" : "time");
1043 if (sblock.fs_minfree >= MINFREE &&
1044 sblock.fs_optim == FS_OPTSPACE)
1045 warnx(OPTWARN, "time", ">=", MINFREE);
1046 if (sblock.fs_minfree < MINFREE &&
1047 sblock.fs_optim == FS_OPTTIME)
1048 warnx(OPTWARN, "space", "<", MINFREE);
1049 warnx("volume label: (-L) %s",