newfs.h revision 203764
192717Sphk/* 298542Smckusick * Copyright (c) 2002 Networks Associates Technology, Inc. 398542Smckusick * All rights reserved. 498542Smckusick * 598542Smckusick * This software was developed for the FreeBSD Project by Marshall 698542Smckusick * Kirk McKusick and Network Associates Laboratories, the Security 798542Smckusick * Research Division of Network Associates, Inc. under DARPA/SPAWAR 898542Smckusick * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS 9110884Smckusick * research program. 1098542Smckusick * 1192717Sphk * Copyright (c) 1980, 1989, 1993 1292717Sphk * The Regents of the University of California. All rights reserved. 1392717Sphk * 1492717Sphk * Redistribution and use in source and binary forms, with or without 1592717Sphk * modification, are permitted provided that the following conditions 1692717Sphk * are met: 1792717Sphk * 1. Redistributions of source code must retain the above copyright 1892717Sphk * notice, this list of conditions and the following disclaimer. 1992717Sphk * 2. Redistributions in binary form must reproduce the above copyright 2092717Sphk * notice, this list of conditions and the following disclaimer in the 2192717Sphk * documentation and/or other materials provided with the distribution. 2292717Sphk * 4. Neither the name of the University nor the names of its contributors 2392717Sphk * may be used to endorse or promote products derived from this software 2492717Sphk * without specific prior written permission. 2592717Sphk * 2692717Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2792717Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2892717Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2992717Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3092717Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3192717Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3292717Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3392717Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3492717Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3592717Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3692717Sphk * SUCH DAMAGE. 3792717Sphk * 3892717Sphk * $FreeBSD: head/sbin/newfs/newfs.h 203764 2010-02-10 20:17:46Z mckusick $ 3992717Sphk */ 4092717Sphk 41110671Sjmallett#include <libufs.h> 4292717Sphk 4392717Sphk/* 44203764Smckusick * The following two constants set the default block and fragment sizes. 45203764Smckusick * Both constants must be a power of 2 and meet the following constraints: 46203764Smckusick * MINBSIZE <= DESBLKSIZE <= MAXBSIZE 47203764Smckusick * sectorsize <= DESFRAGSIZE <= DESBLKSIZE 48203764Smckusick * DESBLKSIZE / DESFRAGSIZE <= 8 49203764Smckusick */ 50203764Smckusick#define DFL_FRAGSIZE 2048 51203764Smckusick#define DFL_BLKSIZE 16384 52203764Smckusick 53203764Smckusick/* 54203764Smckusick * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual 55203764Smckusick * number used depends upon how much information can be stored 56203764Smckusick * in a cylinder group map which must fit in a single file system 57203764Smckusick * block. The default is to use as many as possible blocks per group. 58203764Smckusick */ 59203764Smckusick#define MAXBLKSPERCG 0x7fffffff /* desired fs_fpg ("infinity") */ 60203764Smckusick 61203764Smckusick/* 62203764Smckusick * MAXBLKPG determines the maximum number of data blocks which are 63203764Smckusick * placed in a single cylinder group. The default is one indirect 64203764Smckusick * block worth of data blocks. 65203764Smckusick */ 66203764Smckusick#define MAXBLKPG(bsize) ((bsize) / sizeof(ufs2_daddr_t)) 67203764Smckusick 68203764Smckusick/* 69203764Smckusick * Each file system has a number of inodes statically allocated. 70203764Smckusick * We allocate one inode slot per NFPI fragments, expecting this 71203764Smckusick * to be far more than we will ever need. 72203764Smckusick */ 73203764Smckusick#define NFPI 4 74203764Smckusick 75203764Smckusick/* 7692717Sphk * variables set up by front end. 7792717Sphk */ 78174675Sphkextern int Eflag; /* Erase previous disk contents */ 79110174Sgordonextern int Lflag; /* add a volume label */ 80102231Strhodesextern int Nflag; /* run mkfs without writing file system */ 81102231Strhodesextern int Oflag; /* build UFS1 format file system */ 8292722Sphkextern int Rflag; /* regression test */ 83102231Strhodesextern int Uflag; /* enable soft updates for file system */ 84174675Sphkextern int Xflag; /* exit in middle of newfs for testing */ 85163842Spjdextern int Jflag; /* enable gjournal for file system */ 86126254Srwatsonextern int lflag; /* enable multilabel MAC for file system */ 87140603Swesextern int nflag; /* do not create .snap directory */ 88174011Syarextern intmax_t fssize; /* file system size */ 8998542Smckusickextern int sectorsize; /* bytes/sector */ 9092717Sphkextern int realsectorsize; /* bytes/sector in hardware*/ 9192717Sphkextern int fsize; /* fragment size */ 9292717Sphkextern int bsize; /* block size */ 9398542Smckusickextern int maxbsize; /* maximum clustering */ 9498542Smckusickextern int maxblkspercg; /* maximum blocks per cylinder group */ 9592717Sphkextern int minfree; /* free space threshold */ 9692717Sphkextern int opt; /* optimization preference (space or time) */ 9792717Sphkextern int density; /* number of bytes per inode */ 9892717Sphkextern int maxcontig; /* max contiguous blocks to allocate */ 9992717Sphkextern int maxbpg; /* maximum blocks per file in a cyl group */ 10092717Sphkextern int avgfilesize; /* expected average file size */ 10192717Sphkextern int avgfilesperdir; /* expected number of files per directory */ 102110174Sgordonextern u_char *volumelabel; /* volume label for filesystem */ 103110671Sjmallettextern struct uufsd disk; /* libufs disk structure */ 10495357Sphk 105185588Sluigi/* 106185588Sluigi * To override a limitation in libufs, export the offset (in sectors) of the 107185588Sluigi * partition on the underlying media (file or disk). The value is used as 108185588Sluigi * an offset for all accesses to the media through bread(), which is only 109185588Sluigi * invoked directly in this program. 110185588Sluigi * For bwrite() we need a different approach, namely override the library 111185588Sluigi * version with one defined here. This is because bwrite() is called also 112185588Sluigi * by the library function sbwrite() which we cannot intercept nor want to 113185588Sluigi * rewrite. As a consequence, the internal version of bwrite() adds the 114185588Sluigi * partition offset itself when calling the underlying function, pwrite(). 115185588Sluigi * 116185588Sluigi * XXX This info really ought to go into the struct uufsd, at which point 117185588Sluigi * we can remove the above hack. 118185588Sluigi */ 119185588Sluigiextern ufs2_daddr_t part_ofs; /* partition offset in blocks */ 120185588Sluigi 12195357Sphkvoid mkfs (struct partition *, char *); 122