aboutsummaryrefslogtreecommitdiffstats
path: root/SCHEMA
blob: e0673d1b7733c2985aa31a0379a238a0a6c3a7db (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
		Berkeley DB database schema for filesystem
		------------------------------------------



system environment variables:
DB_HOME:	database home dir, for transaction database + logs
DB_PASSWORD:	if present, AES-encrypt database with this password

db4 environment
===============
	"metadata": metadata
		page size 512
		little endian byte order
	"hash": hash refence counts
		page size 512
		little endian byte order
	"data": user data storage
		page size 2048
		little endian byte order
	optionally encrypted w/ DB4 AES encryption


database "metadata"
===================


inode
-----
key:	/inode/%Lu	(%Lu == inode number)

value record's fields (all little endian):

struct dbfs_raw_inode:
guint64         ino:		inode number (identity)
guint64         version:	linear sequence number, starts @ 1
guint32         mode:		unix mode_t
guint32         nlink:		number of hard links
guint32         uid:		unix user id
guint32         gid:		unix group id
guint64         rdev:		unix dev_t
guint64         size:		inode data size, in bytes
guint64         ctime:		file creation time
guint64         atime:		file last-accessed time
guint64         mtime:		file last-modified time
struct dbfs_extent blocks[0]:	array of extents, describing inode data

struct dbfs_extent:
dbfs_blk_id_t   id:		20-byte sha1 hash of DB-returned data block
guint32		off:		fragment's offset into DB-returned data
guint32		len:		length of fragment

NOTE: sha1 hash covers the entire data block, as originally written to
the database.  File modifications may cause 'off' and 'len' to change,
which implies that 'id' is no longer the sha1 hash of the current
fragment.


directories
-----------
An array of struct dbfs_dirent, aligned on DBFS_DIRENT_ALIGN bounds.

key:	/dir/%Lu		inode number associated with this dir

struct dbfs_dirent:
guint32         magic:		magic number (0xd4d4d4d4U)
guint16         res2:		reserved for future use
guint16         namelen:	length of final filename component
guint64         ino:		inode number of referenced inode
char            name[0]:	UTF8 final filename component (namelen bytes)
0-7 bytes			alignment padding

The array of struct dbfs_dirent is terminated by a final dbfs_dirent
containing a zero-length name (namelen==0).


symbolic links
--------------
key:	/symlink/%Lu		inode number associated with this symlink

value:	UTF8 string, containing link text (variable length)


extended (named) attributes
---------------------------
name max length:	256
data max length:	1MB (1024 * 1024 bytes)

key:	/xattr/%Lu/%s		inode number, attribute name

value:	variable-length binary data


key:	/xattr/%Lu		inode number

value:	An array of struct dbfs_xlist, aligned on DBFS_XLIST_ALIGN bounds.

struct dbfs_xlist:
guint32		namelen		length of attribute name
char		name[0]		UTF8 attribute name (namelen bytes)
0-7 bytes			alignment padding



database "data"
===============
Used for all data storage.  Each file is broken up into chunks of no
more than DBFS_MAX_EXT_LEN (4MB) bytes, called extents.

key:	20-byte SHA-1 hash of data contents
value:	variable-length binary data



database "hash"
===============
Used for keeping a reference count of each item in database "data".

key:	20-byte SHA-1 hash of data contents
value:	struct dbfs_hashref

struct dbfs_hashref:
guint32		refs		Object reference count.