def create_meta_info(self): comment = self.block.comment if self.block.comment_block_id != 0: comment_block = CommentBlock(self.blkdev, self.block.comment_block_id) comment_block.read() comment = comment_block.comment self.meta_info = MetaInfo(self.block.protect, self.block.mod_ts, FSString(comment))
def change_meta_info(self, meta_info): dirty = False # dircache? rebuild_dircache = False if self.volume.is_dircache and self.parent != None: record = self.parent.get_dircache_record(self.name.get_ami_str_name()) if record == None: raise FSError(INTERNAL_ERROR, node=self) else: record = None # alter protect flags protect = meta_info.get_protect() if protect != None and hasattr(self.block, "protect"): self.block.protect = protect self.meta_info.set_protect(protect) dirty = True if record != None: record.protect = protect # alter mod time mod_ts = meta_info.get_mod_ts() if mod_ts != None: self.block.mod_ts = mod_ts self.meta_info.set_mod_ts(mod_ts) dirty = True if record != None: record.mod_ts = mod_ts # alter comment comment = meta_info.get_comment() if comment != None and hasattr(self.block, "comment"): if EntryBlock.needs_extra_comment_block(self.name.get_ami_str_name(), comment.get_ami_str()): if self.block.comment_block_id == 0: # Allocate and initialize extra block for comment blks = self.volume.bitmap.alloc_n(1) if blks is not None: cblk = CommentBlock(self.blkdev, blks[0]) cblk.create(self.block.blk_num) self.block.comment_block_id = cblk.blk_num self.volume.bitmap.write_only_bits() else: raise FSError(NO_FREE_BLOCKS, node=self) else: cblk = CommentBlock(self.blkdev, self.block.comment_block_id) cblk.read() cblk.comment = comment.get_ami_str() cblk.write() else: self.block.comment = comment.get_ami_str() if self.block.comment_block_id != 0: self.volume.bitmap.dealloc_n([self.block.comment_block_id]) self.block.comment_block_id = 0 self.volume.bitmap.write_only_bits() self.meta_info.set_comment(comment) dirty = True if record != None: rebuild_dircache = len(record.comment) < comment record.comment = comment.get_ami_str() # really need update? if dirty: self.block.write() # dirache update if record != None: self.parent.update_dircache_record(record, rebuild_dircache)