Changeset 9c96634 in mainline for uspace/srv/fs/cdfs/cdfs_ops.c
- Timestamp:
- 2017-05-15T18:29:10Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fec333b3
- Parents:
- 8d2dd7f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/cdfs/cdfs_ops.c
r8d2dd7f2 r9c96634 208 208 service_id_t service_id; /**< Service ID of block device */ 209 209 cdfs_enc_t enc; /**< Filesystem string encoding */ 210 char *vol_ident; /**< Volume identifier */ 210 211 } cdfs_t; 211 212 … … 483 484 * @param data File name buffer 484 485 * @param dsize Fine name buffer size 486 * @param enc Encoding 485 487 * @param dtype Directory entry type 486 488 * @return Decoded file name (allocated string) … … 515 517 516 518 return name; 519 } 520 521 /** Decode volume identifier. 522 * 523 * @param data Volume identifier buffer 524 * @param dsize Volume identifier buffer size 525 * @param enc Encoding 526 * @return Decoded volume identifier (allocated string) 527 */ 528 static char *cdfs_decode_vol_ident(void *data, size_t dsize, cdfs_enc_t enc) 529 { 530 char *ident; 531 size_t i; 532 533 ident = cdfs_decode_str(data, dsize, enc); 534 if (ident == NULL) 535 return NULL; 536 537 /* Trim trailing spaces */ 538 i = str_size(ident); 539 while (i > 0 && ident[i - 1] == ' ') 540 --i; 541 ident[i] = '\0'; 542 543 return ident; 517 544 } 518 545 … … 841 868 * @param rlba Place to store LBA of root dir 842 869 * @param rsize Place to store size of root dir 870 * @param vol_ident Place to store pointer to volume identifier 843 871 * @return EOK if found, ENOENT if not 844 872 */ 845 873 static int cdfs_find_joliet_svd(service_id_t sid, cdfs_lba_t altroot, 846 uint32_t *rlba, uint32_t *rsize )874 uint32_t *rlba, uint32_t *rsize, char **vol_ident) 847 875 { 848 876 cdfs_lba_t bi; … … 899 927 *rlba = uint32_lb(vol_desc->data.prisec.root_dir.lba); 900 928 *rsize = uint32_lb(vol_desc->data.prisec.root_dir.size); 929 930 *vol_ident = cdfs_decode_vol_ident(vol_desc->data.prisec.ident, 931 32, enc_ucs2); 932 901 933 block_put(block); 902 934 return EOK; … … 908 940 /** Read the volume descriptors. */ 909 941 static bool iso_read_vol_desc(service_id_t sid, cdfs_lba_t altroot, 910 uint32_t *rlba, uint32_t *rsize, cdfs_enc_t *enc )942 uint32_t *rlba, uint32_t *rsize, cdfs_enc_t *enc, char **vol_ident) 911 943 { 912 944 /* First 16 blocks of isofs are empty */ … … 962 994 uint32_t jrsize; 963 995 964 rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize );996 rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize, vol_ident); 965 997 if (rc == EOK) { 966 998 /* Found */ … … 972 1004 *rsize = uint32_lb(vol_desc->data.prisec.root_dir.size); 973 1005 *enc = enc_ascii; 1006 *vol_ident = cdfs_decode_vol_ident(vol_desc->data.prisec.ident, 1007 32, enc_ascii); 974 1008 } 975 1009 … … 986 1020 987 1021 rc = iso_read_vol_desc(fs->service_id, altroot, &node->lba, 988 &node->size, &fs->enc );1022 &node->size, &fs->enc, &fs->vol_ident); 989 1023 if (rc != EOK) 990 1024 return false; … … 1032 1066 static int cdfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1033 1067 { 1068 char *vol_ident; 1069 1034 1070 /* Initialize the block layer */ 1035 1071 int rc = block_init(service_id, BLOCK_SIZE); … … 1070 1106 uint32_t rsize; 1071 1107 cdfs_enc_t enc; 1072 if (!iso_read_vol_desc(service_id, altroot, &rlba, &rsize, &enc)) { 1108 if (!iso_read_vol_desc(service_id, altroot, &rlba, &rsize, &enc, 1109 &vol_ident)) { 1073 1110 block_cache_fini(service_id); 1074 1111 block_fini(service_id); 1075 1112 return EIO; 1076 1113 } 1114 1115 str_cpy(info->label, FS_LABEL_MAXLEN + 1, vol_ident); 1116 free(vol_ident); 1077 1117 1078 1118 return EOK; … … 1160 1200 block_cache_fini(fs->service_id); 1161 1201 block_fini(fs->service_id); 1202 free(fs->vol_ident); 1162 1203 free(fs); 1163 1204 }
Note:
See TracChangeset
for help on using the changeset viewer.