void-packages/srcpkgs/eject/patches/eject-2.1.5-openrw.patch

18 lines
709 B
Diff

diff -pur eject-1/eject.c eject/eject.c
--- eject-1/eject.c 2011-08-19 11:42:22.697388647 +0400
+++ eject/eject.c 2011-08-19 11:57:27.636724026 +0400
@@ -911,7 +911,12 @@ static void Unmount(const char *fullName
/* Open a device file. */
static int OpenDevice(const char *fullName)
{
- int fd = open(fullName, O_RDONLY|O_NONBLOCK);
+ int fd = open(fullName, O_RDWR|O_NONBLOCK);
+ if (fd == -1 && errno == EACCES) {
+ if (v_option)
+ printf(_("%s: unable to open `%s' for R/W, SCSI commands can be fail. Trying Read-Only\n"), programName, fullName);
+ fd = open(fullName, O_RDONLY|O_NONBLOCK);
+ }
if (fd == -1) {
fprintf(stderr, _("%s: unable to open `%s'\n"), programName, fullName);
exit(1);