Changeset 984a9ba in mainline for uspace/srv/vfs
- Timestamp:
- 2018-07-05T09:34:09Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- Location:
- uspace/srv/vfs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.c
r76f566d r984a9ba 55 55 #define NAME "vfs" 56 56 57 static void vfs_pager( cap_call_handle_t icall_handle,ipc_call_t *icall, void *arg)57 static void vfs_pager(ipc_call_t *icall, void *arg) 58 58 { 59 async_answer_0(icall _handle, EOK);59 async_answer_0(icall, EOK); 60 60 61 61 while (true) { 62 62 ipc_call_t call; 63 cap_call_handle_t chandle =async_get_call(&call);63 async_get_call(&call); 64 64 65 65 if (!IPC_GET_IMETHOD(call)) … … 68 68 switch (IPC_GET_IMETHOD(call)) { 69 69 case IPC_M_PAGE_IN: 70 vfs_page_in( chandle,&call);70 vfs_page_in(&call); 71 71 break; 72 72 default: 73 async_answer_0( chandle, ENOTSUP);73 async_answer_0(&call, ENOTSUP); 74 74 break; 75 75 } … … 88 88 int main(int argc, char **argv) 89 89 { 90 errno_t rc;91 92 90 printf("%s: HelenOS VFS server\n", NAME); 93 91 … … 122 120 */ 123 121 port_id_t port; 124 rc = async_create_port(INTERFACE_PAGER, vfs_pager, NULL, &port);122 errno_t rc = async_create_port(INTERFACE_PAGER, vfs_pager, NULL, &port); 125 123 if (rc != EOK) { 126 124 printf("%s: Cannot create pager port: %s\n", NAME, str_error(rc)); -
uspace/srv/vfs/vfs.h
r76f566d r984a9ba 222 222 extern errno_t vfs_op_write(int fd, aoff64_t, size_t *out_bytes); 223 223 224 extern void vfs_register( cap_call_handle_t,ipc_call_t *);225 226 extern void vfs_page_in( cap_call_handle_t,ipc_call_t *);224 extern void vfs_register(ipc_call_t *); 225 226 extern void vfs_page_in(ipc_call_t *); 227 227 228 228 typedef struct { … … 233 233 extern errno_t vfs_rdwr_internal(int, aoff64_t, bool, rdwr_io_chunk_t *); 234 234 235 extern void vfs_connection( cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg);235 extern void vfs_connection(ipc_call_t *, void *); 236 236 237 237 #endif -
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 } -
uspace/srv/vfs/vfs_ops.c
r76f566d r984a9ba 386 386 return ENOENT; 387 387 388 aid_t msg = async_send_ fast(exch, read ? VFS_OUT_READ : VFS_OUT_WRITE,388 aid_t msg = async_send_4(exch, read ? VFS_OUT_READ : VFS_OUT_WRITE, 389 389 file->node->service_id, file->node->index, LOWER32(pos), 390 390 UPPER32(pos), answer); -
uspace/srv/vfs/vfs_pager.c
r76f566d r984a9ba 42 42 #include <as.h> 43 43 44 void vfs_page_in( cap_call_handle_t req_handle, ipc_call_t *request)44 void vfs_page_in(ipc_call_t *req) 45 45 { 46 aoff64_t offset = IPC_GET_ARG1(*req uest);47 size_t page_size = IPC_GET_ARG2(*req uest);48 int fd = IPC_GET_ARG3(*req uest);46 aoff64_t offset = IPC_GET_ARG1(*req); 47 size_t page_size = IPC_GET_ARG2(*req); 48 int fd = IPC_GET_ARG3(*req); 49 49 void *page; 50 50 errno_t rc; … … 55 55 56 56 if (page == AS_MAP_FAILED) { 57 async_answer_0(req _handle, ENOMEM);57 async_answer_0(req, ENOMEM); 58 58 return; 59 59 } … … 78 78 } while (total < page_size); 79 79 80 async_answer_1(req _handle, rc, (sysarg_t) page);80 async_answer_1(req, rc, (sysarg_t) page); 81 81 82 82 /* -
uspace/srv/vfs/vfs_register.c
r76f566d r984a9ba 108 108 /** VFS_REGISTER protocol function. 109 109 * 110 * @param req_handle Call handle of the request. 111 * @param request Call structure with the request. 112 * 113 */ 114 void vfs_register(cap_call_handle_t req_handle, ipc_call_t *request) 110 * @param req Call structure with the request. 111 * 112 */ 113 void vfs_register(ipc_call_t *req) 115 114 { 116 115 dprintf("Processing VFS_REGISTER request received from %zx.\n", 117 req uest->in_phone_hash);116 req->in_phone_hash); 118 117 119 118 vfs_info_t *vfs_info; … … 124 123 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", 125 124 rc); 126 async_answer_0(req _handle, rc);125 async_answer_0(req, rc); 127 126 return; 128 127 } … … 134 133 if (!fs_info) { 135 134 dprintf("Could not allocate memory for FS info.\n"); 136 async_answer_0(req _handle, ENOMEM);135 async_answer_0(req, ENOMEM); 137 136 return; 138 137 } … … 146 145 if (!vfs_info_sane(&fs_info->vfs_info)) { 147 146 free(fs_info); 148 async_answer_0(req _handle, EINVAL);147 async_answer_0(req, EINVAL); 149 148 return; 150 149 } … … 163 162 fibril_mutex_unlock(&fs_list_lock); 164 163 free(fs_info); 165 async_answer_0(req _handle, EEXIST);164 async_answer_0(req, EEXIST); 166 165 return; 167 166 } … … 184 183 fibril_mutex_unlock(&fs_list_lock); 185 184 free(fs_info); 186 async_answer_0(req _handle, EINVAL);185 async_answer_0(req, EINVAL); 187 186 return; 188 187 } … … 194 193 */ 195 194 195 ipc_call_t call; 196 196 size_t size; 197 cap_call_handle_t chandle; 198 if (!async_share_in_receive(&chandle, &size)) { 197 if (!async_share_in_receive(&call, &size)) { 199 198 dprintf("Unexpected call\n"); 200 199 list_remove(&fs_info->fs_link); … … 202 201 async_hangup(fs_info->sess); 203 202 free(fs_info); 204 async_answer_0( chandle, EINVAL);205 async_answer_0(req _handle, EINVAL);203 async_answer_0(&call, EINVAL); 204 async_answer_0(req, EINVAL); 206 205 return; 207 206 } … … 216 215 async_hangup(fs_info->sess); 217 216 free(fs_info); 218 async_answer_0( chandle, EINVAL);219 async_answer_0(req _handle, EINVAL);217 async_answer_0(&call, EINVAL); 218 async_answer_0(req, EINVAL); 220 219 return; 221 220 } … … 224 223 * Commit to read-only sharing the PLB with the client. 225 224 */ 226 (void) async_share_in_finalize( chandle, plb,225 (void) async_share_in_finalize(&call, plb, 227 226 AS_AREA_READ | AS_AREA_CACHEABLE); 228 227 … … 235 234 */ 236 235 fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next); 237 async_answer_1(req _handle, EOK, (sysarg_t) fs_info->fs_handle);236 async_answer_1(req, EOK, (sysarg_t) fs_info->fs_handle); 238 237 239 238 fibril_condvar_broadcast(&fs_list_cv);
Note:
See TracChangeset
for help on using the changeset viewer.