Changeset 68ed0fb in mainline
- Timestamp:
- 2011-03-06T14:49:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bc24c5e
- Parents:
- 86d0b4b3
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r86d0b4b3 r68ed0fb 97 97 98 98 /*Default block size is 4Kb*/ 99 opt.block_size = 4096;99 opt.block_size = MFS_MAX_BLOCKSIZE; 100 100 opt.n_inodes = 0; 101 101 opt.fs_longnames = false; … … 115 115 case '1': 116 116 opt.fs_magic = MFS_MAGIC_V1; 117 opt.block_size = MFS_ MIN_BLOCK_SIZE;117 opt.block_size = MFS_BLOCKSIZE; 118 118 break; 119 119 case '2': 120 120 opt.fs_magic = MFS_MAGIC_V2; 121 opt.block_size = MFS_ MIN_BLOCK_SIZE;121 opt.block_size = MFS_BLOCKSIZE; 122 122 break; 123 123 case '3': … … 136 136 } 137 137 138 if (opt.block_size < MFS_MIN_BLOCK _SIZE ||139 opt.block_size > MFS_MAX_BLOCK _SIZE) {138 if (opt.block_size < MFS_MIN_BLOCKSIZE || 139 opt.block_size > MFS_MAX_BLOCKSIZE) { 140 140 printf(NAME ":Error! Invalid block size.\n"); 141 141 exit(0); … … 144 144 printf(NAME ":Error! Invalid block size.\n"); 145 145 exit(0); 146 } else if (opt.block_size > MFS_ MIN_BLOCK_SIZE &&146 } else if (opt.block_size > MFS_BLOCKSIZE && 147 147 opt.fs_magic != MFS_MAGIC_V3) { 148 148 printf(NAME ":Error! Block size > 1024 is supported by V3 filesystem only.\n"); … … 168 168 } 169 169 170 rc = block_init(handle, MFS_MIN_BLOCK _SIZE);170 rc = block_init(handle, MFS_MIN_BLOCKSIZE); 171 171 if (rc != EOK) { 172 172 printf(NAME ": Error initializing libblock.\n"); … … 193 193 } 194 194 195 printf("Creating Minix file system on device\n"); 195 /*Minimum block size is 1 Kb*/ 196 opt.dev_nblocks /= 2; 197 198 printf(NAME ": Creating Minix file system on device\n"); 196 199 197 200 /*Prepare superblock*/ … … 211 214 } 212 215 prepare_superblock(sb, &opt); 216 block_write_direct(handle, MFS_SUPERBLOCK, 1, sb); 213 217 } 214 218 … … 218 222 static void prepare_superblock(struct mfs_superblock *sb, mfs_params_t *opt) 219 223 { 220 if (opt->fs_longnames) { 221 if (opt->fs_magic == MFS_MAGIC_V1) 224 int ino_per_block = 0; 225 int fs_version; 226 aoff64_t tmp; 227 228 if (opt->fs_magic == MFS_MAGIC_V1) { 229 fs_version = 1; 230 ino_per_block = V1_INODES_PER_BLOCK; 231 if (opt->fs_longnames) 222 232 opt->fs_magic = MFS_MAGIC_V1L; 223 else 233 } else { 234 fs_version = 2; 235 ino_per_block = V1_INODES_PER_BLOCK; 236 if (opt->fs_longnames) 224 237 opt->fs_magic = MFS_MAGIC_V2L; 225 238 } … … 235 248 UINT32_MAX : opt->dev_nblocks; 236 249 237 if (opt->n_inodes == 0) { 238 aoff64_t tmp = opt->dev_nblocks / 3; 239 sb->s_ninodes = tmp > UINT16_MAX ? UINT16_MAX : tmp; 240 } else { 241 sb->s_ninodes = opt->n_inodes; 242 } 243 250 if (opt->n_inodes == 0) 251 tmp = opt->dev_nblocks / 3; 252 else 253 tmp = opt->n_inodes; 254 255 /*Round up the number of inodes to fill block size*/ 256 if (tmp % ino_per_block) 257 tmp = ((tmp / ino_per_block) + 1) * ino_per_block; 258 sb->s_ninodes = tmp > UINT16_MAX ? UINT16_MAX : tmp; 259 260 /*Compute inode bitmap size in blocks*/ 261 sb->s_ibmap_blocks = sb->s_ninodes / (MFS_BLOCKSIZE * 8); 262 if (sb->s_ibmap_blocks == 0) 263 sb->s_ibmap_blocks = 1; 264 265 /*Compute zone bitmap size in blocks*/ 266 if (fs_version == 1) 267 sb->s_zbmap_blocks = sb->s_nzones / (MFS_BLOCKSIZE * 8); 268 else 269 sb->s_zbmap_blocks = sb->s_nzones2 / (MFS_BLOCKSIZE * 8); 270 if (sb->s_zbmap_blocks == 0) 271 sb->s_zbmap_blocks = 1; 272 273 /*Compute first data zone position*/ 274 sb->s_first_data_zone = 2 + sb->s_zbmap_blocks + sb->s_ibmap_blocks; 275 unsigned long ninodes_blocks = 1 + (sb->s_ninodes / (fs_version == 1 ? 276 V1_INODES_PER_BLOCK : 277 V2_INODES_PER_BLOCK)); 278 sb->s_first_data_zone += ninodes_blocks; 244 279 sb->s_log2_zone_size = 0; 245 280 /*Superblock is now ready to be written on disk*/ 281 printf(NAME ": %d inodes\n", sb->s_ninodes); 282 printf(NAME ": %d zones\n", sb->s_nzones2); 283 printf(NAME ": %d first data zone\n", sb->s_first_data_zone); 246 284 } 247 285 -
uspace/lib/minix/minix.h
r86d0b4b3 r68ed0fb 36 36 #include <sys/types.h> 37 37 38 #define MFS_MAX_BLOCK_SIZE 4096 39 #define MFS_MIN_BLOCK_SIZE 1024 38 #define MFS_BLOCKSIZE 1024 39 40 /*The following block sizes are valid only on V3 filesystem*/ 41 #define MFS_MIN_BLOCKSIZE 1024 42 #define MFS_MAX_BLOCKSIZE 4096 40 43 41 44 #define MFS_ROOT_INO 1 42 #define MFS_SUPER _BLOCK 043 #define MFS_SUPER _BLOCK_SIZE 102445 #define MFS_SUPERBLOCK 1 46 #define MFS_SUPERBLOCK_SIZE 1024 44 47 45 48 #define V2_NR_DIRECT_ZONES 7 … … 48 51 #define V1_NR_DIRECT_ZONES 7 49 52 #define V1_NR_INDIRECT_ZONES 2 53 54 #define V1_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs_inode)) 55 #define V2_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs2_inode)) 56 #define V3_INODES_PER_BLOCK(bs) ((bs) / sizeof(struct mfs2_inode)) 50 57 51 58 #define MFS_MAX_NAME_LEN 14 … … 126 133 127 134 /*MinixFS V1 inode structure as it is on disk*/ 128 struct mfs_ v1_inode {135 struct mfs_inode { 129 136 uint16_t i_mode; 130 137 int16_t i_uid; … … 139 146 } __attribute__ ((packed)); 140 147 141 /*MinixFS V2 inode structure as it is on disk .*/142 struct mfs _v2_inode {148 /*MinixFS V2 inode structure as it is on disk (also valid for V3).*/ 149 struct mfs2_inode { 143 150 uint16_t i_mode; 144 151 uint16_t i_nlinks; -
uspace/srv/fs/minixfs/mfs_super.c
r86d0b4b3 r68ed0fb 68 68 69 69 /* initialize libblock */ 70 rc = block_init(devmap_handle, MFS_SUPER _BLOCK_SIZE);70 rc = block_init(devmap_handle, MFS_SUPERBLOCK_SIZE); 71 71 if (rc != EOK) { 72 72 async_answer_0(rid, rc); … … 75 75 76 76 /* prepare the superblock */ 77 rc = block_bb_read(devmap_handle, MFS_SUPER _BLOCK);77 rc = block_bb_read(devmap_handle, MFS_SUPERBLOCK); 78 78 if (rc != EOK) { 79 79 block_fini(devmap_handle);
Note:
See TracChangeset
for help on using the changeset viewer.