aboutsummaryrefslogtreecommitdiff
path: root/src/tools/myriadfs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/myriadfs.cpp')
-rw-r--r--src/tools/myriadfs.cpp62
1 files changed, 57 insertions, 5 deletions
diff --git a/src/tools/myriadfs.cpp b/src/tools/myriadfs.cpp
index c4004b7..8db59d7 100644
--- a/src/tools/myriadfs.cpp
+++ b/src/tools/myriadfs.cpp
@@ -29,7 +29,6 @@ extern "C" {
29 { 29 {
30 try 30 try
31 { 31 {
32 printf("myriadfs_getattr: Statting file: %s\n", sPath );
33 Bu::MyriadFs::Stat st; 32 Bu::MyriadFs::Stat st;
34 pFs->stat( sPath, st ); 33 pFs->stat( sPath, st );
35 stbuf->st_ino = st.iNode; 34 stbuf->st_ino = st.iNode;
@@ -78,7 +77,8 @@ extern "C" {
78 Bu::MyriadStream ms = pFs->open( sPath, 0 ); 77 Bu::MyriadStream ms = pFs->open( sPath, 0 );
79 fi->fh = iNextFileId; 78 fi->fh = iNextFileId;
80 hOpenFiles.insert( iNextFileId++, ms ); 79 hOpenFiles.insert( iNextFileId++, ms );
81 printf("File opened, %d files open now.\n", hOpenFiles.getSize() ); 80 printf("File '%s' opened, %d files open now.\n",
81 sPath, hOpenFiles.getSize() );
82 return 0; 82 return 0;
83 } 83 }
84 catch(...) 84 catch(...)
@@ -108,10 +108,11 @@ extern "C" {
108 { 108 {
109 try 109 try
110 { 110 {
111 Bu::MyriadStream ms = pFs->open( sPath, 0 ); 111 Bu::MyriadStream ms = pFs->open( sPath, 0, uPerms );
112 fi->fh = iNextFileId; 112 fi->fh = iNextFileId;
113 hOpenFiles.insert( iNextFileId++, ms ); 113 hOpenFiles.insert( iNextFileId++, ms );
114 printf("File created, %d files open now.\n", hOpenFiles.getSize() ); 114 printf("File '%s' created, %d files open now.\n",
115 sPath, hOpenFiles.getSize() );
115 return 0; 116 return 0;
116 } 117 }
117 catch(...) 118 catch(...)
@@ -136,7 +137,8 @@ extern "C" {
136 static int myriadfs_release( const char *sPath, struct fuse_file_info *fi ) 137 static int myriadfs_release( const char *sPath, struct fuse_file_info *fi )
137 { 138 {
138 hOpenFiles.erase( fi->fh ); 139 hOpenFiles.erase( fi->fh );
139 printf("File released, %d files open now.\n", hOpenFiles.getSize() ); 140 printf("File '%s' released, %d files open now.\n",
141 sPath, hOpenFiles.getSize() );
140 142
141 return 0; 143 return 0;
142 } 144 }
@@ -155,6 +157,52 @@ extern "C" {
155 return 0; 157 return 0;
156 } 158 }
157 159
160 static int myriadfs_unlink( const char *sPath )
161 {
162 try
163 {
164 pFs->unlink( sPath );
165 }
166 catch( Bu::MyriadFsException &e )
167 {
168 printf("MyriadFsException: %s\n", e.what() );
169 return -EACCES;
170 }
171 return 0;
172 }
173
174 static int myriadfs_symlink( const char *sTarget, const char *sPath )
175 {
176 try
177 {
178 printf("Path = '%s', Target = '%s'\n", sPath, sTarget );
179 pFs->mkSymLink( sPath, sTarget );
180 }
181 catch( Bu::MyriadFsException &e )
182 {
183 printf("MyriadFsException: %s\n", e.what() );
184 return -EACCES;
185 }
186 return 0;
187 }
188
189 static int myriadfs_readlink( const char *sPath, char *sOut, size_t s )
190 {
191 try
192 {
193 Bu::String sTrg = pFs->readSymLink( sPath );
194 size_t iLen = (s-1>sTrg.getSize())?(sTrg.getSize()):(s-1);
195 memcpy( sOut, sTrg.getStr(), iLen );
196 sOut[iLen] = '\0';
197 }
198 catch( Bu::MyriadFsException &e )
199 {
200 printf("MyriadFsException: %s\n", e.what() );
201 return -EACCES;
202 }
203 return 0;
204 }
205
158 static struct fuse_operations myriadfs_oper; 206 static struct fuse_operations myriadfs_oper;
159 207
160 int main( int argc, char *argv[] ) 208 int main( int argc, char *argv[] )
@@ -172,6 +220,10 @@ extern "C" {
172 myriadfs_oper.mknod = myriadfs_mknod; 220 myriadfs_oper.mknod = myriadfs_mknod;
173 myriadfs_oper.release = myriadfs_release; 221 myriadfs_oper.release = myriadfs_release;
174 myriadfs_oper.utimens = myriadfs_utimens; 222 myriadfs_oper.utimens = myriadfs_utimens;
223 myriadfs_oper.unlink = myriadfs_unlink;
224 myriadfs_oper.rmdir = myriadfs_unlink;
225 myriadfs_oper.symlink = myriadfs_symlink;
226 myriadfs_oper.readlink = myriadfs_readlink;
175 printf("Starting fuse_main.\n"); 227 printf("Starting fuse_main.\n");
176 int iRet = fuse_main( argc, argv, &myriadfs_oper, NULL ); 228 int iRet = fuse_main( argc, argv, &myriadfs_oper, NULL );
177 printf("Done with fuse_main.\n"); 229 printf("Done with fuse_main.\n");