diff options
Diffstat (limited to 'src/unstable/myriadfs.cpp')
-rw-r--r-- | src/unstable/myriadfs.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
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 | } |