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 60c715b047SGordon Tetlow #include <ctype.h> 618fae3551SRodney W. Grimes #include <err.h> 628fae3551SRodney W. Grimes #include <fcntl.h> 638fae3551SRodney W. Grimes #include <fstab.h> 64b1f0fda0SJuli Mallett #include <libufs.h> 658fae3551SRodney W. Grimes #include <paths.h> 668679b1b4SPhilippe Charnier #include <stdio.h> 678fae3551SRodney W. Grimes #include <stdlib.h> 68060ac658SSheldon Hearn #include <string.h> 698fae3551SRodney W. Grimes #include <unistd.h> 708fae3551SRodney W. Grimes 718fae3551SRodney W. Grimes /* the optimization warning string template */ 728fae3551SRodney W. Grimes #define OPTWARN "should optimize for %s with minfree %s %d%%" 738fae3551SRodney W. Grimes 74b1f0fda0SJuli Mallett struct uufsd disk; 75b1f0fda0SJuli Mallett #define sblock disk.d_fs 768fae3551SRodney W. Grimes 77d476a036SWarner Losh void usage(void); 78d476a036SWarner Losh void printfs(void); 798fae3551SRodney W. Grimes 808fae3551SRodney W. Grimes int 81b1f0fda0SJuli Mallett main(int argc, char *argv[]) 828fae3551SRodney W. Grimes { 83907db4ddSJuli Mallett const char *special, *on; 84c33fa91fSDima Dorfman const char *name; 85c715b047SGordon Tetlow int Aflag = 0, Lflag = 0, active = 0, aflag = 0; 86289e09eeSRobert Watson int eflag = 0, fflag = 0, lflag = 0, mflag = 0; 87a61ab64aSKirk McKusick int nflag = 0, oflag = 0, pflag = 0, sflag = 0; 88a9098c89SPoul-Henning Kamp int evalue = 0, fvalue = 0; 89a61ab64aSKirk McKusick int mvalue = 0, ovalue = 0, svalue = 0; 90c715b047SGordon Tetlow char *Lvalue = NULL, *avalue = NULL, *lvalue = NULL, *nvalue = NULL; 91c33fa91fSDima Dorfman const char *chg[2]; 927382c45aSLuoqi Chen struct ufs_args args; 937382c45aSLuoqi Chen struct statfs stfs; 94c715b047SGordon Tetlow int found_arg, ch, i; 958fae3551SRodney W. Grimes 962af14b60SPhilippe Charnier if (argc < 3) 978fae3551SRodney W. Grimes usage(); 9877edab90SPhilippe Charnier found_arg = 0; /* at least one arg is required */ 99c715b047SGordon Tetlow while ((ch = getopt(argc, argv, "AL:a:e:f:l:m:n:o:ps:")) != -1) 10077edab90SPhilippe Charnier switch (ch) { 101a2325efeSRobert Watson case 'A': 102a2325efeSRobert Watson found_arg = 1; 103a2325efeSRobert Watson Aflag++; 104a2325efeSRobert Watson break; 105c715b047SGordon Tetlow case 'L': 106c715b047SGordon Tetlow found_arg = 1; 107c715b047SGordon Tetlow name = "volume label"; 108c715b047SGordon Tetlow Lvalue = optarg; 109c715b047SGordon Tetlow i = -1; 110c715b047SGordon Tetlow while (isalnum(Lvalue[++i])); 111c715b047SGordon Tetlow if (Lvalue[i] != '\0') { 112c715b047SGordon Tetlow errx(10, "bad %s. Valid characters are alphanumerics.", 113c715b047SGordon Tetlow name); 114c715b047SGordon Tetlow } 115c715b047SGordon Tetlow if (strlen(Lvalue) >= MAXVOLLEN) { 116c715b047SGordon Tetlow errx(10, "bad %s. Length is longer than %d.", 117c715b047SGordon Tetlow name, MAXVOLLEN - 1); 118c715b047SGordon Tetlow } 119c715b047SGordon Tetlow Lflag = 1; 120c715b047SGordon Tetlow break; 121289e09eeSRobert Watson case 'a': 122289e09eeSRobert Watson found_arg = 1; 123289e09eeSRobert Watson name = "ACLs"; 124289e09eeSRobert Watson avalue = optarg; 125289e09eeSRobert Watson if (strcmp(avalue, "enable") && strcmp(avalue, "disable")) { 126289e09eeSRobert Watson errx(10, "bad %s (options are %s)", name, 127289e09eeSRobert Watson "`enable' or `disable'"); 128289e09eeSRobert Watson } 129289e09eeSRobert Watson aflag = 1; 130289e09eeSRobert Watson break; 13177edab90SPhilippe Charnier case 'e': 13277edab90SPhilippe Charnier found_arg = 1; 13377edab90SPhilippe Charnier name = "maximum blocks per file in a cylinder group"; 13477edab90SPhilippe Charnier evalue = atoi(optarg); 13577edab90SPhilippe Charnier if (evalue < 1) 13677edab90SPhilippe Charnier errx(10, "%s must be >= 1 (was %s)", name, optarg); 13777edab90SPhilippe Charnier eflag = 1; 13877edab90SPhilippe Charnier break; 139a61ab64aSKirk McKusick case 'f': 140a61ab64aSKirk McKusick found_arg = 1; 141a61ab64aSKirk McKusick name = "average file size"; 142a61ab64aSKirk McKusick fvalue = atoi(optarg); 143a61ab64aSKirk McKusick if (fvalue < 1) 144a61ab64aSKirk McKusick errx(10, "%s must be >= 1 (was %s)", name, optarg); 145a61ab64aSKirk McKusick fflag = 1; 146a61ab64aSKirk McKusick break; 147289e09eeSRobert Watson case 'l': 148289e09eeSRobert Watson found_arg = 1; 149289e09eeSRobert Watson name = "multilabel MAC file system"; 150289e09eeSRobert Watson lvalue = optarg; 151289e09eeSRobert Watson if (strcmp(lvalue, "enable") && strcmp(lvalue, "disable")) { 152289e09eeSRobert Watson errx(10, "bad %s (options are %s)", name, 153289e09eeSRobert Watson "`enable' or `disable'"); 154289e09eeSRobert Watson } 155289e09eeSRobert Watson lflag = 1; 156289e09eeSRobert Watson break; 15777edab90SPhilippe Charnier case 'm': 15877edab90SPhilippe Charnier found_arg = 1; 15977edab90SPhilippe Charnier name = "minimum percentage of free space"; 16077edab90SPhilippe Charnier mvalue = atoi(optarg); 16177edab90SPhilippe Charnier if (mvalue < 0 || mvalue > 99) 16277edab90SPhilippe Charnier errx(10, "bad %s (%s)", name, optarg); 16377edab90SPhilippe Charnier mflag = 1; 16477edab90SPhilippe Charnier break; 16577edab90SPhilippe Charnier case 'n': 16677edab90SPhilippe Charnier found_arg = 1; 16777edab90SPhilippe Charnier name = "soft updates"; 16877edab90SPhilippe Charnier nvalue = optarg; 16977edab90SPhilippe Charnier if (strcmp(nvalue, "enable") && strcmp(nvalue, "disable")) { 17077edab90SPhilippe Charnier errx(10, "bad %s (options are %s)", 17177edab90SPhilippe Charnier name, "`enable' or `disable'"); 17277edab90SPhilippe Charnier } 17377edab90SPhilippe Charnier nflag = 1; 17477edab90SPhilippe Charnier break; 17577edab90SPhilippe Charnier case 'o': 17677edab90SPhilippe Charnier found_arg = 1; 17777edab90SPhilippe Charnier name = "optimization preference"; 17877edab90SPhilippe Charnier chg[FS_OPTSPACE] = "space"; 17977edab90SPhilippe Charnier chg[FS_OPTTIME] = "time"; 18077edab90SPhilippe Charnier if (strcmp(optarg, chg[FS_OPTSPACE]) == 0) 18177edab90SPhilippe Charnier ovalue = FS_OPTSPACE; 18277edab90SPhilippe Charnier else if (strcmp(optarg, chg[FS_OPTTIME]) == 0) 18377edab90SPhilippe Charnier ovalue = FS_OPTTIME; 18477edab90SPhilippe Charnier else 18577edab90SPhilippe Charnier errx(10, "bad %s (options are `space' or `time')", 18677edab90SPhilippe Charnier name); 18777edab90SPhilippe Charnier oflag = 1; 18877edab90SPhilippe Charnier break; 18977edab90SPhilippe Charnier case 'p': 190e50fa3d2SBen Smithurst found_arg = 1; 19177edab90SPhilippe Charnier pflag = 1; 19277edab90SPhilippe Charnier break; 193a61ab64aSKirk McKusick case 's': 194a61ab64aSKirk McKusick found_arg = 1; 195a61ab64aSKirk McKusick name = "expected number of files per directory"; 196a61ab64aSKirk McKusick svalue = atoi(optarg); 197a61ab64aSKirk McKusick if (svalue < 1) 198a61ab64aSKirk McKusick errx(10, "%s must be >= 1 (was %s)", name, optarg); 199a61ab64aSKirk McKusick sflag = 1; 200a61ab64aSKirk McKusick break; 20177edab90SPhilippe Charnier default: 20277edab90SPhilippe Charnier usage(); 20377edab90SPhilippe Charnier } 20477edab90SPhilippe Charnier argc -= optind; 20577edab90SPhilippe Charnier argv += optind; 20677edab90SPhilippe Charnier 20777edab90SPhilippe Charnier if (found_arg == 0 || argc != 1) 20877edab90SPhilippe Charnier usage(); 20977edab90SPhilippe Charnier 210907db4ddSJuli Mallett on = special = argv[0]; 211907db4ddSJuli Mallett if (ufs_disk_fillout(&disk, special) == -1) 212907db4ddSJuli Mallett goto err; 213907db4ddSJuli Mallett if (disk.d_name != special) { 214907db4ddSJuli Mallett special = disk.d_name; 2159ea6e95eSLuoqi Chen if (statfs(special, &stfs) == 0 && 216907db4ddSJuli Mallett strcmp(special, stfs.f_mntonname) == 0) 2177382c45aSLuoqi Chen active = 1; 218b20ae6a0SLuoqi Chen } 2198fae3551SRodney W. Grimes 22077edab90SPhilippe Charnier if (pflag) { 22177edab90SPhilippe Charnier printfs(); 22277edab90SPhilippe Charnier exit(0); 22377edab90SPhilippe Charnier } 224c715b047SGordon Tetlow if (Lflag) { 225c715b047SGordon Tetlow name = "volume label"; 226c715b047SGordon Tetlow strlcpy(sblock.fs_volname, Lvalue, MAXVOLLEN); 227c715b047SGordon Tetlow } 228289e09eeSRobert Watson if (aflag) { 229289e09eeSRobert Watson name = "ACLs"; 230289e09eeSRobert Watson if (strcmp(avalue, "enable") == 0) { 231289e09eeSRobert Watson if (sblock.fs_flags & FS_ACLS) { 232289e09eeSRobert Watson warnx("%s remains unchanged as enabled", name); 233289e09eeSRobert Watson } else { 234289e09eeSRobert Watson sblock.fs_flags |= FS_ACLS; 235289e09eeSRobert Watson warnx("%s set", name); 236289e09eeSRobert Watson } 237289e09eeSRobert Watson } else if (strcmp(avalue, "disable") == 0) { 238289e09eeSRobert Watson if ((~sblock.fs_flags & FS_ACLS) == 239289e09eeSRobert Watson FS_ACLS) { 240289e09eeSRobert Watson warnx("%s remains unchanged as disabled", 241289e09eeSRobert Watson name); 242289e09eeSRobert Watson } else { 243289e09eeSRobert Watson sblock.fs_flags &= ~FS_ACLS; 244273500c2SRobert Watson warnx("%s cleared", name); 245289e09eeSRobert Watson } 246289e09eeSRobert Watson } 247289e09eeSRobert Watson } 24877edab90SPhilippe Charnier if (eflag) { 2492af14b60SPhilippe Charnier name = "maximum blocks per file in a cylinder group"; 25077edab90SPhilippe Charnier if (sblock.fs_maxbpg == evalue) { 25177edab90SPhilippe Charnier warnx("%s remains unchanged as %d", name, evalue); 2522af14b60SPhilippe Charnier } 25377edab90SPhilippe Charnier else { 25477edab90SPhilippe Charnier warnx("%s changes from %d to %d", 25577edab90SPhilippe Charnier name, sblock.fs_maxbpg, evalue); 25677edab90SPhilippe Charnier sblock.fs_maxbpg = evalue; 25777edab90SPhilippe Charnier } 25877edab90SPhilippe Charnier } 259a61ab64aSKirk McKusick if (fflag) { 260a61ab64aSKirk McKusick name = "average file size"; 261a61ab64aSKirk McKusick if (sblock.fs_avgfilesize == fvalue) { 262a61ab64aSKirk McKusick warnx("%s remains unchanged as %d", name, fvalue); 263a61ab64aSKirk McKusick } 264a61ab64aSKirk McKusick else { 265a61ab64aSKirk McKusick warnx("%s changes from %d to %d", 266a61ab64aSKirk McKusick name, sblock.fs_avgfilesize, fvalue); 267a61ab64aSKirk McKusick sblock.fs_avgfilesize = fvalue; 268a61ab64aSKirk McKusick } 269a61ab64aSKirk McKusick } 270289e09eeSRobert Watson if (lflag) { 271289e09eeSRobert Watson name = "multilabel"; 272289e09eeSRobert Watson if (strcmp(lvalue, "enable") == 0) { 273289e09eeSRobert Watson if (sblock.fs_flags & FS_MULTILABEL) { 274289e09eeSRobert Watson warnx("%s remains unchanged as enabled", name); 275289e09eeSRobert Watson } else { 276289e09eeSRobert Watson sblock.fs_flags |= FS_MULTILABEL; 277289e09eeSRobert Watson warnx("%s set", name); 278289e09eeSRobert Watson } 279289e09eeSRobert Watson } else if (strcmp(lvalue, "disable") == 0) { 280289e09eeSRobert Watson if ((~sblock.fs_flags & FS_MULTILABEL) == 281289e09eeSRobert Watson FS_MULTILABEL) { 282289e09eeSRobert Watson warnx("%s remains unchanged as disabled", 283289e09eeSRobert Watson name); 284289e09eeSRobert Watson } else { 285289e09eeSRobert Watson sblock.fs_flags &= ~FS_MULTILABEL; 286273500c2SRobert Watson warnx("%s cleared", name); 287289e09eeSRobert Watson } 288289e09eeSRobert Watson } 289289e09eeSRobert Watson } 29077edab90SPhilippe Charnier if (mflag) { 2918fae3551SRodney W. Grimes name = "minimum percentage of free space"; 29277edab90SPhilippe Charnier if (sblock.fs_minfree == mvalue) { 29377edab90SPhilippe Charnier warnx("%s remains unchanged as %d%%", name, mvalue); 2942af14b60SPhilippe Charnier } 29577edab90SPhilippe Charnier else { 2968fae3551SRodney W. Grimes warnx("%s changes from %d%% to %d%%", 29777edab90SPhilippe Charnier name, sblock.fs_minfree, mvalue); 29877edab90SPhilippe Charnier sblock.fs_minfree = mvalue; 29977edab90SPhilippe Charnier if (mvalue >= MINFREE && sblock.fs_optim == FS_OPTSPACE) 3008fae3551SRodney W. Grimes warnx(OPTWARN, "time", ">=", MINFREE); 30177edab90SPhilippe Charnier if (mvalue < MINFREE && sblock.fs_optim == FS_OPTTIME) 3028fae3551SRodney W. Grimes warnx(OPTWARN, "space", "<", MINFREE); 303b1897c19SJulian Elischer } 30477edab90SPhilippe Charnier } 30577edab90SPhilippe Charnier if (nflag) { 30677edab90SPhilippe Charnier name = "soft updates"; 30777edab90SPhilippe Charnier if (strcmp(nvalue, "enable") == 0) { 30877edab90SPhilippe Charnier if (sblock.fs_flags & FS_DOSOFTDEP) { 30977edab90SPhilippe Charnier warnx("%s remains unchanged as enabled", name); 3101c2665d8SKirk McKusick } else if (sblock.fs_clean == 0) { 3111c2665d8SKirk McKusick warnx("%s cannot be enabled until fsck is run", 3121c2665d8SKirk McKusick name); 31377edab90SPhilippe Charnier } else { 31477edab90SPhilippe Charnier sblock.fs_flags |= FS_DOSOFTDEP; 31577edab90SPhilippe Charnier warnx("%s set", name); 31677edab90SPhilippe Charnier } 31777edab90SPhilippe Charnier } else if (strcmp(nvalue, "disable") == 0) { 31877edab90SPhilippe Charnier if ((~sblock.fs_flags & FS_DOSOFTDEP) == FS_DOSOFTDEP) { 31977edab90SPhilippe Charnier warnx("%s remains unchanged as disabled", name); 32077edab90SPhilippe Charnier } else { 32177edab90SPhilippe Charnier sblock.fs_flags &= ~FS_DOSOFTDEP; 32277edab90SPhilippe Charnier warnx("%s cleared", name); 32377edab90SPhilippe Charnier } 32477edab90SPhilippe Charnier } 32577edab90SPhilippe Charnier } 32677edab90SPhilippe Charnier if (oflag) { 3278fae3551SRodney W. Grimes name = "optimization preference"; 3288fae3551SRodney W. Grimes chg[FS_OPTSPACE] = "space"; 3298fae3551SRodney W. Grimes chg[FS_OPTTIME] = "time"; 33077edab90SPhilippe Charnier if (sblock.fs_optim == ovalue) { 33177edab90SPhilippe Charnier warnx("%s remains unchanged as %s", name, chg[ovalue]); 3328fae3551SRodney W. Grimes } 33377edab90SPhilippe Charnier else { 3348fae3551SRodney W. Grimes warnx("%s changes from %s to %s", 33577edab90SPhilippe Charnier name, chg[sblock.fs_optim], chg[ovalue]); 33677edab90SPhilippe Charnier sblock.fs_optim = ovalue; 33777edab90SPhilippe Charnier if (sblock.fs_minfree >= MINFREE && 33877edab90SPhilippe Charnier ovalue == FS_OPTSPACE) 3398fae3551SRodney W. Grimes warnx(OPTWARN, "time", ">=", MINFREE); 34077edab90SPhilippe Charnier if (sblock.fs_minfree < MINFREE && 34177edab90SPhilippe Charnier ovalue == FS_OPTTIME) 3428fae3551SRodney W. Grimes warnx(OPTWARN, "space", "<", MINFREE); 3438fae3551SRodney W. Grimes } 34477edab90SPhilippe Charnier } 345a61ab64aSKirk McKusick if (sflag) { 346a61ab64aSKirk McKusick name = "expected number of files per directory"; 347a61ab64aSKirk McKusick if (sblock.fs_avgfpdir == svalue) { 348a61ab64aSKirk McKusick warnx("%s remains unchanged as %d", name, svalue); 349a61ab64aSKirk McKusick } 350a61ab64aSKirk McKusick else { 351a61ab64aSKirk McKusick warnx("%s changes from %d to %d", 352a61ab64aSKirk McKusick name, sblock.fs_avgfpdir, svalue); 353a61ab64aSKirk McKusick sblock.fs_avgfpdir = svalue; 354a61ab64aSKirk McKusick } 355a61ab64aSKirk McKusick } 3562af14b60SPhilippe Charnier 357907db4ddSJuli Mallett if (sbwrite(&disk, Aflag) == -1) 358907db4ddSJuli Mallett goto err; 359907db4ddSJuli Mallett ufs_disk_close(&disk); 3607382c45aSLuoqi Chen if (active) { 3617382c45aSLuoqi Chen bzero(&args, sizeof(args)); 362907db4ddSJuli Mallett if (mount("ufs", on, 3637382c45aSLuoqi Chen stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0) 3647382c45aSLuoqi Chen err(9, "%s: reload", special); 3657382c45aSLuoqi Chen warnx("file system reloaded"); 3667382c45aSLuoqi Chen } 3678fae3551SRodney W. Grimes exit(0); 368907db4ddSJuli Mallett err: 369907db4ddSJuli Mallett if (disk.d_error != NULL) 370907db4ddSJuli Mallett errx(11, "%s: %s", special, disk.d_error); 371907db4ddSJuli Mallett else 372907db4ddSJuli Mallett err(12, "%s", special); 3738fae3551SRodney W. Grimes } 3748fae3551SRodney W. Grimes 3758fae3551SRodney W. Grimes void 376b1f0fda0SJuli Mallett usage(void) 3778fae3551SRodney W. Grimes { 378c715b047SGordon Tetlow fprintf(stderr, "%s\n%s\n%s\n%s\n", 379c715b047SGordon Tetlow "usage: tunefs [-A] [-L volname] [-a enable | disable] [-e maxbpg]", 380c715b047SGordon Tetlow " [-f avgfilesize] [-l enable | disable] [-m minfree]", 381c715b047SGordon Tetlow " [-n enable | disable] [-o space | time] [-p]", 382c715b047SGordon Tetlow " [-s avgfpdir] special | filesystem"); 3838fae3551SRodney W. Grimes exit(2); 3848fae3551SRodney W. Grimes } 3858fae3551SRodney W. Grimes 3868fae3551SRodney W. Grimes void 387b1f0fda0SJuli Mallett printfs(void) 38816a7269eSJoerg Wunsch { 38981dc101cSRobert Watson warnx("ACLs: (-a) %s", 39081dc101cSRobert Watson (sblock.fs_flags & FS_ACLS)? "enabled" : "disabled"); 39181dc101cSRobert Watson warnx("MAC multilabel: (-l) %s", 39281dc101cSRobert Watson (sblock.fs_flags & FS_MULTILABEL)? "enabled" : "disabled"); 393b1897c19SJulian Elischer warnx("soft updates: (-n) %s", 394b1897c19SJulian Elischer (sblock.fs_flags & FS_DOSOFTDEP)? "enabled" : "disabled"); 39516a7269eSJoerg Wunsch warnx("maximum blocks per file in a cylinder group: (-e) %d", 39616a7269eSJoerg Wunsch sblock.fs_maxbpg); 397a61ab64aSKirk McKusick warnx("average file size: (-f) %d", 398a61ab64aSKirk McKusick sblock.fs_avgfilesize); 399a61ab64aSKirk McKusick warnx("average number of files in a directory: (-s) %d", 400a61ab64aSKirk McKusick sblock.fs_avgfpdir); 40116a7269eSJoerg Wunsch warnx("minimum percentage of free space: (-m) %d%%", 40216a7269eSJoerg Wunsch sblock.fs_minfree); 40316a7269eSJoerg Wunsch warnx("optimization preference: (-o) %s", 40416a7269eSJoerg Wunsch sblock.fs_optim == FS_OPTSPACE ? "space" : "time"); 40516a7269eSJoerg Wunsch if (sblock.fs_minfree >= MINFREE && 40616a7269eSJoerg Wunsch sblock.fs_optim == FS_OPTSPACE) 40716a7269eSJoerg Wunsch warnx(OPTWARN, "time", ">=", MINFREE); 40816a7269eSJoerg Wunsch if (sblock.fs_minfree < MINFREE && 40916a7269eSJoerg Wunsch sblock.fs_optim == FS_OPTTIME) 41016a7269eSJoerg Wunsch warnx(OPTWARN, "space", "<", MINFREE); 411c715b047SGordon Tetlow warnx("volume label: (-L) %s", 412c715b047SGordon Tetlow sblock.fs_volname); 41316a7269eSJoerg Wunsch } 414