diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-11-19 23:48:03 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-11-19 23:48:03 +0000 |
commit | 2545d1f2a82bc7c23abc0034958b169f9fffe613 (patch) | |
tree | f0240aea48e98d3515b0ee7d49904fe8fe4744de /src | |
parent | d013208dd0cbd42b4f46279772d02ec85c47735f (diff) | |
download | libbu++-2545d1f2a82bc7c23abc0034958b169f9fffe613.tar.gz libbu++-2545d1f2a82bc7c23abc0034958b169f9fffe613.tar.bz2 libbu++-2545d1f2a82bc7c23abc0034958b169f9fffe613.tar.xz libbu++-2545d1f2a82bc7c23abc0034958b169f9fffe613.zip |
MyriadFs is starting out...but the FUSE system is...akward at best.
Diffstat (limited to '')
-rw-r--r-- | src/file.cpp | 1 | ||||
-rw-r--r-- | src/myriad.h | 2 | ||||
-rw-r--r-- | src/myriadfs.cpp | 72 | ||||
-rw-r--r-- | src/myriadfs.h | 20 | ||||
-rw-r--r-- | src/tools/myriadfs.cpp | 38 |
5 files changed, 127 insertions, 6 deletions
diff --git a/src/file.cpp b/src/file.cpp index 0566ee8..008b88e 100644 --- a/src/file.cpp +++ b/src/file.cpp | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <sys/stat.h> | 11 | #include <sys/stat.h> |
12 | #include <fcntl.h> | 12 | #include <fcntl.h> |
13 | #include <unistd.h> | 13 | #include <unistd.h> |
14 | #include <stdlib.h> // for mkstemp | ||
15 | #include <time.h> | 14 | #include <time.h> |
16 | 15 | ||
17 | #include "bu/config.h" | 16 | #include "bu/config.h" |
diff --git a/src/myriad.h b/src/myriad.h index 79c3cda..ed0ef53 100644 --- a/src/myriad.h +++ b/src/myriad.h | |||
@@ -46,7 +46,7 @@ namespace Bu | |||
46 | * Header format is as follows: | 46 | * Header format is as follows: |
47 | * | 47 | * |
48 | * MMMMvBssssSSSS* | 48 | * MMMMvBssssSSSS* |
49 | * M = Magic number (FFC399BD) | 49 | * M = Magic number (0AD3FA84) |
50 | * v = version number | 50 | * v = version number |
51 | * B = Bits per int | 51 | * B = Bits per int |
52 | * s = Blocksize in bytes | 52 | * s = Blocksize in bytes |
diff --git a/src/myriadfs.cpp b/src/myriadfs.cpp index bb72cd5..af60c08 100644 --- a/src/myriadfs.cpp +++ b/src/myriadfs.cpp | |||
@@ -1,7 +1,75 @@ | |||
1 | #include "myriadfs.h" | 1 | #include "bu/myriadfs.h" |
2 | #include "bu/myriadstream.h" | ||
2 | 3 | ||
3 | Bu::MyriadFs::MyriadFs() | 4 | #include <string.h> |
5 | #include <unistd.h> | ||
6 | |||
7 | namespace Bu { subExceptionDef( MyriadFsException ) } | ||
8 | |||
9 | #define Myriad_Fs_MAGIC_CODE ((char *)"\xa7\x18\x8b\x39") | ||
10 | |||
11 | Bu::MyriadFs::MyriadFs( Bu::Stream &rStore, int iBlockSize ) : | ||
12 | rStore( rStore ), | ||
13 | mStore( rStore, iBlockSize ) | ||
4 | { | 14 | { |
15 | if( mStore.hasStream( 1 ) ) | ||
16 | { | ||
17 | // Check to see if this is a MyriadFs stream. | ||
18 | Bu::MyriadStream ms = mStore.openStream( 1 ); | ||
19 | char sMagic[4]; | ||
20 | if( ms.read( sMagic, 4 ) < 4 ) | ||
21 | throw MyriadFsException("The provided stream does not appear to be " | ||
22 | "a MyriadFs stream."); | ||
23 | if( ::strncmp( sMagic, Myriad_Fs_MAGIC_CODE, 4 ) ) | ||
24 | throw MyriadFsException("The provided stream does not appear to be " | ||
25 | "a MyriadFs stream."); | ||
26 | |||
27 | int8_t iVer; | ||
28 | } | ||
29 | else | ||
30 | { | ||
31 | // Create initial header stream | ||
32 | { | ||
33 | mStore.createStream( 1 ); | ||
34 | Bu::MyriadStream ms = mStore.openStream( 1 ); | ||
35 | ms.write( Myriad_Fs_MAGIC_CODE, 4 ); | ||
36 | int8_t iVer = 1; | ||
37 | int32_t iTmp = 1; | ||
38 | ms.write( &iVer, 1 ); | ||
39 | ms.write( &iBlockSize, 4 ); | ||
40 | ms.write( &iTmp, 4 ); // iNumNodes | ||
41 | iTmp = 0; | ||
42 | ms.write( &iTmp, 4 ); // iInode | ||
43 | ms.write( &iTmp, 0 ); // iPosition | ||
44 | } | ||
45 | |||
46 | // Create initial inode stream, with one root node. | ||
47 | { | ||
48 | mStore.createStream( 2 ); | ||
49 | Bu::MyriadStream ms = mStore.openStream( 2 ); | ||
50 | int32_t iUser = 0, iGroup = 0; | ||
51 | #ifndef WIN32 | ||
52 | iUser = getuid(); | ||
53 | iGroup = getgid(); | ||
54 | #endif | ||
55 | int32_t iTmp32 = 0; | ||
56 | int16_t iTmp16 = 0; | ||
57 | ms.write( &iUser, 4 ); | ||
58 | ms.write( &iGroup, 4 ); | ||
59 | ms.write( &iTmp16, 2 ); | ||
60 | ms.write( &iTmp16, 2 ); | ||
61 | iTmp32 = 3; | ||
62 | ms.write( &iTmp32, 4 ); | ||
63 | iTmp32 = 0; | ||
64 | ms.write( &iTmp32, 4 ); | ||
65 | ms.write( &iTmp16, 2 ); | ||
66 | } | ||
67 | |||
68 | // Create inode 0's storage stream. | ||
69 | { | ||
70 | mStore.createStream( 3 ); | ||
71 | } | ||
72 | } | ||
5 | } | 73 | } |
6 | 74 | ||
7 | Bu::MyriadFs::~MyriadFs() | 75 | Bu::MyriadFs::~MyriadFs() |
diff --git a/src/myriadfs.h b/src/myriadfs.h index 687584b..42a3493 100644 --- a/src/myriadfs.h +++ b/src/myriadfs.h | |||
@@ -1,13 +1,20 @@ | |||
1 | #ifndef MYRIAD_FS_H | 1 | #ifndef MYRIAD_FS_H |
2 | #define MYRIAD_FS_H | 2 | #define MYRIAD_FS_H |
3 | 3 | ||
4 | #include "bu/myriad.h" | ||
5 | |||
4 | namespace Bu | 6 | namespace Bu |
5 | { | 7 | { |
8 | class Stream; | ||
9 | |||
10 | subExceptionDecl( MyriadFsException ); | ||
11 | |||
6 | /** | 12 | /** |
7 | * A POSIX compliant, node based filesystem built on top of Myriad. | 13 | * A POSIX compliant, node based filesystem built on top of Myriad. |
8 | * | 14 | * |
15 | * A header is placed into stream 1. | ||
9 | * Header format: | 16 | * Header format: |
10 | * int32_t iMagicHeader | 17 | * int32_t iMagicHeader (A7188B39) |
11 | * int8_t iVersion (1) | 18 | * int8_t iVersion (1) |
12 | * int32_t iNodeSize | 19 | * int32_t iNodeSize |
13 | * int32_t iNumNodes | 20 | * int32_t iNumNodes |
@@ -17,6 +24,11 @@ namespace Bu | |||
17 | * int32_t iInode | 24 | * int32_t iInode |
18 | * int32_t iPosition | 25 | * int32_t iPosition |
19 | * | 26 | * |
27 | * The node headers or inode structures have a base size of 22 bytes. | ||
28 | * Everything else in the block is used for the name. I.e. if you have | ||
29 | * a blocksize of 512 bytes then you wind up with a max name size of | ||
30 | * 512-22=490 characters, or a blocksize of 256 gives you 234 chraacters | ||
31 | * as a max. The node headers are all stored in stream 2. | ||
20 | * Basic node header format: | 32 | * Basic node header format: |
21 | * int32_t iUser | 33 | * int32_t iUser |
22 | * int32_t iGroup | 34 | * int32_t iGroup |
@@ -30,8 +42,12 @@ namespace Bu | |||
30 | class MyriadFs | 42 | class MyriadFs |
31 | { | 43 | { |
32 | public: | 44 | public: |
33 | MyriadFs(); | 45 | MyriadFs( Bu::Stream &rStore, int iBlockSize=512 ); |
34 | virtual ~MyriadFs(); | 46 | virtual ~MyriadFs(); |
47 | |||
48 | private: | ||
49 | Bu::Stream &rStore; | ||
50 | Bu::Myriad mStore; | ||
35 | }; | 51 | }; |
36 | }; | 52 | }; |
37 | 53 | ||
diff --git a/src/tools/myriadfs.cpp b/src/tools/myriadfs.cpp new file mode 100644 index 0000000..66955a5 --- /dev/null +++ b/src/tools/myriadfs.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | #define FUSE_USE_VERSION 26 | ||
2 | |||
3 | #include <fuse.h> | ||
4 | |||
5 | #include <string.h> | ||
6 | |||
7 | extern "C" { | ||
8 | static int myriadfs_getattr( const char *sPath, struct stat *stbuf ) | ||
9 | { | ||
10 | |||
11 | } | ||
12 | |||
13 | static int myriadfs_readdir( const char *sPath, void *buf, | ||
14 | fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi ) | ||
15 | { | ||
16 | } | ||
17 | |||
18 | static int myriadfs_open( const char *sPath, struct fuse_file_info *fi ) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | static int myriadfs_read( const char *sPath, char *buf, size_t iSize, | ||
23 | off_t iOffset, struct fuse_file_info *fi ) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | static struct fuse_operations myriadfs_oper; | ||
28 | |||
29 | int main( int argc, char *argv[] ) | ||
30 | { | ||
31 | memset( &myriadfs_oper, sizeof(myriadfs_oper), 0 ); | ||
32 | myriadfs_oper.getattr = myriadfs_getattr; | ||
33 | myriadfs_oper.readdir = myriadfs_readdir; | ||
34 | myriadfs_oper.open = myriadfs_open; | ||
35 | myriadfs_oper.read = myriadfs_read; | ||
36 | return fuse_main( argc, argv, &myriadfs_oper, NULL ); | ||
37 | } | ||
38 | } | ||