Rev 4419 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4419 | Rev 4537 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | #include <string.h> |
42 | #include <string.h> |
43 | #include <stdarg.h> |
43 | #include <stdarg.h> |
44 | #include <bool.h> |
44 | #include <bool.h> |
45 | #include <futex.h> |
45 | #include <futex.h> |
46 | #include <libadt/list.h> |
46 | #include <adt/list.h> |
47 | #include <vfs/canonify.h> |
47 | #include <vfs/canonify.h> |
48 | 48 | ||
49 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
49 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
50 | 50 | ||
51 | futex_t plb_futex = FUTEX_INITIALIZER; |
51 | futex_t plb_futex = FUTEX_INITIALIZER; |
Line 61... | Line 61... | ||
61 | * Can be NULL. |
61 | * Can be NULL. |
62 | * @param altroot If non-empty, will be used instead of rootfs as the root |
62 | * @param altroot If non-empty, will be used instead of rootfs as the root |
63 | * of the whole VFS tree. |
63 | * of the whole VFS tree. |
64 | * |
64 | * |
65 | * @return EOK on success or an error code from errno.h. |
65 | * @return EOK on success or an error code from errno.h. |
- | 66 | * |
|
66 | */ |
67 | */ |
67 | int vfs_lookup_internal(char *path, int lflag, vfs_lookup_res_t *result, |
68 | int vfs_lookup_internal(char *path, int lflag, vfs_lookup_res_t *result, |
68 | vfs_pair_t *altroot, ...) |
69 | vfs_pair_t *altroot, ...) |
69 | { |
70 | { |
70 | vfs_pair_t *root; |
71 | vfs_pair_t *root; |
Line 174... | Line 175... | ||
174 | */ |
175 | */ |
175 | memset(&plb[first], 0, cnt1); |
176 | memset(&plb[first], 0, cnt1); |
176 | memset(plb, 0, cnt2); |
177 | memset(plb, 0, cnt2); |
177 | futex_up(&plb_futex); |
178 | futex_up(&plb_futex); |
178 | 179 | ||
179 | if ((rc == EOK) && result) { |
180 | if ((rc == EOK) && (result)) { |
180 | result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer); |
181 | result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer); |
181 | result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer); |
182 | result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer); |
182 | result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer); |
183 | result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer); |
183 | result->size = (size_t) IPC_GET_ARG4(answer); |
184 | result->size = (size_t) IPC_GET_ARG4(answer); |
184 | result->lnkcnt = (unsigned) IPC_GET_ARG5(answer); |
185 | result->lnkcnt = (unsigned) IPC_GET_ARG5(answer); |
Line 191... | Line 192... | ||
191 | } |
192 | } |
192 | 193 | ||
193 | return rc; |
194 | return rc; |
194 | } |
195 | } |
195 | 196 | ||
- | 197 | /** Perform a node open operation. |
|
- | 198 | * |
|
- | 199 | * @return EOK on success or an error code from errno.h. |
|
- | 200 | * |
|
- | 201 | */ |
|
- | 202 | int vfs_open_node_internal(vfs_lookup_res_t *result) |
|
- | 203 | { |
|
- | 204 | int phone = vfs_grab_phone(result->triplet.fs_handle); |
|
- | 205 | ||
- | 206 | ipc_call_t answer; |
|
- | 207 | aid_t req = async_send_2(phone, VFS_OPEN_NODE, |
|
- | 208 | (ipcarg_t) result->triplet.dev_handle, |
|
- | 209 | (ipcarg_t) result->triplet.index, &answer); |
|
- | 210 | ||
- | 211 | vfs_release_phone(phone); |
|
- | 212 | ||
- | 213 | ipcarg_t rc; |
|
- | 214 | async_wait_for(req, &rc); |
|
- | 215 | ||
- | 216 | if (rc == EOK) { |
|
- | 217 | result->size = (size_t) IPC_GET_ARG1(answer); |
|
- | 218 | result->lnkcnt = (unsigned) IPC_GET_ARG2(answer); |
|
- | 219 | if (IPC_GET_ARG3(answer) & L_FILE) |
|
- | 220 | result->type = VFS_NODE_FILE; |
|
- | 221 | else if (IPC_GET_ARG3(answer) & L_DIRECTORY) |
|
- | 222 | result->type = VFS_NODE_DIRECTORY; |
|
- | 223 | else |
|
- | 224 | result->type = VFS_NODE_UNKNOWN; |
|
- | 225 | } |
|
- | 226 | ||
- | 227 | return rc; |
|
- | 228 | } |
|
- | 229 | ||
196 | /** |
230 | /** |
197 | * @} |
231 | * @} |
198 | */ |
232 | */ |