summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/include/fs/fs.h
diff options
context:
space:
mode:
authorleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-08-31 16:56:06 +0200
committerleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-08-31 16:56:06 +0200
commitaa1eb39e9266c51082ed2d8744e97ad674b6496c (patch)
tree0dfbead4937804b8154f98ee3864b24e9e024260 /sw/z80/kernel/include/fs/fs.h
parenttime to inode (diff)
downloadz80uPC-aa1eb39e9266c51082ed2d8744e97ad674b6496c.tar.gz
z80uPC-aa1eb39e9266c51082ed2d8744e97ad674b6496c.zip
File system interface
Basic file system implementation Path resolution work in progress
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 2a0e9d4..b92303d 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 */
- uint24_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__