Changeset 2175178 in mainline
- Timestamp:
- 2018-10-03T08:34:52Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b209135
- Parents:
- 174156fd
- git-author:
- Jiri Svoboda <jiri@…> (2018-10-02 21:31:25)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-10-03 08:34:52)
- Location:
- uspace
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkext4/mkext4.c
r174156fd r2175178 45 45 46 46 static void syntax_print(void); 47 static errno_t ext4_version_parse(const char *, ext4_cfg_ver_t *); 47 48 48 49 int main(int argc, char **argv) … … 51 52 char *dev_path; 52 53 service_id_t service_id; 54 ext4_cfg_ver_t ver; 53 55 char *endptr; 54 56 aoff64_t nblocks; 55 57 char *label; 58 59 ver = ext4_def_fs_version; 56 60 57 61 if (argc < 2) { … … 76 80 nblocks = strtol(*argv, &endptr, 10); 77 81 if (*endptr != '\0') { 82 printf(NAME ": Error, invalid argument.\n"); 83 syntax_print(); 84 return 1; 85 } 86 87 --argc; 88 ++argv; 89 } 90 91 if (str_cmp(*argv, "--type") == 0) { 92 --argc; 93 ++argv; 94 if (*argv == NULL) { 95 printf(NAME ": Error, argument missing.\n"); 96 syntax_print(); 97 return 1; 98 } 99 100 rc = ext4_version_parse(*argv, &ver); 101 if (rc != EOK) { 78 102 printf(NAME ": Error, invalid argument.\n"); 79 103 syntax_print(); … … 125 149 (void) nblocks; 126 150 127 rc = ext4_filesystem_create( service_id);151 rc = ext4_filesystem_create(ver, service_id); 128 152 if (rc != EOK) { 129 153 printf(NAME ": Error initializing file system.\n"); … … 141 165 printf("options:\n" 142 166 "\t--size <sectors> Filesystem size, overrides device size\n" 143 "\t--label <label> Volume label\n"); 167 "\t--label <label> Volume label\n" 168 "\t--type <fstype> Filesystem type (ext2, ext2old)\n"); 169 } 170 171 static errno_t ext4_version_parse(const char *str, ext4_cfg_ver_t *ver) 172 { 173 if (str_cmp(str, "ext2old") == 0) { 174 *ver = extver_ext2_old; 175 return EOK; 176 } 177 178 if (str_cmp(str, "ext2") == 0) { 179 *ver = extver_ext2; 180 return EOK; 181 } 182 183 return EINVAL; 144 184 } 145 185 -
uspace/lib/ext4/include/ext4/filesystem.h
r174156fd r2175178 37 37 38 38 #include <block.h> 39 #include "ext4/cfg.h" 39 40 #include "ext4/fstypes.h" 40 41 #include "ext4/types.h" 41 42 42 43 extern errno_t ext4_filesystem_probe(service_id_t); 43 extern errno_t ext4_filesystem_create( service_id_t);44 extern errno_t ext4_filesystem_create(ext4_cfg_ver_t, service_id_t); 44 45 extern errno_t ext4_filesystem_open(ext4_instance_t *, service_id_t, 45 46 enum cache_mode, aoff64_t *, ext4_filesystem_t **); -
uspace/lib/ext4/include/ext4/superblock.h
r174156fd r2175178 39 39 #include <stdint.h> 40 40 #include <uuid.h> 41 #include "ext4/cfg.h" 41 42 #include "ext4/types.h" 42 43 … … 164 165 extern uint32_t ext4_superblock_get_inodes_in_group(ext4_superblock_t *, 165 166 uint32_t); 166 extern errno_t ext4_superblock_create(size_t, uint64_t, ext4_superblock_t **); 167 extern errno_t ext4_superblock_create(size_t, uint64_t, ext4_cfg_ver_t, 168 ext4_superblock_t **); 167 169 extern uint32_t ext4_superblock_get_group_backup_blocks(ext4_superblock_t *, 168 170 uint32_t); -
uspace/lib/ext4/src/directory.c
r174156fd r2175178 369 369 370 370 /* Set type of entry */ 371 if (ext4_inode_is_type(sb, child->inode, EXT4_INODE_MODE_DIRECTORY)) 371 if (!ext4_superblock_has_feature_incompatible(sb, EXT4_FEATURE_INCOMPAT_FILETYPE)) 372 ext4_directory_entry_ll_set_inode_type(sb, entry, 373 EXT4_DIRECTORY_FILETYPE_UNKNOWN); 374 else if (ext4_inode_is_type(sb, child->inode, EXT4_INODE_MODE_DIRECTORY)) 372 375 ext4_directory_entry_ll_set_inode_type(sb, entry, 373 376 EXT4_DIRECTORY_FILETYPE_DIR); -
uspace/lib/ext4/src/filesystem.c
r174156fd r2175178 48 48 #include "ext4/bitmap.h" 49 49 #include "ext4/block_group.h" 50 #include "ext4/cfg.h" 50 51 #include "ext4/directory.h" 51 52 #include "ext4/extent.h" … … 248 249 /** Create new filesystem. 249 250 * 251 * @param ver Filesystem version 250 252 * @param service_id Block device where to create new filesystem 251 253 */ 252 errno_t ext4_filesystem_create( service_id_t service_id)254 errno_t ext4_filesystem_create(ext4_cfg_ver_t ver, service_id_t service_id) 253 255 { 254 256 errno_t rc; … … 280 282 281 283 /* Create superblock */ 282 rc = ext4_superblock_create(dev_bsize, dev_nblocks, &superblock);284 rc = ext4_superblock_create(dev_bsize, dev_nblocks, ver, &superblock); 283 285 if (rc != EOK) 284 286 goto err; -
uspace/lib/ext4/src/superblock.c
r174156fd r2175178 45 45 #include <stdlib.h> 46 46 #include <time.h> 47 #include "ext4/cfg.h" 47 48 #include "ext4/superblock.h" 48 49 … … 1454 1455 * @param dev_bsize Device block size 1455 1456 * @param dev_bcnt Device number of blocks 1457 * @param ver Filesystem version 1456 1458 * @param rsb Place to store pointer to newly allocated superblock 1457 1459 * @return EOK on success or error code 1458 1460 */ 1459 1461 errno_t ext4_superblock_create(size_t dev_bsize, uint64_t dev_bcnt, 1460 ext4_ superblock_t **rsb)1462 ext4_cfg_ver_t ver, ext4_superblock_t **rsb) 1461 1463 { 1462 1464 ext4_superblock_t *sb; … … 1557 1559 ext4_superblock_set_check_interval(sb, 0); 1558 1560 ext4_superblock_set_creator_os(sb, EXT4_SUPERBLOCK_OS_LINUX); 1559 ext4_superblock_set_rev_level(sb, EXT4_GOOD_OLD_REV); 1561 if (ver >= extver_ext2) 1562 ext4_superblock_set_rev_level(sb, EXT4_DYNAMIC_REV); 1563 else 1564 ext4_superblock_set_rev_level(sb, EXT4_GOOD_OLD_REV); 1560 1565 ext4_superblock_set_def_resuid(sb, 0); 1561 1566 ext4_superblock_set_def_resgid(sb, 0); 1567 1568 if (ver >= extver_ext2) { 1569 /* Dynamic rev */ 1570 ext4_superblock_set_first_inode(sb, EXT4_REV0_FIRST_INO); 1571 ext4_superblock_set_inode_size(sb, EXT4_REV0_INODE_SIZE); 1572 ext4_superblock_set_block_group_index(sb, 0); // XXX 1573 ext4_superblock_set_features_compatible(sb, 0); 1574 ext4_superblock_set_features_incompatible(sb, 0); 1575 ext4_superblock_set_features_read_only(sb, 0); 1576 1577 ext4_superblock_set_uuid(sb, &uuid); 1578 /* 16-byte Latin-1 string padded with null characters */ 1579 ext4_superblock_set_volume_name(sb, "HelenOS-Ext4\0\0\0\0"); 1580 /* 64-byte Latin-1 string padded with null characters */ 1581 ext4_superblock_set_last_mounted(sb, 1582 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 1583 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); 1584 sb->algorithm_usage_bitmap = 0; 1585 } 1562 1586 #if 0 1563 /* Dynamic rev */1564 ext4_superblock_set_first_inode(sb, EXT4_REV0_FIRST_INO);1565 ext4_superblock_set_inode_size(sb, EXT4_REV0_INODE_SIZE);1566 ext4_superblock_set_block_group_index(sb, 0); // XXX1567 ext4_superblock_set_features_compatible(sb, 0);1568 ext4_superblock_set_features_incompatible(sb, 0);1569 ext4_superblock_set_features_read_only(sb, 0);1570 1571 ext4_superblock_set_uuid(sb, &uuid);1572 /* 16-byte Latin-1 string padded with null characters */1573 ext4_superblock_set_volume_name(sb, "HelenOS-Ext4\0\0\0\0");1574 /* 64-byte Latin-1 string padded with null characters */1575 ext4_superblock_set_last_mounted(sb,1576 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"1577 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");1578 sb->algorithm_usage_bitmap = 0;1579 1580 1587 /* Journalling */ 1581 1588 ext4_superblock_set_desc_size(sb, EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE);
Note:
See TracChangeset
for help on using the changeset viewer.