Browse code

Introduce register_fd().

Xavier G authored on 11/04/2020 13:33:41
Showing 1 changed files

... ...
@@ -181,6 +181,13 @@ class CombinedFS(Operations):
181 181
 			except OSError as ose:
182 182
 				raise FuseOSError(ose.errno)
183 183
 
184
+	def register_fd(self, file_descriptor):
185
+		with self.filedesc_lock:
186
+			self.filedesc_index += 1
187
+			new_fd_index = self.filedesc_index
188
+			self.filedesc[new_fd_index] = file_descriptor
189
+		return new_fd_index
190
+
184 191
 	# Filesystem methods
185 192
 
186 193
 	def access(self, path, mode):
... ...
@@ -274,11 +281,7 @@ class CombinedFS(Operations):
274 281
 			'filename': filename,
275 282
 			'file_spec': file_spec,
276 283
 		}
277
-		with self.filedesc_lock:
278
-			self.filedesc_index += 1
279
-			new_fd_index = self.filedesc_index
280
-			self.filedesc[new_fd_index] = new_fd
281
-		return new_fd_index
284
+		return self.register_fd(new_fd)
282 285
 
283 286
 	def read(self, path, length, offset, fh):
284 287
 		filedesc = self.filedesc.get(fh)