Changeset a35b458 in mainline for uspace/srv/fs/cdfs/cdfs_ops.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/cdfs/cdfs_ops.c
r3061bc1 ra35b458 92 92 uint8_t mon[2]; 93 93 uint8_t day[2]; 94 94 95 95 uint8_t hour[2]; 96 96 uint8_t min[2]; 97 97 uint8_t sec[2]; 98 98 uint8_t msec[2]; 99 99 100 100 uint8_t offset; 101 101 } __attribute__((packed)) cdfs_datetime_t; … … 105 105 uint8_t mon; 106 106 uint8_t day; 107 107 108 108 uint8_t hour; 109 109 uint8_t min; 110 110 uint8_t sec; 111 111 112 112 uint8_t offset; 113 113 } __attribute__((packed)) cdfs_timestamp_t; … … 121 121 uint8_t length; 122 122 uint8_t ea_length; 123 123 124 124 uint32_t_lb lba; 125 125 uint32_t_lb size; 126 126 127 127 cdfs_timestamp_t timestamp; 128 128 uint8_t flags; … … 130 130 uint8_t gap_size; 131 131 uint16_t_lb sequence_nr; 132 132 133 133 uint8_t name_length; 134 134 uint8_t name[]; … … 139 139 uint8_t length; 140 140 uint8_t ea_length; 141 141 142 142 uint32_t_lb lba; 143 143 uint32_t_lb size; 144 144 145 145 cdfs_timestamp_t timestamp; 146 146 uint8_t flags; … … 148 148 uint8_t gap_size; 149 149 uint16_t_lb sequence_nr; 150 150 151 151 uint8_t name_length; 152 152 uint8_t name[1]; … … 155 155 typedef struct { 156 156 uint8_t flags; /* reserved in primary */ 157 157 158 158 uint8_t system_ident[32]; 159 159 uint8_t ident[32]; 160 160 161 161 uint64_t res1; 162 162 uint32_t_lb lba_size; 163 163 164 164 uint8_t esc_seq[32]; /* reserved in primary */ 165 165 uint16_t_lb set_size; 166 166 uint16_t_lb sequence_nr; 167 167 168 168 uint16_t_lb block_size; 169 169 uint32_t_lb path_table_size; 170 170 171 171 uint32_t path_table_lsb; 172 172 uint32_t opt_path_table_lsb; 173 173 uint32_t path_table_msb; 174 174 uint32_t opt_path_table_msb; 175 175 176 176 cdfs_root_dir_t root_dir; 177 177 uint8_t pad0; 178 178 179 179 uint8_t set_ident[128]; 180 180 uint8_t publisher_ident[128]; 181 181 uint8_t preparer_ident[128]; 182 182 uint8_t app_ident[128]; 183 183 184 184 uint8_t copyright_file_ident[37]; 185 185 uint8_t abstract_file_ident[37]; 186 186 uint8_t biblio_file_ident[37]; 187 187 188 188 cdfs_datetime_t creation; 189 189 cdfs_datetime_t modification; 190 190 cdfs_datetime_t expiration; 191 191 cdfs_datetime_t effective; 192 192 193 193 uint8_t fs_version; 194 194 } __attribute__((packed)) cdfs_vol_desc_prisec_t; … … 236 236 fs_index_t index; /**< Node index */ 237 237 cdfs_t *fs; /**< File system */ 238 238 239 239 ht_link_t nh_link; /**< Nodes hash table link */ 240 240 cdfs_dentry_type_t type; /**< Dentry type */ 241 241 242 242 unsigned int lnkcnt; /**< Link count */ 243 243 uint32_t size; /**< File size if type is CDFS_FILE */ 244 244 245 245 list_t cs_list; /**< Child's siblings list */ 246 246 cdfs_lba_t lba; /**< LBA of data on disk */ … … 301 301 cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link); 302 302 ht_key_t *key = (ht_key_t*)k; 303 303 304 304 return key->service_id == node->fs->service_id && key->index == node->index; 305 305 } … … 308 308 { 309 309 cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link); 310 310 311 311 if (node->type == CDFS_DIRECTORY) { 312 312 link_t *link; … … 317 317 } 318 318 } 319 319 320 320 free(node->fs_node); 321 321 free(node); … … 338 338 .service_id = service_id 339 339 }; 340 340 341 341 ht_link_t *link = hash_table_find(&nodes, &key); 342 342 if (link) { 343 343 cdfs_node_t *node = 344 344 hash_table_get_inst(link, cdfs_node_t, nh_link); 345 345 346 346 *rfn = FS_NODE(node); 347 347 } else 348 348 *rfn = NULL; 349 349 350 350 return EOK; 351 351 } … … 367 367 node->processed = false; 368 368 node->opened = 0; 369 369 370 370 list_initialize(&node->cs_list); 371 371 } … … 375 375 { 376 376 assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY)); 377 377 378 378 cdfs_node_t *node = malloc(sizeof(cdfs_node_t)); 379 379 if (!node) 380 380 return ENOMEM; 381 381 382 382 cdfs_node_initialize(node); 383 383 384 384 node->fs_node = malloc(sizeof(fs_node_t)); 385 385 if (!node->fs_node) { … … 387 387 return ENOMEM; 388 388 } 389 389 390 390 fs_node_initialize(node->fs_node); 391 391 node->fs_node->data = node; 392 392 393 393 fs_node_t *rootfn; 394 394 errno_t rc = cdfs_root_get(&rootfn, fs->service_id); 395 395 396 396 assert(rc == EOK); 397 397 398 398 if (!rootfn) 399 399 node->index = CDFS_SOME_ROOT; 400 400 else 401 401 node->index = index; 402 402 403 403 node->fs = fs; 404 404 405 405 if (lflag & L_DIRECTORY) 406 406 node->type = CDFS_DIRECTORY; 407 407 else 408 408 node->type = CDFS_FILE; 409 409 410 410 /* Insert the new node into the nodes hash table. */ 411 411 hash_table_insert(&nodes, &node->nh_link); 412 412 413 413 *rfn = FS_NODE(node); 414 414 nodes_cached++; 415 415 416 416 return EOK; 417 417 } … … 421 421 cdfs_node_t *parent = CDFS_NODE(pfn); 422 422 cdfs_node_t *node = CDFS_NODE(fn); 423 423 424 424 assert(parent->type == CDFS_DIRECTORY); 425 425 426 426 /* Check for duplicate entries */ 427 427 list_foreach(parent->cs_list, link, cdfs_dentry_t, dentry) { … … 429 429 return EEXIST; 430 430 } 431 431 432 432 /* Allocate and initialize the dentry */ 433 433 cdfs_dentry_t *dentry = malloc(sizeof(cdfs_dentry_t)); 434 434 if (!dentry) 435 435 return ENOMEM; 436 436 437 437 /* Populate and link the new dentry */ 438 438 dentry->name = str_dup(name); … … 441 441 return ENOMEM; 442 442 } 443 443 444 444 link_initialize(&dentry->link); 445 445 dentry->index = node->index; 446 446 447 447 node->lnkcnt++; 448 448 list_append(&dentry->link, &parent->cs_list); 449 449 450 450 return EOK; 451 451 } … … 463 463 char *str; 464 464 uint16_t *buf; 465 465 466 466 switch (enc) { 467 467 case enc_ascii: … … 476 476 if (buf == NULL) 477 477 return NULL; 478 478 479 479 size_t i; 480 480 for (i = 0; i < dsize / sizeof(uint16_t); i++) { … … 482 482 ((unaligned_uint16_t *)data)[i]); 483 483 } 484 484 485 485 size_t dstr_size = dsize / sizeof(uint16_t) * 4 + 1; 486 486 str = malloc(dstr_size); 487 487 if (str == NULL) 488 488 return NULL; 489 489 490 490 rc = utf16_to_str(str, dstr_size, buf); 491 491 free(buf); 492 492 493 493 if (rc != EOK) 494 494 return NULL; … … 498 498 str = NULL; 499 499 } 500 500 501 501 return str; 502 502 } … … 516 516 char *dot; 517 517 char *scolon; 518 518 519 519 name = cdfs_decode_str(data, dsize, enc); 520 520 if (name == NULL) 521 521 return NULL; 522 522 523 523 if (dtype == CDFS_DIRECTORY) 524 524 return name; 525 525 526 526 dot = str_chr(name, '.'); 527 527 528 528 if (dot != NULL) { 529 529 scolon = str_chr(dot, ';'); … … 532 532 *scolon = '\0'; 533 533 } 534 534 535 535 /* If the extension is an empty string, trim the dot separator. */ 536 536 if (dot[1] == '\0') 537 537 *dot = '\0'; 538 538 } 539 539 540 540 return name; 541 541 } … … 552 552 char *ident; 553 553 size_t i; 554 554 555 555 ident = cdfs_decode_str(data, dsize, enc); 556 556 if (ident == NULL) 557 557 return NULL; 558 558 559 559 /* Trim trailing spaces */ 560 560 i = str_size(ident); … … 562 562 --i; 563 563 ident[i] = '\0'; 564 564 565 565 return ident; 566 566 } … … 570 570 cdfs_node_t *node = CDFS_NODE(fs_node); 571 571 assert(node); 572 572 573 573 if (node->processed) 574 574 return EOK; 575 575 576 576 uint32_t blocks = node->size / BLOCK_SIZE; 577 577 if ((node->size % BLOCK_SIZE) != 0) 578 578 blocks++; 579 579 580 580 for (uint32_t i = 0; i < blocks; i++) { 581 581 block_t *block; … … 583 583 if (rc != EOK) 584 584 return rc; 585 585 586 586 cdfs_dir_t *dir; 587 587 588 588 for (size_t offset = 0; offset < BLOCK_SIZE; 589 589 offset += dir->length) { … … 595 595 break; 596 596 } 597 597 598 598 cdfs_dentry_type_t dentry_type; 599 599 if (dir->flags & DIR_FLAG_DIRECTORY) … … 601 601 else 602 602 dentry_type = CDFS_FILE; 603 603 604 604 /* Skip special entries */ 605 605 606 606 if (dir->name_length == 1 && 607 607 dir->name[0] == CDFS_NAME_CURDIR) … … 610 610 dir->name[0] == CDFS_NAME_PARENTDIR) 611 611 continue; 612 612 613 613 // FIXME: hack - indexing by dentry byte offset on disc 614 614 615 615 fs_node_t *fn; 616 616 errno_t rc = create_node(&fn, fs, dentry_type, … … 620 620 621 621 assert(fn != NULL); 622 622 623 623 cdfs_node_t *cur = CDFS_NODE(fn); 624 624 cur->lba = uint32_lb(dir->lba); 625 625 cur->size = uint32_lb(dir->size); 626 626 627 627 char *name = cdfs_decode_name(dir->name, 628 628 dir->name_length, node->fs->enc, dentry_type); 629 629 if (name == NULL) 630 630 return EIO; 631 631 632 632 // FIXME: check return value 633 633 634 634 link_node(fs_node, fn, name); 635 635 free(name); 636 636 637 637 if (dentry_type == CDFS_FILE) 638 638 cur->processed = true; 639 639 } 640 640 641 641 block_put(block); 642 642 } 643 643 644 644 node->processed = true; 645 645 return EOK; … … 650 650 cdfs_lba_t lba = index / BLOCK_SIZE; 651 651 size_t offset = index % BLOCK_SIZE; 652 652 653 653 block_t *block; 654 654 errno_t rc = block_get(&block, fs->service_id, lba, BLOCK_FLAGS_NONE); 655 655 if (rc != EOK) 656 656 return NULL; 657 657 658 658 cdfs_dir_t *dir = (cdfs_dir_t *) (block->data + offset); 659 659 660 660 cdfs_dentry_type_t dentry_type; 661 661 if (dir->flags & DIR_FLAG_DIRECTORY) … … 663 663 else 664 664 dentry_type = CDFS_FILE; 665 665 666 666 fs_node_t *fn; 667 667 rc = create_node(&fn, fs, dentry_type, index); 668 668 if ((rc != EOK) || (fn == NULL)) 669 669 return NULL; 670 670 671 671 cdfs_node_t *node = CDFS_NODE(fn); 672 672 node->lba = uint32_lb(dir->lba); 673 673 node->size = uint32_lb(dir->size); 674 674 node->lnkcnt = 1; 675 675 676 676 if (dentry_type == CDFS_FILE) 677 677 node->processed = true; 678 678 679 679 block_put(block); 680 680 return fn; … … 687 687 .service_id = fs->service_id 688 688 }; 689 689 690 690 ht_link_t *link = hash_table_find(&nodes, &key); 691 691 if (link) { … … 694 694 return FS_NODE(node); 695 695 } 696 696 697 697 return get_uncached_node(fs, index); 698 698 } … … 701 701 { 702 702 cdfs_node_t *parent = CDFS_NODE(pfn); 703 703 704 704 if (!parent->processed) { 705 705 errno_t rc = cdfs_readdir(parent->fs, pfn); … … 707 707 return rc; 708 708 } 709 709 710 710 list_foreach(parent->cs_list, link, cdfs_dentry_t, dentry) { 711 711 if (str_cmp(dentry->name, component) == 0) { … … 714 714 } 715 715 } 716 716 717 717 *fn = NULL; 718 718 return EOK; … … 722 722 { 723 723 cdfs_node_t *node = CDFS_NODE(fn); 724 724 725 725 if (!node->processed) 726 726 cdfs_readdir(node->fs, fn); 727 727 728 728 node->opened++; 729 729 return EOK; … … 763 763 { 764 764 cdfs_node_t *node = CDFS_NODE(fn); 765 765 766 766 if ((node->type == CDFS_DIRECTORY) && (!node->processed)) 767 767 cdfs_readdir(node->fs, fn); 768 768 769 769 *has_children = !list_empty(&node->cs_list); 770 770 return EOK; … … 809 809 { 810 810 *size = BLOCK_SIZE; 811 811 812 812 return EOK; 813 813 } … … 816 816 { 817 817 *count = 0; 818 818 819 819 return EOK; 820 820 } … … 823 823 { 824 824 *count = 0; 825 825 826 826 return EOK; 827 827 } … … 855 855 size_t i, j, k; 856 856 bool match; 857 857 858 858 i = 0; 859 859 while (i + ucs2_esc_seq_len <= 32) { 860 860 if (seq[i] == 0) 861 861 break; 862 862 863 863 for (j = 0; j < ucs2_esc_seq_no; j++) { 864 864 match = true; … … 870 870 } 871 871 } 872 872 873 873 if (!match) 874 874 return EINVAL; 875 875 876 876 i += ucs2_esc_seq_len; 877 877 } 878 878 879 879 while (i < 32) { 880 880 if (seq[i] != 0) … … 882 882 ++i; 883 883 } 884 884 885 885 return EOK; 886 886 } … … 905 905 if (rc != EOK) 906 906 break; 907 907 908 908 cdfs_vol_desc_t *vol_desc = (cdfs_vol_desc_t *) block->data; 909 909 910 910 if (vol_desc->type == VOL_DESC_SET_TERMINATOR) { 911 911 block_put(block); 912 912 break; 913 913 } 914 914 915 915 if ((vol_desc->type != VOL_DESC_SUPPLEMENTARY) || 916 916 (memcmp(vol_desc->standard_ident, CDFS_STANDARD_IDENT, 5) != 0) || … … 919 919 continue; 920 920 } 921 921 922 922 uint16_t set_size = uint16_lb(vol_desc->data.prisec.set_size); 923 923 if (set_size > 1) { … … 929 929 */ 930 930 } 931 931 932 932 uint16_t sequence_nr = uint16_lb(vol_desc->data.prisec.sequence_nr); 933 933 if (sequence_nr != 1) { … … 939 939 continue; 940 940 } 941 941 942 942 uint16_t block_size = uint16_lb(vol_desc->data.prisec.block_size); 943 943 if (block_size != BLOCK_SIZE) { … … 945 945 continue; 946 946 } 947 947 948 948 rc = cdfs_verify_joliet_esc_seq(vol_desc->data.prisec.esc_seq); 949 949 if (rc != EOK) … … 958 958 return EOK; 959 959 } 960 960 961 961 return ENOENT; 962 962 } … … 971 971 if (rc != EOK) 972 972 return rc; 973 973 974 974 cdfs_vol_desc_t *vol_desc = (cdfs_vol_desc_t *) block->data; 975 975 976 976 /* 977 977 * Test for primary volume descriptor … … 984 984 return ENOTSUP; 985 985 } 986 986 987 987 uint16_t set_size = uint16_lb(vol_desc->data.prisec.set_size); 988 988 if (set_size > 1) { … … 994 994 */ 995 995 } 996 996 997 997 uint16_t sequence_nr = uint16_lb(vol_desc->data.prisec.sequence_nr); 998 998 if (sequence_nr != 1) { … … 1004 1004 return ENOTSUP; 1005 1005 } 1006 1006 1007 1007 uint16_t block_size = uint16_lb(vol_desc->data.prisec.block_size); 1008 1008 if (block_size != BLOCK_SIZE) { … … 1010 1010 return ENOTSUP; 1011 1011 } 1012 1012 1013 1013 // TODO: implement path table support 1014 1014 1015 1015 /* Search for Joliet SVD */ 1016 1016 1017 1017 uint32_t jrlba; 1018 1018 uint32_t jrsize; 1019 1019 1020 1020 rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize, vol_ident); 1021 1021 if (rc == EOK) { … … 1031 1031 32, enc_ascii); 1032 1032 } 1033 1033 1034 1034 block_put(block); 1035 1035 return EOK; … … 1040 1040 { 1041 1041 cdfs_node_t *node = CDFS_NODE(rfn); 1042 1042 1043 1043 errno_t rc = iso_read_vol_desc(fs->service_id, altroot, &node->lba, 1044 1044 &node->size, &fs->enc, &fs->vol_ident); 1045 1045 if (rc != EOK) 1046 1046 return rc; 1047 1047 1048 1048 return cdfs_readdir(fs, rfn); 1049 1049 } … … 1060 1060 if (fs == NULL) 1061 1061 goto error; 1062 1062 1063 1063 fs->service_id = sid; 1064 1064 1065 1065 /* Create root node */ 1066 1066 errno_t rc = create_node(&rfn, fs, L_DIRECTORY, cdfs_index++); 1067 1067 1068 1068 if ((rc != EOK) || (!rfn)) 1069 1069 goto error; 1070 1070 1071 1071 /* FS root is not linked */ 1072 1072 CDFS_NODE(rfn)->lnkcnt = 0; 1073 1073 CDFS_NODE(rfn)->lba = 0; 1074 1074 CDFS_NODE(rfn)->processed = false; 1075 1075 1076 1076 /* Check if there is cdfs in given session */ 1077 1077 if (iso_readfs(fs, rfn, altroot) != EOK) 1078 1078 goto error; 1079 1079 1080 1080 list_append(&fs->link, &cdfs_instances); 1081 1081 return fs; … … 1094 1094 if (rc != EOK) 1095 1095 return rc; 1096 1096 1097 1097 cdfs_lba_t altroot = 0; 1098 1098 1099 1099 /* 1100 1100 * Read TOC multisession information and get the start address … … 1106 1106 if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10)) 1107 1107 altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr); 1108 1108 1109 1109 /* Initialize the block cache */ 1110 1110 rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT); … … 1113 1113 return rc; 1114 1114 } 1115 1115 1116 1116 /* Check if this device is not already mounted */ 1117 1117 fs_node_t *rootfn; … … 1123 1123 return EOK; 1124 1124 } 1125 1125 1126 1126 /* Read volume descriptors */ 1127 1127 uint32_t rlba; … … 1135 1135 return rc; 1136 1136 } 1137 1137 1138 1138 str_cpy(info->label, FS_LABEL_MAXLEN + 1, vol_ident); 1139 1139 free(vol_ident); 1140 1140 1141 1141 block_cache_fini(service_id); 1142 1142 block_fini(service_id); … … 1151 1151 if (rc != EOK) 1152 1152 return rc; 1153 1153 1154 1154 cdfs_lba_t altroot = 0; 1155 1155 1156 1156 if (str_lcmp(opts, "altroot=", 8) == 0) { 1157 1157 /* User-defined alternative root on a multi-session disk */ … … 1169 1169 altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr); 1170 1170 } 1171 1171 1172 1172 /* Initialize the block cache */ 1173 1173 rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT); … … 1176 1176 return rc; 1177 1177 } 1178 1178 1179 1179 /* Check if this device is not already mounted */ 1180 1180 fs_node_t *rootfn; … … 1184 1184 block_cache_fini(service_id); 1185 1185 block_fini(service_id); 1186 1186 1187 1187 return EEXIST; 1188 1188 } 1189 1189 1190 1190 /* Create cdfs instance */ 1191 1191 if (cdfs_fs_create(service_id, altroot) == NULL) { 1192 1192 block_cache_fini(service_id); 1193 1193 block_fini(service_id); 1194 1194 1195 1195 return ENOMEM; 1196 1196 } 1197 1197 1198 1198 rc = cdfs_root_get(&rootfn, service_id); 1199 1199 assert(rc == EOK); 1200 1200 1201 1201 cdfs_node_t *root = CDFS_NODE(rootfn); 1202 1202 *index = root->index; 1203 1203 *size = root->size; 1204 1204 1205 1205 return EOK; 1206 1206 } … … 1210 1210 service_id_t service_id = *(service_id_t*)arg; 1211 1211 cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link); 1212 1212 1213 1213 if (node->fs->service_id == service_id) { 1214 1214 hash_table_remove_item(&nodes, &node->nh_link); 1215 1215 } 1216 1216 1217 1217 return true; 1218 1218 } … … 1234 1234 return fs; 1235 1235 } 1236 1236 1237 1237 return NULL; 1238 1238 } … … 1245 1245 if (fs == NULL) 1246 1246 return ENOENT; 1247 1247 1248 1248 cdfs_fs_destroy(fs); 1249 1249 return EOK; … … 1257 1257 .service_id = service_id 1258 1258 }; 1259 1259 1260 1260 ht_link_t *link = hash_table_find(&nodes, &key); 1261 1261 if (link == NULL) 1262 1262 return ENOENT; 1263 1263 1264 1264 cdfs_node_t *node = 1265 1265 hash_table_get_inst(link, cdfs_node_t, nh_link); 1266 1266 1267 1267 if (!node->processed) { 1268 1268 errno_t rc = cdfs_readdir(node->fs, FS_NODE(node)); … … 1270 1270 return rc; 1271 1271 } 1272 1272 1273 1273 ipc_callid_t callid; 1274 1274 size_t len; … … 1277 1277 return EINVAL; 1278 1278 } 1279 1279 1280 1280 if (node->type == CDFS_FILE) { 1281 1281 if (pos >= node->size) { … … 1285 1285 cdfs_lba_t lba = pos / BLOCK_SIZE; 1286 1286 size_t offset = pos % BLOCK_SIZE; 1287 1287 1288 1288 *rbytes = min(len, BLOCK_SIZE - offset); 1289 1289 *rbytes = min(*rbytes, node->size - pos); 1290 1290 1291 1291 block_t *block; 1292 1292 errno_t rc = block_get(&block, service_id, node->lba + lba, … … 1296 1296 return rc; 1297 1297 } 1298 1298 1299 1299 async_data_read_finalize(callid, block->data + offset, 1300 1300 *rbytes); … … 1309 1309 return ENOENT; 1310 1310 } 1311 1311 1312 1312 cdfs_dentry_t *dentry = 1313 1313 list_get_instance(link, cdfs_dentry_t, link); 1314 1314 1315 1315 *rbytes = 1; 1316 1316 async_data_read_finalize(callid, dentry->name, 1317 1317 str_size(dentry->name) + 1); 1318 1318 } 1319 1319 1320 1320 return EOK; 1321 1321 } … … 1328 1328 * the operation is not supported. 1329 1329 */ 1330 1330 1331 1331 return ENOTSUP; 1332 1332 } … … 1339 1339 * the operation is not supported. 1340 1340 */ 1341 1341 1342 1342 return ENOTSUP; 1343 1343 } … … 1346 1346 { 1347 1347 size_t *premove_cnt = (size_t*)arg; 1348 1348 1349 1349 /* Some nodes were requested to be removed from the cache. */ 1350 1350 if (0 < *premove_cnt) { … … 1353 1353 if (!node->opened) { 1354 1354 hash_table_remove_item(&nodes, item); 1355 1355 1356 1356 --nodes_cached; 1357 1357 --*premove_cnt; 1358 1358 } 1359 1359 } 1360 1360 1361 1361 /* Only continue if more nodes were requested to be removed. */ 1362 1362 return 0 < *premove_cnt; … … 1367 1367 if (nodes_cached > NODE_CACHE_SIZE) { 1368 1368 size_t remove_cnt = nodes_cached - NODE_CACHE_SIZE; 1369 1369 1370 1370 if (0 < remove_cnt) 1371 1371 hash_table_apply(&nodes, cache_remove_closed, &remove_cnt); … … 1378 1378 if (index == 0) 1379 1379 return EOK; 1380 1380 1381 1381 ht_key_t key = { 1382 1382 .index = index, 1383 1383 .service_id = service_id 1384 1384 }; 1385 1385 1386 1386 ht_link_t *link = hash_table_find(&nodes, &key); 1387 1387 if (link == 0) 1388 1388 return ENOENT; 1389 1389 1390 1390 cdfs_node_t *node = 1391 1391 hash_table_get_inst(link, cdfs_node_t, nh_link); 1392 1392 1393 1393 assert(node->opened > 0); 1394 1394 1395 1395 node->opened--; 1396 1396 cleanup_cache(service_id); 1397 1397 1398 1398 return EOK; 1399 1399 } … … 1405 1405 * the operation is not supported. 1406 1406 */ 1407 1407 1408 1408 return ENOTSUP; 1409 1409 } … … 1415 1415 * the sync operation is a no-op. 1416 1416 */ 1417 1417 1418 1418 return EOK; 1419 1419 } … … 1438 1438 if (!hash_table_create(&nodes, 0, 0, &nodes_ops)) 1439 1439 return false; 1440 1440 1441 1441 return true; 1442 1442 }
Note:
See TracChangeset
for help on using the changeset viewer.