https://bugs.kde.org/show_bug.cgi?id=367639
--- Comment #21 from Thomas Schmitt <scdbac...@gmx.net> --- Hi, this is about the effort needed to implement multi-session on DVD+RW, DVD-RAM, formatted DVD-RW, BD-RE, overwritably formatted BD-R. It should be possible by duplicating capabilities of growisofs and xorriso. Probably one would be better off by delegating the job into one of these programs, but i assume the separation of ISO 9660 producer and burn program is part of K3B's architecture. cdrskin --grow_overwriteable_iso would fit best into that separation. A compatibility problem is that only growisofs operates on overwritably formatted BD-R, which it formats by default when getting them in blank state. Given the corresponding CLOSE SESSION bug in original growisofs-7.1, the slow speed of formatted BD-R, and this compatibility problem, one should really consider to add option -use-the-force-luke=spare=none by default to growisofs runs on blank unformatted BD-R. The run will succeed with original growisofs-7.1 and the medium will be usable for cdrskin and xorriso, if it does not get closed by growisofs options. If cdrecord supports multi-session on BD-R, then quite surely only on those which are not formatted to be pseudo-overwritable. (I dare to predict this because Joerg Schilling expressed his general objections against emulated multi-session on overwritables.) -------------------------------------------------------------------- Why there is a problem: -C X,0 is not suitable for ISO 9660 multi-session, because Next Writable Address 0 would overwrite the existing session instead of appending a new session after its end. I looked into libk3bdevice/k3bdevice.cpp : ...::getNextWritableAdress(). It inquires the start of the last written session by SCSI command READ TRACK INFORMATION with address type 1. The value is taken from the reply field "Logical Track Start Address". This number is supposed to be 0 with overwritably formatted media. That's well ok for the first parameter value of mkisofs option -C if an ISO 9660 filesystem is present on the medium. The ISO superblock at address 0 is supposed to point to the newest directory tree. The second parameter value for option -C is the Next Writable Address. To obtain it, K3B sends READ TOC/PMA/ATIP with reply format 1, which returns for non-CD media a fabricated Table-Of-Content. The value is taken from reply field "Start Address of First Track in Last Session". (The "last session" is supposed to be the unwritten medium area.) With an overwritably formatted medium, this value is supposed to be always 0. ---------------------------------------------------------------------- How to fix it growisofs style: growisofs introduced emulated multi session by reading the size information of the ISO 9660 filesystem, writing the add-on session after the end of the existing filesyem, and overwriting the ISO 9660 superblock at the start of the medium. So one should read block 16 (* 2048 bytes) of the medium and check its first 6 bytes for {0x01,'C','D','0','0','1'}. If this magic number of ISO 9660 is found, then bytes 80 to 83 of the block tell the number of blocks as little-endian unsigned 32 bit number. This number would be the first block address which does not overwrite blocks from the existing ISO 9660 sessions. One should round it up to the next multiple of 32 blocks, in order to match alignment constraints of some DVD and BD media. (Caution: growisofs rounds to 16, not 32.) This way one gets a suitable second parameter value for mkisofs -C. Next is the problem to talk the burn program into writing the output of mkisofs to the same start block as was told to mkisofs by this value. growisofs source code shows that there is an option -use-the-force-luke=seek=<number> which might be usable together with option -Z (but not -M) to force growisofs into starting the write run at the given block number. One would have to test with DVD+RW, BD-RE, or formatted DVD-RW. cdrskin has option write_start_address=<byte_offset> (i.e. one has to multiply the block number by 2048) which lets writing start at the given byte number. Afterwards, a copy of the new ISO 9660 superblock must be written to block 0 (up to at least block 17), so that mount(8) shows the new directory tree. In this copy it is necessary to add the start block address to the number of blocks counter in the superblock. One will recognize success by the new files of the new session showing up after mount. This last step is tricky with burn programs, because they tend to write more data than given to them. On Linux, one does not need a burn program for writing to overwritable media. Normal open(2), lseek(2), write(2) will do. ---------------------------------------------------------------------- cdrskin's special offer: With cdrskin it is possible to let it decide about the -C parameter values with the promise that it will use the second told value as start address of the future burn run and to copy the patched superblock: $ cdrskin --grow_overwriteable_iso dev=/dev/sr0 -msinfo 2>/dev/null 0,3438672 $ mkisofs ... -M /dev/sr0 -C 0,3438672 ... \ | cdrskin --grow_overwriteable_iso dev=/dev/sr0 -waiti -multi ... - (Note the misspelling: "grow_overwrit*e*able_iso". Sorry for that.) Option --grow_overwriteable_iso does not hamper the work with unformatted multi-session media: CD-R, DVD-R, DVD+R, ... So the shown commands work with the media spectrum from CD-R to BD-RE. Only DVD-R DL and fast blanked DVD-RW cannot do multi-session for drive-media-internal reasons. growisofs and xorriso actually aim to encapsulate this gesture so that the user does not have to care for the multi-session peculiarities. ---------------------------------------------------------------------- Have a nice day :) Thomas -- You are receiving this mail because: You are watching all bug changes.