aboutsummaryrefslogtreecommitdiff
path: root/src/unstable
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2024-11-06 16:01:36 -0800
committerMike Buland <mike@xagasoft.com>2024-11-06 16:01:36 -0800
commit700d4bbcbf59c4447becbab21a6aa7204a8da2f4 (patch)
treeae68c40a5af2d5bc84ac4bbb192fbbda893d64cc /src/unstable
parent6403224b6fe50dfc28d3c25725b6d0910b7eb6c3 (diff)
downloadlibbu++-myriad.tar.gz
libbu++-myriad.tar.bz2
libbu++-myriad.tar.xz
libbu++-myriad.zip
I believe MyriadFs is now threadsafe.myriad
It could probably be more optimized, but it does work.
Diffstat (limited to '')
-rw-r--r--src/unstable/myriadfs.cpp11
-rw-r--r--src/unstable/myriadfs.h12
2 files changed, 20 insertions, 3 deletions
diff --git a/src/unstable/myriadfs.cpp b/src/unstable/myriadfs.cpp
index a2386c2..f748a53 100644
--- a/src/unstable/myriadfs.cpp
+++ b/src/unstable/myriadfs.cpp
@@ -108,6 +108,7 @@ Bu::MyriadFs::~MyriadFs()
108 108
109void Bu::MyriadFs::stat( const Bu::String &sPath, Bu::MyriadFs::Stat &rBuf ) 109void Bu::MyriadFs::stat( const Bu::String &sPath, Bu::MyriadFs::Stat &rBuf )
110{ 110{
111 Bu::MutexLocker lLock( mAccess );
111 int32_t iParent; 112 int32_t iParent;
112 int32_t iNode = lookupInode( sPath, iParent ); 113 int32_t iNode = lookupInode( sPath, iParent );
113 Bu::MyriadStream is = mStore.open( 2, Bu::Myriad::Read ); 114 Bu::MyriadStream is = mStore.open( 2, Bu::Myriad::Read );
@@ -117,6 +118,7 @@ void Bu::MyriadFs::stat( const Bu::String &sPath, Bu::MyriadFs::Stat &rBuf )
117Bu::MyriadStream Bu::MyriadFs::open( const Bu::String &sPath, int iMode, 118Bu::MyriadStream Bu::MyriadFs::open( const Bu::String &sPath, int iMode,
118 uint16_t uPerms ) 119 uint16_t uPerms )
119{ 120{
121 Bu::MutexLocker lLock( mAccess );
120 int32_t iParent = -1; 122 int32_t iParent = -1;
121 int32_t iNode; 123 int32_t iNode;
122 try 124 try
@@ -165,6 +167,7 @@ void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms,
165void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms, 167void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms,
166 uint32_t uSpecial ) 168 uint32_t uSpecial )
167{ 169{
170 Bu::MutexLocker lLock( mAccess );
168 int32_t iParent = -1; 171 int32_t iParent = -1;
169// int32_t iNode; 172// int32_t iNode;
170 try 173 try
@@ -201,6 +204,7 @@ void Bu::MyriadFs::mkDir( const Bu::String &sPath, uint16_t iPerms )
201void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget, 204void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget,
202 const Bu::String &sPath ) 205 const Bu::String &sPath )
203{ 206{
207 Bu::MutexLocker lLock( mAccess );
204 int32_t iParent = -1; 208 int32_t iParent = -1;
205 int32_t iNode; 209 int32_t iNode;
206 try 210 try
@@ -233,6 +237,7 @@ void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget,
233void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget, 237void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget,
234 const Bu::String &sPath ) 238 const Bu::String &sPath )
235{ 239{
240 Bu::MutexLocker lLock( mAccess );
236 int32_t iParent = -1; 241 int32_t iParent = -1;
237 int32_t iNode; 242 int32_t iNode;
238 243
@@ -268,6 +273,7 @@ void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget,
268 273
269Bu::String Bu::MyriadFs::readSymLink( const Bu::String &sPath ) 274Bu::String Bu::MyriadFs::readSymLink( const Bu::String &sPath )
270{ 275{
276 Bu::MutexLocker lLock( mAccess );
271 int32_t iParent = -1; 277 int32_t iParent = -1;
272 int32_t iNode; 278 int32_t iNode;
273 iNode = lookupInode( sPath, iParent ); 279 iNode = lookupInode( sPath, iParent );
@@ -280,6 +286,7 @@ Bu::String Bu::MyriadFs::readSymLink( const Bu::String &sPath )
280 286
281Bu::MyriadFs::Dir Bu::MyriadFs::readDir( const Bu::String &sPath ) 287Bu::MyriadFs::Dir Bu::MyriadFs::readDir( const Bu::String &sPath )
282{ 288{
289 Bu::MutexLocker lLock( mAccess );
283 int32_t iParent = -1; 290 int32_t iParent = -1;
284 int32_t iNode = lookupInode( sPath, iParent ); 291 int32_t iNode = lookupInode( sPath, iParent );
285 return readDir( iNode ); 292 return readDir( iNode );
@@ -288,6 +295,7 @@ Bu::MyriadFs::Dir Bu::MyriadFs::readDir( const Bu::String &sPath )
288void Bu::MyriadFs::setTimes( const Bu::String &sPath, int64_t iATime, 295void Bu::MyriadFs::setTimes( const Bu::String &sPath, int64_t iATime,
289 int64_t iMTime ) 296 int64_t iMTime )
290{ 297{
298 Bu::MutexLocker lLock( mAccess );
291 int32_t iParent = -1; 299 int32_t iParent = -1;
292 int32_t iNode; 300 int32_t iNode;
293 301
@@ -298,6 +306,7 @@ void Bu::MyriadFs::setTimes( const Bu::String &sPath, int64_t iATime,
298 306
299void Bu::MyriadFs::unlink( const Bu::String &sPath ) 307void Bu::MyriadFs::unlink( const Bu::String &sPath )
300{ 308{
309 Bu::MutexLocker lLock( mAccess );
301 int32_t iParent = -1; 310 int32_t iParent = -1;
302// int32_t iNode; 311// int32_t iNode;
303 312
@@ -353,6 +362,7 @@ void Bu::MyriadFs::unlink( const Bu::String &sPath )
353 362
354void Bu::MyriadFs::setFileSize( const Bu::String &sPath, int32_t iSize ) 363void Bu::MyriadFs::setFileSize( const Bu::String &sPath, int32_t iSize )
355{ 364{
365 Bu::MutexLocker lLock( mAccess );
356 int32_t iParent = -1; 366 int32_t iParent = -1;
357 int32_t iNode; 367 int32_t iNode;
358 iNode = lookupInode( sPath, iParent ); 368 iNode = lookupInode( sPath, iParent );
@@ -362,6 +372,7 @@ void Bu::MyriadFs::setFileSize( const Bu::String &sPath, int32_t iSize )
362 372
363void Bu::MyriadFs::rename( const Bu::String &sFrom, const Bu::String &sTo ) 373void Bu::MyriadFs::rename( const Bu::String &sFrom, const Bu::String &sTo )
364{ 374{
375 Bu::MutexLocker lLock( mAccess );
365 mkHardLink( sFrom, sTo ); 376 mkHardLink( sFrom, sTo );
366 unlink( sFrom ); 377 unlink( sFrom );
367} 378}
diff --git a/src/unstable/myriadfs.h b/src/unstable/myriadfs.h
index 4e1749e..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/mutex.h" 14#include "bu/debugmutex.h"
15 15
16namespace Bu 16namespace Bu
17{ 17{
@@ -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::Mutex mAccess; 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;