Changeset 19a057f9 in mainline
- Timestamp:
- 2011-03-05T11:03:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 939b7d2
- Parents:
- 55c51c28
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r55c51c28 r19a057f9 59 59 } help_level_t; 60 60 61 typedef struct mfs_params { 62 mfs_version_t fs_version; 63 uint32_t block_size; 64 size_t devblock_size; 65 unsigned long n_inodes; 66 aoff64_t dev_nblocks; 67 bool fs_longnames; 68 } mfs_params_t; 69 61 70 static void help_cmd_mkminix(help_level_t level); 62 71 static int num_of_set_bits(uint32_t n); 63 static void prepare_superblock(struct mfs_superblock *sb );64 static void prepare_superblock_v3(struct mfs3_superblock *sb );72 static void prepare_superblock(struct mfs_superblock *sb, mfs_params_t *opt); 73 static void prepare_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt); 65 74 66 75 static struct option const long_options[] = { … … 75 84 }; 76 85 77 typedef struct mfs_params {78 mfs_version_t fs_version;79 uint32_t block_size;80 size_t devblock_size;81 unsigned long n_inodes;82 aoff64_t dev_nblocks;83 bool fs_longnames;84 } mfs_params_t;85 86 86 int main (int argc, char **argv) 87 87 { … … 90 90 devmap_handle_t handle; 91 91 92 struct mfs_superblock *s p;93 struct mfs3_superblock *s p3;92 struct mfs_superblock *sb; 93 struct mfs3_superblock *sb3; 94 94 95 95 mfs_params_t opt; … … 200 200 201 201 if (opt.fs_version == MFS_VERSION_V3) { 202 prepare_superblock_v3(sp3); 203 } else { 204 prepare_superblock(sp); 202 sb3 = (struct mfs3_superblock *) malloc(sizeof(struct mfs3_superblock)); 203 if (!sb3) { 204 printf(NAME ": Error, not enough memory"); 205 return 2; 206 } 207 prepare_superblock_v3(sb3, &opt); 208 } else { 209 sb = (struct mfs_superblock *) malloc(sizeof(struct mfs_superblock)); 210 if (!sb) { 211 printf(NAME ": Error, not enough memory"); 212 return 2; 213 } 214 prepare_superblock(sb, &opt); 205 215 } 206 216 … … 208 218 } 209 219 210 static void prepare_superblock(struct mfs_superblock *sp) 211 { 212 } 213 214 static void prepare_superblock_v3(struct mfs3_superblock *sp) 220 static void prepare_superblock(struct mfs_superblock *sb, mfs_params_t *opt) 221 { 222 switch (opt->fs_version) { 223 case MFS_VERSION_V1L: 224 sb->s_magic = MFS_MAGIC_V1L; 225 break; 226 case MFS_VERSION_V1: 227 sb->s_magic = MFS_MAGIC_V1; 228 break; 229 case MFS_VERSION_V2: 230 sb->s_magic = MFS_MAGIC_V2; 231 break; 232 case MFS_VERSION_V2L: 233 sb->s_magic = MFS_MAGIC_V2L; 234 break; 235 default: 236 break; 237 } 238 239 /*Valid only for MFS V1*/ 240 sb->s_nzones = opt->dev_nblocks > UINT16_MAX ? 241 UINT16_MAX : opt->dev_nblocks; 242 243 /*Valid only for MFS V2*/ 244 sb->s_nzones2 = opt->dev_nblocks > UINT32_MAX ? 245 UINT32_MAX : opt->dev_nblocks; 246 247 if (opt->n_inodes == 0) { 248 aoff64_t tmp = opt->dev_nblocks / 3; 249 sb->s_ninodes = tmp > UINT16_MAX ? UINT16_MAX : tmp; 250 } else { 251 sb->s_ninodes = opt->n_inodes; 252 } 253 254 sb->s_log2_zone_size = 0; 255 256 } 257 258 static void prepare_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt) 215 259 { 216 260 }
Note:
See TracChangeset
for help on using the changeset viewer.