Changeset 984a9ba in mainline for uspace/srv/vfs/vfs_ipc.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ipc.c
r76f566d r984a9ba 35 35 #include <vfs/canonify.h> 36 36 37 static void vfs_in_clone( cap_call_handle_t req_handle, ipc_call_t *request)38 { 39 int oldfd = IPC_GET_ARG1(*req uest);40 int newfd = IPC_GET_ARG2(*req uest);41 bool desc = IPC_GET_ARG3(*req uest);37 static void vfs_in_clone(ipc_call_t *req) 38 { 39 int oldfd = IPC_GET_ARG1(*req); 40 int newfd = IPC_GET_ARG2(*req); 41 bool desc = IPC_GET_ARG3(*req); 42 42 43 43 int outfd = -1; 44 44 errno_t rc = vfs_op_clone(oldfd, newfd, desc, &outfd); 45 async_answer_1(req _handle, rc, outfd);46 } 47 48 static void vfs_in_fsprobe( cap_call_handle_t req_handle, ipc_call_t *request)49 { 50 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req uest);45 async_answer_1(req, rc, outfd); 46 } 47 48 static void vfs_in_fsprobe(ipc_call_t *req) 49 { 50 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 51 51 char *fs_name = NULL; 52 cap_call_handle_t chandle;53 52 vfs_fs_probe_info_t info; 54 size_t len;55 53 errno_t rc; 56 54 … … 62 60 FS_NAME_MAXLEN, 0, NULL); 63 61 if (rc != EOK) { 64 async_answer_0(req _handle, rc);62 async_answer_0(req, rc); 65 63 return; 66 64 } 67 65 68 66 rc = vfs_op_fsprobe(fs_name, service_id, &info); 69 async_answer_0(req _handle, rc);67 async_answer_0(req, rc); 70 68 if (rc != EOK) 71 69 goto out; 72 70 73 71 /* Now we should get a read request */ 74 if (!async_data_read_receive(&chandle, &len)) 72 ipc_call_t call; 73 size_t len; 74 if (!async_data_read_receive(&call, &len)) 75 75 goto out; 76 76 77 77 if (len > sizeof(info)) 78 78 len = sizeof(info); 79 (void) async_data_read_finalize( chandle, &info, len);79 (void) async_data_read_finalize(&call, &info, len); 80 80 81 81 out: … … 83 83 } 84 84 85 static void vfs_in_fstypes(cap_call_handle_t req_handle, ipc_call_t *request) 86 { 87 cap_call_handle_t chandle; 88 size_t len; 85 static void vfs_in_fstypes(ipc_call_t *req) 86 { 89 87 vfs_fstypes_t fstypes; 90 88 errno_t rc; … … 92 90 rc = vfs_get_fstypes(&fstypes); 93 91 if (rc != EOK) { 94 async_answer_0(req _handle, ENOMEM);92 async_answer_0(req, ENOMEM); 95 93 return; 96 94 } 97 95 98 96 /* Send size of the data */ 99 async_answer_1(req _handle, EOK, fstypes.size);97 async_answer_1(req, EOK, fstypes.size); 100 98 101 99 /* Now we should get a read request */ 102 if (!async_data_read_receive(&chandle, &len)) 100 ipc_call_t call; 101 size_t len; 102 if (!async_data_read_receive(&call, &len)) 103 103 goto out; 104 104 105 105 if (len > fstypes.size) 106 106 len = fstypes.size; 107 (void) async_data_read_finalize( chandle, fstypes.buf, len);107 (void) async_data_read_finalize(&call, fstypes.buf, len); 108 108 109 109 out: … … 111 111 } 112 112 113 static void vfs_in_mount( cap_call_handle_t req_handle, ipc_call_t *request)114 { 115 int mpfd = IPC_GET_ARG1(*req uest);113 static void vfs_in_mount(ipc_call_t *req) 114 { 115 int mpfd = IPC_GET_ARG1(*req); 116 116 117 117 /* … … 120 120 * in the request. 121 121 */ 122 service_id_t service_id = (service_id_t) IPC_GET_ARG2(*req uest);123 124 unsigned int flags = (unsigned int) IPC_GET_ARG3(*req uest);125 unsigned int instance = IPC_GET_ARG4(*req uest);122 service_id_t service_id = (service_id_t) IPC_GET_ARG2(*req); 123 124 unsigned int flags = (unsigned int) IPC_GET_ARG3(*req); 125 unsigned int instance = IPC_GET_ARG4(*req); 126 126 127 127 char *opts = NULL; … … 132 132 MAX_MNTOPTS_LEN, 0, NULL); 133 133 if (rc != EOK) { 134 async_answer_0(req _handle, rc);134 async_answer_0(req, rc); 135 135 return; 136 136 } … … 144 144 if (rc != EOK) { 145 145 free(opts); 146 async_answer_0(req _handle, rc);146 async_answer_0(req, rc); 147 147 return; 148 148 } … … 151 151 rc = vfs_op_mount(mpfd, service_id, flags, instance, opts, fs_name, 152 152 &outfd); 153 async_answer_1(req _handle, rc, outfd);153 async_answer_1(req, rc, outfd); 154 154 155 155 free(opts); … … 157 157 } 158 158 159 static void vfs_in_open( cap_call_handle_t req_handle, ipc_call_t *request)160 { 161 int fd = IPC_GET_ARG1(*req uest);162 int mode = IPC_GET_ARG2(*req uest);159 static void vfs_in_open(ipc_call_t *req) 160 { 161 int fd = IPC_GET_ARG1(*req); 162 int mode = IPC_GET_ARG2(*req); 163 163 164 164 errno_t rc = vfs_op_open(fd, mode); 165 async_answer_0(req _handle, rc);166 } 167 168 static void vfs_in_put( cap_call_handle_t req_handle, ipc_call_t *request)169 { 170 int fd = IPC_GET_ARG1(*req uest);165 async_answer_0(req, rc); 166 } 167 168 static void vfs_in_put(ipc_call_t *req) 169 { 170 int fd = IPC_GET_ARG1(*req); 171 171 errno_t rc = vfs_op_put(fd); 172 async_answer_0(req _handle, rc);173 } 174 175 static void vfs_in_read( cap_call_handle_t req_handle, ipc_call_t *request)176 { 177 int fd = IPC_GET_ARG1(*req uest);178 aoff64_t pos = MERGE_LOUP32(IPC_GET_ARG2(*req uest),179 IPC_GET_ARG3(*req uest));172 async_answer_0(req, rc); 173 } 174 175 static void vfs_in_read(ipc_call_t *req) 176 { 177 int fd = IPC_GET_ARG1(*req); 178 aoff64_t pos = MERGE_LOUP32(IPC_GET_ARG2(*req), 179 IPC_GET_ARG3(*req)); 180 180 181 181 size_t bytes = 0; 182 182 errno_t rc = vfs_op_read(fd, pos, &bytes); 183 async_answer_1(req _handle, rc, bytes);184 } 185 186 static void vfs_in_rename( cap_call_handle_t req_handle, ipc_call_t *request)183 async_answer_1(req, rc, bytes); 184 } 185 186 static void vfs_in_rename(ipc_call_t *req) 187 187 { 188 188 /* The common base directory. */ … … 192 192 errno_t rc; 193 193 194 basefd = IPC_GET_ARG1(*req uest);194 basefd = IPC_GET_ARG1(*req); 195 195 196 196 /* Retrieve the old path. */ … … 220 220 221 221 out: 222 async_answer_0(req _handle, rc);222 async_answer_0(req, rc); 223 223 224 224 if (old) … … 228 228 } 229 229 230 static void vfs_in_resize( cap_call_handle_t req_handle, ipc_call_t *request)231 { 232 int fd = IPC_GET_ARG1(*req uest);233 int64_t size = MERGE_LOUP32(IPC_GET_ARG2(*req uest), IPC_GET_ARG3(*request));230 static void vfs_in_resize(ipc_call_t *req) 231 { 232 int fd = IPC_GET_ARG1(*req); 233 int64_t size = MERGE_LOUP32(IPC_GET_ARG2(*req), IPC_GET_ARG3(*req)); 234 234 errno_t rc = vfs_op_resize(fd, size); 235 async_answer_0(req _handle, rc);236 } 237 238 static void vfs_in_stat( cap_call_handle_t req_handle, ipc_call_t *request)239 { 240 int fd = IPC_GET_ARG1(*req uest);235 async_answer_0(req, rc); 236 } 237 238 static void vfs_in_stat(ipc_call_t *req) 239 { 240 int fd = IPC_GET_ARG1(*req); 241 241 errno_t rc = vfs_op_stat(fd); 242 async_answer_0(req _handle, rc);243 } 244 245 static void vfs_in_statfs( cap_call_handle_t req_handle, ipc_call_t *request)246 { 247 int fd = (int) IPC_GET_ARG1(*req uest);242 async_answer_0(req, rc); 243 } 244 245 static void vfs_in_statfs(ipc_call_t *req) 246 { 247 int fd = (int) IPC_GET_ARG1(*req); 248 248 249 249 errno_t rc = vfs_op_statfs(fd); 250 async_answer_0(req _handle, rc);251 } 252 253 static void vfs_in_sync( cap_call_handle_t req_handle, ipc_call_t *request)254 { 255 int fd = IPC_GET_ARG1(*req uest);250 async_answer_0(req, rc); 251 } 252 253 static void vfs_in_sync(ipc_call_t *req) 254 { 255 int fd = IPC_GET_ARG1(*req); 256 256 errno_t rc = vfs_op_sync(fd); 257 async_answer_0(req _handle, rc);258 } 259 260 static void vfs_in_unlink( cap_call_handle_t req_handle, ipc_call_t *request)261 { 262 int parentfd = IPC_GET_ARG1(*req uest);263 int expectfd = IPC_GET_ARG2(*req uest);257 async_answer_0(req, rc); 258 } 259 260 static void vfs_in_unlink(ipc_call_t *req) 261 { 262 int parentfd = IPC_GET_ARG1(*req); 263 int expectfd = IPC_GET_ARG2(*req); 264 264 265 265 char *path; … … 268 268 rc = vfs_op_unlink(parentfd, expectfd, path); 269 269 270 async_answer_0(req _handle, rc);271 } 272 273 static void vfs_in_unmount( cap_call_handle_t req_handle, ipc_call_t *request)274 { 275 int mpfd = IPC_GET_ARG1(*req uest);270 async_answer_0(req, rc); 271 } 272 273 static void vfs_in_unmount(ipc_call_t *req) 274 { 275 int mpfd = IPC_GET_ARG1(*req); 276 276 errno_t rc = vfs_op_unmount(mpfd); 277 async_answer_0(req _handle, rc);278 } 279 280 static void vfs_in_wait_handle( cap_call_handle_t req_handle, ipc_call_t *request)281 { 282 bool high_fd = IPC_GET_ARG1(*req uest);277 async_answer_0(req, rc); 278 } 279 280 static void vfs_in_wait_handle(ipc_call_t *req) 281 { 282 bool high_fd = IPC_GET_ARG1(*req); 283 283 int fd = -1; 284 284 errno_t rc = vfs_op_wait_handle(high_fd, &fd); 285 async_answer_1(req _handle, rc, fd);286 } 287 288 static void vfs_in_walk( cap_call_handle_t req_handle, ipc_call_t *request)285 async_answer_1(req, rc, fd); 286 } 287 288 static void vfs_in_walk(ipc_call_t *req) 289 289 { 290 290 /* … … 292 292 * For defined flags, see <ipc/vfs.h>. 293 293 */ 294 int parentfd = IPC_GET_ARG1(*req uest);295 int flags = IPC_GET_ARG2(*req uest);294 int parentfd = IPC_GET_ARG1(*req); 295 int flags = IPC_GET_ARG2(*req); 296 296 297 297 int fd = 0; … … 302 302 free(path); 303 303 } 304 async_answer_1(req _handle, rc, fd);305 } 306 307 static void vfs_in_write( cap_call_handle_t req_handle, ipc_call_t *request)308 { 309 int fd = IPC_GET_ARG1(*req uest);310 aoff64_t pos = MERGE_LOUP32(IPC_GET_ARG2(*req uest),311 IPC_GET_ARG3(*req uest));304 async_answer_1(req, rc, fd); 305 } 306 307 static void vfs_in_write(ipc_call_t *req) 308 { 309 int fd = IPC_GET_ARG1(*req); 310 aoff64_t pos = MERGE_LOUP32(IPC_GET_ARG2(*req), 311 IPC_GET_ARG3(*req)); 312 312 313 313 size_t bytes = 0; 314 314 errno_t rc = vfs_op_write(fd, pos, &bytes); 315 async_answer_1(req _handle, rc, bytes);316 } 317 318 void vfs_connection( cap_call_handle_t icall_handle,ipc_call_t *icall, void *arg)315 async_answer_1(req, rc, bytes); 316 } 317 318 void vfs_connection(ipc_call_t *icall, void *arg) 319 319 { 320 320 bool cont = true; … … 324 324 * This call needs to be answered. 325 325 */ 326 async_answer_0(icall _handle, EOK);326 async_answer_0(icall, EOK); 327 327 328 328 while (cont) { 329 329 ipc_call_t call; 330 cap_call_handle_t chandle =async_get_call(&call);330 async_get_call(&call); 331 331 332 332 if (!IPC_GET_IMETHOD(call)) … … 335 335 switch (IPC_GET_IMETHOD(call)) { 336 336 case VFS_IN_CLONE: 337 vfs_in_clone( chandle,&call);337 vfs_in_clone(&call); 338 338 break; 339 339 case VFS_IN_FSPROBE: 340 vfs_in_fsprobe( chandle,&call);340 vfs_in_fsprobe(&call); 341 341 break; 342 342 case VFS_IN_FSTYPES: 343 vfs_in_fstypes( chandle,&call);343 vfs_in_fstypes(&call); 344 344 break; 345 345 case VFS_IN_MOUNT: 346 vfs_in_mount( chandle,&call);346 vfs_in_mount(&call); 347 347 break; 348 348 case VFS_IN_OPEN: 349 vfs_in_open( chandle,&call);349 vfs_in_open(&call); 350 350 break; 351 351 case VFS_IN_PUT: 352 vfs_in_put( chandle,&call);352 vfs_in_put(&call); 353 353 break; 354 354 case VFS_IN_READ: 355 vfs_in_read( chandle,&call);355 vfs_in_read(&call); 356 356 break; 357 357 case VFS_IN_REGISTER: 358 vfs_register( chandle,&call);358 vfs_register(&call); 359 359 cont = false; 360 360 break; 361 361 case VFS_IN_RENAME: 362 vfs_in_rename( chandle,&call);362 vfs_in_rename(&call); 363 363 break; 364 364 case VFS_IN_RESIZE: 365 vfs_in_resize( chandle,&call);365 vfs_in_resize(&call); 366 366 break; 367 367 case VFS_IN_STAT: 368 vfs_in_stat( chandle,&call);368 vfs_in_stat(&call); 369 369 break; 370 370 case VFS_IN_STATFS: 371 vfs_in_statfs( chandle,&call);371 vfs_in_statfs(&call); 372 372 break; 373 373 case VFS_IN_SYNC: 374 vfs_in_sync( chandle,&call);374 vfs_in_sync(&call); 375 375 break; 376 376 case VFS_IN_UNLINK: 377 vfs_in_unlink( chandle,&call);377 vfs_in_unlink(&call); 378 378 break; 379 379 case VFS_IN_UNMOUNT: 380 vfs_in_unmount( chandle,&call);380 vfs_in_unmount(&call); 381 381 break; 382 382 case VFS_IN_WAIT_HANDLE: 383 vfs_in_wait_handle( chandle,&call);383 vfs_in_wait_handle(&call); 384 384 break; 385 385 case VFS_IN_WALK: 386 vfs_in_walk( chandle,&call);386 vfs_in_walk(&call); 387 387 break; 388 388 case VFS_IN_WRITE: 389 vfs_in_write( chandle,&call);389 vfs_in_write(&call); 390 390 break; 391 391 default: 392 async_answer_0( chandle, ENOTSUP);392 async_answer_0(&call, ENOTSUP); 393 393 break; 394 394 }
Note:
See TracChangeset
for help on using the changeset viewer.