4

I've run into an error stemming from lacking permissions when using the CDIO library to issue an eject command to my USB CD-ROM drive. I always get an error message like this:

INFO: ioctl CDROM_SEND_PACKET for command PREVENT ALLOW MEDIUM REMOVAL (0x1e) failed: Operation not permitted

The ioctl call is part of the cdda-player app I call as follows:

cdda-player -ev /dev/sr0

After taking a look into the sourcecode of libcdio, I found out that this line of code makes trouble:

int i_rc = ioctl (p_env->gen.fd, CDROM_SEND_PACKET, &cgc);

When I run the code as root (using sudo), everything works fine. Here are the permissions for my CD-ROM drive:

pi@autoradio:/import/valen/autoradio/libcdio-master $ ls -al /dev/sr0 
brw-rw----+ 1 root cdrom 11, 0 Jul  5 22:42 /dev/sr0

pi@autoradio:/import/valen/autoradio/libcdio-master $ ls -al /dev/sg0 
crw-rw----+ 1 root cdrom 21, 0 Jul  5 22:38 /dev/sg0

pi@autoradio:~ $ getfacl /dev/sr0 
getfacl: Removing leading '/' from absolute path names 
# file: dev/sr0 
# owner: root 
# group: cdrom 
user::rw- 
user:pi:rw- 
group::rw- 
mask::rw- 
other::---

The user pi is part of the cdrom group. The standard eject utility does work, though.

Now: Which permissions do I have to set for the eject operation to work as an ordinary user? Thank you.

UPDATE: Here is my kernel version:

pi@autoradio:/import/valen/autoradio/libcdio-master $ uname -a 
Linux autoradio 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux 
1

OK, after a hint from one of the maintainers of libcdio, I found out that the version I installed was out of date and contained a bug based on improper use of O_RDWR vs. O_RDONLY. After the update, suddenly everything works fine. Nevertheless thank you for your hints!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.