Changeset 03bc76a in mainline
- Timestamp:
- 2011-09-04T12:33:10Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c699b0c
- Parents:
- 8ff0bd2
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r8ff0bd2 r03bc76a 97 97 static inline int write_block(aoff64_t off, size_t size, const void *data); 98 98 99 static devmap_handle_t handle;99 static service_id_t service_id; 100 100 static int shift; 101 101 … … 201 201 } 202 202 203 rc = devmap_device_get_handle(device_name, &handle, 0);203 rc = loc_service_get_id(device_name, &service_id, 0); 204 204 if (rc != EOK) { 205 205 printf(NAME ": Error resolving device `%s'.\n", device_name); … … 207 207 } 208 208 209 rc = block_init(EXCHANGE_SERIALIZE, handle, 2048);209 rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048); 210 210 if (rc != EOK) { 211 211 printf(NAME ": Error initializing libblock.\n"); … … 213 213 } 214 214 215 rc = block_get_bsize( handle, &devblock_size);215 rc = block_get_bsize(service_id, &devblock_size); 216 216 if (rc != EOK) { 217 217 printf(NAME ": Error determining device block size.\n"); … … 219 219 } 220 220 221 rc = block_get_nblocks( handle, &sb.dev_nblocks);221 rc = block_get_nblocks(service_id, &sb.dev_nblocks); 222 222 if (rc != EOK) { 223 223 printf(NAME ": Warning, failed to obtain block device size.\n"); … … 271 271 return 2; 272 272 } 273 274 block_fini(service_id); 273 275 274 276 return 0; … … 600 602 sb->s_disk_version = 3; 601 603 602 rc = block_write_direct( handle, MFS_SUPERBLOCK << 1, 1 << 1, sb);604 rc = block_write_direct(service_id, MFS_SUPERBLOCK << 1, 1 << 1, sb); 603 605 free(sb); 604 606 … … 690 692 uint8_t *data_ptr = (uint8_t *) data; 691 693 692 rc = block_write_direct( handle, tmp_off << 2, size << 2, data_ptr);694 rc = block_write_direct(service_id, tmp_off << 2, size << 2, data_ptr); 693 695 694 696 if (rc != EOK) … … 698 700 tmp_off++; 699 701 700 return block_write_direct( handle, tmp_off << 2, size << 2, data_ptr);701 } 702 return block_write_direct( handle, off << shift, size << shift, data);702 return block_write_direct(service_id, tmp_off << 2, size << 2, data_ptr); 703 } 704 return block_write_direct(service_id, off << shift, size << shift, data); 703 705 } 704 706 -
uspace/srv/fs/minixfs/mfs.c
r8ff0bd2 r03bc76a 38 38 */ 39 39 40 #define _MAIN41 42 40 #include <ipc/services.h> 43 41 #include <ns.h> … … 55 53 .write_retains_size = false, 56 54 }; 57 58 59 /**60 * This connection fibril processes VFS requests from VFS.61 *62 * In order to support simultaneous VFS requests, our design is as follows.63 * The connection fibril accepts VFS requests from VFS. If there is only one64 * instance of the fibril, VFS will need to serialize all VFS requests it sends65 * to MinixFS. To overcome this bottleneck, VFS can send MinixFS the IPC_M_CONNECT_ME_TO66 * call. In that case, a new connection fibril will be created, which in turn67 * will accept the call. Thus, a new phone will be opened for VFS.68 *69 * There are few issues with this arrangement. First, VFS can run out of70 * available phones. In that case, VFS can close some other phones or use one71 * phone for more serialized requests. Similarily, MinixFS can refuse to duplicate72 * the connection. VFS should then just make use of already existing phones and73 * route its requests through them. To avoid paying the fibril creation price74 * upon each request, MinixFS might want to keep the connections open after the75 * request has been completed.76 */77 78 static void mfs_connection(ipc_callid_t iid, ipc_call_t *icall)79 {80 if (iid) {81 /*82 * This only happens for connections opened by83 * IPC_M_CONNECT_ME_TO calls as opposed to callback connections84 * created by IPC_M_CONNECT_TO_ME.85 */86 async_answer_0(iid, EOK);87 }88 89 while (1) {90 ipc_callid_t callid;91 ipc_call_t call;92 93 callid = async_get_call(&call);94 int method = IPC_GET_IMETHOD(call);95 96 /*mfsdebug(NAME "method = %d\n", method);*/97 switch (method) {98 case VFS_OUT_MOUNTED:99 mfs_mounted(callid, &call);100 break;101 case VFS_OUT_MOUNT:102 mfs_mount(callid, &call);103 break;104 case VFS_OUT_STAT:105 mfs_stat(callid, &call);106 break;107 case VFS_OUT_LOOKUP:108 mfs_lookup(callid, &call);109 break;110 case VFS_OUT_READ:111 mfs_read(callid, &call);112 break;113 case VFS_OUT_OPEN_NODE:114 mfs_open_node(callid, &call);115 break;116 case VFS_OUT_CLOSE:117 mfs_close(callid, &call);118 break;119 case VFS_OUT_WRITE:120 mfs_write(callid, &call);121 break;122 case VFS_OUT_TRUNCATE:123 mfs_truncate(callid, &call);124 break;125 case VFS_OUT_DESTROY:126 mfs_destroy(callid, &call);127 break;128 case VFS_OUT_UNMOUNTED:129 mfs_unmounted(callid, &call);130 break;131 case VFS_OUT_UNMOUNT:132 mfs_unmount(callid, &call);133 break;134 case VFS_OUT_SYNC:135 mfs_sync(callid, &call);136 break;137 default:138 async_answer_0(callid, ENOTSUP);139 break;140 }141 }142 }143 144 55 145 56 int main(int argc, char **argv) … … 163 74 } 164 75 165 rc = fs_register(vfs_sess, &mfs_ reg, &mfs_vfs_info, mfs_connection);76 rc = fs_register(vfs_sess, &mfs_vfs_info, &mfs_ops, &mfs_libfs_ops); 166 77 if (rc != EOK) 167 78 goto err; -
uspace/srv/fs/minixfs/mfs.h
r8ff0bd2 r03bc76a 58 58 #endif 59 59 60 #ifdef _MAIN61 #define GLOBAL62 #else63 #define GLOBAL extern64 #endif65 66 60 #define on_error(r, inst) do { \ 67 61 if (r != EOK) inst; \ 68 62 }while(0) 69 70 GLOBAL fs_reg_t mfs_reg;71 63 72 64 typedef uint32_t bitchunk_t; … … 144 136 struct mfs_instance { 145 137 link_t link; 146 devmap_handle_t handle;138 service_id_t service_id; 147 139 struct mfs_sb_info *sbi; 148 140 unsigned open_nodes_cnt; … … 159 151 160 152 /*mfs_ops.c*/ 161 extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request); 162 extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request); 163 extern void mfs_lookup(ipc_callid_t rid, ipc_call_t *request); 164 extern int mfs_instance_get(devmap_handle_t handle, 165 struct mfs_instance **instance); 166 167 extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request); 168 extern void mfs_close(ipc_callid_t rid, ipc_call_t *request); 169 extern void mfs_open_node(ipc_callid_t rid, ipc_call_t *request); 170 171 extern void 172 mfs_read(ipc_callid_t rid, ipc_call_t *request); 173 174 extern void 175 mfs_write(ipc_callid_t rid, ipc_call_t *request); 176 177 extern void 178 mfs_truncate(ipc_callid_t rid, ipc_call_t *request); 179 180 extern void 181 mfs_destroy(ipc_callid_t rid, ipc_call_t *request); 182 183 extern void 184 mfs_unmounted(ipc_callid_t rid, ipc_call_t *request); 185 186 extern void 187 mfs_unmount(ipc_callid_t rid, ipc_call_t *request); 188 189 extern void 190 mfs_sync(ipc_callid_t rid, ipc_call_t *request); 153 extern vfs_out_ops_t mfs_ops; 154 extern libfs_ops_t mfs_libfs_ops; 191 155 192 156 extern int -
uspace/srv/fs/minixfs/mfs_balloc.c
r8ff0bd2 r03bc76a 150 150 uint32_t block = idx / (sbi->block_size * 8) + start_block; 151 151 152 r = block_get(&b, inst-> handle, block, BLOCK_FLAGS_NONE);152 r = block_get(&b, inst->service_id, block, BLOCK_FLAGS_NONE); 153 153 on_error(r, goto out_err); 154 154 … … 216 216 217 217 for (i = *search / bits_per_block; i < nblocks; ++i) { 218 r = block_get(&b, inst-> handle, i + start_block,218 r = block_get(&b, inst->service_id, i + start_block, 219 219 BLOCK_FLAGS_NONE); 220 220 -
uspace/srv/fs/minixfs/mfs_dentry.c
r8ff0bd2 r03bc76a 61 61 } 62 62 63 r = block_get(&b, inst-> handle, block, BLOCK_FLAGS_NONE);63 r = block_get(&b, inst->service_id, block, BLOCK_FLAGS_NONE); 64 64 on_error(r, goto out_err); 65 65 … … 115 115 on_error(r, goto out); 116 116 117 r = block_get(&b, mnode->instance-> handle, block, BLOCK_FLAGS_NONE);117 r = block_get(&b, mnode->instance->service_id, block, BLOCK_FLAGS_NONE); 118 118 on_error(r, goto out); 119 119 -
uspace/srv/fs/minixfs/mfs_inode.c
r8ff0bd2 r03bc76a 93 93 const int itable_off = sbi->itable_off; 94 94 95 r = block_get(&b, instance-> handle,95 r = block_get(&b, instance->service_id, 96 96 itable_off + inum / sbi->ino_per_block, 97 97 BLOCK_FLAGS_NONE); … … 149 149 const int ino_off = inum % sbi->ino_per_block; 150 150 151 r = block_get(&b, instance-> handle,151 r = block_get(&b, instance->service_id, 152 152 itable_off + inum / sbi->ino_per_block, 153 153 BLOCK_FLAGS_NONE); … … 221 221 const bool native = sbi->native; 222 222 223 r = block_get(&b, mnode->instance-> handle,223 r = block_get(&b, mnode->instance->service_id, 224 224 itable_off + inum / sbi->ino_per_block, 225 225 BLOCK_FLAGS_NONE); … … 263 263 const bool native = sbi->native; 264 264 265 r = block_get(&b, mnode->instance-> handle,265 r = block_get(&b, mnode->instance->service_id, 266 266 itable_off + inum / sbi->ino_per_block, 267 267 BLOCK_FLAGS_NONE); -
uspace/srv/fs/minixfs/mfs_ops.c
r8ff0bd2 r03bc76a 38 38 39 39 #define OPEN_NODES_KEYS 2 40 #define OPEN_NODES_ DEV_HANDLE_KEY 040 #define OPEN_NODES_SERVICE_KEY 0 41 41 #define OPEN_NODES_INODE_KEY 1 42 42 #define OPEN_NODES_BUCKETS 256 … … 51 51 static fs_index_t mfs_index_get(fs_node_t *fsnode); 52 52 static unsigned mfs_lnkcnt_get(fs_node_t *fsnode); 53 static char mfs_plb_get_char(unsigned pos);54 53 static bool mfs_is_directory(fs_node_t *fsnode); 55 54 static bool mfs_is_file(fs_node_t *fsnode); 56 55 static int mfs_has_children(bool *has_children, fs_node_t *fsnode); 57 static int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle);58 static devmap_handle_t mfs_device_get(fs_node_t *fsnode);56 static int mfs_root_get(fs_node_t **rfn, service_id_t service_id); 57 static service_id_t mfs_device_get(fs_node_t *fsnode); 59 58 static aoff64_t mfs_size_get(fs_node_t *node); 60 59 static int mfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component); 61 static int mfs_create_node(fs_node_t **rfn, devmap_handle_t handle, int flags);60 static int mfs_create_node(fs_node_t **rfn, service_id_t service_id, int flags); 62 61 static int mfs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name); 63 62 static int mfs_unlink(fs_node_t *, fs_node_t *, const char *name); … … 68 67 static void open_nodes_remove_cb(link_t *link); 69 68 70 static int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,69 static int mfs_node_get(fs_node_t **rfn, service_id_t service_id, 71 70 fs_index_t index); 71 static int 72 mfs_instance_get(service_id_t service_id, struct mfs_instance **instance); 72 73 73 74 … … 92 93 .unlink = mfs_unlink, 93 94 .destroy = mfs_destroy_node, 94 .plb_get_char = mfs_plb_get_char,95 95 .has_children = mfs_has_children, 96 96 .lnkcnt_get = mfs_lnkcnt_get … … 109 109 struct mfs_node *mnode = hash_table_get_instance(item, struct mfs_node, link); 110 110 assert(keys > 0); 111 if (mnode->instance-> handle!=112 (( devmap_handle_t) key[OPEN_NODES_DEV_HANDLE_KEY])) {111 if (mnode->instance->service_id != 112 ((service_id_t) key[OPEN_NODES_SERVICE_KEY])) { 113 113 return false; 114 114 } … … 140 140 } 141 141 142 void mfs_mounted(ipc_callid_t rid, ipc_call_t *request) 143 { 144 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 142 static int 143 mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index, 144 aoff64_t *size, unsigned *linkcnt) 145 { 145 146 enum cache_mode cmode; 146 147 struct mfs_superblock *sb; … … 151 152 mfs_version_t version; 152 153 uint16_t magic; 153 154 /* Accept the mount options */ 155 char *opts; 156 int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL); 157 158 if (rc != EOK) { 159 mfsdebug("Can't accept async data write\n"); 160 async_answer_0(rid, rc); 161 return; 162 } 154 int rc; 163 155 164 156 /* Check for option enabling write through. */ … … 168 160 cmode = CACHE_MODE_WB; 169 161 170 free(opts);171 172 162 /* initialize libblock */ 173 rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, 1024); 174 if (rc != EOK) { 175 mfsdebug("libblock initialization failed\n"); 176 async_answer_0(rid, rc); 177 return; 178 } 163 rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048); 164 if (rc != EOK) 165 return rc; 179 166 180 167 /*Allocate space for generic MFS superblock*/ 181 168 sbi = malloc(sizeof(*sbi)); 182 183 169 if (!sbi) { 184 async_answer_0(rid, ENOMEM);185 return ;170 block_fini(service_id); 171 return ENOMEM; 186 172 } 187 173 188 174 /*Allocate space for filesystem instance*/ 189 175 instance = malloc(sizeof(*instance)); 190 191 176 if (!instance) { 192 async_answer_0(rid, ENOMEM);193 return ;177 block_fini(service_id); 178 return ENOMEM; 194 179 } 195 180 … … 197 182 198 183 sb = malloc(MFS_SUPERBLOCK_SIZE); 199 200 184 if (!sb) { 201 async_answer_0(rid, ENOMEM);202 return ;185 block_fini(service_id); 186 return ENOMEM; 203 187 } 204 188 205 189 /* Read the superblock */ 206 rc = block_read_direct( devmap_handle, MFS_SUPERBLOCK << 1, 1, sb);190 rc = block_read_direct(service_id, MFS_SUPERBLOCK << 1, 1, sb); 207 191 if (rc != EOK) { 208 block_fini(devmap_handle); 209 async_answer_0(rid, rc); 210 return; 192 block_fini(service_id); 193 return rc; 211 194 } 212 195 … … 221 204 if (!check_magic_number(sb3->s_magic, &native, &version, &longnames)) { 222 205 mfsdebug("magic number not recognized\n"); 223 block_fini(devmap_handle); 224 async_answer_0(rid, ENOTSUP); 225 return; 206 block_fini(service_id); 207 return ENOTSUP; 226 208 } 227 209 … … 278 260 free(sb); 279 261 280 rc = block_cache_init(devmap_handle, sbi->block_size, 0, cmode); 281 262 rc = block_cache_init(service_id, sbi->block_size, 0, cmode); 282 263 if (rc != EOK) { 283 block_fini(devmap_handle); 284 async_answer_0(rid, EINVAL); 264 free(sbi); 265 free(instance); 266 block_cache_fini(service_id); 267 block_fini(service_id); 285 268 mfsdebug("block cache initialization failed\n"); 286 return ;269 return EINVAL; 287 270 } 288 271 289 272 /*Initialize the instance structure and add it to the list*/ 290 273 link_initialize(&instance->link); 291 instance-> handle = devmap_handle;274 instance->service_id = service_id; 292 275 instance->sbi = sbi; 293 276 … … 299 282 300 283 fs_node_t *fn; 301 mfs_node_get(&fn, devmap_handle, MFS_ROOT_INO); 302 303 struct mfs_node *nroot = fn->data; 304 305 async_answer_3(rid, EOK, 306 MFS_ROOT_INO, 307 0, 308 nroot->ino_i->i_nlinks); 309 310 mfs_node_put(fn); 311 } 312 313 void mfs_mount(ipc_callid_t rid, ipc_call_t *request) 314 { 315 libfs_mount(&mfs_libfs_ops, mfs_reg.fs_handle, rid, request); 316 } 317 318 void mfs_unmount(ipc_callid_t rid, ipc_call_t *request) 319 { 320 libfs_unmount(&mfs_libfs_ops, rid, request); 321 } 322 323 void mfs_unmounted(ipc_callid_t rid, ipc_call_t *request) 324 { 325 devmap_handle_t devmap = (devmap_handle_t) IPC_GET_ARG1(*request); 284 mfs_node_get(&fn, service_id, MFS_ROOT_INO); 285 286 struct mfs_node *mroot = fn->data; 287 288 *index = mroot->ino_i->index; 289 *size = mroot->ino_i->i_size; 290 *linkcnt = mroot->ino_i->i_nlinks; 291 292 return mfs_node_put(fn); 293 } 294 295 static int 296 mfs_unmounted(service_id_t service_id) 297 { 326 298 struct mfs_instance *inst; 327 299 328 int r = mfs_instance_get(devmap, &inst); 329 if (r != EOK) { 330 async_answer_0(rid, r); 331 return; 332 } 333 334 if (inst->open_nodes_cnt != 0) { 335 async_answer_0(rid, EBUSY); 336 return; 337 } 338 339 (void) block_cache_fini(devmap); 340 block_fini(devmap); 300 int r = mfs_instance_get(service_id, &inst); 301 if (r != EOK) 302 return r; 303 304 if (inst->open_nodes_cnt != 0) 305 return EBUSY; 306 307 (void) block_cache_fini(service_id); 308 block_fini(service_id); 341 309 342 310 /* Remove the instance from the list */ … … 347 315 free(inst->sbi); 348 316 free(inst); 349 350 async_answer_0(rid, EOK); 351 } 352 353 devmap_handle_t mfs_device_get(fs_node_t *fsnode) 317 return EOK; 318 } 319 320 service_id_t mfs_device_get(fs_node_t *fsnode) 354 321 { 355 322 struct mfs_node *node = fsnode->data; 356 return node->instance-> handle;357 } 358 359 static int mfs_create_node(fs_node_t **rfn, devmap_handle_t handle, int flags)323 return node->instance->service_id; 324 } 325 326 static int mfs_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 360 327 { 361 328 int r; … … 367 334 mfsdebug("%s()\n", __FUNCTION__); 368 335 369 r = mfs_instance_get( handle, &inst);336 r = mfs_instance_get(service_id, &inst); 370 337 on_error(r, return r); 371 338 … … 421 388 422 389 unsigned long key[] = { 423 [OPEN_NODES_ DEV_HANDLE_KEY] = inst->handle,390 [OPEN_NODES_SERVICE_KEY] = inst->service_id, 424 391 [OPEN_NODES_INODE_KEY] = inum, 425 392 }; … … 498 465 } 499 466 500 void mfs_stat(ipc_callid_t rid, ipc_call_t *request) 501 { 502 libfs_stat(&mfs_libfs_ops, mfs_reg.fs_handle, rid, request); 503 } 504 505 static int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, 467 static int 468 mfs_node_get(fs_node_t **rfn, service_id_t service_id, 506 469 fs_index_t index) 507 470 { … … 511 474 mfsdebug("%s()\n", __FUNCTION__); 512 475 513 rc = mfs_instance_get( devmap_handle, &instance);476 rc = mfs_instance_get(service_id, &instance); 514 477 on_error(rc, return rc); 515 478 … … 517 480 } 518 481 519 static int mfs_node_put(fs_node_t *fsnode) 482 static int 483 mfs_node_put(fs_node_t *fsnode) 520 484 { 521 485 int rc = EOK; … … 530 494 if (mnode->refcnt == 0) { 531 495 unsigned long key[] = { 532 [OPEN_NODES_ DEV_HANDLE_KEY] = mnode->instance->handle,496 [OPEN_NODES_SERVICE_KEY] = mnode->instance->service_id, 533 497 [OPEN_NODES_INODE_KEY] = mnode->ino_i->index 534 498 }; … … 588 552 /* Check if the node is not already open */ 589 553 unsigned long key[] = { 590 [OPEN_NODES_ DEV_HANDLE_KEY] = inst->handle,554 [OPEN_NODES_SERVICE_KEY] = inst->service_id, 591 555 [OPEN_NODES_INODE_KEY] = index, 592 556 }; … … 659 623 } 660 624 661 static int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle)662 { 663 int rc = mfs_node_get(rfn, handle, MFS_ROOT_INO);625 static int mfs_root_get(fs_node_t **rfn, service_id_t service_id) 626 { 627 int rc = mfs_node_get(rfn, service_id, MFS_ROOT_INO); 664 628 return rc; 665 }666 667 void mfs_lookup(ipc_callid_t rid, ipc_call_t *request)668 {669 libfs_lookup(&mfs_libfs_ops, mfs_reg.fs_handle, rid, request);670 }671 672 static char mfs_plb_get_char(unsigned pos)673 {674 return mfs_reg.plb_ro[pos % PLB_SIZE];675 629 } 676 630 … … 772 726 } 773 727 774 void 775 mfs_read(ipc_callid_t rid, ipc_call_t *request) 728 static int 729 mfs_read(service_id_t service_id, fs_index_t index, aoff64_t pos, 730 size_t *rbytes) 776 731 { 777 732 int rc; 778 devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(*request);779 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);780 aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request),781 IPC_GET_ARG4(*request));782 733 fs_node_t *fn; 783 734 784 rc = mfs_node_get(&fn, handle, index); 785 if (rc != EOK) { 786 async_answer_0(rid, rc); 787 return; 788 } 789 if (!fn) { 790 async_answer_0(rid, ENOENT); 791 return; 792 } 735 rc = mfs_node_get(&fn, service_id, index); 736 if (rc != EOK) 737 return rc; 738 if (!fn) 739 return ENOENT; 793 740 794 741 struct mfs_node *mnode; … … 827 774 rc = mfs_node_put(fn); 828 775 async_answer_0(callid, rc != EOK ? rc : ENOENT); 829 async_answer_1(rid, rc != EOK ? rc : ENOENT, 0); 830 return; 776 return rc; 831 777 found: 832 778 async_data_read_finalize(callid, d_info.d_name, … … 866 812 } 867 813 868 rc = block_get(&b, handle, zone, BLOCK_FLAGS_NONE);814 rc = block_get(&b, service_id, zone, BLOCK_FLAGS_NONE); 869 815 on_error(rc, goto out_error); 870 816 … … 875 821 if (rc != EOK) { 876 822 mfs_node_put(fn); 877 async_answer_0(rid, rc); 878 return; 823 return rc; 879 824 } 880 825 } 881 826 out_success: 882 827 rc = mfs_node_put(fn); 883 async_answer_1(rid, rc, (sysarg_t)bytes);884 return ;828 *rbytes = bytes; 829 return rc; 885 830 out_error: 886 831 ; 887 832 int tmp = mfs_node_put(fn); 888 833 async_answer_0(callid, tmp != EOK ? tmp : rc); 889 async_answer_0(rid, tmp != EOK ? tmp : rc); 890 } 891 892 void 893 mfs_write(ipc_callid_t rid, ipc_call_t *request) 894 { 895 devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(*request); 896 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 897 aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), 898 IPC_GET_ARG4(*request)); 899 834 return tmp != EOK ? tmp : rc; 835 } 836 837 static int 838 mfs_write(service_id_t service_id, fs_index_t index, aoff64_t pos, 839 size_t *wbytes, aoff64_t *nsize) 840 { 900 841 fs_node_t *fn; 901 842 int r; 902 843 int flags = BLOCK_FLAGS_NONE; 903 844 904 r = mfs_node_get(&fn, handle, index); 905 if (r != EOK) { 906 async_answer_0(rid, r); 907 return; 908 } 909 910 if (!fn) { 911 async_answer_0(rid, ENOENT); 912 return; 913 } 845 r = mfs_node_get(&fn, service_id, index); 846 if (r != EOK) 847 return r; 848 if (!fn) 849 return ENOENT; 914 850 915 851 ipc_callid_t callid; … … 953 889 954 890 block_t *b; 955 r = block_get(&b, handle, block, flags);891 r = block_get(&b, service_id, block, flags); 956 892 on_error(r, goto out_err); 957 893 … … 962 898 if (r != EOK) { 963 899 mfs_node_put(fn); 964 async_answer_0(rid, r); 965 return; 900 return r; 966 901 } 967 902 … … 969 904 ino_i->dirty = true; 970 905 r = mfs_node_put(fn); 971 async_answer_2(rid, r, bytes, pos + bytes); 972 return; 906 *nsize = pos + bytes; 907 *wbytes = bytes; 908 return r; 973 909 974 910 out_err: 975 911 mfs_node_put(fn); 976 912 async_answer_0(callid, r); 977 async_answer_0(rid, r); 978 } 979 980 void 981 mfs_destroy(ipc_callid_t rid, ipc_call_t *request) 982 { 983 devmap_handle_t handle = (devmap_handle_t)IPC_GET_ARG1(*request); 984 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 913 return r; 914 } 915 916 static int 917 mfs_destroy(service_id_t service_id, fs_index_t index) 918 { 985 919 fs_node_t *fn; 986 920 int r; 987 921 988 r = mfs_node_get(&fn, handle, index); 989 if (r != EOK) { 990 async_answer_0(rid, r); 991 return; 992 } 993 if (!fn) { 994 async_answer_0(rid, ENOENT); 995 return; 996 } 922 r = mfs_node_get(&fn, service_id, index); 923 if (r != EOK) 924 return r; 925 if (!fn) 926 return ENOENT; 997 927 998 928 /*Destroy the inode*/ 999 929 r = mfs_destroy_node(fn); 1000 async_answer_0(rid, r);930 return r; 1001 931 } 1002 932 … … 1031 961 } 1032 962 1033 void 1034 mfs_truncate(ipc_callid_t rid, ipc_call_t *request) 1035 { 1036 devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(*request); 1037 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1038 aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), 1039 IPC_GET_ARG4(*request)); 963 static int 964 mfs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size) 965 { 1040 966 fs_node_t *fn; 1041 967 int r; 1042 968 1043 r = mfs_node_get(&fn, handle, index); 1044 if (r != EOK) { 1045 async_answer_0(rid, r); 1046 return; 1047 } 1048 1049 if (!fn) { 1050 async_answer_0(rid, r); 1051 return; 1052 } 969 r = mfs_node_get(&fn, service_id, index); 970 if (r != EOK) 971 return r; 972 if (!fn) 973 return r; 1053 974 1054 975 struct mfs_node *mnode = fn->data; … … 1060 981 r = inode_shrink(mnode, ino_i->i_size - size); 1061 982 1062 async_answer_0(rid, r);1063 983 mfs_node_put(fn); 1064 } 1065 1066 int mfs_instance_get(devmap_handle_t handle, struct mfs_instance **instance) 1067 { 1068 link_t *link; 984 return r; 985 } 986 987 static int 988 mfs_instance_get(service_id_t service_id, struct mfs_instance **instance) 989 { 1069 990 struct mfs_instance *instance_ptr; 1070 991 1071 992 fibril_mutex_lock(&inst_list_mutex); 1072 993 1073 for (link = inst_list.next; link != &inst_list; link = link->next) { 994 if (list_empty(&inst_list)) { 995 fibril_mutex_unlock(&inst_list_mutex); 996 return EINVAL; 997 } 998 999 list_foreach(inst_list, link) { 1074 1000 instance_ptr = list_get_instance(link, struct mfs_instance, 1075 1001 link); 1076 1002 1077 if (instance_ptr-> handle == handle) {1003 if (instance_ptr->service_id == service_id) { 1078 1004 *instance = instance_ptr; 1079 1005 fibril_mutex_unlock(&inst_list_mutex); … … 1117 1043 } 1118 1044 1119 void 1120 mfs_close(ipc_callid_t rid, ipc_call_t *request) 1121 { 1122 async_answer_0(rid, EOK); 1123 } 1124 1125 void 1126 mfs_open_node(ipc_callid_t rid, ipc_call_t *request) 1127 { 1128 libfs_open_node(&mfs_libfs_ops, mfs_reg.fs_handle, rid, request); 1129 } 1130 1131 void 1132 mfs_sync(ipc_callid_t rid, ipc_call_t *request) 1133 { 1134 devmap_handle_t devmap = (devmap_handle_t) IPC_GET_ARG1(*request); 1135 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1136 1045 static int 1046 mfs_close(service_id_t service_id, fs_index_t index) 1047 { 1048 return 0; 1049 } 1050 1051 static int 1052 mfs_sync(service_id_t service_id, fs_index_t index) 1053 { 1137 1054 fs_node_t *fn; 1138 int rc = mfs_node_get(&fn, devmap, index); 1139 if (rc != EOK) { 1140 async_answer_0(rid, rc); 1141 return; 1142 } 1143 if (!fn) { 1144 async_answer_0(rid, ENOENT); 1145 return; 1146 } 1055 int rc = mfs_node_get(&fn, service_id, index); 1056 if (rc != EOK) 1057 return rc; 1058 if (!fn) 1059 return ENOENT; 1147 1060 1148 1061 struct mfs_node *mnode = fn->data; 1149 1062 mnode->ino_i->dirty = true; 1150 1063 1151 rc = mfs_node_put(fn); 1152 async_answer_0(rid, rc); 1153 } 1064 return mfs_node_put(fn); 1065 } 1066 1067 vfs_out_ops_t mfs_ops = { 1068 .mounted = mfs_mounted, 1069 .unmounted = mfs_unmounted, 1070 .read = mfs_read, 1071 .write = mfs_write, 1072 .truncate = mfs_truncate, 1073 .close = mfs_close, 1074 .destroy = mfs_destroy, 1075 .sync = mfs_sync, 1076 }; 1154 1077 1155 1078 /** -
uspace/srv/fs/minixfs/mfs_rw.c
r8ff0bd2 r03bc76a 296 296 int r; 297 297 298 r = block_get(&b, inst-> handle, zone, BLOCK_FLAGS_NOREAD);298 r = block_get(&b, inst->service_id, zone, BLOCK_FLAGS_NOREAD); 299 299 on_error(r, return r); 300 300 … … 331 331 return ENOMEM; 332 332 333 r = block_get(&b, inst-> handle, zone, BLOCK_FLAGS_NONE);333 r = block_get(&b, inst->service_id, zone, BLOCK_FLAGS_NONE); 334 334 if (r != EOK) { 335 335 free(*ind_zone); … … 360 360 block_t *b; 361 361 362 r = block_get(&b, inst-> handle, zone, BLOCK_FLAGS_NONE);362 r = block_get(&b, inst->service_id, zone, BLOCK_FLAGS_NONE); 363 363 on_error(r, return r); 364 364
Note:
See TracChangeset
for help on using the changeset viewer.