def update_inode_table(self, table_inode, inode_number): if table_inode: table_inode.time_modified = datetime.datetime.now( ) #TIME OF MODIFICATION array_inode = InodeOps.InodeOperations().convert_table_to_array( table_inode) MemoryInterface.update_inode_table(array_inode, inode_number)
def INODE_NUMBER_TO_INODE(self, inode_number): array_inode = MemoryInterface.inode_number_to_inode(inode_number) inode = InodeOps.InodeOperations().convert_array_to_table(array_inode) if inode: inode.time_accessed = str( datetime.datetime.now())[:19] #TIME OF ACCESS return inode
def unlink(self, inode_number, parent_inode_number): '''WRITE YOUR CODE HERE''' error = -1 inode = self.INODE_NUMBER_TO_INODE(inode_number) if(inode == False): return error parent_inode = self.INODE_NUMBER_TO_INODE(parent_inode_number) if(parent_inode == False): return error #unlinking dir, make sure it is empty, dir inode can only be deleted if its empty if inode.type == 1 and len(inode.directory) != 0: print("ERROR: cant unlink non empty directory") return error #if the file is an inode decrement its links if inode.type == 0: inode.links -=1 if(inode.links == 0): interface.free_data_block(inode,0) MemoryInterface.update_inode_table(False, inode_number) return parent_inode if inode.type == 1: interface.free_data_block(inode,0) MemoryInterface.update_inode_table(False, inode_number) return parent_inode array_inode = InodeOps.InodeOperations().convert_table_to_array(inode) MemoryInterface.update_inode_table(array_inode, inode_number) return parent_inode
def INODE_NUMBER_TO_INODE(self, inode_number): array_inode = ClientStub.ClientStub().inode_number_to_inode( inode_number) inode = InodeOps.InodeOperations().convert_array_to_table(array_inode) if inode: inode.time_accessed = datetime.datetime.now() #TIME OF ACCESS return inode
def INODE_NUMBER_TO_INODE(self, inode_number): #print(inode_number) array_inode = MemoryInterface.inode_number_to_inode(inode_number) #print("###############") #print(array_inode) inode = InodeOps.InodeOperations().convert_array_to_table(array_inode) #print(inode) if inode: inode.time_accessed = datetime.datetime.now() #TIME OF ACCESS return inode