Changeset 44358c1 in mainline
- Timestamp:
- 2007-11-07T18:46:43Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7f3e3e7
- Parents:
- b818cff
- Location:
- uspace/srv/vfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_mount.c
rb818cff r44358c1 66 66 { 67 67 int dev_handle; 68 vfs_node_t *mp_node = NULL; 68 69 69 70 /* … … 137 138 /* 138 139 * Lookup the root node of the filesystem being mounted. 140 * In this case, we don't need to take the unlink_futex as the root node 141 * cannot be removed. However, we do take a reference to it so that 142 * we can track how many times it has been mounted. 139 143 */ 140 144 int rc; … … 146 150 return; 147 151 } 152 vfs_node_t *mr_node = vfs_node_get(&mounted_root); 153 if (!mr_node) { 154 free(buf); 155 ipc_answer_fast_0(rid, ENOMEM); 156 return; 157 } 148 158 149 159 /* … … 156 166 * We already have the root FS. 157 167 */ 168 futex_down(&unlink_futex); 158 169 rc = vfs_lookup_internal((char *) (buf + FS_NAME_MAXLEN), 159 170 size - FS_NAME_MAXLEN, &mp, NULL); … … 162 173 * The lookup failed for some reason. 163 174 */ 164 futex_up(&rootfs_futex); 175 futex_up(&unlink_futex); 176 futex_up(&rootfs_futex); 177 vfs_node_put(mr_node); /* failed -> drop reference */ 165 178 free(buf); 166 179 ipc_answer_fast_0(rid, rc); 167 180 return; 168 181 } 182 mp_node = vfs_node_get(&mp); 183 if (!mp_node) { 184 futex_up(&unlink_futex); 185 futex_up(&rootfs_futex); 186 vfs_node_put(mr_node); /* failed -> drop reference */ 187 free(buf); 188 ipc_answer_fast_0(rid, ENOMEM); 189 return; 190 } 191 /* 192 * Now we hold a reference to mp_node. 193 * It will be dropped upon the corresponding VFS_UNMOUNT. 194 * This prevents the mount point from being deleted. 195 */ 196 futex_up(&unlink_futex); 169 197 } else { 170 198 /* … … 188 216 futex_up(&rootfs_futex); 189 217 free(buf); 218 vfs_node_put(mr_node); /* failed -> drop reference */ 190 219 ipc_answer_fast_0(rid, ENOENT); 191 220 return; … … 218 247 vfs_release_phone(phone); 219 248 249 if ((rc1 != EOK) || (rc2 != EOK)) { 250 /* Mount failed, drop references to mr_node and mp_node. */ 251 vfs_node_put(mr_node); 252 if (mp_node) 253 vfs_node_put(mp_node); 254 } 255 220 256 if (rc2 == EOK) 221 257 ipc_answer_fast_0(rid, rc1); -
uspace/srv/vfs/vfs_unlink.c
rb818cff r44358c1 40 40 41 41 /** 42 * This futex serializes concurrent VFS_CREATE, VFS_OPEN and VFS_UNLINK43 * operations.42 * This futex prevents the race between a triplet-to-VFS-node resolution and a 43 * concurrent VFS_UNLINK or VFS_RMDIR operation. 44 44 */ 45 45 atomic_t unlink_futex = FUTEX_INITIALIZER;
Note:
See TracChangeset
for help on using the changeset viewer.