From 5e3d036d3a10d919e54035b1365005f26886ed75 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 8 Mar 2015 12:16:48 +0100 Subject: Change VFS a bit in preparation for IPC code : ... Handles now have a copy of data and ops, and may reference a null node in the case of an IPC channel. --- src/kernel/include/prng.h | 2 ++ src/kernel/include/vfs.h | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/kernel/include') diff --git a/src/kernel/include/prng.h b/src/kernel/include/prng.h index 0a9e036..4321ada 100644 --- a/src/kernel/include/prng.h +++ b/src/kernel/include/prng.h @@ -1,3 +1,5 @@ +#pragma once + #include #include diff --git a/src/kernel/include/vfs.h b/src/kernel/include/vfs.h index a34681b..90944b2 100644 --- a/src/kernel/include/vfs.h +++ b/src/kernel/include/vfs.h @@ -40,15 +40,22 @@ struct fs; struct fs_node; typedef struct user_region user_region_t; +typedef struct fs_node_ops fs_node_ops_t; // ------------------------------------------- // Structure defining a handle to an open file // This structure is entirely managed by the VFS, the underlying filesystem does not see it +// For IPC structures (sockets, channels), fs and node are null because the handle does not reference +// an underlying object. The ops and data fields are filled in by the IPC code with corresponding +// data structures. All VFS calls are done on ops and data as specified in the handle and not the node. typedef struct fs_handle { struct fs *fs; struct fs_node *node; + fs_node_ops_t *ops; + fs_node_ptr data; + int refs; int mode; @@ -74,7 +81,7 @@ typedef struct fs_handle { // - dispose() is not called on the root node when a filesystem is shutdown // - delete() is not expected to delete recursively : it should fail on a non-empty directory -typedef struct { +typedef struct fs_node_ops { bool (*open)(fs_node_ptr n, int mode); size_t (*read)(fs_node_ptr f, size_t offset, size_t len, char* buf); size_t (*write)(fs_node_ptr f, size_t offset, size_t len, const char* buf); -- cgit v1.2.3