void setup_tables(void) { unsigned i; memset(inode_map,0xff,sizeof(inode_map)); memset(zone_map,0xff,sizeof(zone_map)); memset(super_block_buffer,0,BLOCK_SIZE); MAGIC = magic; ZONESIZE = 0; MAXSIZE = (7+512+512L*512L)*1024L; ZONES = BLOCKS; INODES = BLOCKS/3; if( BLOCKS > 32768L ) INODES += (BLOCKS-32768)*4/3; if( INODES > 63424L ) INODES = 63424L; if ((INODES & 8191) > 8188) INODES -= 5; if ((INODES & 8191) < 10) INODES -= 20; IMAPS = UPPER(INODES,BITS_PER_BLOCK); ZMAPS = 0; while (ZMAPS != UPPER(BLOCKS - NORM_FIRSTZONE,BITS_PER_BLOCK)) ZMAPS = UPPER(BLOCKS - NORM_FIRSTZONE,BITS_PER_BLOCK); FIRSTZONE = NORM_FIRSTZONE; for (i = FIRSTZONE ; i<ZONES ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<INODES ; i++) unmark_inode(i); inode_buffer = malloc(2048); if (!inode_buffer) die("Unable to allocate buffer for inodes"); memset(inode_buffer,0,2048); printf("%u inodes\n",INODES); printf("%u blocks\n",ZONES); printf("Firstdatazone=%d (%d)\n",FIRSTZONE,NORM_FIRSTZONE); printf("Zonesize=%d\n",BLOCK_SIZE<<ZONESIZE); printf("Maxsize=%ld\n\n",MAXSIZE); }
void setup_tables(void) { int i; memset(inode_map,0xff,sizeof(inode_map)); memset(zone_map,0xff,sizeof(zone_map)); memset(super_block_buffer,0,BLOCK_SIZE); MAGIC = MINIX_SUPER_MAGIC; ZONESIZE = 0; MAXSIZE = (7+512+512*512)*1024; ZONES = BLOCKS; /* some magic nrs: 1 inode / 3 blocks */ INODES = BLOCKS/3; /* I don't want some off-by-one errors, so this hack... */ if ((INODES & 8191) > 8188) INODES -= 5; if ((INODES & 8191) < 10) INODES -= 20; IMAPS = UPPER(INODES,BITS_PER_BLOCK); ZMAPS = 0; while (ZMAPS != UPPER(BLOCKS - NORM_FIRSTZONE,BITS_PER_BLOCK)) ZMAPS = UPPER(BLOCKS - NORM_FIRSTZONE,BITS_PER_BLOCK); FIRSTZONE = NORM_FIRSTZONE; for (i = FIRSTZONE ; i<ZONES ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<INODES ; i++) unmark_inode(i); inode_buffer = malloc(INODE_BUFFER_SIZE); if (!inode_buffer) die("Unable to allocate buffer for inodes"); memset(inode_buffer,0,INODE_BUFFER_SIZE); printf("%d inodes\n",INODES); printf("%d blocks\n",ZONES); printf("Firstdatazone=%d (%d)\n",FIRSTZONE,NORM_FIRSTZONE); printf("Zonesize=%d\n",BLOCK_SIZE<<ZONESIZE); printf("Maxsize=%d\n\n",MAXSIZE); }
static void setup_tables(void) { int i; unsigned long inodes; super_block_buffer = calloc(1, BLOCK_SIZE); if (!super_block_buffer) die(_("unable to alloc buffer for superblock")); memset(boot_block_buffer,0,512); Super.s_magic = magic; Super.s_log_zone_size = 0; Super.s_max_size = version2 ? 0x7fffffff : (7+512+512*512)*1024; if (version2) Super.s_zones = BLOCKS; else Super.s_nzones = BLOCKS; /* some magic nrs: 1 inode / 3 blocks */ if ( req_nr_inodes == 0 ) inodes = BLOCKS/3; else inodes = req_nr_inodes; /* Round up inode count to fill block size */ if (version2) inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & ~(MINIX2_INODES_PER_BLOCK - 1)); else inodes = ((inodes + MINIX_INODES_PER_BLOCK - 1) & ~(MINIX_INODES_PER_BLOCK - 1)); if (inodes > 65535) inodes = 65535; Super.s_ninodes = inodes; /* The old code here * ZMAPS = 0; * while (ZMAPS != UPPER(BLOCKS - NORM_FIRSTZONE + 1,BITS_PER_BLOCK)) * ZMAPS = UPPER(BLOCKS - NORM_FIRSTZONE + 1,BITS_PER_BLOCK); * was no good, since it may loop. - aeb */ Super.s_imap_blocks = UPPER(INODES + 1, BITS_PER_BLOCK); Super.s_zmap_blocks = UPPER(BLOCKS - (1+IMAPS+INODE_BLOCKS), BITS_PER_BLOCK+1); Super.s_firstdatazone = NORM_FIRSTZONE; inode_map = malloc(IMAPS * BLOCK_SIZE); zone_map = malloc(ZMAPS * BLOCK_SIZE); if (!inode_map || !zone_map) die(_("unable to allocate buffers for maps")); memset(inode_map,0xff,IMAPS * BLOCK_SIZE); memset(zone_map,0xff,ZMAPS * BLOCK_SIZE); for (i = FIRSTZONE ; i<ZONES ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<=INODES ; i++) unmark_inode(i); inode_buffer = malloc(INODE_BUFFER_SIZE); if (!inode_buffer) die(_("unable to allocate buffer for inodes")); memset(inode_buffer,0,INODE_BUFFER_SIZE); printf(_("%ld inodes\n"),INODES); printf(_("%ld blocks\n"),ZONES); printf(_("Firstdatazone=%ld (%ld)\n"),FIRSTZONE,NORM_FIRSTZONE); printf(_("Zonesize=%d\n"),BLOCK_SIZE<<ZONESIZE); printf(_("Maxsize=%ld\n\n"),MAXSIZE); }
static void setup_tables(void) { unsigned long inodes, zmaps, imaps, zones, i; super_block_buffer = calloc(1, MINIX_BLOCK_SIZE); if (!super_block_buffer) err(MKFS_EX_ERROR, _("%s: unable to allocate buffer for superblock"), device_name); memset(boot_block_buffer,0,512); super_set_magic(); if (fs_version == 3) { Super3.s_log_zone_size = 0; Super3.s_blocksize = MINIX_BLOCK_SIZE; } else { Super.s_log_zone_size = 0; } super_init_maxsize(); super_set_nzones(); zones = get_nzones(); /* some magic nrs: 1 inode / 3 blocks */ if ( req_nr_inodes == 0 ) inodes = BLOCKS/3; else inodes = req_nr_inodes; /* Round up inode count to fill block size */ if (fs_version == 2 || fs_version == 3) inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & ~(MINIX2_INODES_PER_BLOCK - 1)); else inodes = ((inodes + MINIX_INODES_PER_BLOCK - 1) & ~(MINIX_INODES_PER_BLOCK - 1)); if (fs_version == 3) Super3.s_ninodes = inodes; else { Super.s_ninodes = inodes; if (inodes > MINIX_MAX_INODES) inodes = MINIX_MAX_INODES; } super_set_map_blocks(inodes); imaps = get_nimaps(); zmaps = get_nzmaps(); inode_map = malloc(imaps * MINIX_BLOCK_SIZE); zone_map = malloc(zmaps * MINIX_BLOCK_SIZE); if (!inode_map || !zone_map) err(MKFS_EX_ERROR, _("%s: unable to allocate buffers for maps"), device_name); memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE); memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE); for (i = get_first_zone() ; i<zones ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<=inodes; i++) unmark_inode(i); inode_buffer = malloc(get_inode_buffer_size()); if (!inode_buffer) err(MKFS_EX_ERROR, _("%s: unable to allocate buffer for inodes"), device_name); memset(inode_buffer,0, get_inode_buffer_size()); printf(P_("%lu inode\n", "%lu inodes\n", inodes), inodes); printf(P_("%lu block\n", "%lu blocks\n", zones), zones); printf(_("Firstdatazone=%jd (%jd)\n"), get_first_zone(), first_zone_data()); printf(_("Zonesize=%zu\n"), (size_t) MINIX_BLOCK_SIZE << get_zone_size()); printf(_("Maxsize=%zu\n\n"),get_max_size()); }
static void setup_tables(const struct fs_control *ctl) { unsigned long inodes, zmaps, imaps, zones, i; super_block_buffer = xcalloc(1, MINIX_BLOCK_SIZE); memset(boot_block_buffer,0,512); super_set_magic(ctl); if (fs_version == 3) { Super3.s_log_zone_size = 0; Super3.s_blocksize = MINIX_BLOCK_SIZE; } else { Super.s_log_zone_size = 0; } super_init_maxsize(); super_set_nzones(ctl); zones = get_nzones(); /* some magic nrs: 1 inode / 3 blocks for smaller filesystems, * for one inode / 16 blocks for large ones. mkfs will eventually * crab about too far when getting close to the maximum size. */ if (ctl->fs_inodes == 0) if (2048 * 1024 < ctl->fs_blocks) /* 2GB */ inodes = ctl->fs_blocks / 16; else if (512 * 1024 < ctl->fs_blocks) /* 0.5GB */ inodes = ctl->fs_blocks / 8; else inodes = ctl->fs_blocks / 3; else inodes = ctl->fs_inodes; /* Round up inode count to fill block size */ if (fs_version == 2 || fs_version == 3) inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & ~(MINIX2_INODES_PER_BLOCK - 1)); else inodes = ((inodes + MINIX_INODES_PER_BLOCK - 1) & ~(MINIX_INODES_PER_BLOCK - 1)); if (fs_version == 3) Super3.s_ninodes = inodes; else { Super.s_ninodes = inodes; if (inodes > MINIX_MAX_INODES) inodes = MINIX_MAX_INODES; } super_set_map_blocks(ctl, inodes); if (MINIX_MAX_INODES < first_zone_data()) errx(MKFS_EX_ERROR, _("First data block at %jd, which is too far (max %d).\n" "Try specifying fewer inodes by passing --inodes <num>"), first_zone_data(), MINIX_MAX_INODES); imaps = get_nimaps(); zmaps = get_nzmaps(); inode_map = xmalloc(imaps * MINIX_BLOCK_SIZE); zone_map = xmalloc(zmaps * MINIX_BLOCK_SIZE); memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE); memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE); for (i = get_first_zone() ; i<zones ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<=inodes; i++) unmark_inode(i); inode_buffer = xmalloc(get_inode_buffer_size()); memset(inode_buffer,0, get_inode_buffer_size()); printf(P_("%lu inode\n", "%lu inodes\n", inodes), inodes); printf(P_("%lu block\n", "%lu blocks\n", zones), zones); printf(_("Firstdatazone=%jd (%jd)\n"), get_first_zone(), first_zone_data()); printf(_("Zonesize=%zu\n"), (size_t) MINIX_BLOCK_SIZE << get_zone_size()); printf(_("Maxsize=%zu\n\n"),get_max_size()); }