newfs.h revision 230049
1/* 2 * Copyright (c) 2002 Networks Associates Technology, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by Marshall 6 * Kirk McKusick and Network Associates Laboratories, the Security 7 * Research Division of Network Associates, Inc. under DARPA/SPAWAR 8 * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS 9 * research program. 10 * 11 * Copyright (c) 1980, 1989, 1993 12 * The Regents of the University of California. All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * $FreeBSD: stable/9/sbin/newfs/newfs.h 230049 2012-01-13 07:19:02Z mckusick $ 39 */ 40 41#include <libufs.h> 42 43/* 44 * The following two constants set the default block and fragment sizes. 45 * Both constants must be a power of 2 and meet the following constraints: 46 * MINBSIZE <= DESBLKSIZE <= MAXBSIZE 47 * sectorsize <= DESFRAGSIZE <= DESBLKSIZE 48 * DESBLKSIZE / DESFRAGSIZE <= 8 49 */ 50#define DFL_FRAGSIZE 4096 51#define DFL_BLKSIZE 32768 52 53/* 54 * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual 55 * number used depends upon how much information can be stored 56 * in a cylinder group map which must fit in a single file system 57 * block. The default is to use as many as possible blocks per group. 58 */ 59#define MAXBLKSPERCG 0x7fffffff /* desired fs_fpg ("infinity") */ 60 61/* 62 * MAXBLKPG determines the maximum number of data blocks which are 63 * placed in a single cylinder group. The default is one indirect 64 * block worth of data blocks. 65 */ 66#define MAXBLKPG(bsize) ((bsize) / sizeof(ufs2_daddr_t)) 67 68/* 69 * Each file system has a number of inodes statically allocated. 70 * We allocate one inode slot per NFPI fragments, expecting this 71 * to be far more than we will ever need. 72 */ 73#define NFPI 2 74 75/* 76 * variables set up by front end. 77 */ 78extern int Eflag; /* Erase previous disk contents */ 79extern int Lflag; /* add a volume label */ 80extern int Nflag; /* run mkfs without writing file system */ 81extern int Oflag; /* build UFS1 format file system */ 82extern int Rflag; /* regression test */ 83extern int Uflag; /* enable soft updates for file system */ 84extern int Xflag; /* exit in middle of newfs for testing */ 85extern int Jflag; /* enable gjournal for file system */ 86extern int lflag; /* enable multilabel MAC for file system */ 87extern int nflag; /* do not create .snap directory */ 88extern int tflag; /* enable TRIM */ 89extern intmax_t fssize; /* file system size */ 90extern int sectorsize; /* bytes/sector */ 91extern int realsectorsize; /* bytes/sector in hardware*/ 92extern int fsize; /* fragment size */ 93extern int bsize; /* block size */ 94extern int maxbsize; /* maximum clustering */ 95extern int maxblkspercg; /* maximum blocks per cylinder group */ 96extern int minfree; /* free space threshold */ 97extern int opt; /* optimization preference (space or time) */ 98extern int density; /* number of bytes per inode */ 99extern int maxcontig; /* max contiguous blocks to allocate */ 100extern int maxbpg; /* maximum blocks per file in a cyl group */ 101extern int avgfilesize; /* expected average file size */ 102extern int avgfilesperdir; /* expected number of files per directory */ 103extern u_char *volumelabel; /* volume label for filesystem */ 104extern struct uufsd disk; /* libufs disk structure */ 105 106/* 107 * To override a limitation in libufs, export the offset (in sectors) of the 108 * partition on the underlying media (file or disk). The value is used as 109 * an offset for all accesses to the media through bread(), which is only 110 * invoked directly in this program. 111 * For bwrite() we need a different approach, namely override the library 112 * version with one defined here. This is because bwrite() is called also 113 * by the library function sbwrite() which we cannot intercept nor want to 114 * rewrite. As a consequence, the internal version of bwrite() adds the 115 * partition offset itself when calling the underlying function, pwrite(). 116 * 117 * XXX This info really ought to go into the struct uufsd, at which point 118 * we can remove the above hack. 119 */ 120extern ufs2_daddr_t part_ofs; /* partition offset in blocks */ 121 122void mkfs (struct partition *, char *); 123