rpms/eject/F-8 eject-2.1.5-umount.patch, 1.1, 1.2 eject.spec, 1.31, 1.32

Zdenek Prikryl (zprikryl) fedora-extras-commits at redhat.com
Mon Mar 17 15:39:38 UTC 2008


Author: zprikryl

Update of /cvs/extras/rpms/eject/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14746

Modified Files:
	eject-2.1.5-umount.patch eject.spec 
Log Message:
Rewriten patch for removable flag
Resolves #437362


eject-2.1.5-umount.patch:

Index: eject-2.1.5-umount.patch
===================================================================
RCS file: /cvs/extras/rpms/eject/F-8/eject-2.1.5-umount.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- eject-2.1.5-umount.patch	12 Mar 2008 12:16:00 -0000	1.1
+++ eject-2.1.5-umount.patch	17 Mar 2008 15:39:31 -0000	1.2
@@ -1,15 +1,6 @@
---- eject/eject.c.umount	2008-03-12 11:25:55.000000000 +0100
-+++ eject/eject.c	2008-03-12 11:47:24.000000000 +0100
-@@ -30,6 +30,8 @@
-  *
-  */
- 
-+#define _ATFILE_SOURCE
-+
- #include "i18n.h"
- 
- #ifndef DEFAULTDEVICE
-@@ -42,6 +44,7 @@
+--- eject/eject.c.umount	2008-03-17 10:56:51.000000000 +0100
++++ eject/eject.c	2008-03-17 13:19:12.000000000 +0100
+@@ -42,6 +42,7 @@
  #include <string.h>
  #include <fcntl.h>
  #include <limits.h>
@@ -17,35 +8,39 @@
  
  #ifdef GETOPTLONG
  #include <getopt.h>
-@@ -1127,6 +1130,69 @@ static char *MultiplePartitions(const ch
+@@ -1127,6 +1128,71 @@ static char *MultiplePartitions(const ch
  	return 0;
  }
  
 +/*
-+ * Find device name with the given major and minor number. Returns NULL if not
++ * Find device name in /sys/block/. Returns NULL if not
 + * found. The returned pointer must be free()'d.
 + */
-+static char* FindDeviceMajorMinor(int maj, int min)
++static char* FindDeviceSysBlock(const char* deviceName)
 +{
-+	DIR *dir = opendir("/dev");
++	DIR *dir = opendir("/sys/block");
 +	struct dirent *d;
-+	int dfd = dirfd(dir);
-+	struct stat st;
++	char *baseName = strrchr(deviceName, '/');
 +	char *device;
-+
-+	if (!dir || dfd == -1) {
-+		perror("/dev");
++	int len;
++	
++	baseName = baseName ? baseName + 1 : deviceName;
++	if (!dir) {
++		perror("/sys/block");
 +		return NULL;
-+	}	
++	}
 +	while ((d = readdir(dir)) != NULL) { 
-+		if (d->d_type == DT_DIR || d->d_type == DT_UNKNOWN || d->d_type == DT_LNK)
-+			continue;
-+		if (fstatat(dfd, d->d_name, &st, O_RDONLY) != 0)
++		if (d->d_type != DT_DIR && d->d_type != DT_UNKNOWN)
 +			continue;
-+		if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {   
-+			device = strdup(d->d_name);
-+			closedir(dir);
-+			return device;
++		len = strlen(d->d_name);
++		if (!strncmp(baseName, d->d_name, len)) {
++			if ((*(baseName+len) >= '0' &&
++			     *(baseName+len) <= '9') ||
++			     *(baseName+len) == '\0') {
++				device = strdup(d->d_name);
++				closedir(dir);
++				return device;
++			}
 +		}
 +	}
 +	closedir(dir);
@@ -62,13 +57,11 @@
 +	int removable = 0;
 +	char *device;
 +	char path[PATH_MAX];
-+	int maj, min;
 +
-+	GetMajorMinor(deviceName, &maj, &min);
-+	if ((device = FindDeviceMajorMinor(maj, 0)) == NULL) {
++	if ((device = FindDeviceSysBlock(deviceName)) == NULL) {
 +		fprintf(stderr,
-+				_("%s: did not find a device with %d-0 major-minor numbers\n"),
-+				programName, maj);
++				_("%s: did not find a device %s in /sys/block/\n"),
++				programName, deviceName);
 +		exit(1);
 +	}
 +	snprintf(path, sizeof(path), "/sys/block/%s/removable", device);


Index: eject.spec
===================================================================
RCS file: /cvs/extras/rpms/eject/F-8/eject.spec,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- eject.spec	12 Mar 2008 12:30:21 -0000	1.31
+++ eject.spec	17 Mar 2008 15:39:31 -0000	1.32
@@ -1,7 +1,7 @@
 Summary: A program that ejects removable media using software control.
 Name: eject
 Version: 2.1.5
-Release: 6%{dist}
+Release: 7%{dist}
 License: GPL
 Group: System Environment/Base
 Source: http://metalab.unc.edu/pub/Linux/utils/disk-management/%{name}-%{version}.tar.gz
@@ -74,6 +74,10 @@
 %{_mandir}/man1/*
 
 %changelog
+* Mon Mar 17 2008 Zdenek Prikryl <zprikryl at redhat.com> 2.1.5-7
+- Rewriten patch for removable flag
+- Resolves #437362
+
 * Wed Mar 12 2008 Zdenek Prikryl <zprikryl at redhat.com> 2.1.5-6
 - Added check for a removable flag
 - Added dist tag




More information about the fedora-extras-commits mailing list