summaryrefslogtreecommitdiff
path: root/src/myriadfs.h
blob: edbdaf5f1d44ab9e8573c5659c9fc08f08873fec (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
/*
 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#ifndef MYRIAD_FS_H
#define MYRIAD_FS_H

#include "bu/myriad.h"

namespace Bu
{
	class Stream;

	subExceptionDecl( MyriadFsException );

	/**
	 * A POSIX compliant, node based filesystem built on top of Myriad.
	 *
	 * A header is placed into stream 1.
	 * Header format:
	 *   int32_t iMagicHeader  (A7188B39)
	 *   int8_t iVersion (1)
	 *   int32_t iNodeSize
	 *   int32_t iNumNodes
	 *   NodeLookup[iNumNodes] nNode
	 *
	 * Node lookup:
	 *   int32_t iInode
	 *   int32_t iPosition
	 *
	 * The node headers or inode structures have a base size of 22 bytes.
	 * Everything else in the block is used for the name.  I.e. if you have
	 * a blocksize of 512 bytes then you wind up with a max name size of
	 * 512-22=490 characters, or a blocksize of 256 gives you 234 chraacters
	 * as a max.  The node headers are all stored in stream 2.
	 * Basic node header format:
	 *   int32_t iUser
	 *   int32_t iGroup
	 *   int16_t iMeta
	 *   int16_t iPerms
	 *   int32_t iStreamIndex
	 *   int32_t iParentNode
	 *   int16_t iNameSize
	 *   char[iNameSize] sName
	 */
	class MyriadFs
	{
	public:
		MyriadFs( Bu::Stream &rStore, int iBlockSize=512 );
		virtual ~MyriadFs();

	private:
		Bu::Stream &rStore;
		Bu::Myriad mStore;
	};
};

#endif