We expect v_node
to be subclassed with specific kinds of v_nodes
, and different read()
, write()
, open()
, and close()
methods.
Per process file descriptor table:
Every process will have an eight member long array of struct file descriptors. A member will be present if a file is open. The struct file_descriptor
contains its own index, and a file*
that corresponds to its open file the system-wide open_files
array.
System-Wide open_files
Array:
There will be one system wide file array with 32 members of struct files.
A file
contains
v_node
Struct file
Content
R_PERM
), write (W_PERM
), and/or executable (X_PERM
) permissions.v_node*
:v_node
pointer. Depending on the file type, it would point to different v_nodes (i.e. keyboard console v_node, pipe v_node, …). The v_node
pointer acts as an interface for a file's interaction based function calls (open, read, etc.).file*
pointing to this file. When refcount
becomes 0, we should clear out this file
Struct v_node
Content
Each vnode will have an inode pointer, a lock, and function pointers pointing to the correct implementations dependent upon type of file. These function pointers will be set upon initialization.
v_node
Functions
{open(), read(), write(), close()
}
When a process calls one of these functions from a v_node
, a file descriptor (from per process file descriptor array) and corresponding file (from system wide file array) must be valid. Each of these functions have to be separately implemented for each v_node
subclass.
open_files_lock
protects the global open_files
array that stores the file
open file descriptor objects.
file
s in the open_files
array, it will grab this lock and increment refcountread()
and write()
should block, all other functions should not block