Changeset f49b0ea in mainline for uspace/srv/vfs/vfs_ops.c
- Timestamp:
- 2008-06-06T15:16:41Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cde485d
- Parents:
- f86c184
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
rf86c184 rf49b0ea 63 63 64 64 futex_t rootfs_futex = FUTEX_INITIALIZER; 65 vfs_ triplet_t rootfs = {65 vfs_pair_t rootfs = { 66 66 .fs_handle = 0, 67 .dev_handle = 0, 68 .index = 0, 67 .dev_handle = 0 69 68 }; 70 71 static int72 lookup_root(fs_handle_t fs_handle, dev_handle_t dev_handle,73 vfs_lookup_res_t *result)74 {75 vfs_pair_t altroot = {76 .fs_handle = fs_handle,77 .dev_handle = dev_handle,78 };79 80 return vfs_lookup_internal("/", L_DIRECTORY, result, &altroot);81 }82 69 83 70 void vfs_mount(ipc_callid_t rid, ipc_call_t *request) … … 164 151 buf[size] = '\0'; 165 152 166 /* 167 * Lookup the root node of the filesystem being mounted. 168 * In this case, we don't need to take the namespace_futex as the root 169 * node cannot be removed. However, we do take a reference to it so 170 * that we can track how many times it has been mounted. 171 */ 172 vfs_lookup_res_t mr_res; 173 rc = lookup_root(fs_handle, dev_handle, &mr_res); 174 if (rc != EOK) { 175 free(buf); 176 ipc_answer_0(rid, rc); 177 return; 178 } 179 vfs_node_t *mr_node = vfs_node_get(&mr_res); 180 if (!mr_node) { 181 free(buf); 182 ipc_answer_0(rid, ENOMEM); 183 return; 184 } 185 186 /* Finally, we need to resolve the path to the mountpoint. */ 153 /* Resolve the path to the mountpoint. */ 187 154 vfs_lookup_res_t mp_res; 188 155 futex_down(&rootfs_futex); … … 194 161 rwlock_write_unlock(&namespace_rwlock); 195 162 futex_up(&rootfs_futex); 196 vfs_node_put(mr_node);197 163 free(buf); 198 164 ipc_answer_0(rid, EBUSY); … … 204 170 rwlock_write_unlock(&namespace_rwlock); 205 171 futex_up(&rootfs_futex); 206 vfs_node_put(mr_node); /* failed -> drop reference */207 172 free(buf); 208 173 ipc_answer_0(rid, rc); … … 213 178 rwlock_write_unlock(&namespace_rwlock); 214 179 futex_up(&rootfs_futex); 215 vfs_node_put(mr_node); /* failed -> drop reference */216 180 free(buf); 217 181 ipc_answer_0(rid, ENOMEM); … … 233 197 free(buf); 234 198 235 /* Inform the mount point about the root mount. */ 236 phone = vfs_grab_phone(mr_res.triplet.fs_handle); 237 rc = async_req_5_0(phone, VFS_MOUNT, 238 (ipcarg_t) mr_res.triplet.dev_handle, 239 (ipcarg_t) mr_res.triplet.index, 240 (ipcarg_t) mr_res.triplet.fs_handle, 241 (ipcarg_t) mr_res.triplet.dev_handle, 242 (ipcarg_t) mr_res.triplet.index); 199 /* Tell the mountee that it is being mounted. */ 200 phone = vfs_grab_phone(fs_handle); 201 rc = async_req_1_0(phone, VFS_MOUNTED, 202 (ipcarg_t) dev_handle); 243 203 vfs_release_phone(phone); 244 204 245 if (rc == EOK) 246 rootfs = mr_res.triplet;247 else248 vfs_node_put(mr_node);205 if (rc == EOK) { 206 rootfs.fs_handle = fs_handle; 207 rootfs.dev_handle = dev_handle; 208 } 249 209 250 210 futex_up(&rootfs_futex); … … 258 218 futex_up(&rootfs_futex); 259 219 free(buf); 260 vfs_node_put(mr_node); /* failed -> drop reference */261 220 ipc_answer_0(rid, ENOENT); 262 221 return; … … 269 228 /* 270 229 * At this point, we have all necessary pieces: file system and device 271 * handles, and we know the mount point VFS node and also the root node 272 * of the file system being mounted. 273 */ 274 275 /** 276 * @todo 277 * Add more IPC parameters so that we can send mount mode/flags. 278 */ 230 * handles, and we know the mount point VFS node. 231 */ 232 279 233 phone = vfs_grab_phone(mp_res.triplet.fs_handle); 280 rc = async_req_ 5_0(phone, VFS_MOUNT,234 rc = async_req_4_0(phone, VFS_MOUNT, 281 235 (ipcarg_t) mp_res.triplet.dev_handle, 282 236 (ipcarg_t) mp_res.triplet.index, 283 (ipcarg_t) mr_res.triplet.fs_handle, 284 (ipcarg_t) mr_res.triplet.dev_handle, 285 (ipcarg_t) mr_res.triplet.index); 237 (ipcarg_t) fs_handle, 238 (ipcarg_t) dev_handle); 286 239 vfs_release_phone(phone); 287 240 288 241 if (rc != EOK) { 289 /* Mount failed, drop references to mr_node and mp_node. */ 290 vfs_node_put(mr_node); 242 /* Mount failed, drop reference to mp_node. */ 291 243 if (mp_node) 292 244 vfs_node_put(mp_node);
Note:
See TracChangeset
for help on using the changeset viewer.