mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 05:58:22 +00:00
devman and vfs: check if a function is not implemented before calling
This commit is contained in:
+1
-5
@@ -45,10 +45,6 @@ static int devfs_open(dirnode_t* parent, char* name){
|
||||
}
|
||||
|
||||
static int devfs_close(){return 0;}
|
||||
static int devfs_mkdir() UNIMPLEMENTED
|
||||
static int devfs_create() UNIMPLEMENTED
|
||||
static int devfs_write() UNIMPLEMENTED
|
||||
static int devfs_read() UNIMPLEMENTED
|
||||
|
||||
static int devfs_getdirent(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount){
|
||||
|
||||
@@ -84,7 +80,7 @@ static int devfs_chmod(vnode_t* node, mode_t mode){
|
||||
}
|
||||
|
||||
static fscalls_t devfscalls = {
|
||||
devfs_mount, devfs_unmount, devfs_open, devfs_close, devfs_mkdir, devfs_create, devfs_write, devfs_read, devfs_getdirent, devfs_chmod
|
||||
devfs_mount, devfs_unmount, devfs_open, devfs_close, NULL, NULL, NULL, NULL, devfs_getdirent, devfs_chmod
|
||||
};
|
||||
|
||||
void devfs_init(){
|
||||
|
||||
+17
-2
@@ -87,7 +87,9 @@ int vfs_write(int* error, vnode_t* node, void* buff, size_t count, size_t offset
|
||||
|
||||
return writecount;
|
||||
}
|
||||
|
||||
|
||||
if(!node->fs->calls->write)
|
||||
return ENOSYS;
|
||||
|
||||
spinlock_acquire(&lock);
|
||||
|
||||
@@ -156,7 +158,6 @@ int vfs_read(int* error, vnode_t* node, void* buff, size_t count, size_t offset,
|
||||
if(!fd)
|
||||
fd = &tmpfd;
|
||||
|
||||
|
||||
int type = GETTYPE(node->st.st_mode);
|
||||
|
||||
if(type == TYPE_SOCKET)
|
||||
@@ -175,6 +176,9 @@ int vfs_read(int* error, vnode_t* node, void* buff, size_t count, size_t offset,
|
||||
int readcount = devman_read(error, node->st.st_rdev, buff, count, offset);
|
||||
return readcount;
|
||||
}
|
||||
|
||||
if(!node->fs->calls->read)
|
||||
return ENOSYS;
|
||||
|
||||
spinlock_acquire(&lock);
|
||||
|
||||
@@ -187,6 +191,9 @@ int vfs_read(int* error, vnode_t* node, void* buff, size_t count, size_t offset,
|
||||
}
|
||||
|
||||
int vfs_close(vnode_t* node){
|
||||
|
||||
if(!node->fs->calls->close)
|
||||
return ENOSYS;
|
||||
|
||||
spinlock_acquire(&lock);
|
||||
|
||||
@@ -207,6 +214,9 @@ int vfs_close(vnode_t* node){
|
||||
int vfs_getdirent(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount){
|
||||
|
||||
int err = 0;
|
||||
|
||||
if(!node->vnode.fs->calls->getdirent)
|
||||
return ENOSYS;
|
||||
|
||||
spinlock_acquire(&lock);
|
||||
|
||||
@@ -295,6 +305,11 @@ int vfs_create(dirnode_t* ref, char* path, mode_t mode){
|
||||
spinlock_release(&lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(!parent->vnode.fs->calls->create){
|
||||
spinlock_release(&lock);
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
result = parent->vnode.fs->calls->create(parent, name, mode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user