bugCompact Disc Input and Control Library - Bugs: bug #63091, cdio_eject_media fails when mount...


bug #63091: cdio_eject_media fails when mount point of the device to eject contains spaces

Submitter:  Alban Browaeys <prahal>
Submitted:  Fri 23 Sep 2022 06:30:33 AM UTC
Category:  library code Severity:  5 - Average
Item Group:  libcdio Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Fri 23 Sep 2022 03:31:05 PM UTC, comment #2: 

You can close this issue. This was handled in https://git.savannah.gnu.org/cgit/libcdio.git/commit/?id=0d550dc9307901edd817333a5b530241d08ad889 by patch from https://lists.gnu.org/archive/html/libcdio-devel/2022-02/msg00000.html by Miguel Borges de Freitas. I came to the same conclusion (use getmntent instead of home made decoding code) and in the process of coding it, I found this mail on the devel ML.

Alban Browaeys <prahal>
Fri 23 Sep 2022 06:41:43 AM UTC, comment #1: 

A test can be made with cdemu:
build and install cdemu

ffmpeg -f lavfi -i color=size=1280x720:rate=25:color=black -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100  -target pal-dvd -aspect 16:9 -t 10 output.mpeg
VIDEO_FORMAT=PAL dvdauthor -t -o ./dvd output.mpeg
VIDEO_FORMAT=PAL dvdauthor -T -o ./dvd output.mpeg
genisoimage -o dvdvideo.iso -V A\ TEST -dvd-video DVD
cdemu load 0 dvdvideo.iso

in /proc/mounts you now have:

/dev/sr0 /media/prahal/A\040TEST udf ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8 0 0

then calling cdio_eject_media on /dev/sr0 opened via cdio_open should output the error to umount and the cdemu disk will not be ejected.

I tried to cook a test code but I get undefined reference when I compile:

#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <cdio/cdio.h>

int main() {
        CdIo_t * cdio = cdio_open("/dev/sr0", DRIVER_DEVICE);
        if (!cdio) return -1;


        return 0;


$ gcc -o b -lcdio -lm  b.c
/usr/bin/ld: /tmp/cc2zZweC.o: in function `main':
b.c:(.text+0x15): undefined reference to `cdio_open'
/usr/bin/ld: b.c:(.text+0x35): undefined reference to `cdio_eject_media'
/usr/bin/ld: b.c:(.text+0x41): undefined reference to `cdio_destroy'
collect2: error: ld returned 1 exit status

I have the headers installed (confirmed by cpp b.c) and the library is in the search path and has the symbols per objdump -S.

Alban Browaeys <prahal>
Fri 23 Sep 2022 06:30:33 AM UTC, original submission:  

fstab,mtab,.proc/mounts escape spaces with \040.
libcdio "is_mounted" reads /proc/mounts or /etc/mtab to get the mount point path via fscanf thus it gets the path with the spaces encoded as \040. Then its caller "eject_media_linux"
calls "umount" (via "do_umount") with this path containing \040 which umount is unable to handle thus the error to the terminal:

umount: /media/prahal/Boule\040et\040Bill: No such file or directory

and the failure to eject the DVD (Kodi is a user of cdio_eject_media).

I believe lib/driver/gnu_linux.c should embed the decode logic from https://salsa.debian.org/debian/sysvinit/-/blob/master/src/fstab-decode.c, ie after a backslash translate:
R("\\", '\\'),
R("011", '\t'),
R("012", '\n'),
R("040", ' '),
R("134", '\\')
in the mount point path.

Would do_umount be the proper place thereof or is_mounted before copying the mount point path to the out parameter?

This issue breaks eject on all API users when there is a "fstab escaped" character.

Alban Browaeys <prahal>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by prahal (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code