diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-07-10 11:31:46 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-07-10 11:31:46 +0800 |
| commit | e90b72ec3082588b296956730bd2930cf8d5d671 (patch) | |
| tree | 36ff6916af9b4176ea5a9662219d11e721f0b691 /include/fs/file.h | |
| parent | 1767d390fbf3d0c65389de46caf0b6d43ef3b6ad (diff) | |
| download | lume-e90b72ec3082588b296956730bd2930cf8d5d671.tar.gz lume-e90b72ec3082588b296956730bd2930cf8d5d671.tar.xz | |
refactor: promote new architecture to repository root
Archive the deprecated implementation under lume-legacy, make the new kernel the default root-level build, and update repository entry points without changing kernel behavior.
Diffstat (limited to 'include/fs/file.h')
| -rw-r--r-- | include/fs/file.h | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/include/fs/file.h b/include/fs/file.h deleted file mode 100644 index 9aff1af..0000000 --- a/include/fs/file.h +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2026 Richard QIn - */ - -#pragma once -#include "common/types.h" -#include "fs/fs.h" - -enum FileType -{ - FD_NONE, - FD_INODE, - FD_DEVICE, - FD_PIPE -}; - -class Pipe; - -struct file -{ - enum FileType type; - int ref; - char readable; - char writable; - - Pipe *pipe; // pipeline pointer - Inode *ip; // VFS Inode - uint32 off; // Current Offset -}; - -class Pipe -{ -public: - static constexpr uint32_t SIZE = 512; - - Pipe() : nread(0), nwrite(0), read_open(true), write_open(true) - { - lock.init("pipe"); - } - - // forbid copy - Pipe(const Pipe &) = delete; - Pipe &operator=(const Pipe &) = delete; - - ~Pipe() - { - // - } - - // creates a pair of connected file objects - static int create_pair(struct file **f0, struct file **f1); - - int read(uint64_t addr, int n); - int write(uint64_t addr, int n); - void close(bool is_writer); - -private: - Spinlock lock; - char data[SIZE]; - uint32_t nread; // read - uint32_t nwrite; // write - bool read_open; - bool write_open; -}; - -namespace FileTable -{ - void init(); - struct file *alloc(); // Allocate a free file handle - struct file *dup(struct file *f); // Duplicate handle (sys_dup) - void close(struct file *f); // Close handle - - int stat(struct file *f, uint64 addr); - int read(struct file *f, uint64 addr, int n); - int write(struct file *f, uint64 addr, int n); - int lseek(struct file *f, int offset, int whence); -} // namespace FileTable |
