@@ -646,6 +646,9 @@ def add_entry(self, path_object):
646
646
647
647
self .contents [path_object_name ] = path_object
648
648
path_object .parent_dir = self
649
+ if path_object .st_ino is None :
650
+ self .filesystem .last_ino += 1
651
+ path_object .st_ino = self .filesystem .last_ino
649
652
self .st_nlink += 1
650
653
path_object .st_nlink += 1
651
654
path_object .st_dev = self .st_dev
@@ -878,8 +881,8 @@ def __init__(self, path_separator=os.path.sep, total_size=None,
878
881
# A heap containing all free positions in self.open_files list
879
882
self ._free_fd_heap = []
880
883
# last used numbers for inodes (st_ino) and devices (st_dev)
881
- self ._last_ino = 0
882
- self ._last_dev = 0
884
+ self .last_ino = 0
885
+ self .last_dev = 0
883
886
self .mount_points = {}
884
887
self .add_mount_point (self .root .name , total_size )
885
888
self ._add_standard_streams ()
@@ -896,8 +899,8 @@ def reset(self, total_size=None):
896
899
897
900
self .open_files = []
898
901
self ._free_fd_heap = []
899
- self ._last_ino = 0
900
- self ._last_dev = 0
902
+ self .last_ino = 0
903
+ self .last_dev = 0
901
904
self .mount_points = {}
902
905
self .add_mount_point (self .root .name , total_size )
903
906
self ._add_standard_streams ()
@@ -994,14 +997,18 @@ def add_mount_point(self, path, total_size=None):
994
997
path = self .absnormpath (path )
995
998
if path in self .mount_points :
996
999
self .raise_os_error (errno .EEXIST , path )
997
- self ._last_dev += 1
1000
+ self .last_dev += 1
998
1001
self .mount_points [path ] = {
999
- 'idev' : self ._last_dev , 'total_size' : total_size , 'used_size' : 0
1002
+ 'idev' : self .last_dev , 'total_size' : total_size , 'used_size' : 0
1000
1003
}
1001
1004
# special handling for root path: has been created before
1002
- root_dir = (self .root if path == self .root .name
1003
- else self .create_dir (path ))
1004
- root_dir .st_dev = self ._last_dev
1005
+ if path == self .root .name :
1006
+ root_dir = self .root
1007
+ self .last_ino += 1
1008
+ root_dir .st_ino = self .last_ino
1009
+ else :
1010
+ root_dir = self .create_dir (path )
1011
+ root_dir .st_dev = self .last_dev
1005
1012
return self .mount_points [path ]
1006
1013
1007
1014
def _auto_mount_drive_if_needed (self , path , force = False ):
@@ -2293,8 +2300,6 @@ def create_dir(self, directory_path, perm_bits=PERM_DEF):
2293
2300
for new_dir in new_dirs :
2294
2301
new_dir .st_mode = S_IFDIR | perm_bits
2295
2302
2296
- self ._last_ino += 1
2297
- current_dir .st_ino = self ._last_ino
2298
2303
return current_dir
2299
2304
2300
2305
def create_file (self , file_path , st_mode = S_IFREG | PERM_DEF_FILE ,
@@ -2448,8 +2453,6 @@ def add_real_directory(self, source_path, read_only=True, lazy_read=True,
2448
2453
new_dir = FakeDirectoryFromRealDirectory (
2449
2454
source_path , self , read_only , target_path )
2450
2455
parent_dir .add_entry (new_dir )
2451
- self ._last_ino += 1
2452
- new_dir .st_ino = self ._last_ino
2453
2456
else :
2454
2457
new_dir = self .create_dir (target_path )
2455
2458
for base , _ , files in os .walk (source_path ):
@@ -2557,8 +2560,6 @@ def create_file_internally(self, file_path,
2557
2560
encoding = encoding , errors = errors ,
2558
2561
side_effect = side_effect )
2559
2562
2560
- self ._last_ino += 1
2561
- file_object .st_ino = self ._last_ino
2562
2563
self .add_object (parent_directory , file_object )
2563
2564
2564
2565
if st_size is None and contents is None :
0 commit comments