Nucleus
Barry Device driver interface 7864e7f (3 years, 2 months ago)
diff --git a/vfs/devfs/file.c b/vfs/devfs/file.c
index a984c1d..0217a8e 100644
--- a/vfs/devfs/file.c
+++ b/vfs/devfs/file.c
@@ -1,6 +1,9 @@
#include <stdint.h>
#include <stddef.h>
#include <string.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <nucleus/driver.h>
#include <nucleus/memory.h>
#include <nucleus/vfs.h>
@@ -71,5 +74,14 @@ devfs_write(File *file, char *buf, size_t size, off_t offset)
int
devfs_open(File *file)
{
- return 0;
+ if (S_ISREG(file->inode->mode) || S_ISDIR(file->inode->mode))
+ return 0;
+
+ /* Assign correct File Operations */
+ file->ops = find_driver(MAJOR(file->inode->dev));
+ if (!file->ops)
+ return -ENXIO;
+ if (!file->ops->open)
+ return 0;
+ return file->ops->open(file);
}