Ejemplo n.º 1
0
 def __init__(self, filehandle):
     self._objid = ObCacheId(filehandle)
     if self._objid.bucketNameVersionIsV1():
         self.prefix = "%08X_%s." % (fnv1_hash(self._objid.bytes), str(self._objid).upper())
         self._name_version = 1
     else:
         self.prefix = "%016X_%s." % (hash64(self._objid), str(self._objid).upper())
         self._name_version = 2
     self.best_name = None
     self.best_version = None
Ejemplo n.º 2
0
def unparse_indirect(run_options, tObj, blockList, treeIndex, depth):
    ba = bytearray()
    btypeList = get_unparse_handle_list(tObj.ftype, Btype.BTYPE_INDIRECT)
    indirBlockId = ObCacheId()
    offset = 0xFFFFFFFF & ((treeIndex << 16) + depth)
    ba = unparse_obj_handles(run_options,
                             tObj,
                             ba,
                             indirBlockId,
                             objBtypeList=btypeList,
                             ownerFh=tObj.filehandle,
                             dataOffset=offset,
                             indirectBlockList=blockList)
    return indirBlockId, ba
Ejemplo n.º 3
0
def generate_bucket_name(objId,
                         ownerObjId,
                         objType,
                         version=OBJ_VERSION_INITIAL,
                         nameprefix=None):
    '''
    Generate bucketnames given oid and owner obj id.
    Special objects that are outside the filesystem tree have V1 names.
    All other objects have V2 names
    '''
    if isinstance(objId, Filehandle):
        objId = ObCacheId(objId)

    if objId.bucketNameVersionIsV1():
        nameVersion = 1
    else:
        nameVersion = 2

    if objId.isRootId():
        ownerObjId = objId
        objType = Btype.BTYPE_DIR

    if nameVersion == 1:
        prefix = fnv1_hash(objId.bytes)
    else:
        prefix = hash64(objId)

    parentHash = hash64(ownerObjId)
    snapshotid = 0xFFFFFFFF
    if nameVersion == 1:
        name = "%08X_%s.%011u.%08X.%04u" % (prefix, str(objId).upper(),
                                            version, snapshotid, nameVersion)
    else:
        name = "%016X_%s.%04u.%016X.%011u.%08X.%04u" % (prefix, objId.__str__(
        ).upper(), objType, parentHash, version, snapshotid, nameVersion)
    if not nameprefix:
        return name
    return nameprefix + name
Ejemplo n.º 4
0
def unparse_segment(run_options, tobj, ftype, ownerfh, offset, data):
    'pass owning object offset and data at offset'
    segmentId = ObCacheId()
    return segmentId, unparse_segment_using_obid(run_options, segmentId, tobj,
                                                 ftype, ownerfh, offset, data)