summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-08-23 21:13:06 +0200
committerleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-08-23 21:13:06 +0200
commit7fa5e85eb624f0f614e022c8a8274bbb4de66cbf (patch)
tree925be0a481e4cc2f48f0b5eb703832f179d5be80
parentfilesystem structure intro and docs (diff)
downloadz80uPC-7fa5e85eb624f0f614e022c8a8274bbb4de66cbf.tar.gz
z80uPC-7fa5e85eb624f0f614e022c8a8274bbb4de66cbf.zip
Filesystem struct order
-rw-r--r--sw/z80/kernel/filesystem.c45
-rw-r--r--sw/z80/kernel/include/filesystem.h56
2 files changed, 79 insertions, 22 deletions
diff --git a/sw/z80/kernel/filesystem.c b/sw/z80/kernel/filesystem.c
index 101af75..38a5456 100644
--- a/sw/z80/kernel/filesystem.c
+++ b/sw/z80/kernel/filesystem.c
@@ -1 +1,44 @@
-#include "filesystem.h" \ No newline at end of file
+#include "filesystem.h"
+
+struct filesystem * fs_parse_superblock(struct filesystem *fs)
+{
+
+}
+
+/* resolves an arbitrary path */
+uint16_t fs_parse_path(const char *path)
+{
+
+}
+
+/* gets inode from inumber */
+inode_t * fs_get_inode(inode_t *buffer, uint16_t i_number)
+{
+
+}
+
+inode_t * fs_new_inode(inode_t *inode, const char *name)
+{
+
+}
+
+int fs_free_inode(const inode_t *inode)
+{
+
+}
+
+void fs_chmod(inode_t *inode, uint8_t mode)
+{
+
+}
+
+void fs_chown(inode_t *inode, uint8_t uid)
+{
+
+}
+
+int fs_rename(inode_t *inode, const char *name)
+{
+
+}
+
diff --git a/sw/z80/kernel/include/filesystem.h b/sw/z80/kernel/include/filesystem.h
index 6505d5e..98c1e90 100644
--- a/sw/z80/kernel/include/filesystem.h
+++ b/sw/z80/kernel/include/filesystem.h
@@ -5,9 +5,8 @@
#define FS_OFFSET 0x1000
-#define FS_BLOCK_SIZE 512
+#define FS_BLOCKS_SIZE 512
#define FS_BLOCKS_N 12
-/* #define FS_IBLOCKS_N 1 */
#define INODE_TYPE_FILE 0
#define INODE_TYPE_DIR 1
@@ -17,44 +16,47 @@ typedef struct time_s
{
uint16_t time;
uint16_t date;
+
} time_t;
/* on-disk structures */
struct fs_superblock
{
- uint8_t magic;
- uint16_t blk_size; /* default is 512 bytes */
- uint16_t imap_size; /* size of the inode bitmap in blocks */
- uint16_t dmap_size; /* size of the data blocks map in blocks */
+ uint magic :5; /* identifier */
+ uint serial_port :3; /* serial port id from serial.h */
+ uint16_t blk_size; /* default is 512 bytes */
+ uint16_t imap_size; /* size of the inode table in blocks */
+ uint16_t dmap_size; /* size of the data blocks map in blocks */
};
-struct fs_blk
+struct fs_blk_entry
{
- uint size;
+ uint16_t b_number; /* block number */
+ uint16_t data_size; /* bytes used */
};
typedef struct fs_inode
{
- uint i_used :1; // inode is free
- uint i_mode :3; // inode mode (rwx)
- uint8_t i_uid; // user (owner) id
- uint16_t i_number; // identifier
+ uint16_t i_number; /* identifier */
- uint16_t i_blocks; // number of blocks
+ uint i_mode :3; /* inode mode (rwx) */
+ uint i_uid :3; /* user (owner) id */
+ uint i_type :2; /* inode type */
- struct fs_blk i_block[FS_BLOCKS_N]; // direct blocks
-/* struct fs_blk i_iblock[FS_IBLOCKS_N]; // indirect blocks */
+ uint8_t i_blocks; /* number of blocks */
+ struct fs_blk_entry i_block[FS_BLOCKS_N]; /* direct blocks */
- inode_t *parent;
+ uint16_t parent;
+
} inode_t;
/* inode table structures */
+/* i_number is derived from location */
struct fs_inode_entry
{
- uint16_t i_number;
uint8_t str_len;
char name[24];
};
@@ -67,11 +69,23 @@ struct filesystem
inode_t *mntpt;
};
-void fs_parse_superblock(struct filesystem *fs);
+struct filesystem * fs_parse_superblock(struct filesystem *fs);
+
+/* resolves an arbitrary path */
+uint16_t fs_parse_path(const char *path);
+
+/* gets inode from inumber */
+inode_t * fs_get_inode(inode_t *buffer, uint16_t i_number);
+
+inode_t * fs_new_inode(inode_t *inode, const char *name);
+
+int fs_free_inode(const inode_t *inode);
+
+void fs_chmod(inode_t *inode, uint8_t mode);
+
+void fs_chown(inode_t *inode, uint8_t uid);
-void fs_write_imap();
-void fs_write_dmap();
+int fs_rename(inode_t *inode, const char *name);
-/* void fs_ */
#endif // __FILESYSTEM_H__