diff options
Diffstat (limited to 'src/unstable')
-rw-r--r-- | src/unstable/myriadcache.h | 4 | ||||
-rw-r--r-- | src/unstable/myriadfs.cpp | 30 | ||||
-rw-r--r-- | src/unstable/myriadfs.h | 14 |
3 files changed, 28 insertions, 20 deletions
diff --git a/src/unstable/myriadcache.h b/src/unstable/myriadcache.h index d6842a5..f71f9b5 100644 --- a/src/unstable/myriadcache.h +++ b/src/unstable/myriadcache.h | |||
@@ -86,8 +86,8 @@ namespace Bu | |||
86 | { | 86 | { |
87 | Bu::ReadWriteMutex::WriteLocker wl( rwStore ); | 87 | Bu::ReadWriteMutex::WriteLocker wl( rwStore ); |
88 | { | 88 | { |
89 | Bu::MyriadStream ms = mStore.create( Bu::Myriad::Create ); | 89 | Bu::Myriad::StreamId id = mStore.allocate(); |
90 | hIndex.insert( o->getKey(), ms.getId() ); | 90 | hIndex.insert( o->getKey(), id ); |
91 | } | 91 | } |
92 | _save( o ); | 92 | _save( o ); |
93 | 93 | ||
diff --git a/src/unstable/myriadfs.cpp b/src/unstable/myriadfs.cpp index ab9ca74..f748a53 100644 --- a/src/unstable/myriadfs.cpp +++ b/src/unstable/myriadfs.cpp | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "bu/config.h" | 8 | #include "bu/config.h" |
9 | #include "bu/myriadfs.h" | 9 | #include "bu/myriadfs.h" |
10 | #include "bu/myriadstream.h" | 10 | #include "bu/myriadstream.h" |
11 | #include "bu/mutexlocker.h" | ||
11 | 12 | ||
12 | #include <string.h> | 13 | #include <string.h> |
13 | #include <unistd.h> | 14 | #include <unistd.h> |
@@ -107,6 +108,7 @@ Bu::MyriadFs::~MyriadFs() | |||
107 | 108 | ||
108 | void Bu::MyriadFs::stat( const Bu::String &sPath, Bu::MyriadFs::Stat &rBuf ) | 109 | void Bu::MyriadFs::stat( const Bu::String &sPath, Bu::MyriadFs::Stat &rBuf ) |
109 | { | 110 | { |
111 | Bu::MutexLocker lLock( mAccess ); | ||
110 | int32_t iParent; | 112 | int32_t iParent; |
111 | int32_t iNode = lookupInode( sPath, iParent ); | 113 | int32_t iNode = lookupInode( sPath, iParent ); |
112 | Bu::MyriadStream is = mStore.open( 2, Bu::Myriad::Read ); | 114 | Bu::MyriadStream is = mStore.open( 2, Bu::Myriad::Read ); |
@@ -116,6 +118,7 @@ void Bu::MyriadFs::stat( const Bu::String &sPath, Bu::MyriadFs::Stat &rBuf ) | |||
116 | Bu::MyriadStream Bu::MyriadFs::open( const Bu::String &sPath, int iMode, | 118 | Bu::MyriadStream Bu::MyriadFs::open( const Bu::String &sPath, int iMode, |
117 | uint16_t uPerms ) | 119 | uint16_t uPerms ) |
118 | { | 120 | { |
121 | Bu::MutexLocker lLock( mAccess ); | ||
119 | int32_t iParent = -1; | 122 | int32_t iParent = -1; |
120 | int32_t iNode; | 123 | int32_t iNode; |
121 | try | 124 | try |
@@ -164,6 +167,7 @@ void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms, | |||
164 | void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms, | 167 | void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms, |
165 | uint32_t uSpecial ) | 168 | uint32_t uSpecial ) |
166 | { | 169 | { |
170 | Bu::MutexLocker lLock( mAccess ); | ||
167 | int32_t iParent = -1; | 171 | int32_t iParent = -1; |
168 | // int32_t iNode; | 172 | // int32_t iNode; |
169 | try | 173 | try |
@@ -200,6 +204,7 @@ void Bu::MyriadFs::mkDir( const Bu::String &sPath, uint16_t iPerms ) | |||
200 | void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget, | 204 | void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget, |
201 | const Bu::String &sPath ) | 205 | const Bu::String &sPath ) |
202 | { | 206 | { |
207 | Bu::MutexLocker lLock( mAccess ); | ||
203 | int32_t iParent = -1; | 208 | int32_t iParent = -1; |
204 | int32_t iNode; | 209 | int32_t iNode; |
205 | try | 210 | try |
@@ -232,6 +237,7 @@ void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget, | |||
232 | void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget, | 237 | void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget, |
233 | const Bu::String &sPath ) | 238 | const Bu::String &sPath ) |
234 | { | 239 | { |
240 | Bu::MutexLocker lLock( mAccess ); | ||
235 | int32_t iParent = -1; | 241 | int32_t iParent = -1; |
236 | int32_t iNode; | 242 | int32_t iNode; |
237 | 243 | ||
@@ -267,6 +273,7 @@ void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget, | |||
267 | 273 | ||
268 | Bu::String Bu::MyriadFs::readSymLink( const Bu::String &sPath ) | 274 | Bu::String Bu::MyriadFs::readSymLink( const Bu::String &sPath ) |
269 | { | 275 | { |
276 | Bu::MutexLocker lLock( mAccess ); | ||
270 | int32_t iParent = -1; | 277 | int32_t iParent = -1; |
271 | int32_t iNode; | 278 | int32_t iNode; |
272 | iNode = lookupInode( sPath, iParent ); | 279 | iNode = lookupInode( sPath, iParent ); |
@@ -279,6 +286,7 @@ Bu::String Bu::MyriadFs::readSymLink( const Bu::String &sPath ) | |||
279 | 286 | ||
280 | Bu::MyriadFs::Dir Bu::MyriadFs::readDir( const Bu::String &sPath ) | 287 | Bu::MyriadFs::Dir Bu::MyriadFs::readDir( const Bu::String &sPath ) |
281 | { | 288 | { |
289 | Bu::MutexLocker lLock( mAccess ); | ||
282 | int32_t iParent = -1; | 290 | int32_t iParent = -1; |
283 | int32_t iNode = lookupInode( sPath, iParent ); | 291 | int32_t iNode = lookupInode( sPath, iParent ); |
284 | return readDir( iNode ); | 292 | return readDir( iNode ); |
@@ -287,6 +295,7 @@ Bu::MyriadFs::Dir Bu::MyriadFs::readDir( const Bu::String &sPath ) | |||
287 | void Bu::MyriadFs::setTimes( const Bu::String &sPath, int64_t iATime, | 295 | void Bu::MyriadFs::setTimes( const Bu::String &sPath, int64_t iATime, |
288 | int64_t iMTime ) | 296 | int64_t iMTime ) |
289 | { | 297 | { |
298 | Bu::MutexLocker lLock( mAccess ); | ||
290 | int32_t iParent = -1; | 299 | int32_t iParent = -1; |
291 | int32_t iNode; | 300 | int32_t iNode; |
292 | 301 | ||
@@ -297,6 +306,7 @@ void Bu::MyriadFs::setTimes( const Bu::String &sPath, int64_t iATime, | |||
297 | 306 | ||
298 | void Bu::MyriadFs::unlink( const Bu::String &sPath ) | 307 | void Bu::MyriadFs::unlink( const Bu::String &sPath ) |
299 | { | 308 | { |
309 | Bu::MutexLocker lLock( mAccess ); | ||
300 | int32_t iParent = -1; | 310 | int32_t iParent = -1; |
301 | // int32_t iNode; | 311 | // int32_t iNode; |
302 | 312 | ||
@@ -352,6 +362,7 @@ void Bu::MyriadFs::unlink( const Bu::String &sPath ) | |||
352 | 362 | ||
353 | void Bu::MyriadFs::setFileSize( const Bu::String &sPath, int32_t iSize ) | 363 | void Bu::MyriadFs::setFileSize( const Bu::String &sPath, int32_t iSize ) |
354 | { | 364 | { |
365 | Bu::MutexLocker lLock( mAccess ); | ||
355 | int32_t iParent = -1; | 366 | int32_t iParent = -1; |
356 | int32_t iNode; | 367 | int32_t iNode; |
357 | iNode = lookupInode( sPath, iParent ); | 368 | iNode = lookupInode( sPath, iParent ); |
@@ -361,6 +372,7 @@ void Bu::MyriadFs::setFileSize( const Bu::String &sPath, int32_t iSize ) | |||
361 | 372 | ||
362 | void Bu::MyriadFs::rename( const Bu::String &sFrom, const Bu::String &sTo ) | 373 | void Bu::MyriadFs::rename( const Bu::String &sFrom, const Bu::String &sTo ) |
363 | { | 374 | { |
375 | Bu::MutexLocker lLock( mAccess ); | ||
364 | mkHardLink( sFrom, sTo ); | 376 | mkHardLink( sFrom, sTo ); |
365 | unlink( sFrom ); | 377 | unlink( sFrom ); |
366 | } | 378 | } |
@@ -572,27 +584,17 @@ int32_t Bu::MyriadFs::allocInode( uint16_t uPerms, uint32_t uSpecial ) | |||
572 | { | 584 | { |
573 | case typeRegFile: | 585 | case typeRegFile: |
574 | case typeSymLink: | 586 | case typeSymLink: |
575 | { | 587 | rs.uStreamIndex = mStore.allocate(); |
576 | Bu::MyriadStream ms = mStore.create( | ||
577 | Bu::Myriad::Create | ||
578 | ); | ||
579 | rs.uStreamIndex = ms.getId(); | ||
580 | } | ||
581 | break; | 588 | break; |
582 | 589 | ||
583 | case typeDir: | 590 | case typeDir: |
584 | { | ||
585 | Bu::MyriadStream ms = mStore.create( | ||
586 | Bu::Myriad::Create | ||
587 | ); | ||
588 | rs.uStreamIndex = ms.getId(); | ||
589 | } | ||
590 | // sio << "Creating directory node, storage: " | 591 | // sio << "Creating directory node, storage: " |
591 | // << rs.uStreamIndex << sio.nl; | 592 | // << rs.uStreamIndex << sio.nl; |
592 | { | 593 | { |
593 | Bu::MyriadStream msDir = mStore.open( | 594 | Bu::MyriadStream msDir = mStore.create( |
594 | rs.uStreamIndex, Bu::Myriad::Write | 595 | Bu::Myriad::Write |
595 | ); | 596 | ); |
597 | rs.uStreamIndex = msDir.getId(); | ||
596 | uint32_t uSize = 0; | 598 | uint32_t uSize = 0; |
597 | msDir.write( &uSize, 4 ); | 599 | msDir.write( &uSize, 4 ); |
598 | } | 600 | } |
diff --git a/src/unstable/myriadfs.h b/src/unstable/myriadfs.h index ff14292..e3008bc 100644 --- a/src/unstable/myriadfs.h +++ b/src/unstable/myriadfs.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <sys/types.h> | 11 | #include <sys/types.h> |
12 | 12 | ||
13 | #include "bu/myriad.h" | 13 | #include "bu/myriad.h" |
14 | #include "bu/readwritemutex.h" | 14 | #include "bu/debugmutex.h" |
15 | 15 | ||
16 | namespace Bu | 16 | namespace Bu |
17 | { | 17 | { |
@@ -108,7 +108,7 @@ namespace Bu | |||
108 | Truncate = 0x08, ///< Truncate file if it does exist | 108 | Truncate = 0x08, ///< Truncate file if it does exist |
109 | Append = 0x10, ///< Always append on every write | 109 | Append = 0x10, ///< Always append on every write |
110 | NonBlock = 0x20, ///< Open file in non-blocking mode | 110 | NonBlock = 0x20, ///< Open file in non-blocking mode |
111 | Exclusive = 0x44, ///< Create file, if it exists then fail | 111 | Exclusive = 0x40, ///< Create file, if it exists then fail |
112 | 112 | ||
113 | // Helpful mixes | 113 | // Helpful mixes |
114 | ReadWrite = 0x03, ///< Open for reading and writing | 114 | ReadWrite = 0x03, ///< Open for reading and writing |
@@ -172,7 +172,13 @@ namespace Bu | |||
172 | typedef Bu::Hash<int32_t, int32_t> NodeIndex; | 172 | typedef Bu::Hash<int32_t, int32_t> NodeIndex; |
173 | 173 | ||
174 | private: | 174 | private: |
175 | /** | ||
176 | * Lookup inode. | ||
177 | */ | ||
175 | int32_t lookupInode( const Bu::String &sPath, int32_t &iParent ); | 178 | int32_t lookupInode( const Bu::String &sPath, int32_t &iParent ); |
179 | /** | ||
180 | * Lookup inode. | ||
181 | */ | ||
176 | int32_t lookupInode( Bu::String::const_iterator iStart, | 182 | int32_t lookupInode( Bu::String::const_iterator iStart, |
177 | int32_t iNode, int32_t &iParent ); | 183 | int32_t iNode, int32_t &iParent ); |
178 | void readInode( int32_t iNode, RawStat &rs, MyriadStream &rIs ); | 184 | void readInode( int32_t iNode, RawStat &rs, MyriadStream &rIs ); |
@@ -190,12 +196,12 @@ namespace Bu | |||
190 | void setTimes( int32_t iNode, int64_t iATime, int64_t iMTime ); | 196 | void setTimes( int32_t iNode, int64_t iATime, int64_t iMTime ); |
191 | void destroyNode( int32_t iNode ); | 197 | void destroyNode( int32_t iNode ); |
192 | 198 | ||
193 | Bu::String filePart( const Bu::String &sPath ); | 199 | static Bu::String filePart( const Bu::String &sPath ); |
194 | 200 | ||
195 | private: | 201 | private: |
196 | Bu::Stream &rStore; | 202 | Bu::Stream &rStore; |
197 | Bu::Myriad mStore; | 203 | Bu::Myriad mStore; |
198 | Bu::ReadWriteMutex mNodeIndex; | 204 | Bu::DebugMutex mAccess; |
199 | NodeIndex hNodeIndex; | 205 | NodeIndex hNodeIndex; |
200 | int32_t iUser; | 206 | int32_t iUser; |
201 | int32_t iGroup; | 207 | int32_t iGroup; |