i_ops: change link and unlink to inode-tracking
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
8c346a7018
commit
7e4e70853e
3 changed files with 26 additions and 35 deletions
30
fs/vfs/vfs.c
30
fs/vfs/vfs.c
|
|
@ -208,7 +208,7 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t
|
|||
return res;
|
||||
}
|
||||
|
||||
res = ino->i_ops.link(parent, new_ino, name, &new_dirent);
|
||||
res = ino->i_ops.link(ino, new_ino, name, &new_dirent);
|
||||
|
||||
if (res < 0) {
|
||||
fs->fs_ops.free_inode(fs, new_ino);
|
||||
|
|
@ -216,6 +216,7 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t
|
|||
return res;
|
||||
}
|
||||
|
||||
new_dirent->fs = fs;
|
||||
*out = new_dirent;
|
||||
write_unlock(&ino->rwlock);
|
||||
return 0;
|
||||
|
|
@ -235,33 +236,10 @@ int vfs_unlink(dirent_t *parent, const char *name)
|
|||
return -ENOTDIR;
|
||||
}
|
||||
|
||||
dirent_t *dent = NULL;
|
||||
int res = inode_find_dirent_locked(ino, name, &dent);
|
||||
if (res < 0) {
|
||||
write_unlock(&ino->rwlock);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = ino->i_ops.unlink(dent);
|
||||
if (res < 0) {
|
||||
dirent_dec_ref(dent);
|
||||
write_unlock(&ino->rwlock);
|
||||
return res;
|
||||
}
|
||||
|
||||
list_item_t *item = ino->dirents.head;
|
||||
while (item) {
|
||||
if (item->ptr == dent) {
|
||||
list_remove(item);
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
dirent_dec_ref(dent);
|
||||
int res = ino->i_ops.unlink(ino, name);
|
||||
|
||||
write_unlock(&ino->rwlock);
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
int vfs_mount(const char *mount_point, fs_t *fs_to_mount)
|
||||
|
|
|
|||
Loading…
Reference in a new issue