Rev 4584 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4584 | Rev 4586 | ||
|---|---|---|---|
| Line 41... | Line 41... | ||
| 41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
| 42 | #include <as.h> |
42 | #include <as.h> |
| 43 | #include <assert.h> |
43 | #include <assert.h> |
| 44 | #include <dirent.h> |
44 | #include <dirent.h> |
| 45 | #include <mem.h> |
45 | #include <mem.h> |
| - | 46 | #include <sys/stat.h> |
|
| 46 | 47 | ||
| 47 | /** Register file system server. |
48 | /** Register file system server. |
| 48 | * |
49 | * |
| 49 | * This function abstracts away the tedious registration protocol from |
50 | * This function abstracts away the tedious registration protocol from |
| 50 | * file system implementations and lets them to reuse this registration glue |
51 | * file system implementations and lets them to reuse this registration glue |
| Line 426... | Line 427... | ||
| 426 | ops->node_put(cur); |
427 | ops->node_put(cur); |
| 427 | if (tmp) |
428 | if (tmp) |
| 428 | ops->node_put(tmp); |
429 | ops->node_put(tmp); |
| 429 | } |
430 | } |
| 430 | 431 | ||
| - | 432 | void libfs_stat(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid, |
|
| - | 433 | ipc_call_t *request) |
|
| - | 434 | { |
|
| - | 435 | dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
|
| - | 436 | fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); |
|
| - | 437 | fs_node_t *fn = ops->node_get(dev_handle, index); |
|
| - | 438 | ||
| - | 439 | ipc_callid_t callid; |
|
| - | 440 | size_t size; |
|
| - | 441 | if (!ipc_data_read_receive(&callid, &size) || |
|
| - | 442 | size < sizeof(struct stat)) { |
|
| - | 443 | ipc_answer_0(callid, EINVAL); |
|
| - | 444 | ipc_answer_0(rid, EINVAL); |
|
| - | 445 | return; |
|
| - | 446 | } |
|
| - | 447 | ||
| - | 448 | struct stat *stat = malloc(sizeof(struct stat)); |
|
| - | 449 | if (!stat) { |
|
| - | 450 | ipc_answer_0(callid, ENOMEM); |
|
| - | 451 | ipc_answer_0(rid, ENOMEM); |
|
| - | 452 | return; |
|
| - | 453 | } |
|
| - | 454 | memset(stat, 0, sizeof(struct stat)); |
|
| - | 455 | ||
| - | 456 | stat->fs_handle = fs_handle; |
|
| - | 457 | stat->dev_handle = dev_handle; |
|
| - | 458 | stat->index = index; |
|
| - | 459 | stat->lnkcnt = ops->lnkcnt_get(fn); |
|
| - | 460 | stat->is_file = ops->is_file(fn); |
|
| - | 461 | stat->size = ops->size_get(fn); |
|
| - | 462 | ||
| - | 463 | ipc_data_read_finalize(callid, stat, sizeof(struct stat)); |
|
| - | 464 | ipc_answer_0(rid, EOK); |
|
| - | 465 | ||
| - | 466 | free(stat); |
|
| - | 467 | } |
|
| - | 468 | ||
| 431 | /** Open VFS triplet. |
469 | /** Open VFS triplet. |
| 432 | * |
470 | * |
| 433 | * @param ops libfs operations structure with function pointers to |
471 | * @param ops libfs operations structure with function pointers to |
| 434 | * file system implementation |
472 | * file system implementation |
| 435 | * @param rid Request ID of the VFS_OUT_OPEN_NODE request. |
473 | * @param rid Request ID of the VFS_OUT_OPEN_NODE request. |