Rev 2757 | Rev 2760 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2757 | Rev 2758 | ||
|---|---|---|---|
| Line 68... | Line 68... | ||
| 68 | 68 | ||
| 69 | /* Forward declarations of static functions. */ |
69 | /* Forward declarations of static functions. */ |
| 70 | static bool tmpfs_match(void *, const char *); |
70 | static bool tmpfs_match(void *, const char *); |
| 71 | static void *tmpfs_create_node(int); |
71 | static void *tmpfs_create_node(int); |
| 72 | static bool tmpfs_link_node(void *, void *, const char *); |
72 | static bool tmpfs_link_node(void *, void *, const char *); |
| 73 | static int tmpfs_unlink_node(void *); |
73 | static int tmpfs_unlink_node(void *, void *); |
| 74 | static void tmpfs_destroy_node(void *); |
74 | static void tmpfs_destroy_node(void *); |
| 75 | 75 | ||
| 76 | /* Implementation of helper functions. */ |
76 | /* Implementation of helper functions. */ |
| 77 | static unsigned long tmpfs_index_get(void *nodep) |
77 | static unsigned long tmpfs_index_get(void *nodep) |
| 78 | { |
78 | { |
| Line 168... | Line 168... | ||
| 168 | unsigned tmpfs_next_index = 1; |
168 | unsigned tmpfs_next_index = 1; |
| 169 | 169 | ||
| 170 | static void tmpfs_dentry_initialize(tmpfs_dentry_t *dentry) |
170 | static void tmpfs_dentry_initialize(tmpfs_dentry_t *dentry) |
| 171 | { |
171 | { |
| 172 | dentry->index = 0; |
172 | dentry->index = 0; |
| 173 | dentry->parent = NULL; |
- | |
| 174 | dentry->sibling = NULL; |
173 | dentry->sibling = NULL; |
| 175 | dentry->child = NULL; |
174 | dentry->child = NULL; |
| 176 | dentry->name = NULL; |
175 | dentry->name = NULL; |
| 177 | dentry->type = TMPFS_NONE; |
176 | dentry->type = TMPFS_NONE; |
| 178 | dentry->lnkcnt = 0; |
177 | dentry->lnkcnt = 0; |
| Line 248... | Line 247... | ||
| 248 | tmp = tmp->sibling; |
247 | tmp = tmp->sibling; |
| 249 | tmp->sibling = childp; |
248 | tmp->sibling = childp; |
| 250 | } else { |
249 | } else { |
| 251 | parentp->child = childp; |
250 | parentp->child = childp; |
| 252 | } |
251 | } |
| 253 | childp->parent = parentp; |
- | |
| 254 | 252 | ||
| 255 | return true; |
253 | return true; |
| 256 | } |
254 | } |
| 257 | 255 | ||
| 258 | int tmpfs_unlink_node(void *nodeptr) |
256 | int tmpfs_unlink_node(void *prnt, void *chld) |
| 259 | { |
257 | { |
| 260 | tmpfs_dentry_t *dentry = (tmpfs_dentry_t *)nodeptr; |
258 | tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt; |
| - | 259 | tmpfs_dentry_t *childp = (tmpfs_dentry_t *)chld; |
|
| 261 | 260 | ||
| 262 | if (dentry->child) |
- | |
| 263 | return ENOTEMPTY; |
- | |
| 264 | - | ||
| 265 | if (!dentry->parent) |
261 | if (!parentp) |
| 266 | return EBUSY; |
262 | return EBUSY; |
| 267 | 263 | ||
| - | 264 | if (childp->child) |
|
| - | 265 | return ENOTEMPTY; |
|
| - | 266 | ||
| 268 | if (dentry->parent->child == dentry) { |
267 | if (parentp->child == childp) { |
| 269 | dentry->parent->child = dentry->sibling; |
268 | parentp->child = childp->sibling; |
| 270 | } else { |
269 | } else { |
| 271 | /* TODO: consider doubly linked list for organizing siblings. */ |
270 | /* TODO: consider doubly linked list for organizing siblings. */ |
| 272 | tmpfs_dentry_t *tmp = dentry->parent->child; |
271 | tmpfs_dentry_t *tmp = parentp->child; |
| 273 | while (tmp->sibling != dentry) |
272 | while (tmp->sibling != childp) |
| 274 | tmp = tmp->sibling; |
273 | tmp = tmp->sibling; |
| 275 | tmp->sibling = dentry->sibling; |
274 | tmp->sibling = childp->sibling; |
| 276 | } |
275 | } |
| 277 | dentry->sibling = NULL; |
276 | childp->sibling = NULL; |
| 278 | dentry->parent = NULL; |
- | |
| 279 | 277 | ||
| 280 | free(dentry->name); |
278 | free(childp->name); |
| 281 | dentry->name = NULL; |
279 | childp->name = NULL; |
| 282 | 280 | ||
| 283 | dentry->lnkcnt--; |
281 | childp->lnkcnt--; |
| 284 | 282 | ||
| 285 | return EOK; |
283 | return EOK; |
| 286 | } |
284 | } |
| 287 | 285 | ||
| 288 | void tmpfs_destroy_node(void *nodep) |
286 | void tmpfs_destroy_node(void *nodep) |