Changes in uspace/srv/fs/mfs/mfs_ops.c [1eaa3cf:5b56dc7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r1eaa3cf r5b56dc7 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);69 66 70 67 static hash_table_t open_nodes; … … 87 84 .destroy = mfs_destroy_node, 88 85 .has_children = mfs_has_children, 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 86 .lnkcnt_get = mfs_lnkcnt_get 93 87 }; 94 88 95 89 /* Hash table interface for open nodes hash table */ 90 96 91 typedef struct { 97 92 service_id_t service_id; … … 195 190 /* This is a V1 or V2 Minix filesystem */ 196 191 magic = sb->s_magic; 197 } else if (check_magic_number(sb3->s_magic, &native, 198 &version, &longnames)) { 192 } else if (check_magic_number(sb3->s_magic, &native, &version, &longnames)) { 199 193 /* This is a V3 Minix filesystem */ 200 194 magic = sb3->s_magic; … … 216 210 sbi->isearch = 0; 217 211 sbi->zsearch = 0; 218 sbi->nfree_zones_valid = false;219 sbi->nfree_zones = 0;220 212 221 213 if (version == MFS_VERSION_V3) { … … 353 345 uint32_t inum; 354 346 347 mfsdebug("%s()\n", __FUNCTION__); 348 355 349 r = mfs_instance_get(service_id, &inst); 356 350 if (r != EOK) … … 385 379 ino_i->i_mode = S_IFDIR; 386 380 ino_i->i_nlinks = 1; /* This accounts for the '.' dentry */ 387 } else {381 } else 388 382 ino_i->i_mode = S_IFREG; 389 ino_i->i_nlinks = 0;390 }391 383 392 384 ino_i->i_uid = 0; … … 427 419 free(ino_i); 428 420 out_err: 429 mfs_free_inode(inst, inum);430 421 return r; 431 422 } … … 438 429 struct mfs_dentry_info d_info; 439 430 int r; 431 432 mfsdebug("%s()\n", __FUNCTION__); 440 433 441 434 if (!S_ISDIR(ino_i->i_mode)) … … 459 452 460 453 if (comp_size == dentry_name_size && 461 memcmp(component, d_info.d_name, dentry_name_size) == 0) {454 !bcmp(component, d_info.d_name, dentry_name_size)) { 462 455 /* Hit! */ 463 456 mfs_node_core_get(rfn, mnode->instance, … … 485 478 struct mfs_instance *instance; 486 479 480 mfsdebug("%s()\n", __FUNCTION__); 481 487 482 rc = mfs_instance_get(service_id, &instance); 488 483 if (rc != EOK) … … 497 492 int rc = EOK; 498 493 struct mfs_node *mnode = fsnode->data; 494 495 mfsdebug("%s()\n", __FUNCTION__); 499 496 500 497 fibril_mutex_lock(&open_nodes_lock); … … 557 554 int rc; 558 555 556 mfsdebug("%s()\n", __FUNCTION__); 557 559 558 fibril_mutex_lock(&open_nodes_lock); 560 559 … … 569 568 if (already_open) { 570 569 mnode = hash_table_get_inst(already_open, struct mfs_node, link); 571 572 570 *rfn = mnode->fsnode; 573 571 mnode->refcnt++; … … 650 648 struct mfs_sb_info *sbi = parent->instance->sbi; 651 649 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, ".");676 675 destroy_dentry = true; 677 676 goto exit; … … 701 700 bool has_children; 702 701 int r; 702 703 mfsdebug("%s()\n", __FUNCTION__); 703 704 704 705 if (!parent) … … 923 924 924 925 r = mfs_write_map(mnode, pos, block, &dummy); 925 if (r != EOK) { 926 mfs_free_zone(mnode->instance, block); 926 if (r != EOK) 927 927 goto out_err; 928 }929 928 930 929 flags = BLOCK_FLAGS_NOREAD; … … 966 965 mfs_destroy(service_id_t service_id, fs_index_t index) 967 966 { 968 fs_node_t *fn = NULL;967 fs_node_t *fn; 969 968 int r; 970 969 … … 1137 1136 } 1138 1137 1139 static int1140 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 int1158 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 int1176 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 the1190 * 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 1206 1138 vfs_out_ops_t mfs_ops = { 1207 1139 .mounted = mfs_mounted,
Note:
See TracChangeset
for help on using the changeset viewer.