Hello, currently cryptsetup tries to detect whether or not a device is readonly with the BLKROGET ioctl call. This does not work for cdroms under linux. I do not know why and whether or not this is intended. The attached patch changes this. It makes cryptsetup try to open the devide Read-Write. When this fails and the error is EROFS, then it is assumed that the device is readonly and cryptsetup tries to open it read-only and proceeds as normal. Regards, Till
--- cryptsetup-1.0.5.orig/lib/setup.c 2007-05-02 16:44:06.000000000 +0200 +++ cryptsetup-1.0.5/lib/setup.c 2007-08-17 18:45:28.000000000 +0200 @@ -318,26 +318,25 @@ char buf[128]; uint64_t size; unsigned long size_small; - int readonly; + int readonly = 0; int ret = -1; int fd; - fd = open(device, O_RDONLY); + fd = open(device, O_RDWR); if (fd < 0) { - set_error("Error opening device: %s", - strerror_r(errno, buf, 128)); - return -1; + if (errno == EROFS) { + readonly = 1; + fd = open(device, O_RDONLY); + } + } else { + close(fd); + fd = open(device, O_RDONLY); } - -#ifdef BLKROGET - if (ioctl(fd, BLKROGET, &readonly) < 0) { - set_error("BLKROGET failed on device: %s", + if (fd < 0) { + set_error("Error opening device: %s", strerror_r(errno, buf, 128)); return -1; } -#else -# error BLKROGET not available -#endif #ifdef BLKGETSIZE64 if (ioctl(fd, BLKGETSIZE64, &size) >= 0) {
--------------------------------------------------------------------- dm-crypt mailing list - http://www.saout.de/misc/dm-crypt/ To unsubscribe, e-mail: dm-crypt-unsubscribe@xxxxxxxx For additional commands, e-mail: dm-crypt-help@xxxxxxxx