summaryrefslogtreecommitdiff
path: root/include/kernel/fs.h
blob: a2b0086a65b2c53187d86bb3d4820ed9587feabe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _FS_H
#define _FS_H

#include <stdint.h>
#include <sys/types.h>

#define NRSUPER 8
#define NRFILE 128
#define NROPEN 32

/* these shouldn't change */
#define BLOCK_SIZE 1024
#define SUPER_MAGIC 0x137F

struct file {
  uint16_t f_mode;
  uint16_t f_flags;
  /* TODO: inode pointer here */
  off_t f_pos;
};

struct super_block {
  uint16_t s_ninodes;
  uint16_t s_nzones;
  uint16_t s_imap_blocks;
  uint16_t s_zmap_blocks;
  uint16_t s_firstdatazone;
  uint16_t s_log_zone_size;
  uint32_t s_max_size;
  uint16_t s_magic;
  /* loaded in memory only */
  struct s_buff *s_imap[8];
  struct s_buff *s_zmap[8];
  uint16_t s_dev;
  uint16_t s_dirt;
  uint16_t s_start;
  uint16_t s_super;
  uint16_t s_imap_off;
  uint16_t s_zmap_off;
  uint16_t s_inode_off;
} __attribute__((packed));

struct m_inode {
  uint16_t i_mode;
  uint16_t i_uid;
  uint32_t i_size;
  uint32_t i_mtime;
  uint8_t i_gid;
  uint8_t i_nlinks;
  uint16_t i_zone[9];
} __attribute__((packed));

extern struct super_block sblocks[NRSUPER];

size_t block_read(void*, size_t , size_t);
size_t block_write(void*, size_t , size_t);

void mount_root(void);

void fs_init(void);

#endif