rpms/eject/devel eject-2.1.5-opendevice.patch, NONE, 1.1 eject-2.1.5-spaces.patch, NONE, 1.1 eject.spec, 1.28, 1.29

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Oct 30 14:53:49 UTC 2006


Author: than

Update of /cvs/dist/rpms/eject/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv30801

Modified Files:
	eject.spec 
Added Files:
	eject-2.1.5-opendevice.patch eject-2.1.5-spaces.patch 
Log Message:
apply upstream patch to fix #212467


eject-2.1.5-opendevice.patch:
 eject.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

--- NEW FILE eject-2.1.5-opendevice.patch ---
--- eject.c	2006/02/11 01:54:38	1.8
+++ eject.c	2006/06/11 22:48:16	1.9
@@ -543,10 +543,11 @@
 
 #ifdef CDROMCLOSETRAY
 
-	/* Try to open the CDROM tray and measure the time therefor
-	 * needed.  In my experience the function needs less than 0.05
+	/* Try to open the CDROM tray and measure the time needed.
+	 * In my experience the function needs less than 0.05
 	 * seconds if the tray was already open, and at least 1.5 seconds
-	 * if it was closed.  */
+	 * if it was closed.
+	 */
 	gettimeofday(&time_start, NULL);
 	
 	/* Send the CDROMEJECT command to the device. */
@@ -813,10 +814,17 @@
 }
 
 
-/* Open a device file. */
+/* Open a device file. Try opening first read/write, and if that fails then read only. */
 static int OpenDevice(const char *fullName)
 {
-	int fd = open(fullName, O_RDONLY|O_NONBLOCK);
+	int fd;
+
+	fd = open(fullName, O_RDWR|O_NONBLOCK);
+	if (fd != -1) {
+		return fd;
+	}
+	
+	fd = open(fullName, O_RDONLY|O_NONBLOCK);
 	if (fd == -1) {
 		fprintf(stderr, _("%s: unable to open `%s'\n"), programName, fullName);
 		exit(1);

eject-2.1.5-spaces.patch:
 eject.c |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

--- NEW FILE eject-2.1.5-spaces.patch ---
--- eject.c	2006/07/15 23:28:28	1.10
+++ eject.c	2006/10/16 22:58:39	1.11
@@ -370,6 +370,30 @@
 
 
 /*
+ * Linux mangles spaces in mount points by changing them to an octal string
+ * of '\040'.  So lets scan the mount point and fix it up by replacing all
+ * occurrences off '\0##' with the ASCII value of 0##.  Requires a writable
+ * string as input as we mangle in place.  Some of this was taken from the
+ * util-linux package.
+ */
+#define octalify(a) ((a) & 7)
+#define tooctal(s) (64*octalify(s[1]) + 8*octalify(s[2]) + octalify(s[3]))
+#define isoctal(a) (((a) & ~7) == '0')
+static char *DeMangleMount(char *s)
+{
+	char *tmp = s;
+	while ((tmp = strchr(tmp, '\\')) != NULL) {
+		if (isoctal(tmp[1]) && isoctal(tmp[2]) && isoctal(tmp[3])) {
+			tmp[0] = tooctal(tmp);
+			memmove(tmp+1, tmp+4, strlen(tmp)-3);
+		}
+		++tmp;
+	}
+	return s;
+}
+
+
+/*
  * Given name, such as foo, see if any of the following exist:
  *
  * foo (if foo starts with '.' or '/')
@@ -884,8 +908,8 @@
 			if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
 				((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
 				FCLOSE(fp);
-				*deviceName = strdup(s1);
-				*mountName = strdup(s2);
+				*deviceName = DeMangleMount(strdup(s1));
+				*mountName = DeMangleMount(strdup(s2));
 				return 1;
 			}
 		}
@@ -928,8 +952,8 @@
 		rc = sscanf(line, "%1023s %1023s", s1, s2);
 		if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) {
 			FCLOSE(fp);
-			*deviceName = strdup(s1);
-			*mountName = strdup(s2);
+			*deviceName = DeMangleMount(strdup(s1));
+			*mountName = DeMangleMount(strdup(s2));
 			return 1;
 		}
 	}


Index: eject.spec
===================================================================
RCS file: /cvs/dist/rpms/eject/devel/eject.spec,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- eject.spec	28 Aug 2006 13:51:12 -0000	1.28
+++ eject.spec	30 Oct 2006 14:53:46 -0000	1.29
@@ -1,13 +1,15 @@
 Summary: A program that ejects removable media using software control.
 Name: eject
 Version: 2.1.5
-Release: 4
+Release: 5
 License: GPL
 Group: System Environment/Base
 Source: http://metalab.unc.edu/pub/Linux/utils/disk-management/%{name}-%{version}.tar.gz
 Source1: eject.pam
 Patch1: eject-2.1.1-verbose.patch
 Patch2: eject-timeout.patch
+Patch3: eject-2.1.5-opendevice.patch
+Patch4: eject-2.1.5-spaces.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 URL: http://www.pobox.com/~tranter
 ExcludeArch: s390 s390x
@@ -29,6 +31,8 @@
 %setup -q -n %{name}
 %patch1 -p1 -b .versbose
 %patch2 -p1 -b .timeout
+%patch3 -p0 -b .opendevice
+%patch4 -p0 -b .spaces
 
 %build
 %configure
@@ -68,6 +72,9 @@
 %{_mandir}/man1/*
 
 %changelog
+* Mon Oct 30 2006 Than Ngo <than at redhat.com> 2.1.5-5
+- apply upstream patch to fix #212467
+
 * Mon Aug 28 2006 Than Ngo <than at redhat.com> 2.1.5-4
 - fix #204222, Password error window popuped by calling "eject" command from remote
 




More information about the fedora-cvs-commits mailing list