inode: add initial refcounts
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
bdd3915f83
commit
30c597c175
1 changed files with 10 additions and 4 deletions
|
|
@ -54,7 +54,9 @@ int inode_find_dirent(inode_t *inode, const char *name, dirent_t **out)
|
||||||
dirent_t *dent = item->ptr;
|
dirent_t *dent = item->ptr;
|
||||||
if (!strcmp(dent->name, name)) {
|
if (!strcmp(dent->name, name)) {
|
||||||
/* found */
|
/* found */
|
||||||
|
dirent_inc_ref(dent);
|
||||||
*out = dent;
|
*out = dent;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
item = item->next;
|
item = item->next;
|
||||||
|
|
@ -67,9 +69,11 @@ inode_t *inode_create()
|
||||||
{
|
{
|
||||||
inode_t *ret = slab_alloc(inode_slab);
|
inode_t *ret = slab_alloc(inode_slab);
|
||||||
|
|
||||||
if (ret)
|
if (!ret)
|
||||||
memset(ret, 0, sizeof(*ret));
|
return NULL;
|
||||||
|
|
||||||
|
ret->refcount = 1;
|
||||||
|
memset(ret, 0, sizeof(*ret));
|
||||||
rwlock_init(&ret->rwlock);
|
rwlock_init(&ret->rwlock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -136,8 +140,10 @@ dirent_t *dirent_create(const char *name)
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret->rec_len = sizeof(dirent_t);
|
memset(ret, 0, sizeof(dirent_t));
|
||||||
|
|
||||||
|
ret->rec_len = sizeof(dirent_t);
|
||||||
|
ret->refcount = 1;
|
||||||
ret->name_len = strlen(name);
|
ret->name_len = strlen(name);
|
||||||
ret->name = strdup(name);
|
ret->name = strdup(name);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue