The sysutils/eject port is quite useful to eject those cdroms and other removeable media. However, you need to know the "real" name of the device in order to eject it. Indeed, eject(1), given a "arg" argument tries to eject from the "/dev/argc" device, which is good, but could be better. The attached patch makes it look around a bit more, first in /dev/arg, then /dev/argc and just plain ./arg. Also, if the file found is a symlink, the patch makes eject unfold the link to find what device is behind it so it can umount it correctly. Fix: Attach the following patch to the ports infrastructure. I tried to contact the author of the original software: no response. --- eject.c 2003/04/04 04:55:07 1.1 +++ eject.c 2003/04/06 22:09:37 1.3 @@ -104,6 +104,15 @@ if (sts < 0) { perror(program); exit(1); + } else { + int c; + char *dev_bak = malloc(MAXPATHLEN); + if (c = readlink(device, dev_bak, MAXPATHLEN)) { + dev_bak[c] = '\0'; + name = dev_bak; + } else { + free(dev_bak); + } } sts = unmount_fs(name, &err); @@ -130,15 +139,23 @@ char *name; char **device; { - int sts; + int sts, i; struct stat sb; - - if (asprintf(device, "/dev/%sc", name) == -1) - return sts; - if (vflag || nflag) { - printf("%s: using device %s\n", program, *device); + const char* dev_list[] = { "/dev/%sc", "/dev/%s", "%s" }; + for (i = 0; i < 2; i++) { + if (asprintf(device, dev_list[i], name) == -1) + return sts; + if (vflag || nflag) { + printf("%s: trying device %s\n", program, *device); + } + sts = stat(*device, &sb); + if (sts) { /* stat failed, try next */ + free(*device); + continue; + } else { + break; + } } - sts = stat(*device, &sb); return sts; } How-To-Repeat: try to umount cdrom or umount cdr
State Changed From-To: open->closed Commited, thanks!