📄 growisofs.c
字号:
/* * growisofs 7.0 by Andy Polyakov <appro@fy.chalmers.se>. * * Version 6.0 is dedicated to all personal friends of mine! The code * was initially intended to be a 2006 New Year gift to them, but it * didn't happen:-( But it doesn't change the fact that I think of * you, guys! Cheers! * * Use-it-on-your-own-risk, GPL bless... * * This front-end to mkisofs(8) was originally developed to facilitate * appending of data to ISO9660 volumes residing on random write access * DVD media such as DVD+RW, DVD-RAM, as well as plain files/iso images. * At later stages even support for multi-session recording to DVD * write-once media such as DVD+R and DVD-R was added. * * As for growing random access volumes. The idea is very simple. The * program appends new data as it was added to a multisession media and * then copies the new volume descriptor(s) to the beginning of media * thus effectively updating the root catalog reference... * * For further details see http://fy.chalmers.se/~appro/linux/DVD+RW/. * * Revision history: * * 1.1: * - flush cache before copying volume descriptors; * 2.0: * - support for /dev/raw*; * - support for set-root-uid operation (needed for /dev/raw*); * - support for first "session" burning (needed for "poor-man"); * - "poor-man" support for those who don't want to recompile the * kernel; * 2.1: * - mkisofs_pid typo; * 2.2: * - uninitialized in_device variable; * - -help option; * 3.0: * - support for DVD+R; * 3.1: * - -Z fails if a file system is present and stdin is not a tty; * 3.2: * - support for image burning (needed for DVD+R as you can't use dd); * 3.3: * - 'growisofs -Z /dev/scdN image.iso' is too confusing, implement * 'growisofs -Z /dev/scdN=image.iso' instead; * 4.0: * - transport C++-fication for better portability; * - support for -dvd-compat option (improved DVD+R/RW compatibility); * - -dvd-video implies -dvd-compat; * - support for SONY DRU-500A; * - progress indicator for -Z /dev/scdN=image.iso; * - agressive -poor-man-ing; * 4.1: * - uninitialized errno at exit from -Z /dev/scdN=image.iso; * 4.2: * - don't print initial bogus progress indicator values; * - apparently some firmwares exhibit ambiguity in DVD+R disc * finalizing code; * 5.0: * - enforced 32K write strategy (needed for DVD-R[W]); * - support for DVD-RW Restricted Overwrite Mode; * - support for DVD-R[W] Sequential Mode; * 5.1: * - support for writing speed control; * 5.2: * - re-make it work under Linux 2.2 kernel; * - progress indicator to display recording velocity; * - code to protect against overburns; * - undocumented -use-the-force-luke flag to overwrite the media * none interactively; * - brown-bag bug in "LONG WRITE IN PROGRESS" handling code fixed; * 5.3: * - Pioneer workarounds/fix-ups, most notably DVR-x05 doesn't seem * to digest immediate "SYNC CACHE"; * - support for DVD-RW Quick Format, upon release verified to work * with Pioneer DVR-x05; * - bug in DVD+RW overburn "protection" code fixed; * - media reload is moved here from dvd+rw-format; * - refuse to burn if session starts close to or beyond 4GB limit * (limitation of Linux isofs implementation); * - dry_run check is postponed all the way till the first write; * 5.4: * - split first write to two to avoid "empty DMA table?" in kernel log; * - setup_fds is introduced to assist ports to another platforms; * - set-root-uid assistant code directly at entry point (see main()); * - OpenBSD/NetBSD support added, it's worth noting that unlike 3.3 * port by Maarten Hofman, it's /dev/rcd?c which is expected to be * passed as argument, not /dev/cd?c. * 5.5: * - fix for ENOENT at unmount, I should have called myself with execlp, * not execl; * - security: chdir("/") in set-root-uid assistant; * - use /proc/mounts instead of MOUNTED (a.k.a. /etc/mtab) in Linux * umount code; * 5.6: * - unconditional exit in set-root-uid assistant, mostly for aesthetic * reasons; * - support for DVD-RW DAO recordings (whenever Pioneer-ish Quick * Format is not an option, DAO should fill in for it, as it's the * only recording strategy applicable after *minimal* blanking * procedure); * - support for SG_IO pass-through interface, or in other words * support for Linux 2>=5; * - 'growisofs -M /dev/cdrom=/dev/zero', this is basically a counter- * intuitive kludge assigned to fill up multi-session write-once * media for better compatibility with DVD-ROM/-Video units, to keep * it mountable [in the burner unit] volume descriptors from previous * session are copied to the new session; * - disable -dvd-compat with -M option and DVD+R, advice to fill up * the media as above instead; * - postpone Write Page setup all the way till after dry_run check; * - if recording to write-once media is terminated by external event, * leave the session opened, so that the recording can be resumed * (though no promises about final results are made, it's just that * leaving it open makes more sense than to close the session); * - ask unit to perform OPC if READ DISC INFORMATION doesn't return * any OPC descriptors; * - get rid of redundant Quick Grow in Restricted Overwrite; * - Solaris 2.x support is merged, it's volume manager aware, i.e. * you can run it with or without volume manager; * 5.7: * - Solaris USB workaround; * - 15 min timeout for FLUSH CACHE in DVD-RW DAO; * - revalidate recording speed; * - load media upon start-up (Linux used to auto-close tray upon open, * but not the others, which is why this functionality is added so * late); * 5.8: * - elder Ricoh firmwares seem to report events differently, which * triggered growisofs and dvd+rw-format to end-less loop at startup * [event handling was introduced in 5.6 for debugging purposes]; * - int ioctl_fd is transformed to void *ioctl_handle to facilitate * port to FreeBSD; * - FreeBSD support contributed by Matthew Dillon; * - volume descriptors from second session were discarded in * Restricted Overwrite since 5.6; * 5.9: * - some [SONY] firmwares make it impossible to tell apart minimally * and fully blanked media, so we need a way to engage DAO manually * [in DVD-RW]... let's treat multiple -dvd-compat options as "cry" * for DAO; * - refuse to finalize even DVD-R media with -M flag (advise to fill * it up with -M /dev/cdrom=/dev/zero too), apparently DVD-units * [or is it just SONY?] also "misplace" legacy lead-out in the same * manner as DVD+units; * - oops! DAO hung at >4MB buffer because of sign overflow; * - couple of human-readable error messages in poor_mans_pwrite64; * - work around Plextor firmware deficiency which [also] manifests as * end-less loop upon startup; * 5.10: * - increase timeout for OPC, NEC multi-format derivatives might * require more time to fulfill the OPC procedure; * - extended syntax for -use-the-force-luke option, it's now possible * to engage DVD-R[W] dummy mode by -use-the-force-luke=[tty,]dummy * for example, where "tty" substitutes for the original non-extended * option meaning, see the source for more easter eggs; * - FreeBSD: compile-time option to pass -M /dev/fd/0 to mkisofs to * make life easier for those who mount devfs, but not fdescfs; * - eliminate potential race conditions; * - avoid end-less loop if no media was in upon tray load; * - interpret value of MKISOFS environment variable as absolute path * to mkisofs binary; * - to facilitate for GUI front-ends return different exit codes, most * notably exit value of 128|errno denotes a fatal error upon program * startup [messages worth popping up in a separate modal dialog * perhaps?], errno - fatal error during recording and 1 - warnings * at exit; * - to facilitate for GUI front-ends auto-format blank DVD+RW media; * - Linux: fix for failure to copy volume descriptors when DVD-RW * Restricted Overwrite procedure is applied to patched kernel; * - FreeBSD: growisofs didn't close tray upon startup nor did the rest * of the tools work with open tray; * - bark at -o option and terminate execution, the "problem" was that * users seem to misspell -overburn once in a while, in which case it * was passed down to mkisofs and an iso-image was dumped to current
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -