mkfs.c (186335) | mkfs.c (214921) |
---|---|
1/* $NetBSD: mkfs.c,v 1.20 2004/06/24 22:30:13 lukem Exp $ */ 2 3/* 4 * Copyright (c) 2002 Networks Associates Technology, Inc. 5 * All rights reserved. 6 * 7 * This software was developed for the FreeBSD Project by Marshall 8 * Kirk McKusick and Network Associates Laboratories, the Security --- 25 unchanged lines hidden (view full) --- 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 */ 40 41#include <sys/cdefs.h> | 1/* $NetBSD: mkfs.c,v 1.20 2004/06/24 22:30:13 lukem Exp $ */ 2 3/* 4 * Copyright (c) 2002 Networks Associates Technology, Inc. 5 * All rights reserved. 6 * 7 * This software was developed for the FreeBSD Project by Marshall 8 * Kirk McKusick and Network Associates Laboratories, the Security --- 25 unchanged lines hidden (view full) --- 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/mkfs.c 186334 2008-12-19 18:45:43Z sam $"); | 42__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/mkfs.c 214921 2010-11-07 16:05:04Z cognet $"); |
43 44#include <sys/param.h> 45#include <sys/time.h> 46#include <sys/resource.h> 47 48#include <stdio.h> 49#include <stdlib.h> 50#include <string.h> 51#include <unistd.h> 52#include <errno.h> 53 54#include "makefs.h" | 43 44#include <sys/param.h> 45#include <sys/time.h> 46#include <sys/resource.h> 47 48#include <stdio.h> 49#include <stdlib.h> 50#include <string.h> 51#include <unistd.h> 52#include <errno.h> 53 54#include "makefs.h" |
55#include "ffs.h" |
|
55 56#include <ufs/ufs/dinode.h> 57#include <ufs/ffs/fs.h> 58 59#include "ffs/ufs_bswap.h" 60#include "ffs/ufs_inode.h" 61#include "ffs/ffs_extern.h" 62#include "ffs/newfs_extern.h" 63 | 56 57#include <ufs/ufs/dinode.h> 58#include <ufs/ffs/fs.h> 59 60#include "ffs/ufs_bswap.h" 61#include "ffs/ufs_inode.h" 62#include "ffs/ffs_extern.h" 63#include "ffs/newfs_extern.h" 64 |
65#ifndef BBSIZE 66#define BBSIZE 8192 /* size of boot area, with label */ 67#endif 68 |
|
64static void initcg(int, time_t, const fsinfo_t *); 65static int ilog2(int); 66 67static int count_digits(int); 68 69/* 70 * make file system for cylinder-group style file systems 71 */ --- 25 unchanged lines hidden (view full) --- 97static int bsize; /* block size */ 98static int maxbsize; /* maximum clustering */ 99static int maxblkspercg; 100static int minfree; /* free space threshold */ 101static int opt; /* optimization preference (space or time) */ 102static int density; /* number of bytes per inode */ 103static int maxcontig; /* max contiguous blocks to allocate */ 104static int maxbpg; /* maximum blocks per file in a cyl group */ | 69static void initcg(int, time_t, const fsinfo_t *); 70static int ilog2(int); 71 72static int count_digits(int); 73 74/* 75 * make file system for cylinder-group style file systems 76 */ --- 25 unchanged lines hidden (view full) --- 102static int bsize; /* block size */ 103static int maxbsize; /* maximum clustering */ 104static int maxblkspercg; 105static int minfree; /* free space threshold */ 106static int opt; /* optimization preference (space or time) */ 107static int density; /* number of bytes per inode */ 108static int maxcontig; /* max contiguous blocks to allocate */ 109static int maxbpg; /* maximum blocks per file in a cyl group */ |
110static int bbsize; /* boot block size */ |
|
105static int sbsize; /* superblock size */ 106static int avgfilesize; /* expected average file size */ 107static int avgfpdir; /* expected number of files per directory */ 108 109struct fs * 110ffs_mkfs(const char *fsys, const fsinfo_t *fsopts) 111{ 112 int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg; 113 int32_t cylno, i, csfrags; 114 long long sizepb; 115 void *space; 116 int size, blks; 117 int nprintcols, printcolwidth; | 111static int sbsize; /* superblock size */ 112static int avgfilesize; /* expected average file size */ 113static int avgfpdir; /* expected number of files per directory */ 114 115struct fs * 116ffs_mkfs(const char *fsys, const fsinfo_t *fsopts) 117{ 118 int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg; 119 int32_t cylno, i, csfrags; 120 long long sizepb; 121 void *space; 122 int size, blks; 123 int nprintcols, printcolwidth; |
124 ffs_opt_t *ffs_opts = fsopts->fs_specific; |
|
118 | 125 |
119 Oflag = fsopts->version; | 126 Oflag = ffs_opts->version; |
120 fssize = fsopts->size / fsopts->sectorsize; 121 sectorsize = fsopts->sectorsize; | 127 fssize = fsopts->size / fsopts->sectorsize; 128 sectorsize = fsopts->sectorsize; |
122 fsize = fsopts->fsize; 123 bsize = fsopts->bsize; 124 maxbsize = fsopts->maxbsize; 125 maxblkspercg = fsopts->maxblkspercg; 126 minfree = fsopts->minfree; 127 opt = fsopts->optimization; 128 density = fsopts->density; 129 maxcontig = fsopts->maxcontig; 130 maxbpg = fsopts->maxbpg; 131 avgfilesize = fsopts->avgfilesize; 132 avgfpdir = fsopts->avgfpdir; | 129 fsize = ffs_opts->fsize; 130 bsize = ffs_opts->bsize; 131 maxbsize = ffs_opts->maxbsize; 132 maxblkspercg = ffs_opts->maxblkspercg; 133 minfree = ffs_opts->minfree; 134 opt = ffs_opts->optimization; 135 density = ffs_opts->density; 136 maxcontig = ffs_opts->maxcontig; 137 maxbpg = ffs_opts->maxbpg; 138 avgfilesize = ffs_opts->avgfilesize; 139 avgfpdir = ffs_opts->avgfpdir; 140 bbsize = BBSIZE; |
133 sbsize = SBLOCKSIZE; 134 135 if (Oflag == 0) { 136 sblock.fs_old_inodefmt = FS_42INODEFMT; 137 sblock.fs_maxsymlinklen = 0; 138 sblock.fs_old_flags = 0; 139 } else { 140 sblock.fs_old_inodefmt = FS_44INODEFMT; --- 692 unchanged lines hidden --- | 141 sbsize = SBLOCKSIZE; 142 143 if (Oflag == 0) { 144 sblock.fs_old_inodefmt = FS_42INODEFMT; 145 sblock.fs_maxsymlinklen = 0; 146 sblock.fs_old_flags = 0; 147 } else { 148 sblock.fs_old_inodefmt = FS_44INODEFMT; --- 692 unchanged lines hidden --- |