Rev 4551 | Rev 4566 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4551 | Rev 4555 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | #include <stdio.h> |
42 | #include <stdio.h> |
43 | #include <stdlib.h> |
43 | #include <stdlib.h> |
44 | #include <string.h> |
44 | #include <string.h> |
45 | #include <bool.h> |
45 | #include <bool.h> |
46 | #include <futex.h> |
- | |
47 | #include <fibril_sync.h> |
46 | #include <fibril_sync.h> |
48 | #include <adt/list.h> |
47 | #include <adt/list.h> |
49 | #include <unistd.h> |
48 | #include <unistd.h> |
50 | #include <ctype.h> |
49 | #include <ctype.h> |
51 | #include <fcntl.h> |
50 | #include <fcntl.h> |
Line 1129... | Line 1128... | ||
1129 | * The name has already been unlinked by vfs_lookup_internal(). |
1128 | * The name has already been unlinked by vfs_lookup_internal(). |
1130 | * We have to get and put the VFS node to ensure that it is |
1129 | * We have to get and put the VFS node to ensure that it is |
1131 | * VFS_DESTROY'ed after the last reference to it is dropped. |
1130 | * VFS_DESTROY'ed after the last reference to it is dropped. |
1132 | */ |
1131 | */ |
1133 | vfs_node_t *node = vfs_node_get(&lr); |
1132 | vfs_node_t *node = vfs_node_get(&lr); |
1134 | futex_down(&nodes_futex); |
1133 | fibril_mutex_lock(&nodes_mutex); |
1135 | node->lnkcnt--; |
1134 | node->lnkcnt--; |
1136 | futex_up(&nodes_futex); |
1135 | fibril_mutex_unlock(&nodes_mutex); |
1137 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1136 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1138 | vfs_node_put(node); |
1137 | vfs_node_put(node); |
1139 | ipc_answer_0(rid, EOK); |
1138 | ipc_answer_0(rid, EOK); |
1140 | } |
1139 | } |
1141 | 1140 | ||
Line 1280... | Line 1279... | ||
1280 | ipc_answer_0(rid, ENOMEM); |
1279 | ipc_answer_0(rid, ENOMEM); |
1281 | free(old); |
1280 | free(old); |
1282 | free(new); |
1281 | free(new); |
1283 | return; |
1282 | return; |
1284 | } |
1283 | } |
1285 | futex_down(&nodes_futex); |
1284 | fibril_mutex_lock(&nodes_mutex); |
1286 | new_node->lnkcnt--; |
1285 | new_node->lnkcnt--; |
1287 | futex_up(&nodes_futex); |
1286 | fibril_mutex_unlock(&nodes_mutex); |
1288 | break; |
1287 | break; |
1289 | default: |
1288 | default: |
1290 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1289 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1291 | ipc_answer_0(rid, ENOTEMPTY); |
1290 | ipc_answer_0(rid, ENOTEMPTY); |
1292 | free(old); |
1291 | free(old); |
Line 1302... | Line 1301... | ||
1302 | ipc_answer_0(rid, rc); |
1301 | ipc_answer_0(rid, rc); |
1303 | free(old); |
1302 | free(old); |
1304 | free(new); |
1303 | free(new); |
1305 | return; |
1304 | return; |
1306 | } |
1305 | } |
1307 | futex_down(&nodes_futex); |
1306 | fibril_mutex_lock(&nodes_mutex); |
1308 | old_node->lnkcnt++; |
1307 | old_node->lnkcnt++; |
1309 | futex_up(&nodes_futex); |
1308 | fibril_mutex_unlock(&nodes_mutex); |
1310 | /* Destroy the link for the old name. */ |
1309 | /* Destroy the link for the old name. */ |
1311 | rc = vfs_lookup_internal(oldc, L_UNLINK, NULL, NULL); |
1310 | rc = vfs_lookup_internal(oldc, L_UNLINK, NULL, NULL); |
1312 | if (rc != EOK) { |
1311 | if (rc != EOK) { |
1313 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1312 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1314 | vfs_node_put(old_node); |
1313 | vfs_node_put(old_node); |
Line 1317... | Line 1316... | ||
1317 | ipc_answer_0(rid, rc); |
1316 | ipc_answer_0(rid, rc); |
1318 | free(old); |
1317 | free(old); |
1319 | free(new); |
1318 | free(new); |
1320 | return; |
1319 | return; |
1321 | } |
1320 | } |
1322 | futex_down(&nodes_futex); |
1321 | fibril_mutex_lock(&nodes_mutex); |
1323 | old_node->lnkcnt--; |
1322 | old_node->lnkcnt--; |
1324 | futex_up(&nodes_futex); |
1323 | fibril_mutex_unlock(&nodes_mutex); |
1325 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1324 | fibril_rwlock_write_unlock(&namespace_rwlock); |
1326 | vfs_node_put(old_node); |
1325 | vfs_node_put(old_node); |
1327 | if (new_node) |
1326 | if (new_node) |
1328 | vfs_node_put(new_node); |
1327 | vfs_node_put(new_node); |
1329 | free(old); |
1328 | free(old); |