211,9 → 211,44 |
static unsigned long create_node(tmpfs_dentry_t *dentry, |
const char *component, int lflag) |
{ |
assert(dentry->type == TMPFS_DIRECTORY); |
assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY)); |
|
tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t)); |
if (!node) |
return 0; |
size_t len = strlen(component); |
char *name = malloc(len + 1); |
if (!name) { |
free(node); |
return 0; |
} |
strcpy(name, component); |
|
tmpfs_dentry_initialize(node); |
node->index = tmpfs_next_index++; |
node->name = name; |
node->parent = dentry; |
if (lflag & L_DIRECTORY) |
node->type = TMPFS_DIRECTORY; |
else |
node->type = TMPFS_FILE; |
|
/* Insert the new node into the namespace. */ |
if (dentry->child) { |
tmpfs_dentry_t *tmp = dentry->child; |
while (tmp->sibling) |
tmp = tmp->sibling; |
tmp->sibling = node; |
} else { |
dentry->child = node; |
} |
|
/* Insert the new node into the dentry hash table. */ |
hash_table_insert(&dentries, &node->index, &node->dh_link); |
return node->index; |
} |
|
static int destroy_component(tmpfs_dentry_t *dentry) |
{ |
return EPERM; |
279,7 → 314,7 |
} |
unsigned long index = create_node(dcur, |
component, lflag); |
if (index) { |
if (index > 0) { |
ipc_answer_4(rid, EOK, |
tmpfs_reg.fs_handle, dev_handle, |
index, 0); |