OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [fs/] [c0fs/] [c0fs.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * The disk layout of our simple unix-like filesystem.
3
 *
4
 * Copyright (C) 2007, 2008 Bahadir Balban
5
 */
6
 
7
#ifndef __C0FS_LAYOUT_H__
8
#define __C0FS_LAYOUT_H__
9
 
10
#include <l4lib/types.h>
11
#include <l4/lib/list.h>
12
#include <l4/macros.h>
13
#include <l4/config.h>
14
#include INC_GLUE(memory.h)
15
 
16
/*
17
 *
18
 * Filesystem layout:
19
 *
20
 * |---------------|
21
 * |    Group 0    |
22
 * |---------------|
23
 * |    Group 1    |
24
 * |---------------|
25
 * |      ...      |
26
 * |---------------|
27
 * |    Group n    |
28
 * |---------------|
29
 *
30
 *
31
 * Group layout:
32
 *
33
 * |---------------|
34
 * |  Superblock   |
35
 * |---------------|
36
 * |  Inode table  |
37
 * |---------------|
38
 * |  Data blocks  |
39
 * |---------------|
40
 *
41
 * or
42
 *
43
 * |---------------|
44
 * |  Data blocks  |
45
 * |---------------|
46
 *
47
 */
48
 
49
#define BLOCK_SIZE              PAGE_SIZE
50
#define BLOCK_BITS              PAGE_BITS
51
#define GROUP_SIZE              SZ_8MB
52
#define INODE_TABLE_SIZE        ((GROUP_SIZE / BLOCK_SIZE) / 2)
53
#define INODE_BITMAP_SIZE       (INODE_TABLE_SIZE >> 5)
54
 
55
 
56
struct sfs_superblock {
57
        u32 magic;              /* Filesystem magic number */
58
        u64 fssize;             /* Total size of filesystem */
59
        u32 total;              /* To */
60
        u32 groupmap[];         /* Bitmap of all fs groups */
61
};
62
 
63
struct sfs_group_table {
64
        u32 total;
65
        u32 free;
66
        u32 groupmap[];
67
};
68
 
69
struct sfs_inode_table {
70
        u32 total;
71
        u32 free;
72
        u32 inodemap[INODE_BITMAP_SIZE];
73
        struct sfs_inode inode[INODE_TABLE_SIZE];
74
};
75
 
76
/*
77
 * The purpose of an inode:
78
 *
79
 * 1) Uniquely identify a file or a directory.
80
 * 2) Keep file/directory metadata.
81
 * 3) Provide access means to file blocks/directory contents.
82
 */
83
#define INODE_DIRECT_BLOCKS     5
84
struct sfs_inode_blocks {
85
        int  szidx;             /* Direct array index size */
86
        unsigned long indirect;
87
        unsigned long indirect2;
88
        unsigned long indirect3;
89
        unsigned long direct[];
90
};
91
 
92
struct sfs_inode {
93
        u32 unum;       /* Unit number this inode is in */
94
        u32 inum;       /* Inode number */
95
        u32 mode;       /* File permissions */
96
        u32 owner;      /* File owner */
97
        u64 atime;      /* Last access time */
98
        u64 mtime;      /* Last content modification */
99
        u64 ctime;      /* Last inode modification */
100
        u64 size;       /* Size of contents */
101
        struct sfs_inode_blocks blocks;
102
} __attribute__ ((__packed__));
103
 
104
struct sfs_dentry {
105
        u32 inum;       /* Inode number */
106
        u32 nlength;    /* Name length */
107
        u8  name[];     /* Name string */
108
} __attribute__ ((__packed__));
109
 
110
 
111
void sfs_register_type(struct link *);
112
 
113
#endif /* __C0FS_LAYOUT_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.