libfs: add support for special files not backed by a filesystem

This commit is contained in:
2026-04-01 18:57:59 +01:00
parent f2e6e7785d
commit 8ebf44dca9
3 changed files with 7 additions and 1 deletions
+5
View File
@@ -1,5 +1,10 @@
#include "file.h"
void fs_file_set_ops(struct fs_file *f, const struct fs_file_ops *ops)
{
f->f_ops = ops;
}
struct fs_inode *fs_file_get_inode(const struct fs_file *f)
{
return f->f_inode;
+1
View File
@@ -23,6 +23,7 @@ struct fs_file_ops {
*f_readdir)(struct fs_file *, struct xpc_buffer *, off_t *);
};
extern void fs_file_set_ops(struct fs_file *f, const struct fs_file_ops *ops);
extern struct fs_inode *fs_file_get_inode(const struct fs_file *f);
extern size_t fs_file_get_cursor(const struct fs_file *f);
extern enum fs_status fs_file_read(
+1 -1
View File
@@ -39,7 +39,7 @@ extern kern_status_t fs_msg_seek(
return KERN_OK;
}
if (new_offset > f->f_inode->i_size) {
if (f->f_inode && new_offset > f->f_inode->i_size) {
*out_err = EINVAL;
return KERN_OK;
}