Rev 4296 | Rev 4537 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4296 | Rev 4420 | ||
|---|---|---|---|
| Line 46... | Line 46... | ||
| 46 | #include <async.h> |
46 | #include <async.h> |
| 47 | #include <atomic.h> |
47 | #include <atomic.h> |
| 48 | #include <futex.h> |
48 | #include <futex.h> |
| 49 | #include <errno.h> |
49 | #include <errno.h> |
| 50 | #include <string.h> |
50 | #include <string.h> |
| 51 | #include <ipc/devmap.h> |
51 | #include <devmap.h> |
| 52 | #include "../../../srv/vfs/vfs.h" |
52 | #include "../../../srv/vfs/vfs.h" |
| 53 | 53 | ||
| 54 | int vfs_phone = -1; |
54 | int vfs_phone = -1; |
| 55 | futex_t vfs_phone_futex = FUTEX_INITIALIZER; |
55 | futex_t vfs_phone_futex = FUTEX_INITIALIZER; |
| 56 | 56 | ||
| Line 113... | Line 113... | ||
| 113 | { |
113 | { |
| 114 | while (vfs_phone < 0) |
114 | while (vfs_phone < 0) |
| 115 | vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0); |
115 | vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0); |
| 116 | } |
116 | } |
| 117 | 117 | ||
| 118 | static int device_get_handle(const char *name, dev_handle_t *handle, |
- | |
| 119 | const unsigned int flags) |
- | |
| 120 | { |
- | |
| 121 | int phone; |
- | |
| 122 | - | ||
| 123 | if (flags & IPC_FLAG_BLOCKING) |
- | |
| 124 | phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); |
- | |
| 125 | else |
- | |
| 126 | phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); |
- | |
| 127 | - | ||
| 128 | if (phone < 0) |
- | |
| 129 | return phone; |
- | |
| 130 | - | ||
| 131 | ipc_call_t answer; |
- | |
| 132 | aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, flags, 0, |
- | |
| 133 | &answer); |
- | |
| 134 | - | ||
| 135 | ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1); |
- | |
| 136 | - | ||
| 137 | if (retval != EOK) { |
- | |
| 138 | async_wait_for(req, NULL); |
- | |
| 139 | ipc_hangup(phone); |
- | |
| 140 | return retval; |
- | |
| 141 | } |
- | |
| 142 | - | ||
| 143 | async_wait_for(req, &retval); |
- | |
| 144 | - | ||
| 145 | if (handle != NULL) |
- | |
| 146 | *handle = -1; |
- | |
| 147 | - | ||
| 148 | if (retval == EOK) { |
- | |
| 149 | if (handle != NULL) |
- | |
| 150 | *handle = (dev_handle_t) IPC_GET_ARG1(answer); |
- | |
| 151 | } |
- | |
| 152 | - | ||
| 153 | ipc_hangup(phone); |
- | |
| 154 | return retval; |
- | |
| 155 | } |
- | |
| 156 | - | ||
| 157 | int mount(const char *fs_name, const char *mp, const char *dev, |
118 | int mount(const char *fs_name, const char *mp, const char *dev, |
| 158 | const unsigned int flags) |
119 | const char *opts, unsigned int flags) |
| 159 | { |
120 | { |
| 160 | int res; |
121 | int res; |
| 161 | ipcarg_t rc; |
122 | ipcarg_t rc; |
| 162 | aid_t req; |
123 | aid_t req; |
| 163 | dev_handle_t dev_handle; |
124 | dev_handle_t dev_handle; |
| 164 | 125 | ||
| 165 | res = device_get_handle(dev, &dev_handle, flags); |
126 | res = devmap_device_get_handle(dev, &dev_handle, flags); |
| 166 | if (res != EOK) |
127 | if (res != EOK) |
| 167 | return res; |
128 | return res; |
| 168 | 129 | ||
| 169 | size_t mpa_size; |
130 | size_t mpa_size; |
| 170 | char *mpa = absolutize(mp, &mpa_size); |
131 | char *mpa = absolutize(mp, &mpa_size); |
| Line 183... | Line 144... | ||
| 183 | futex_up(&vfs_phone_futex); |
144 | futex_up(&vfs_phone_futex); |
| 184 | free(mpa); |
145 | free(mpa); |
| 185 | return (int) rc; |
146 | return (int) rc; |
| 186 | } |
147 | } |
| 187 | 148 | ||
| - | 149 | rc = ipc_data_write_start(vfs_phone, (void *) opts, str_size(opts)); |
|
| - | 150 | if (rc != EOK) { |
|
| - | 151 | async_wait_for(req, NULL); |
|
| - | 152 | async_serialize_end(); |
|
| - | 153 | futex_up(&vfs_phone_futex); |
|
| - | 154 | free(mpa); |
|
| - | 155 | return (int) rc; |
|
| - | 156 | } |
|
| - | 157 | ||
| 188 | rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); |
158 | rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); |
| 189 | if (rc != EOK) { |
159 | if (rc != EOK) { |
| 190 | async_wait_for(req, NULL); |
160 | async_wait_for(req, NULL); |
| 191 | async_serialize_end(); |
161 | async_serialize_end(); |
| 192 | futex_up(&vfs_phone_futex); |
162 | futex_up(&vfs_phone_futex); |
| 193 | free(mpa); |
163 | free(mpa); |
| - | 164 | return (int) rc; |
|
| - | 165 | } |
|
| - | 166 | ||
| - | 167 | /* Ask VFS whether it likes fs_name. */ |
|
| - | 168 | rc = async_req_0_0(vfs_phone, IPC_M_PING); |
|
| - | 169 | if (rc != EOK) { |
|
| - | 170 | async_wait_for(req, NULL); |
|
| - | 171 | async_serialize_end(); |
|
| - | 172 | futex_up(&vfs_phone_futex); |
|
| - | 173 | free(mpa); |
|
| 194 | return (int) rc; |
174 | return (int) rc; |
| 195 | } |
175 | } |
| 196 | 176 | ||
| 197 | async_wait_for(req, &rc); |
177 | async_wait_for(req, &rc); |
| 198 | async_serialize_end(); |
178 | async_serialize_end(); |