Hi, i decided to regard a device with 0 lseekable size as not suitable for -cut_out. The test for suitable type rejects S_ISDIR, S_ISLNK, S_ISFIFO, and S_ISSOCK. So if an operating system offers non-POSIX types, it will be possible to test whether they are elsewise suitable.
Please give the code a thorough test, especially with weird -cut_out arguments. --------------------------------------------------------------------------- Committed are: https://dev.lovelyhq.com/libburnia/libisofs.git commit 011e2e85e6dfe6e5d882d198c29fd15c02d38e5e Author: Thomas Schmitt <scdbac...@gmx.net> Date: Tue Apr 26 12:12:15 2022 +0200 Allowed lseekable device files with iso_tree_add_new_cut_out_node(). Proof-of-concept by Ivan Shmakov. commit f457a4f8b9a59906cde1b6577e7116944a37d2d0 Author: Thomas Schmitt <scdbac...@gmx.net> Date: Tue Apr 26 12:06:18 2022 +0200 Added missing stream type names to a diagnostic function commit 2af17490a08c29b033942da42d27b5bda076ad05 Author: Thomas Schmitt <scdbac...@gmx.net> Date: Tue Apr 26 12:03:53 2022 +0200 Bug fix: The lseek methods of IsoFileSource for local filesystem and loaded ISO returned libisofs error codes as positive off_t numbers https://dev.lovelyhq.com/libburnia/libisoburn.git commit fc587966d3c770be8b71e57e924cb5cbf7121f76 Author: Thomas Schmitt <scdbac...@gmx.net> Date: Tue Apr 26 12:17:22 2022 +0200 Allowed lseekable device files with -cut_out. Proof-of-concept by Ivan Shmakov. --------------------------------------------------------------------------- Mentioning in man xorriso: =========================================================================== Map a byte interval of a regular disk file or of a device file into a regular file in the ISO image. The file depicted by disk_path has to support random read access. ... Another use case is copying the content of a device file as interval or as a whole into the emerging ISO filesystem. The fact that the byte_count is allowed to be unreasonably high enables copying of a whole device: -cut_out /dev/sdd3 0 1000g /content_of_sdd3 --------------------------------------------------------------------------- Behavior with the various file types and situations: =========================================================================== Intentional failures: --------------------------------------------------------------------------- S_IFIFO: xorriso : ERRFILE : /home/test/fifo xorriso : FAILURE : -cut_out: File type (name_pipe) is not suitable for this command: '/home/test/fifo' --------------------------------------------------------------------------- S_IFLNK: xorriso : ERRFILE : /home/test/link xorriso : FAILURE : -cut_out: File type (symbolic_link) is not suitable for this command: '/home/test/link' --------------------------------------------------------------------------- S_IFSOCK: xorriso : ERRFILE : /run/user/1000/pulse/native xorriso : FAILURE : -cut_out: File type (unix_socket) is not suitable for this command: '/run/user/1000/pulse/native' --------------------------------------------------------------------------- S_IFDIR: xorriso : ERRFILE : /run/user/1000/pulse xorriso : FAILURE : -cut_out: File type (directory) is not suitable for this command: '/run/user/1000/pulse' --------------------------------------------------------------------------- S_IFREG not large enough: xorriso : ERRFILE : /home/x xorriso : SORRY : -cut_out: Byte offset 32768 larger than addressable file size 1209 : '/home/x' --------------------------------------------------------------------------- S_IFCHR (tests are made on Linux): xorriso : FAILURE : -cut_out: Special file with addressable size range of 0 encountered xorriso : ERRFILE : /dev/zero xorriso : FAILURE : -cut_out: File (char_device) does not support random read access: '/dev/zero' --------------------------------------------------------------------------- S_IFBLK without read permission: xorriso : FAILURE : Determination of random-access readable capacity failed: '/dev/sdb' : Permission denied xorriso : ERRFILE : /dev/sdb xorriso : FAILURE : -cut_out: File (block_device) does not support random read access: '/dev/sdb' --------------------------------------------------------------------------- S_IFBLK not large enough: xorriso : ERRFILE : /dev/sdc xorriso : FAILURE : -cut_out: Byte offset 4294967296 larger than addressable file size 2004877312 : '/dev/sdc' =========================================================================== Successes: --------------------------------------------------------------------------- S_IFBLK of sufficient size: (only a message of severity DEBUG appears, like with the others too: xorriso : DEBUG : -cut_out from /dev/sdc , byte 1024 to 3072, and graft as /sdc ) --------------------------------------------------------------------------- S_IFREG of sufficient size: (only a message of severity DEBUG appears, like with the others too: xorriso : DEBUG : -cut_out from /home/x , byte 1024 to 3072, and graft as /x ) --------------------------------------------------------------------------- Have a nice day :) Thomas