Changes in uspace/srv/fs/mfs/mfs_ops.c [5b56dc7:1eaa3cf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r5b56dc7 r1eaa3cf 64 64 static int mfs_check_sanity(struct mfs_sb_info *sbi); 65 65 static bool is_power_of_two(uint32_t n); 66 static int mfs_size_block(service_id_t service_id, uint32_t *size); 67 static int mfs_total_block_count(service_id_t service_id, uint64_t *count); 68 static int mfs_free_block_count(service_id_t service_id, uint64_t *count); 66 69 67 70 static hash_table_t open_nodes; … … 84 87 .destroy = mfs_destroy_node, 85 88 .has_children = mfs_has_children, 86 .lnkcnt_get = mfs_lnkcnt_get 89 .lnkcnt_get = mfs_lnkcnt_get, 90 .size_block = mfs_size_block, 91 .total_block_count = mfs_total_block_count, 92 .free_block_count = mfs_free_block_count 87 93 }; 88 94 89 95 /* Hash table interface for open nodes hash table */ 90 91 96 typedef struct { 92 97 service_id_t service_id; … … 190 195 /* This is a V1 or V2 Minix filesystem */ 191 196 magic = sb->s_magic; 192 } else if (check_magic_number(sb3->s_magic, &native, &version, &longnames)) { 197 } else if (check_magic_number(sb3->s_magic, &native, 198 &version, &longnames)) { 193 199 /* This is a V3 Minix filesystem */ 194 200 magic = sb3->s_magic; … … 210 216 sbi->isearch = 0; 211 217 sbi->zsearch = 0; 218 sbi->nfree_zones_valid = false; 219 sbi->nfree_zones = 0; 212 220 213 221 if (version == MFS_VERSION_V3) { … … 345 353 uint32_t inum; 346 354 347 mfsdebug("%s()\n", __FUNCTION__);348 349 355 r = mfs_instance_get(service_id, &inst); 350 356 if (r != EOK) … … 379 385 ino_i->i_mode = S_IFDIR; 380 386 ino_i->i_nlinks = 1; /* This accounts for the '.' dentry */ 381 } else 387 } else { 382 388 ino_i->i_mode = S_IFREG; 389 ino_i->i_nlinks = 0; 390 } 383 391 384 392 ino_i->i_uid = 0; … … 419 427 free(ino_i); 420 428 out_err: 429 mfs_free_inode(inst, inum); 421 430 return r; 422 431 } … … 429 438 struct mfs_dentry_info d_info; 430 439 int r; 431 432 mfsdebug("%s()\n", __FUNCTION__);433 440 434 441 if (!S_ISDIR(ino_i->i_mode)) … … 452 459 453 460 if (comp_size == dentry_name_size && 454 !bcmp(component, d_info.d_name, dentry_name_size)) {461 memcmp(component, d_info.d_name, dentry_name_size) == 0) { 455 462 /* Hit! */ 456 463 mfs_node_core_get(rfn, mnode->instance, … … 478 485 struct mfs_instance *instance; 479 486 480 mfsdebug("%s()\n", __FUNCTION__);481 482 487 rc = mfs_instance_get(service_id, &instance); 483 488 if (rc != EOK) … … 492 497 int rc = EOK; 493 498 struct mfs_node *mnode = fsnode->data; 494 495 mfsdebug("%s()\n", __FUNCTION__);496 499 497 500 fibril_mutex_lock(&open_nodes_lock); … … 554 557 int rc; 555 558 556 mfsdebug("%s()\n", __FUNCTION__);557 558 559 fibril_mutex_lock(&open_nodes_lock); 559 560 … … 568 569 if (already_open) { 569 570 mnode = hash_table_get_inst(already_open, struct mfs_node, link); 571 570 572 *rfn = mnode->fsnode; 571 573 mnode->refcnt++; … … 648 650 struct mfs_sb_info *sbi = parent->instance->sbi; 649 651 bool destroy_dentry = false; 650 651 mfsdebug("%s()\n", __FUNCTION__);652 652 653 653 if (str_size(name) > sbi->max_name_len) … … 673 673 r = mfs_insert_dentry(child, "..", parent->ino_i->index); 674 674 if (r != EOK) { 675 mfs_remove_dentry(child, "."); 675 676 destroy_dentry = true; 676 677 goto exit; … … 700 701 bool has_children; 701 702 int r; 702 703 mfsdebug("%s()\n", __FUNCTION__);704 703 705 704 if (!parent) … … 924 923 925 924 r = mfs_write_map(mnode, pos, block, &dummy); 926 if (r != EOK) 925 if (r != EOK) { 926 mfs_free_zone(mnode->instance, block); 927 927 goto out_err; 928 } 928 929 929 930 flags = BLOCK_FLAGS_NOREAD; … … 965 966 mfs_destroy(service_id_t service_id, fs_index_t index) 966 967 { 967 fs_node_t *fn ;968 fs_node_t *fn = NULL; 968 969 int r; 969 970 … … 1136 1137 } 1137 1138 1139 static int 1140 mfs_size_block(service_id_t service_id, uint32_t *size) 1141 { 1142 struct mfs_instance *inst; 1143 int rc; 1144 1145 rc = mfs_instance_get(service_id, &inst); 1146 if (rc != EOK) 1147 return rc; 1148 1149 if (NULL == inst) 1150 return ENOENT; 1151 1152 *size = inst->sbi->block_size; 1153 1154 return EOK; 1155 } 1156 1157 static int 1158 mfs_total_block_count(service_id_t service_id, uint64_t *count) 1159 { 1160 struct mfs_instance *inst; 1161 int rc; 1162 1163 rc = mfs_instance_get(service_id, &inst); 1164 if (rc != EOK) 1165 return rc; 1166 1167 if (NULL == inst) 1168 return ENOENT; 1169 1170 *count = (uint64_t) MFS_BMAP_SIZE_BITS(inst->sbi, BMAP_ZONE); 1171 1172 return EOK; 1173 } 1174 1175 static int 1176 mfs_free_block_count(service_id_t service_id, uint64_t *count) 1177 { 1178 uint32_t block_free; 1179 1180 struct mfs_instance *inst; 1181 int rc = mfs_instance_get(service_id, &inst); 1182 if (rc != EOK) 1183 return rc; 1184 1185 struct mfs_sb_info *sbi = inst->sbi; 1186 1187 if (!sbi->nfree_zones_valid) { 1188 /* The cached number of free zones is not valid, 1189 * we need to scan the bitmap to retrieve the 1190 * current value. 1191 */ 1192 1193 rc = mfs_count_free_zones(inst, &block_free); 1194 if (rc != EOK) 1195 return rc; 1196 1197 sbi->nfree_zones = block_free; 1198 sbi->nfree_zones_valid = true; 1199 } 1200 1201 *count = sbi->nfree_zones; 1202 1203 return EOK; 1204 } 1205 1138 1206 vfs_out_ops_t mfs_ops = { 1139 1207 .mounted = mfs_mounted,
Note:
See TracChangeset
for help on using the changeset viewer.