mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 05:58:22 +00:00
fs: link
This commit is contained in:
+10
-1
@@ -220,8 +220,17 @@ static int tmpfs_readlink(vnode_t *node, char** buff, size_t* linksize){
|
||||
|
||||
}
|
||||
|
||||
static int tmpfs_link(dirnode_t* parent, char* name, vnode_t* link){
|
||||
|
||||
if(!hashtable_insert(&parent->children, name, link))
|
||||
return ENOMEM;
|
||||
|
||||
++link->st.st_nlink;
|
||||
|
||||
}
|
||||
|
||||
static fscalls_t funcs = {
|
||||
tmpfs_mount, tmpfs_unmount, tmpfs_open, tmpfs_close, tmpfs_mkdir, tmpfs_create, tmpfs_write, tmpfs_read, tmpfs_getdirent, tmpfs_chmod, tmpfs_mksocket, tmpfs_symlink, tmpfs_readlink
|
||||
tmpfs_mount, tmpfs_unmount, tmpfs_open, tmpfs_close, tmpfs_mkdir, tmpfs_create, tmpfs_write, tmpfs_read, tmpfs_getdirent, tmpfs_chmod, tmpfs_mksocket, tmpfs_symlink, tmpfs_readlink, tmpfs_link
|
||||
};
|
||||
|
||||
|
||||
|
||||
+41
-8
@@ -297,9 +297,7 @@ int vfs_mksocket(dirnode_t* ref, char* path, mode_t mode){
|
||||
|
||||
spinlock_release(&lock);
|
||||
|
||||
if(result) return result;
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
int vfs_symlink(dirnode_t* ref, char* path, char* target, mode_t mode){
|
||||
@@ -334,12 +332,49 @@ int vfs_symlink(dirnode_t* ref, char* path, char* target, mode_t mode){
|
||||
|
||||
spinlock_release(&lock);
|
||||
|
||||
if(result) return result;
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int vfs_link(dirnode_t* ref, vnode_t* link, char* path){
|
||||
|
||||
dirnode_t* parent = NULL;
|
||||
dirnode_t* buff = NULL;
|
||||
char name[512];
|
||||
|
||||
spinlock_acquire(&lock);
|
||||
|
||||
int result = vfs_resolvepath(&buff, &parent, ref, path, name, true, VFS_MAX_LOOP);
|
||||
|
||||
if(buff){
|
||||
spinlock_release(&lock);
|
||||
return EEXIST;
|
||||
}
|
||||
|
||||
if(!parent){
|
||||
spinlock_release(&lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(!parent->vnode.fs->calls->link){
|
||||
spinlock_release(&lock);
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
if(link->fs != parent->vnode.fs)
|
||||
return EXDEV;
|
||||
|
||||
result = parent->vnode.fs->calls->link(parent, link, name);
|
||||
|
||||
spinlock_release(&lock);
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int vfs_mkdir(dirnode_t* ref, char* path, mode_t mode){
|
||||
|
||||
dirnode_t* parent = NULL;
|
||||
@@ -365,9 +400,7 @@ int vfs_mkdir(dirnode_t* ref, char* path, mode_t mode){
|
||||
|
||||
spinlock_release(&lock);
|
||||
|
||||
if(result) return result;
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
int vfs_mount(dirnode_t* ref, char* device, char* mountpoint, char* fs, int mountflags, void* fsinfo){
|
||||
|
||||
Reference in New Issue
Block a user