Package: eject Version: 2.1.5+deb1-4 Tags: patch User: [EMAIL PROTECTED] Usertags: origin-ubuntu ubuntu-patch jaunty
Hello, As reported in https://launchpad.net/bugs/264071, eject -X does not properly resolve symlinks: $ eject -Xv eject: using default device `cdrom' eject: device name is `cdrom' eject: expanded name is `/dev/cdrom' eject: `/dev/cdrom' is a link to `/dev/scd0' eject: `/dev/scd0' is not mounted eject: `/dev/scd0' is not a mount point eject: listing CD-ROM speed eject: error while finding CD-ROM name It appears to be complaining because /proc/sys/dev/cdrom/info references 'sr0' rather than 'scd0'. /dev/sr0 is just another symlink to /dev/scd0. Attached patch (by Adam Buchbinder) fixes this by resolving symbolic links. It was sent to eject's upstream by email (since we did not find a proper bug tracker). It was applied in Ubuntu some weeks ago without any regression reports. Thanks for considering, Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
diff -u eject-2.1.5/configure.in eject-2.1.5-new/configure.in
--- eject-2.1.5/configure.in 2006-06-03 21:58:18.000000000 -0400
+++ eject-2.1.5-new/configure.in 2008-09-23 10:22:09.000000000 -0400
@@ -28,7 +28,7 @@
AC_C_CONST
dnl Checks for library functions.
-AC_CHECK_FUNCS(regcomp strdup strerror)
+AC_CHECK_FUNCS(regcomp strdup strerror asprintf)
dnl only try standard kernel paths if the toolchain
dnl is unable to locate linux includes by itself
diff -u eject-2.1.5/eject.c eject-2.1.5-new/eject.c
--- eject-2.1.5/eject.c 2006-02-10 20:54:38.000000000 -0500
+++ eject-2.1.5-new/eject.c 2008-09-23 10:32:47.000000000 -0400
@@ -30,6 +30,9 @@
*
*/
+/* for asprintf() */
+#define _GNU_SOURCE
+
#include "i18n.h"
#ifndef DEFAULTDEVICE
@@ -594,6 +597,8 @@
#endif
}
+static char *SymLink(const char *name);
+
/*
* Read Speed of CD-ROM drive. From Linux 2.6.13, the current speed is correctly reported
*/
@@ -601,6 +606,7 @@
{
char line[512];
char *str_speed, *str_name;
+ int ld = 6; // max symbolic link depth
int drive_number = -1, i;
FILE *f = fopen("/proc/sys/dev/cdrom/info", "r");
@@ -616,6 +622,23 @@
if (drive_number == -1) {
if (strncmp(line, "drive name:", 11) == 0) {
str_name = strtok(&line[11], "\t ");
+ // str_name may contain a symlink
+ char *full_str_name, *dev_name;
+ int ret = asprintf(&full_str_name, "/dev/%s", str_name);
+ if (ret == -1) {
+ fprintf(stderr, _("%s: error while allocating string\n"), programName);
+ exit(1);
+ }
+ full_str_name[strlen(full_str_name)-1] = '\0'; // chop trailing \n
+ while ((dev_name = SymLink(full_str_name)) && ld > 0) {
+ if (v_option)
+ printf(_("%s: `%s' is a link to `%s'\n"), programName, full_str_name, dev_name);
+ free(full_str_name);
+ full_str_name = strdup(dev_name);
+ free(dev_name);
+ ld--;
+ }
+ str_name = rindex(full_str_name, '/') + 1;
drive_number = 0;
while (strncmp(shortName, str_name, strlen(shortName)) != 0) {
drive_number++;
signature.asc
Description: Digital signature

