Somewhere we appear to be sending PREVENT_MEDIA_REMOVAL on a non-write fd. Kernel rejects this. Add in some debug messages to try and track this down. diff -urNp dvd+rw-tools-5.21.4.10.8/growisofs.c dvd+rw-tools-dsd/growisofs.c --- dvd+rw-tools-5.21.4.10.8/growisofs.c 2004-08-25 00:02:29.000000000 +0100 +++ dvd+rw-tools-dsd/growisofs.c 2004-12-10 03:04:50.962460088 +0000 @@ -472,6 +472,7 @@ char *find_raw_device(struct stat64 *sb) dev_minor = minor (sb->st_rdev); if ((rawctl=open ("/dev/rawctl",O_RDONLY)) < 0) return NULL; + fprintf(stderr, "1 opened %d\n", rawctl); for (i=1;i<256;i++) { req.raw_minor = i; @@ -515,12 +516,14 @@ char *setup_fds (char *device) */ #endif - if ((in_fd = open64 (device,O_RDONLY)) < 0) + if ((in_fd = open64 (device,O_RDONLY)) < 0) { + fprintf(stderr, "2 opened %d\n", in_fd); if (!(errno == ENOMEDIUM || errno == EMEDIUMTYPE) || (in_fd = open64 (device,O_RDONLY|O_NONBLOCK)) < 0) fprintf (stderr,":-( unable to open64(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); - + fprintf(stderr, "3 maybe opened %d\n", in_fd); + } #ifdef GET_REAL setreuid ((uid_t)-1,uid); #endif @@ -536,10 +539,12 @@ char *setup_fds (char *device) fprintf (stderr,":-( unable to re-open64(\"%s\",O_RDONLY): ", device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr, "4 opened %d\n", in_fd); open_rw: if ((out_fd = open64 (device,O_RDWR)) < 0) fprintf (stderr,":-( unable to open64(\"%s\",O_RDWR): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr, "5 opened %d\n", out_fd); if (fstat64(out_fd,&sc) < 0) fprintf (stderr,":-( unable to stat64(\"%s\"): ",device), perror (NULL), exit (FATAL_START(errno)); @@ -561,11 +566,12 @@ char *setup_fds (char *device) * with set-root-uid should fill in for the kernel * deficiency... */ - if ((fd = open64 (device,O_RDWR|O_NONBLOCK)) >= 0) + if ((fd = open64 (device,O_RDWR|O_NONBLOCK)) >= 0) { ioctl_handle=(void *)(long)fd; - else + fprintf(stderr, "6 opened %d\n", fd); + } else ioctl_handle=(void *)(long)dup(in_fd); - + fprintf(stderr,"7 ioctl %d\n", ioctl_handle); /* * get_mmc_profile terminates the program if ioctl_handle is * not an MMC unit... @@ -659,6 +665,8 @@ char *setup_fds (char *device) fprintf (stderr,":-( unable to open(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"8 opened %d\n", in_fd); + if (fstat (in_fd,&sb) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), perror (NULL), exit (FATAL_START(errno)); @@ -674,10 +682,12 @@ char *setup_fds (char *device) if ((in_fd = open (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to reopen(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"9 opened %d\n", in_fd); open_rw: if ((out_fd = open (device,O_RDWR)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"9 opened %d\n", out_fd); opened_rw: poor_man = 0; close (ioctl_fd); @@ -694,6 +704,7 @@ char *setup_fds (char *device) * access to DVD burner(s), but not to any other device. */ ioctl_handle = (void *)(long)open (device,O_RDWR); /* O_RDWR is a must for SCIOCCOMMAND */ + fprintf(stderr,"10 opened %d\n", ioctl_handle); if (ioctl_handle == INVALID_HANDLE) { fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",device), perror (NULL); @@ -760,6 +771,7 @@ char *setup_fds (char *device) if ((in_fd = open (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"11 opened %d\n", in_fd); if (fstat (in_fd,&sb) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), @@ -771,10 +783,12 @@ char *setup_fds (char *device) if ((in_fd = open (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to reopen(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"12 opened %d\n", in_fd); open_rw: if ((out_fd = open (device,O_RDWR)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"13 opened %d\n", out_fd); if (fstat(out_fd,&sc) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), perror (NULL), exit (FATAL_START(errno)); @@ -878,6 +892,7 @@ char *setup_fds (char *device) (in_fd = open64 (device,O_RDONLY|O_NONBLOCK)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"14 opened %d\n", in_fd); if (fstat64 (in_fd,&sb) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), @@ -895,10 +910,12 @@ char *setup_fds (char *device) if ((in_fd = open64 (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to reopen(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"15 opened %d\n", in_fd); open_rw: if ((out_fd = open64 (device,O_RDWR)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"16 opened %d\n", out_fd); if (fstat64(out_fd,&sc) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), perror (NULL), exit (FATAL_START(errno)); @@ -1022,6 +1039,7 @@ char *setup_fds (char *device) if ((in_fd = open64 (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"17 opened %d\n", in_fd); if (fstat64 (in_fd,&sb) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), @@ -1039,10 +1057,12 @@ char *setup_fds (char *device) if ((in_fd = open64 (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to reopen(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"18 opened %d\n", in_fd); open_rw: if ((out_fd = open64 (device,O_RDWR)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"19 opened %d\n", out_fd); if (fstat64(out_fd,&sc) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), perror (NULL), exit (FATAL_START(errno)); @@ -1084,6 +1104,7 @@ char *setup_fds (char *device) sprintf (rscsi,"/dev/rscsi/c%ut%u%c%x", (m>>16)&0xFF,(m>>12)&0xF,'l',(m>>8)&0xF); ioctl_handle = (void *)(long)open64 (rscsi,O_RDONLY); + fprintf(stderr,"20 opened %d\n", ioctl_handle); if (ioctl_handle == INVALID_HANDLE) { fprintf (stderr,":-( unable to open(\"%s\",O_RDONLY): ",rscsi), perror (NULL); @@ -1187,6 +1208,7 @@ char *setup_fds (char *device) fprintf (stderr,":-( unable to open(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); } + fprintf(stderr,"21 opened %d\n", in_fd); if (fstat64 (in_fd,&sb) < 0) fprintf (stderr,":-( unable to stat(\"%s\"): ",device), @@ -1204,9 +1226,11 @@ char *setup_fds (char *device) if ((in_fd = open64 (device,O_RDONLY)) < 0) fprintf (stderr,":-( unable to reopen(\"%s\",O_RDONLY): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"22 opened %d\n", in_fd); if ((out_fd = open64 (device,O_RDWR)) < 0) fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",device), perror (NULL), exit (FATAL_START(errno)); + fprintf(stderr,"23 opened %d\n", out_fd); opened_rw: poor_man = 0; close (ioctl_fd); @@ -1248,6 +1272,7 @@ char *setup_fds (char *device) memcpy (s,"/scsi",6); ioctl_handle = (void *)(long)open64 (hw_path,O_RDWR); + fprintf(stderr,"24 opened %d\n", ioctl_handle); if (ioctl_handle == INVALID_HANDLE) fprintf (stderr,":-( unable to open(\"%s\",O_RDWR): ",hw_path), perror (NULL), exit (FATAL_START(errno)); @@ -1268,7 +1293,8 @@ char *setup_fds (char *device) poor_man = 1; out_fd = dup (ioctl_fd); if (in_fd<0 && (in_fd=open64 (hw_path,O_RDONLY))<0) - /* hope for the best? */ ; + /* hope for the best? */ ; + fprintf(stderr,"25 opened %d\n", in_fd); setuid (uid); /* drop all privileges */ mediad_get_exclusiveuse (hw_path,"growisofs"); if (mediad_last_error ()==RMED_NOERROR) diff -urNp dvd+rw-tools-5.21.4.10.8/growisofs_mmc.cpp dvd+rw-tools-dsd/growisofs_mmc.cpp --- dvd+rw-tools-5.21.4.10.8/growisofs_mmc.cpp 2004-07-16 13:48:57.000000000 +0100 +++ dvd+rw-tools-dsd/growisofs_mmc.cpp 2004-12-10 02:03:50.347958080 +0000 @@ -1625,6 +1625,7 @@ pwrite64_t poor_mans_setup (void *fd,off cmd[0] = 0x1E; // PREVENT/ALLOW MEDIA REMOVAL cmd[4] = 1; // "Prevent" cmd[5] = 0; + fprintf (stderr,"preventing removal on fd %d\n",(int)fd); if ((err=cmd.transport ())) sperror ("PREVENT MEDIA REMOVAL",err), exit (FATAL_START(errno));