コード例 #1
0
 def createDescription(self):
     superblock = self.getSuperblock()
     block_size = 1024 << superblock["log_block_size"].value
     nb_block = superblock["blocks_count"].value
     total = nb_block * block_size
     used = (superblock["free_blocks_count"].value) * block_size
     desc = "EXT2/EXT3"
     if "group[0]/inode_table/inode[7]/blocks" in self:
         if 0 < self["group[0]/inode_table/inode[7]/blocks"].value:
             desc = "EXT3"
         else:
             desc = "EXT2"
     return desc + " file system: total=%s, used=%s, block=%s" % (
         humanFilesize(total), humanFilesize(used),
         humanFilesize(block_size))
コード例 #2
0
ファイル: fat.py プロジェクト: azumimuo/family-xbmc-addon
 def __call__(self, prev):
     name = self.path + "[]"
     address, size, last = self.cluster.next()
     if self.filesize:
         if self.done >= self.filesize:
             error("(FAT) bad metadata for " + self.path)
             return
         field = File(self.root, name, size=size)
         if prev.first is None:
             field._description = 'File size: %s' % humanFilesize(self.filesize//8)
             field.setSubIStream(self.createInputStream)
         field.datasize = min(self.filesize - self.done, size)
         self.done += field.datasize
     else:
         field = Directory(self.root, name, size=size)
     padding = self.root.getFieldByAddress(address, feed=False)
     if not isinstance(padding, (PaddingBytes, RawBytes)):
         error("(FAT) address %u doesn't point to a padding field" % address)
         return
     if last:
         next = None
     else:
         next = lambda: self(field)
     field.setLinks(prev.first, next)
     self.root.writeFieldsIn(padding, address, (field,))
     return field
コード例 #3
0
ファイル: mbr.py プロジェクト: azumimuo/family-xbmc-addon
 def createDescription(self):
     desc = "Partition header: "
     if self.isUsed():
         system = self["system"].display
         size = self["size"].value * BLOCK_SIZE
         desc += "%s, %s" % (system, humanFilesize(size))
     else:
         desc += "(unused)"
     return desc
コード例 #4
0
 def createDescription(self):
     desc = "Partition header: "
     if self.isUsed():
         system = self["system"].display
         size = self["size"].value * BLOCK_SIZE
         desc += "%s, %s" % (system, humanFilesize(size))
     else:
         desc += "(unused)"
     return desc
コード例 #5
0
ファイル: tar.py プロジェクト: azumimuo/family-xbmc-addon
 def createDescription(self):
     if self.isEmpty():
         desc = "(terminator, empty header)"
     else:
         filename = self["name"].value
         filesize = humanFilesize(self.getOctal("size"))
         desc = "(%s: %s, %s)" % \
             (filename, self["type"].display, filesize)
     return "Tar File " + desc
コード例 #6
0
ファイル: tar.py プロジェクト: bopopescu/repo-1
 def createDescription(self):
     if self.isEmpty():
         desc = "(terminator, empty header)"
     else:
         filename = self["name"].value
         filesize = humanFilesize(self.getOctal("size"))
         desc = "(%s: %s, %s)" % \
             (filename, self["type"].display, filesize)
     return "Tar File " + desc
コード例 #7
0
ファイル: linux_swap.py プロジェクト: bopopescu/repo-1
 def createDescription(self):
     if self["magic"].value == "S1SUSPEND\0":
         text = "Suspend swap file version 1"
     elif self["magic"].value == "SWAPSPACE2":
         text = "Linux swap file version 2"
     else:
         text = "Linux swap file version 1"
     nb_page = self.getPageCount()
     return "%s, page size: %s, %s pages" % (
         text, humanFilesize(PAGE_SIZE), nb_page)
コード例 #8
0
 def createDescription(self):
     desc = "Inode %s: " % self.uniq_id
     size = self["size"].value
     if self["blocks"].value == 0:
         desc += "(unused)"
     elif 11 <= self.uniq_id:
         size = humanFilesize(size)
         desc += "file, size=%s, mode=%s" % (size, self.getMode())
     else:
         if self.uniq_id in self.inode_type_name:
             desc += self.inode_type_name[self.uniq_id]
             if self.uniq_id == 2:
                 desc += " (%s)" % self.getMode()
         else:
             desc += "special"
     return desc
コード例 #9
0
ファイル: png.py プロジェクト: azumimuo/family-xbmc-addon
 def __init__(self, parent, name, description=None):
     FieldSet.__init__(self, parent, name, description)
     self._size = (self["size"].value + 3*4) * 8
     if MAX_CHUNK_SIZE < (self._size//8):
         raise ParserError("PNG: Chunk is too big (%s)"
             % humanFilesize(self._size//8))
     tag = self["tag"].value
     self.desc_func = None
     self.value_func = None
     if tag in self.TAG_INFO:
         self._name, self.parse_func, desc, value_func = self.TAG_INFO[tag]
         if value_func:
             self.value_func = value_func
             self.createValue = self.createValueFunc
         if desc:
             if isinstance(desc, str):
                 self._description = desc
             else:
                 self.desc_func = desc
     else:
         self._description = ""
         self.parse_func = None
コード例 #10
0
ファイル: padding.py プロジェクト: bopopescu/repo-1
    def checkPattern(self):
        if not (config.check_padding_pattern):
            return False
        if self.pattern is None:
            return False

        if self.MAX_SIZE < self._size / 8:
            self.info("only check first %s of padding" %
                      humanFilesize(self.MAX_SIZE))
            content = self._parent.stream.readBytes(self.absolute_address,
                                                    self.MAX_SIZE)
        else:
            content = self.value
        index = 0
        pattern_len = len(self.pattern)
        while index < len(content):
            if content[index:index + pattern_len] != self.pattern:
                self.warning("padding contents doesn't look normal"
                             " (invalid pattern at byte %u)!" % index)
                return False
            index += pattern_len
        return True
コード例 #11
0
ファイル: padding.py プロジェクト: azumimuo/family-xbmc-addon
    def checkPattern(self):
        if not(config.check_padding_pattern):
            return False
        if self.pattern is None:
            return False

        if self.MAX_SIZE < self._size/8:
            self.info("only check first %s of padding" % humanFilesize(self.MAX_SIZE))
            content = self._parent.stream.readBytes(
                self.absolute_address, self.MAX_SIZE)
        else:
            content = self.value
        index = 0
        pattern_len = len(self.pattern)
        while index < len(content):
            if content[index:index+pattern_len] != self.pattern:
                self.warning(
                    "padding contents doesn't look normal"
                    " (invalid pattern at byte %u)!"
                    % index)
                return False
            index += pattern_len
        return True
コード例 #12
0
ファイル: ntfs.py プロジェクト: azumimuo/family-xbmc-addon
 def createDescription(self):
     size = self["nb_sectors"].value * self["bios/bytes_per_sector"].value
     return "NTFS Master Boot Record (%s)" % humanFilesize(size)
コード例 #13
0
 def createDescription(self):
     size = self["nb_sectors"].value * self["bios/bytes_per_sector"].value
     return "NTFS Master Boot Record (%s)" % humanFilesize(size)
コード例 #14
0
ファイル: pifv.py プロジェクト: azumimuo/family-xbmc-addon
 def createDescription(self):
     return "%d blocks of %s" % (
         self["num_blocks"].value, humanFilesize(self["len"].value))
コード例 #15
0
 def createDescription(self):
     desc = "Group %s: %s" % (self.uniq_id, humanFilesize(self.size/8))
     if "superblock_copy" in self:
         desc += " (with superblock copy)"
     return desc