Rev 2593 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2593 | Rev 2619 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | #include "vfs.h" |
44 | #include "vfs.h" |
45 | 45 | ||
46 | void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
46 | void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
47 | { |
47 | { |
48 | if (!vfs_files_init()) { |
48 | if (!vfs_files_init()) { |
49 | ipc_answer_fast_0(rid, ENOMEM); |
49 | ipc_answer_0(rid, ENOMEM); |
50 | return; |
50 | return; |
51 | } |
51 | } |
52 | 52 | ||
53 | /* |
53 | /* |
54 | * The POSIX interface is open(path, flags, mode). |
54 | * The POSIX interface is open(path, flags, mode). |
Line 58... | Line 58... | ||
58 | int flags = IPC_GET_ARG1(*request); |
58 | int flags = IPC_GET_ARG1(*request); |
59 | int mode = IPC_GET_ARG2(*request); |
59 | int mode = IPC_GET_ARG2(*request); |
60 | size_t size; |
60 | size_t size; |
61 | 61 | ||
62 | ipc_callid_t callid; |
62 | ipc_callid_t callid; |
63 | ipc_call_t call; |
- | |
64 | 63 | ||
65 | if (!ipc_data_receive(&callid, &call, NULL, &size)) { |
64 | if (!ipc_data_receive(&callid, NULL, &size)) { |
66 | ipc_answer_fast_0(callid, EINVAL); |
65 | ipc_answer_0(callid, EINVAL); |
67 | ipc_answer_fast_0(rid, EINVAL); |
66 | ipc_answer_0(rid, EINVAL); |
68 | return; |
67 | return; |
69 | } |
68 | } |
70 | 69 | ||
71 | /* |
70 | /* |
72 | * Now we are on the verge of accepting the path. |
71 | * Now we are on the verge of accepting the path. |
Line 75... | Line 74... | ||
75 | * directly into the PLB using some kind of a callback. |
74 | * directly into the PLB using some kind of a callback. |
76 | */ |
75 | */ |
77 | char *path = malloc(size); |
76 | char *path = malloc(size); |
78 | 77 | ||
79 | if (!path) { |
78 | if (!path) { |
80 | ipc_answer_fast_0(callid, ENOMEM); |
79 | ipc_answer_0(callid, ENOMEM); |
81 | ipc_answer_fast_0(rid, ENOMEM); |
80 | ipc_answer_0(rid, ENOMEM); |
82 | return; |
81 | return; |
83 | } |
82 | } |
84 | 83 | ||
85 | int rc; |
84 | int rc; |
86 | if ((rc = ipc_data_deliver(callid, &call, path, size))) { |
85 | if ((rc = ipc_data_deliver(callid, path, size))) { |
87 | ipc_answer_fast_0(rid, rc); |
86 | ipc_answer_0(rid, rc); |
88 | free(path); |
87 | free(path); |
89 | return; |
88 | return; |
90 | } |
89 | } |
91 | 90 | ||
92 | /* |
91 | /* |
Line 101... | Line 100... | ||
101 | */ |
100 | */ |
102 | vfs_triplet_t triplet; |
101 | vfs_triplet_t triplet; |
103 | rc = vfs_lookup_internal(path, size, &triplet, NULL); |
102 | rc = vfs_lookup_internal(path, size, &triplet, NULL); |
104 | if (rc) { |
103 | if (rc) { |
105 | futex_up(&unlink_futex); |
104 | futex_up(&unlink_futex); |
106 | ipc_answer_fast_0(rid, rc); |
105 | ipc_answer_0(rid, rc); |
107 | free(path); |
106 | free(path); |
108 | return; |
107 | return; |
109 | } |
108 | } |
110 | 109 | ||
111 | /* |
110 | /* |
Line 121... | Line 120... | ||
121 | * structure. |
120 | * structure. |
122 | */ |
121 | */ |
123 | int fd = vfs_fd_alloc(); |
122 | int fd = vfs_fd_alloc(); |
124 | if (fd < 0) { |
123 | if (fd < 0) { |
125 | vfs_node_put(node); |
124 | vfs_node_put(node); |
126 | ipc_answer_fast_0(rid, fd); |
125 | ipc_answer_0(rid, fd); |
127 | return; |
126 | return; |
128 | } |
127 | } |
129 | vfs_file_t *file = vfs_file_get(fd); |
128 | vfs_file_t *file = vfs_file_get(fd); |
130 | file->node = node; |
129 | file->node = node; |
131 | 130 | ||
Line 140... | Line 139... | ||
140 | vfs_node_put(node); |
139 | vfs_node_put(node); |
141 | 140 | ||
142 | /* |
141 | /* |
143 | * Success! Return the new file descriptor to the client. |
142 | * Success! Return the new file descriptor to the client. |
144 | */ |
143 | */ |
145 | ipc_answer_fast_1(rid, EOK, fd); |
144 | ipc_answer_1(rid, EOK, fd); |
146 | } |
145 | } |
147 | 146 | ||
148 | /** |
147 | /** |
149 | * @} |
148 | * @} |
150 | */ |
149 | */ |