122,77 → 122,6 |
root->type = TMPFS_DIRECTORY; |
hash_table_insert(&dentries, &root->index, &root->dh_link); |
|
/* |
* This is only for debugging. Once we can create files and directories |
* using VFS, we can get rid of this. |
*/ |
tmpfs_dentry_t *d; |
d = (tmpfs_dentry_t *) malloc(sizeof(tmpfs_dentry_t)); |
if (!d) { |
free(root); |
root = NULL; |
return false; |
} |
tmpfs_dentry_initialize(d); |
d->index = tmpfs_next_index++; |
root->child = d; |
d->parent = root; |
d->type = TMPFS_DIRECTORY; |
d->name = "dir1"; |
hash_table_insert(&dentries, &d->index, &d->dh_link); |
|
d = (tmpfs_dentry_t *) malloc(sizeof(tmpfs_dentry_t)); |
if (!d) { |
free(root->child); |
free(root); |
root = NULL; |
return false; |
} |
tmpfs_dentry_initialize(d); |
d->index = tmpfs_next_index++; |
root->child->sibling = d; |
d->parent = root; |
d->type = TMPFS_DIRECTORY; |
d->name = "dir2"; |
hash_table_insert(&dentries, &d->index, &d->dh_link); |
|
d = (tmpfs_dentry_t *) malloc(sizeof(tmpfs_dentry_t)); |
if (!d) { |
free(root->child->sibling); |
free(root->child); |
free(root); |
root = NULL; |
return false; |
} |
tmpfs_dentry_initialize(d); |
d->index = tmpfs_next_index++; |
root->child->child = d; |
d->parent = root->child; |
d->type = TMPFS_FILE; |
d->name = "file1"; |
d->data = "This is the contents of /dir1/file1.\n"; |
d->size = strlen(d->data); |
hash_table_insert(&dentries, &d->index, &d->dh_link); |
|
d = (tmpfs_dentry_t *) malloc(sizeof(tmpfs_dentry_t)); |
if (!d) { |
free(root->child->sibling); |
free(root->child->child); |
free(root->child); |
free(root); |
root = NULL; |
return false; |
} |
tmpfs_dentry_initialize(d); |
d->index = tmpfs_next_index++; |
root->child->sibling->child = d; |
d->parent = root->child->sibling; |
d->type = TMPFS_FILE; |
d->name = "file2"; |
d->data = "This is the contents of /dir2/file2.\n"; |
d->size = strlen(d->data); |
hash_table_insert(&dentries, &d->index, &d->dh_link); |
|
return true; |
} |
|