- Timestamp:
- Jul 25, 2009, 3:10:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
baculafs/trunk/baculafs.py
r780 r781 47 47 #logging.debug('BC init done') 48 48 49 50 def ls(self, path): 51 49 def cd(self, path): 52 50 path = path + "/" 53 51 logging.debug( "(" + path + ")" ) … … 63 61 # path ok, now wait for prompt 64 62 self.bconsole.expect( BCONSOLE_RESTORE_PROMPT ) 63 return True 65 64 elif index == 1: 66 65 #print "wrong path" 66 return False 67 elif index == 2: 68 logging.error( "EOF bconsole" ) 69 #raise? 70 return False 71 elif index == 3: 72 logging.error( "TIMEOUT bconsole" ) 73 return False 74 75 def ls(self, path): 76 logging.debug( "(" + path + ")" ) 77 78 if self.cd( path ): 79 self.bconsole.sendline( 'ls' ) 80 self.bconsole.expect( BCONSOLE_RESTORE_PROMPT ) 81 lines = self.bconsole.before.splitlines() 82 #logging.debug( str(lines) ) 83 return lines 84 else: 67 85 return 68 elif index == 2:69 print "error EOF"70 raise71 elif index == 3:72 print "error TIMEOUT"73 return74 75 self.bconsole.sendline( 'ls' )76 self.bconsole.expect( BCONSOLE_RESTORE_PROMPT )77 lines = self.bconsole.before.splitlines()78 #logging.debug( str(lines) )79 return lines80 86 81 87 ############### … … 95 101 #logging.debug('init finished') 96 102 103 104 def _getattr(self,path): 105 # TODO: may cause problems with filenames that ends with "/" 106 path = path.rstrip( '/' ) 107 logging.debug( '"' + path + '"' ) 108 109 if (path in self.files): 110 #logging.debug( "(" + path + ")=" + str(self.files[path]) ) 111 return self.files[path] 112 113 if Bconsole().cd(path): 114 # don't define files, because these have not been checked 115 self.files[path] = { 'type': self.TYPE_DIR, 'dirs': [ ".", ".." ] } 116 117 return self.files[path] 118 119 120 121 97 122 def _getdir(self, path): 98 123 … … 103 128 if (path in self.files): 104 129 #logging.debug( "(" + path + ")=" + str(self.files[path]) ) 105 if self.files[path]['type'] == self.TYPE_FILE: 106 logging.debug( '"' + path + '"=file (cached)' ) 130 if self.files[path]['type'] == self.TYPE_NONE: 131 logging.info( '"' + path + '" does not exist (cached)' ) 132 return self.files[path] 133 elif self.files[path]['type'] == self.TYPE_FILE: 134 logging.info( '"' + path + '"=file (cached)' ) 107 135 return self.files[path] 108 136 elif ((self.files[path]['type'] == self.TYPE_DIR) and ('files' in self.files[path])): 109 logging. debug( '"' + path + '"=dir (cached)' )137 logging.info( '"' + path + '"=dir (cached)' ) 110 138 return self.files[path] 111 139 112 140 try: 113 141 files = Bconsole().ls(path) 114 #logging.debug( " files: " + str( files ) )142 logging.debug( " files: " + str( files ) ) 115 143 116 144 # setting initial empty directory. Add entires later in this function … … 144 172 logging.debug( '"' + path + '"' ) 145 173 174 st = fuse.Stat() 175 176 if not (path in self.files): 177 self._getattr(path) 178 179 if not (path in self.files): 180 return -errno.ENOENT 181 146 182 file = self.files[path] 147 st = fuse.Stat()148 149 #file = self._getdir( path )150 183 151 184 if file['type'] == self.TYPE_FILE: … … 153 186 st.st_nlink = 1 154 187 st.st_size = 0 188 return st 155 189 elif file['type'] == self.TYPE_DIR: 156 190 st.st_mode = stat.S_IFDIR | 0755 … … 159 193 else: 160 194 st.st_nlink = 2 161 else: 162 return -errno.ENOENT 163 return st 195 return st 196 197 # TODO: check for existens 198 return -errno.ENOENT 199 164 200 165 201
Note:
See TracChangeset
for help on using the changeset viewer.