Changeset 6ba36a0 in mainline
- Timestamp:
- 2018-10-03T15:31:58Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9b0ceb1
- Parents:
- b209135
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkext4/mkext4.c
rb209135 r6ba36a0 52 52 char *dev_path; 53 53 service_id_t service_id; 54 ext4_cfg_ ver_t ver;54 ext4_cfg_t cfg; 55 55 char *endptr; 56 56 aoff64_t nblocks; 57 c har *label;57 const char *label = ""; 58 58 59 ver= ext4_def_fs_version;59 cfg.version = ext4_def_fs_version; 60 60 61 61 if (argc < 2) { … … 98 98 } 99 99 100 rc = ext4_version_parse(*argv, & ver);100 rc = ext4_version_parse(*argv, &cfg.version); 101 101 if (rc != EOK) { 102 102 printf(NAME ": Error, invalid argument.\n"); … … 146 146 } 147 147 148 (void)label;148 cfg.volume_name = label; 149 149 (void) nblocks; 150 150 151 rc = ext4_filesystem_create( ver, service_id);151 rc = ext4_filesystem_create(&cfg, service_id); 152 152 if (rc != EOK) { 153 153 printf(NAME ": Error initializing file system.\n"); -
uspace/lib/ext4/include/ext4/cfg.h
rb209135 r6ba36a0 34 34 #define LIBEXT4_CFG_H_ 35 35 36 #include "types.h" 37 36 38 /** Versions available to choose from when creating a new file system. */ 37 39 typedef enum { … … 45 47 #define ext4_def_fs_version extver_ext2 46 48 49 /** Configuration of a new ext4 file system */ 50 typedef struct { 51 /** File system version */ 52 ext4_cfg_ver_t version; 53 /** Volume name encoded as UTF-8 string */ 54 const char *volume_name; 55 } ext4_cfg_t; 56 47 57 #endif 48 58 -
uspace/lib/ext4/include/ext4/filesystem.h
rb209135 r6ba36a0 42 42 43 43 extern errno_t ext4_filesystem_probe(service_id_t, ext4_fs_probe_info_t *); 44 extern errno_t ext4_filesystem_create(ext4_cfg_ ver_t, service_id_t);44 extern errno_t ext4_filesystem_create(ext4_cfg_t *, service_id_t); 45 45 extern errno_t ext4_filesystem_open(ext4_instance_t *, service_id_t, 46 46 enum cache_mode, aoff64_t *, ext4_filesystem_t **); -
uspace/lib/ext4/include/ext4/superblock.h
rb209135 r6ba36a0 120 120 extern errno_t ext4_superblock_get_volume_name(ext4_superblock_t *, char *, 121 121 size_t); 122 extern voidext4_superblock_set_volume_name(ext4_superblock_t *, const char *);122 extern errno_t ext4_superblock_set_volume_name(ext4_superblock_t *, const char *); 123 123 extern const char *ext4_superblock_get_last_mounted(ext4_superblock_t *); 124 124 extern void ext4_superblock_set_last_mounted(ext4_superblock_t *, const char *); … … 166 166 extern uint32_t ext4_superblock_get_inodes_in_group(ext4_superblock_t *, 167 167 uint32_t); 168 extern errno_t ext4_superblock_create(size_t, uint64_t, ext4_cfg_ ver_t,168 extern errno_t ext4_superblock_create(size_t, uint64_t, ext4_cfg_t *, 169 169 ext4_superblock_t **); 170 170 extern uint32_t ext4_superblock_get_group_backup_blocks(ext4_superblock_t *, -
uspace/lib/ext4/include/ext4/types.h
rb209135 r6ba36a0 235 235 } ext4_filesystem_t; 236 236 237 /** Size of buffer for volume name. To hold 16 latin-1 chars encoded as UTF-8 238 * and a null terminator we need 2 * 16 + 1 bytes 239 */ 240 #define EXT4_VOL_NAME_BYTES 33 241 237 242 typedef struct { 238 /** Volume name, to hold 16 latin-1 chars in UTF-8 and null terminator 239 * we need 2 * 16 + 1 bytes 240 */ 241 char vol_name[33]; 243 char vol_name[EXT4_VOL_NAME_BYTES]; 242 244 } ext4_fs_probe_info_t; 243 245 -
uspace/lib/ext4/src/filesystem.c
rb209135 r6ba36a0 249 249 /** Create new filesystem. 250 250 * 251 * @param ver Filesystem version252 * @param service_id Block device where to create new file system253 */ 254 errno_t ext4_filesystem_create(ext4_cfg_ ver_t ver, service_id_t service_id)251 * @param cfg Configuration of new file system 252 * @param service_id Block device where to create new file system 253 */ 254 errno_t ext4_filesystem_create(ext4_cfg_t *cfg, service_id_t service_id) 255 255 { 256 256 errno_t rc; … … 282 282 283 283 /* Create superblock */ 284 rc = ext4_superblock_create(dev_bsize, dev_nblocks, ver, &superblock);284 rc = ext4_superblock_create(dev_bsize, dev_nblocks, cfg, &superblock); 285 285 if (rc != EOK) 286 286 goto err; -
uspace/lib/ext4/src/superblock.c
rb209135 r6ba36a0 912 912 * @param sb Superblock 913 913 * @param name New name of the volume 914 */ 915 void ext4_superblock_set_volume_name(ext4_superblock_t *sb, const char *name) 916 { 917 memcpy(sb->volume_name, name, sizeof(sb->volume_name)); 914 * @return EOK on success or error code 915 */ 916 errno_t ext4_superblock_set_volume_name(ext4_superblock_t *sb, const char *name) 917 { 918 size_t off; 919 wchar_t ch; 920 size_t wi; 921 922 off = 0; 923 wi = 0; 924 while (wi < sizeof(sb->volume_name)) { 925 ch = str_decode(name, &off, STR_NO_LIMIT); 926 if (ch == 0) 927 break; 928 if (ch > 255) 929 return EINVAL; 930 931 sb->volume_name[wi++] = ch; 932 } 933 934 while (wi < sizeof(sb->volume_name)) 935 sb->volume_name[wi++] = '\0'; 936 937 return EOK; 918 938 } 919 939 … … 1475 1495 * @param dev_bsize Device block size 1476 1496 * @param dev_bcnt Device number of blocks 1477 * @param ver Filesystem version1497 * @param cfg Configuration of new file system 1478 1498 * @param rsb Place to store pointer to newly allocated superblock 1479 1499 * @return EOK on success or error code 1480 1500 */ 1481 1501 errno_t ext4_superblock_create(size_t dev_bsize, uint64_t dev_bcnt, 1482 ext4_cfg_ ver_t ver, ext4_superblock_t **rsb)1502 ext4_cfg_t *cfg, ext4_superblock_t **rsb) 1483 1503 { 1484 1504 ext4_superblock_t *sb; … … 1579 1599 ext4_superblock_set_check_interval(sb, 0); 1580 1600 ext4_superblock_set_creator_os(sb, EXT4_SUPERBLOCK_OS_LINUX); 1581 if ( ver>= extver_ext2)1601 if (cfg->version >= extver_ext2) 1582 1602 ext4_superblock_set_rev_level(sb, EXT4_DYNAMIC_REV); 1583 1603 else … … 1586 1606 ext4_superblock_set_def_resgid(sb, 0); 1587 1607 1588 if ( ver>= extver_ext2) {1608 if (cfg->version >= extver_ext2) { 1589 1609 /* Dynamic rev */ 1590 1610 ext4_superblock_set_first_inode(sb, EXT4_REV0_FIRST_INO); … … 1596 1616 1597 1617 ext4_superblock_set_uuid(sb, &uuid); 1598 /* 16-byte Latin-1 string padded with null characters */ 1599 ext4_superblock_set_volume_name(sb, "HelenOS-Ext4\0\0\0\0"); 1618 1619 rc = ext4_superblock_set_volume_name(sb, cfg->volume_name); 1620 if (rc != EOK) 1621 goto error; 1622 1600 1623 /* 64-byte Latin-1 string padded with null characters */ 1601 1624 ext4_superblock_set_last_mounted(sb, -
uspace/srv/volsrv/mkfs.c
rb209135 r6ba36a0 148 148 switch (fstype) { 149 149 case fs_exfat: 150 case fs_ext4: 150 151 case fs_fat: 151 152 vlsupp->supported = true; 152 153 break; 153 154 case fs_minix: 154 case fs_ext4:155 155 case fs_cdfs: 156 156 break;
Note:
See TracChangeset
for help on using the changeset viewer.