kern

view src/fs.h @ 91:f83f50c17c3b

continuing with the fs added strtol and strstr to klibc
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 09 Dec 2011 15:29:54 +0200
parents 7ff2b4971216
children 083849df660b
line source
1 #ifndef FS_H_
2 #define FS_H_
4 #include <inttypes.h>
6 #define MAGIC 0xccf5ccf5
7 #define BLKSZ 1024
9 #define SECT_TO_BLK(x) ((x) / (BLKSZ / 512))
11 #define DEVNO(maj, min) ((((maj) & 0xff) << 8) | ((min) & 0xff))
12 #define DEV_MAJOR(dev) (((dev) >> 8) & 0xff)
13 #define DEV_MINOR(dev) ((dev) & 0xff)
16 typedef uint32_t dev_t;
17 typedef uint32_t blkid;
19 struct superblock {
20 uint32_t magic; /* magic number */
21 int ver; /* filesystem version */
22 int blksize; /* only BLKSZ supported at the moment */
24 /* total number of blocks */
25 unsigned int num_blocks;
26 /* inode allocation bitmap start and count */
27 blkid ibm_start;
28 unsigned int ibm_count;
29 /* inode table start and count */
30 blkid itbl_start;
31 unsigned int itbl_count;
32 /* data block allocation bitmap start and count */
33 blkid dbm_start;
34 unsigned int dbm_count;
35 /* data blocks start and count */
36 blkid data_start;
37 unsigned int data_count;
39 int root_ino; /* root direcotry inode */
41 /* the following are valid only at runtime, ignored on disk */
42 uint32_t *ibm; /* memory inode bitmap */
43 uint32_t *dbm; /* memory datablock bitmap */
45 } __attribute__((packed));
48 /* 20 direct blocks + 10 attributes + 2 indirect = 128 bytes per inode */
49 #define NDIRBLK 20
50 struct inode {
51 int ino;
52 int uid, gid, mode;
53 int nlink;
54 dev_t dev;
55 uint32_t atime, ctime, mtime;
56 uint32_t size;
57 blkid blk[NDIRBLK]; /* direct blocks */
58 blkid ind; /* indirect */
59 blkid dind; /* double-indirect */
60 } __attribute__((packed));
63 int sys_mount(char *mntpt, char *devname, unsigned int flags);
64 int sys_umount(char *devname);
66 int sys_open(char *pathname, int flags, unsigned int mode);
67 int sys_close(int fd);
69 int sys_read(int fd, void *buf, int sz);
70 int sys_write(int fd, void *buf, int sz);
71 long sys_lseek(int fd, long offs, int from);
73 int lookup_path(const char *path);
76 #endif /* FS_H_ */