Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/makefs/ffs/mkfs.c
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | |||||
static int bbsize; /* boot block size */ | static int bbsize; /* boot block size */ | ||||
static int sbsize; /* superblock size */ | static int sbsize; /* superblock size */ | ||||
static int avgfilesize; /* expected average file size */ | static int avgfilesize; /* expected average file size */ | ||||
static int avgfpdir; /* expected number of files per directory */ | static int avgfpdir; /* expected number of files per directory */ | ||||
struct fs * | struct fs * | ||||
ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp) | ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp) | ||||
{ | { | ||||
int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg; | int fragsperinode, optimalfpg, origdensity, mindensity; | ||||
int minfpg, lastminfpg; | |||||
int32_t csfrags; | int32_t csfrags; | ||||
uint32_t i, cylno; | uint32_t i, cylno; | ||||
long long sizepb; | long long sizepb; | ||||
ino_t maxinum; | |||||
int minfragsperinode; /* minimum ratio of frags to inodes */ | |||||
void *space; | void *space; | ||||
int size; | int size; | ||||
int nprintcols, printcolwidth; | int nprintcols, printcolwidth; | ||||
ffs_opt_t *ffs_opts = fsopts->fs_specific; | ffs_opt_t *ffs_opts = fsopts->fs_specific; | ||||
Oflag = ffs_opts->version; | Oflag = ffs_opts->version; | ||||
fssize = fsopts->size / fsopts->sectorsize; | fssize = fsopts->size / fsopts->sectorsize; | ||||
sectorsize = fsopts->sectorsize; | sectorsize = fsopts->sectorsize; | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp) | ||||
* this goal is achieved we try to expand to have at least | * this goal is achieved we try to expand to have at least | ||||
* 1 cylinder group. Once this goal is achieved, we pack as | * 1 cylinder group. Once this goal is achieved, we pack as | ||||
* many blocks into each cylinder group map as will fit. | * many blocks into each cylinder group map as will fit. | ||||
* | * | ||||
* We start by calculating the smallest number of blocks that we | * We start by calculating the smallest number of blocks that we | ||||
* can put into each cylinder group. If this is too big, we reduce | * can put into each cylinder group. If this is too big, we reduce | ||||
* the density until it fits. | * the density until it fits. | ||||
*/ | */ | ||||
maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock); | |||||
minfragsperinode = 1 + fssize / maxinum; | |||||
mindensity = minfragsperinode * fsize; | |||||
if (density == 0) | |||||
density = MAX(2, minfragsperinode) * fsize; | |||||
if (density < mindensity) { | |||||
origdensity = density; | origdensity = density; | ||||
density = mindensity; | |||||
fprintf(stderr, "density increased from %d to %d\n", | |||||
origdensity, density); | |||||
} | |||||
origdensity = density; | |||||
if (!ffs_opts->min_inodes) | |||||
density = MIN(density, MAX(2, minfragsperinode) * fsize); | |||||
for (;;) { | for (;;) { | ||||
fragsperinode = MAX(numfrags(&sblock, density), 1); | fragsperinode = MAX(numfrags(&sblock, density), 1); | ||||
minfpg = fragsperinode * INOPB(&sblock); | minfpg = fragsperinode * INOPB(&sblock); | ||||
if (minfpg > sblock.fs_size) | if (minfpg > sblock.fs_size) | ||||
minfpg = sblock.fs_size; | minfpg = sblock.fs_size; | ||||
sblock.fs_ipg = INOPB(&sblock); | sblock.fs_ipg = INOPB(&sblock); | ||||
sblock.fs_fpg = roundup(sblock.fs_iblkno + | sblock.fs_fpg = roundup(sblock.fs_iblkno + | ||||
sblock.fs_ipg / INOPF(&sblock), sblock.fs_frag); | sblock.fs_ipg / INOPF(&sblock), sblock.fs_frag); | ||||
▲ Show 20 Lines • Show All 516 Lines • Show Last 20 Lines |