How to use the pycdlib.rockridge.RRSLRecord function in pycdlib

To help you get started, we’ve selected a few pycdlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clalancette / pycdlib / tests / unit / test_rockridge.py View on Github external
def test_rrsl_component_factory_root():
    com = pycdlib.rockridge.RRSLRecord.Component.factory(b'/')
    assert(com.flags == 0x8)
    assert(com.curr_length == 0)
    assert(com.data == b'/')
github clalancette / pycdlib / tests / unit / test_rockridge.py View on Github external
def test_rrslrecord_set_continued_not_initialized():
    sl = pycdlib.rockridge.RRSLRecord()
    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        sl.set_continued()
    assert(str(excinfo.value) == 'SL record not initialized')
github clalancette / pycdlib / tests / unit / test_rockridge.py View on Github external
def test_rrslrecord_parse_double_initialized():
    sl = pycdlib.rockridge.RRSLRecord()
    sl.parse(b'SL\x08\x01\x00\x00\x03foo')
    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        sl.parse(b'SL\x08\x01\x00\x00\x03foo')
    assert(str(excinfo.value) == 'SL record already initialized')
github clalancette / pycdlib / tests / unit / test_rockridge.py View on Github external
def test_rrslrecord_last_component_continued_no_components():
    sl = pycdlib.rockridge.RRSLRecord()
    sl.new()
    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        sl.last_component_continued()
    assert(str(excinfo.value) == 'Trying to get continued on a non-existent component!')
github clalancette / pycdlib / tests / unit / test_rockridge.py View on Github external
def test_rrslrecord_new_double_initialized():
    sl = pycdlib.rockridge.RRSLRecord()
    sl.new()
    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        sl.new()
    assert(str(excinfo.value) == 'SL record already initialized')
github clalancette / pycdlib / tests / unit / test_rockridge.py View on Github external
def test_rrslrecord_record_not_initialized():
    sl = pycdlib.rockridge.RRSLRecord()
    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        sl.record()
    assert(str(excinfo.value) == 'SL record not initialized')
github clalancette / pycdlib / pycdlib / rockridge.py View on Github external
curr_sl.new()

        sl_rec_header_len = RRSLRecord.header_length()

        thislen = RRSLRecord.length([b'a'])
        if curr_dr_len + thislen < ALLOWED_DR_SIZE:
            # There is enough room in the directory record for at least
            # part of the symlink
            curr_comp_area_length = ALLOWED_DR_SIZE - curr_dr_len - sl_rec_header_len
            self.dr_entries.sl_records.append(curr_sl)
            curr_dr_len += sl_rec_header_len
            sl_in_dr = True
        else:
            # Not enough room in the directory record, so proceed to
            # the continuation entry directly.
            curr_comp_area_length = RRSLRecord.maximum_component_area_length()
            self.ce_entries.sl_records.append(curr_sl)
            if self.dr_entries.ce_record is not None:
                self.dr_entries.ce_record.add_record(sl_rec_header_len)
            sl_in_dr = False

        for index, comp in enumerate(symlink_path.split(b'/')):
            special = False
            if index == 0 and comp == b'':
                comp = b'/'
                special = True
                mincomp = comp
            elif comp == b'.':
                special = True
                mincomp = comp
            elif comp == b'..':
                special = True
github clalancette / pycdlib / pycdlib / rockridge.py View on Github external
done = False
            while not done:
                minimum = RRSLRecord.Component.length(mincomp)
                if minimum > curr_comp_area_length:
                    # There wasn't enough room in the last SL record
                    # for more data.  Set the 'continued' flag on the old
                    # SL record, and then create a new one.
                    curr_sl.set_continued()
                    if offset != 0:
                        # If we need to continue this particular
                        # *component* in the next SL record, then we
                        # also need to mark the curr_sl's last component
                        # header as continued.
                        curr_sl.set_last_component_continued()

                    curr_sl = RRSLRecord()
                    curr_sl.new()
                    self.ce_entries.sl_records.append(curr_sl)
                    curr_comp_area_length = RRSLRecord.maximum_component_area_length()
                    if self.dr_entries.ce_record is not None:
                        self.dr_entries.ce_record.add_record(sl_rec_header_len)
                    sl_in_dr = False

                if special:
                    complen = minimum
                    length = 0
                    compslice = comp
                else:
                    complen = RRSLRecord.Component.length(comp[offset:])
                    if complen > curr_comp_area_length:
                        length = curr_comp_area_length - 2
                    else: