summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/include/fs/fs.h
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-09-10 17:50:20 +0200
committerNao Pross <naopross@thearcway.org>2017-09-10 17:50:20 +0200
commit828c21bd4dc3b168a3182458ca167d742a192bd6 (patch)
tree81a0616d958d1d26bc2035e303ff84fc17ed624b /sw/z80/kernel/include/fs/fs.h
parentpartial implementation for ctc drivers and memory management (diff)
parentmacro fix (diff)
downloadz80uPC-828c21bd4dc3b168a3182458ca167d742a192bd6.tar.gz
z80uPC-828c21bd4dc3b168a3182458ca167d742a192bd6.zip
Merge remote-tracking branch 'origin/atlas' into naopross
Diffstat (limited to 'sw/z80/kernel/include/fs/fs.h')
-rw-r--r--sw/z80/kernel/include/fs/fs.h80
1 files changed, 38 insertions, 42 deletions
diff --git a/sw/z80/kernel/include/fs/fs.h b/sw/z80/kernel/include/fs/fs.h
index 81c86b7..ad20adb 100644
--- a/sw/z80/kernel/include/fs/fs.h
+++ b/sw/z80/kernel/include/fs/fs.h
@@ -1,5 +1,5 @@
-#ifndef INODE_H
-#define INODE_H
+#ifndef __FS_H__
+#define __FS_H__
#include "types.h"
@@ -11,57 +11,53 @@
#define INODE_TYPE_FILE 0x0
#define INODE_TYPE_DIR 0x1
-#define INODE_TYPE_HLINK 0x2
-#define INODE_TYPE_SLINK 0x3
+#define INODE_TYPE_SLINK 0x2
+#define INODE_TYPE_SPECIAL 0x3
-typedef struct time_s
+#define INODE_META_SIZE 8
+
+/* inode basic structure */
+struct fs_inode
{
- struct
- {
- uint minutes :6;
- uint hour :5;
+ /* inode meta data */
- } time;
+ uint mode :3; // chmod
+ uint uid :3; // chown
+ uint type :2; // file, dir, sym-link, special
- struct
- {
- uint day :5;
- uint month :4;
- uint year :12;
+ time_t ctime; // creation time
- } date;
+ uint24_t size; // inode size
-} time_t;
+ /* data storage informations */
+ /* it doesn't allocate memory, virtual size FS_BLOCKS_N */
+ blk_t blocks[];
+};
-struct fs_superblock
-{
- uint8_t magic; // identifier
+#define FS_DEV_ROM 0x7f /* 01111111 */
+#define FS_DEV_NULL 0x80 /* 10000000 */
- uint16_t blk_size; // size of a single block
- uint16_t imap_size; // quantity of inodes
- uint16_t dmap_size; // quantity of blocks
-}
+#define FS_ROM_SPACE 0x2000 // second rom
-struct fs_inode
-{
-
- /* inode meta data */
- uint mode :3; // chmod
- uint uid :3; // chown
- uint type :2; // file, dir, hard-link, sym-link
+#define FS_INO_ROOT 0x0 // first inode
- time_t ctime; // creation time
+#define FS_INODE_ROOT(inode) {inode.dev = 0xff; inode.inode = 0x0}
+#define FS_INODE_NULL(inode) {inode.dev = 0x80; inode.inode = 0x0}
- /* data storage informations */
- uint16_t size;
- uint16_t blocks[FS_BLOCKS_N];
+#define FS_USE_ROM(inode) {inode.dev == 0x7f}
-}
+/* get block seek in current device */
+devsize_t fs_block(blk_t block);
-struct fs_inumber
-{
- uint dev : 4; // device id, global in the fs
- ino_t rel; // inode id relative to the volume
-}
+/* get common inode seek in current device */
+/* c_inode must be set first */
+/* returns seek at the beginning of blocks field */
+devsize_t fs_inode(struct fs_inode *buf);
+
+/* common inode for syscalls */
+extern inode_t c_inode;
+
+/* parse a path, absolute or relative to c_inode */
+inode_t fs_parse_path(const char *path);
-#endif
+#endif // __FS_H__