rpms/eject/F-7 eject-2.1.5-umount.patch, 1.2, 1.3 eject.spec, 1.31, 1.32
Zdenek Prikryl (zprikryl)
fedora-extras-commits at redhat.com
Wed Apr 2 09:04:33 UTC 2008
- Previous message (by thread): rpms/libarchive/devel .cvsignore, 1.2, 1.3 libarchive.spec, 1.1, 1.2 sources, 1.2, 1.3
- Next message (by thread): rpms/system-config-rootpassword/devel .cvsignore, 1.12, 1.13 sources, 1.13, 1.14 system-config-rootpassword.spec, 1.22, 1.23
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: zprikryl
Update of /cvs/extras/rpms/eject/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17554
Modified Files:
eject-2.1.5-umount.patch eject.spec
Log Message:
Added check if device is hotpluggable (#438610)
Added support for symlinks in /sys/block (#439406)
eject-2.1.5-umount.patch:
Index: eject-2.1.5-umount.patch
===================================================================
RCS file: /cvs/extras/rpms/eject/F-7/eject-2.1.5-umount.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- eject-2.1.5-umount.patch 17 Mar 2008 15:51:48 -0000 1.2
+++ eject-2.1.5-umount.patch 2 Apr 2008 09:04:17 -0000 1.3
@@ -1,5 +1,5 @@
---- eject/eject.c.umount 2008-03-17 10:56:51.000000000 +0100
-+++ eject/eject.c 2008-03-17 13:19:12.000000000 +0100
+--- eject/eject.c.umount 2008-03-27 09:40:44.000000000 +0100
++++ eject/eject.c 2008-04-02 09:37:37.000000000 +0200
@@ -42,6 +42,7 @@
#include <string.h>
#include <fcntl.h>
@@ -8,7 +8,7 @@
#ifdef GETOPTLONG
#include <getopt.h>
-@@ -1127,6 +1128,71 @@ static char *MultiplePartitions(const ch
+@@ -1127,6 +1128,145 @@ static char *MultiplePartitions(const ch
return 0;
}
@@ -20,17 +20,17 @@
+{
+ DIR *dir = opendir("/sys/block");
+ struct dirent *d;
-+ char *baseName = strrchr(deviceName, '/');
++ const char *baseName = strrchr(deviceName, '/');
+ char *device;
+ int len;
+
+ baseName = baseName ? baseName + 1 : deviceName;
+ if (!dir) {
-+ perror("/sys/block");
++ fprintf(stderr, _("%s: can not open directory /sys/block/"), programName);
+ return NULL;
+ }
+ while ((d = readdir(dir)) != NULL) {
-+ if (d->d_type != DT_DIR && d->d_type != DT_UNKNOWN)
++ if (d->d_type != DT_DIR && d->d_type != DT_LNK && d->d_type != DT_UNKNOWN)
+ continue;
+ len = strlen(d->d_name);
+ if (!strncmp(baseName, d->d_name, len)) {
@@ -48,6 +48,32 @@
+}
+
+/*
++ * From given path gets a subsystem. Returns subsystem if any found
++ * otherwise returns NULL. Returned value must not be free()'d
++ */
++static char *GetSubSystem(const char *sysfspath)
++{
++ static char subsystem[PATH_MAX];
++ char link_subsystem[PATH_MAX];
++ struct stat buf;
++ char *pos;
++
++ snprintf(link_subsystem, sizeof(link_subsystem), "%s/subsystem", sysfspath);
++
++ if (lstat(link_subsystem, &buf) == -1)
++ return NULL;
++ if (!S_ISLNK(buf.st_mode))
++ return NULL;
++ if (readlink(link_subsystem, subsystem, sizeof(subsystem)) == -1)
++ return NULL;
++ if ((pos = strrchr(subsystem, '/')) == NULL)
++ return NULL;
++ strncpy(subsystem, pos+1, sizeof(subsystem));
++
++ return subsystem;
++}
++
++/*
+ * Check content of /sys/block/<dev>/removable. Returns 1 if the file
+ * contains '1' otherwise returns 0.
+ */
@@ -66,30 +92,80 @@
+ }
+ snprintf(path, sizeof(path), "/sys/block/%s/removable", device);
+ free(device);
-+ if((fp = fopen(path, "r")) == NULL) {
-+ perror(path);
-+ exit(1);
-+ }
-+
++ if((fp = fopen(path, "r")) == NULL)
++ return removable;
+ if (fgetc(fp) == '1')
+ removable = 1;
+
+ fclose(fp);
+ return removable;
+}
++
++/* Check if a device is on hotpluggable subsystem. Returns 1 if is
++ * otherwise returns 0.
++ */
++static int CheckHotpluggable(const char* deviceName)
++{
++ int hotpluggable = 0;
++ char *device;
++ char path[PATH_MAX];
++ char *device_chain;
++ struct stat buf;
++ char *subsystem;
++ char *pos;
++
++ if ((device = FindDeviceSysBlock(deviceName)) == NULL) {
++ fprintf(stderr, _("%s: did not find a device %s in /sys/block/\n"),
++ programName, deviceName);
++ exit(1);
++ }
++ snprintf(path, sizeof(path), "/sys/block/%s/device", device);
++ free(device);
++
++ if (lstat(path, &buf) == -1)
++ return hotpluggable;
++ if (!S_ISLNK(buf.st_mode))
++ return hotpluggable;
++ if ((device_chain = SymLink(path)) == NULL)
++ return hotpluggable;
++ while ( strncmp(device_chain, "", sizeof(device_chain) != 0)) {
++ subsystem = GetSubSystem(device_chain);
++ if (subsystem) {
++ /* as hotpluggable we assume devices on these buses */
++ if (strncmp("usb", subsystem, sizeof("usb")) == 0 ||
++ strncmp("ieee1394", subsystem, sizeof("ieee1394")) == 0 ||
++ strncmp("pcmcia", subsystem, sizeof("pcmcia")) == 0 ||
++ strncmp("mmc", subsystem, sizeof("mmc")) == 0 ||
++ strncmp("ccw", subsystem, sizeof("ccw")) == 0) {
++ hotpluggable = 1;
++ break;
++ }
++ }
++ /* remove one member from devicechain */
++ pos = strrchr(device_chain, '/');
++ if (pos)
++ pos[0] = '\0';
++ else
++ device_chain[0] = '\0';
++ }
++
++ return hotpluggable;
++}
/* handle -x option */
static void HandleXOption(char *deviceName)
-@@ -1270,6 +1336,15 @@ int main(int argc, char **argv)
+@@ -1270,6 +1410,17 @@ int main(int argc, char **argv)
exit(0);
}
+ /* Check if device has removable flag*/
+ if (v_option)
-+ printf(_("%s: checking if device \"%s\" has a removable flag\n"), programName, deviceName);
-+ if (!CheckRemovable(deviceName))
++ printf(_("%s: checking if device \"%s\" has a removable or hotpluggable flag\n"),
++ programName, deviceName);
++ if (!CheckRemovable(deviceName) && !CheckHotpluggable(deviceName))
+ {
-+ fprintf(stderr, _("%s: device \"%s\" doesn't have a removable flag\n"), programName, deviceName);
++ fprintf(stderr, _("%s: device \"%s\" doesn't have a removable or hotpluggable flag\n"),
++ programName, deviceName);
+ exit(1);
+ }
+
Index: eject.spec
===================================================================
RCS file: /cvs/extras/rpms/eject/F-7/eject.spec,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- eject.spec 17 Mar 2008 15:51:48 -0000 1.31
+++ eject.spec 2 Apr 2008 09:04:17 -0000 1.32
@@ -1,7 +1,7 @@
Summary: A program that ejects removable media using software control.
Name: eject
Version: 2.1.5
-Release: 7%{dist}
+Release: 8%{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
+* Wed Apr 02 2008 Zdenek Prikryl <zprikryl at redhat.com> 2.1.5-8
+- Added check if device is hotpluggable (#438610)
+- Added support for symlinks in /sys/block (#439406)
+
* Mon Mar 17 2008 Zdenek Prikryl <zprikryl at redhat.com> 2.1.5-7
- Rewriten patch for removable flag
- Resolves #437362
- Previous message (by thread): rpms/libarchive/devel .cvsignore, 1.2, 1.3 libarchive.spec, 1.1, 1.2 sources, 1.2, 1.3
- Next message (by thread): rpms/system-config-rootpassword/devel .cvsignore, 1.12, 1.13 sources, 1.13, 1.14 system-config-rootpassword.spec, 1.22, 1.23
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list