summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-30 11:41:20 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-30 11:41:20 -0400
commit9da9cd84dd084f521d9cbdae292deea96e36f86c (patch)
tree40fda2070a2ba8db6900c1a6bbc9a194c26f6c65 /kernel/include
parentlossy RLE for apple (diff)
downloadcomus-9da9cd84dd084f521d9cbdae292deea96e36f86c.tar.gz
comus-9da9cd84dd084f521d9cbdae292deea96e36f86c.tar.bz2
comus-9da9cd84dd084f521d9cbdae292deea96e36f86c.zip
update fs headers 3.0
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/comus/fs.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/kernel/include/comus/fs.h b/kernel/include/comus/fs.h
index 77d065e..5989afc 100644
--- a/kernel/include/comus/fs.h
+++ b/kernel/include/comus/fs.h
@@ -83,6 +83,16 @@ struct stat {
unsigned long s_length;
};
+/// seek whence
+enum {
+ /// seek from start of file
+ SEEK_SET = 0,
+ /// seek from current position
+ SEEK_CUR = 1,
+ /// seek from end of file
+ SEEK_END = 2,
+};
+
/// generic file pointer type. file system open function
/// must extend this struct, allocate it on the heap,
/// and return it as a generic file pointer.
@@ -103,13 +113,16 @@ struct stat {
/// size_t sector; // data
/// };
///
-/// int example_open(const char *fullpath, struct file **out)
+/// int example_open(struct file_system *fs, const char *fullpath,
+/// struct file **out)
/// {
/// struct example_file *file;
///
/// // do some checks here to get file info at full path
+/// // header = example_locate(fs, fullpath); ??
///
/// file = kalloc(sizeof(struct example_file));
+/// file->f_type = F_REG;
/// file->read = example_read;
/// file->write = example_write;
/// file->seek = example_seek;
@@ -121,10 +134,12 @@ struct stat {
/// ```
///
struct file {
+ /// file type
+ enum file_type f_type;
/// read from the file
int (*read)(struct file *file, char *buffer, size_t nbytes);
/// write into the file
- int (*write)(struct file *file, char *buffer, size_t nbytes);
+ int (*write)(struct file *file, const char *buffer, size_t nbytes);
/// seeks the file
int (*seek)(struct file *file, long int offset, int whence);
/// get directory entry at index
@@ -185,9 +200,9 @@ struct file_system {
/// filesystem name
const char *fs_name;
/// opens a file
- int (*open)(const char *fullpath, struct file **out);
+ int (*open)(struct file_system *fs, const char *fullpath, struct file **out);
/// stats a file
- int (*stat)(const char *fullpath, struct stat *file);
+ int (*stat)(struct file_system *fs, const char *fullpath, struct stat *file);
};
// list of all disks on the system