This commit is contained in:
parent
302c09c160
commit
68e9047d04
118
sysvinit-2.86-hddown.patch
Normal file
118
sysvinit-2.86-hddown.patch
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
--- src/hddown.c
|
||||||
|
+++ src/hddown.c 2007-06-05 14:37:50.248140535 +0200
|
||||||
|
@@ -18,6 +18,106 @@ char *v_hddown = "@(#)hddown.c 1.02 22
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <linux/hdreg.h>
|
||||||
|
|
||||||
|
+#define USE_SYSFS
|
||||||
|
+#ifdef USE_SYSFS
|
||||||
|
+
|
||||||
|
+#include <limits.h>
|
||||||
|
+#include <errno.h>
|
||||||
|
+#define SYS_BLK "/sys/block"
|
||||||
|
+#define DEV_BASE "/dev"
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Find all disks through /sys/block.
|
||||||
|
+ */
|
||||||
|
+static char *list_disks(DIR* blk)
|
||||||
|
+{
|
||||||
|
+ struct dirent *d;
|
||||||
|
+
|
||||||
|
+ while ((d = readdir(blk))) {
|
||||||
|
+ if (d->d_name[1] == 'd' && (d->d_name[0] == 'h' || d->d_name[0] == 's')) {
|
||||||
|
+ char buf[NAME_MAX+1];
|
||||||
|
+ int fd, ret;
|
||||||
|
+ FILE *fp;
|
||||||
|
+
|
||||||
|
+ ret = snprintf(buf, sizeof(buf), SYS_BLK "/%s/removable", d->d_name);
|
||||||
|
+ if ((ret >= sizeof(buf)) || (ret < 0))
|
||||||
|
+ goto empty;
|
||||||
|
+
|
||||||
|
+ fd = open(buf, O_RDONLY|O_NOCTTY);
|
||||||
|
+ if ((fd < 0) && (errno != ENOENT))
|
||||||
|
+ goto empty;
|
||||||
|
+
|
||||||
|
+ fp = fdopen(fd, "r");
|
||||||
|
+ if (fp == (FILE*)0) {
|
||||||
|
+ close(fd);
|
||||||
|
+ goto empty;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = getc(fp);
|
||||||
|
+ fclose(fp);
|
||||||
|
+
|
||||||
|
+ if (ret == '0') break; /* found disk, out here */
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (d == (struct dirent*)0)
|
||||||
|
+ goto empty;
|
||||||
|
+ return d->d_name;
|
||||||
|
+empty:
|
||||||
|
+ return (char*)0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Put an disk in standby mode.
|
||||||
|
+ * Code stolen from hdparm.c
|
||||||
|
+ */
|
||||||
|
+static int do_standby_idedisk(char *device)
|
||||||
|
+{
|
||||||
|
+#ifndef WIN_STANDBYNOW1
|
||||||
|
+#define WIN_STANDBYNOW1 0xE0
|
||||||
|
+#endif
|
||||||
|
+#ifndef WIN_STANDBYNOW2
|
||||||
|
+#define WIN_STANDBYNOW2 0x94
|
||||||
|
+#endif
|
||||||
|
+ unsigned char args1[4] = {WIN_STANDBYNOW1,0,0,0};
|
||||||
|
+ unsigned char args2[4] = {WIN_STANDBYNOW2,0,0,0};
|
||||||
|
+ char buf[NAME_MAX+1];
|
||||||
|
+ int fd, ret;
|
||||||
|
+
|
||||||
|
+ ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device);
|
||||||
|
+ if ((ret >= sizeof(buf)) || (ret < 0))
|
||||||
|
+ return -1;
|
||||||
|
+
|
||||||
|
+ if ((fd = open(buf, O_RDWR)) < 0)
|
||||||
|
+ return -1;
|
||||||
|
+
|
||||||
|
+ ret = ioctl(fd, HDIO_DRIVE_CMD, &args1) &&
|
||||||
|
+ ioctl(fd, HDIO_DRIVE_CMD, &args2);
|
||||||
|
+ close(fd);
|
||||||
|
+
|
||||||
|
+ if (ret)
|
||||||
|
+ return -1;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * List all disks and put them in standby mode.
|
||||||
|
+ * This has the side-effect of flushing the writecache,
|
||||||
|
+ * which is exactly what we want on poweroff.
|
||||||
|
+ */
|
||||||
|
+int hddown(void)
|
||||||
|
+{
|
||||||
|
+ DIR *blk;
|
||||||
|
+ char *disk;
|
||||||
|
+
|
||||||
|
+ if ((blk = opendir(SYS_BLK)) == (DIR*)0)
|
||||||
|
+ return -1;
|
||||||
|
+
|
||||||
|
+ while ((disk = list_disks(blk)))
|
||||||
|
+ do_standby_idedisk(disk);
|
||||||
|
+
|
||||||
|
+ return closedir(blk);
|
||||||
|
+}
|
||||||
|
+#else /* ! USE_SYSFS */
|
||||||
|
#define MAX_DISKS 64
|
||||||
|
#define PROC_IDE "/proc/ide"
|
||||||
|
#define DEV_BASE "/dev"
|
||||||
|
@@ -104,7 +204,7 @@ int hddown(void)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+#endif /* ! USE_SYSFS */
|
||||||
|
#else /* __linux__ */
|
||||||
|
|
||||||
|
int hddown(void)
|
@ -1,14 +1,18 @@
|
|||||||
--- .pkgextract
|
--- .pkgextract
|
||||||
+++ .pkgextract 2006-08-18 14:45:28.000000000 +0200
|
+++ .pkgextract 2006-08-18 14:45:28.000000000 +0200
|
||||||
@@ -0,0 +1,8 @@
|
@@ -0,0 +1,12 @@
|
||||||
+patch -p0 -b -s --suffix=.sulogin < ../sysvinit-2.86-sulogin.patch
|
+patch -p0 -b -s --suffix=.nfs4pidof < ../sysvinit-2.86-nfs4pidof.patch
|
||||||
+patch -p0 -b -s --suffix=.ststdmn < ../sysvinit-2.82-startstop.patch
|
+patch -p0 -b -s --suffix=.sulogin < ../sysvinit-2.86-sulogin.patch
|
||||||
+patch -p0 -b -s --suffix=.suse < ../sysvinit-2.85-suse.patch
|
+patch -p0 -b -s --suffix=.ststdmn < ../sysvinit-2.82-startstop.patch
|
||||||
+patch -p0 -b -s --suffix=.paths < ../sysvinit-2.85-paths.patch
|
+patch -p0 -b -s --suffix=.suse < ../sysvinit-2.85-suse.patch
|
||||||
+patch -p0 -b -s --suffix=.race < ../sysvinit-2.86-race.patch
|
+patch -p0 -b -s --suffix=.paths < ../sysvinit-2.85-paths.patch
|
||||||
+patch -p0 -b -s --suffix=.lib64 < ../sysvinit-2.86-lib64.patch
|
+patch -p0 -b -s --suffix=.utmp < ../sysvinit-2.86-utmp.patch
|
||||||
+patch -p0 -b -s --suffix=.mltline < ../sysvinit-2.82-multiline.patch
|
+patch -p0 -b -s --suffix=.race < ../sysvinit-2.86-race.patch
|
||||||
+patch -p0 -b -s --suffix=.utmp < ../sysvinit-2.86-utmp.patch
|
+patch -p0 -b -s --suffix=.lib64 < ../sysvinit-2.86-lib64.patch
|
||||||
|
+patch -p0 -b -s --suffix=.mltline < ../sysvinit-2.82-multiline.patch
|
||||||
|
+patch -p0 -b -s --suffix=.usage < ../sysvinit-2.86-usage-message.patch
|
||||||
|
+patch -p0 -b -s --suffix=.fulltime < ../sysvinit-2.86-full-time.patch
|
||||||
|
+patch -p0 -b -s --suffix=.hddown < ../sysvinit-2.86-hddown.patch
|
||||||
--- src/Makefile
|
--- src/Makefile
|
||||||
+++ src/Makefile 2006-08-18 14:45:28.000000000 +0200
|
+++ src/Makefile 2006-08-18 14:45:28.000000000 +0200
|
||||||
@@ -8,17 +8,20 @@
|
@@ -8,17 +8,20 @@
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jun 5 14:45:21 CEST 2007 - werner@suse.de
|
||||||
|
|
||||||
|
- /sbin/halt: list and powerdown all disks even SATA/SCSI
|
||||||
|
(bug #229210)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri May 11 12:10:18 CEST 2007 - werner@suse.de
|
Fri May 11 12:10:18 CEST 2007 - werner@suse.de
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ Group: System/Base
|
|||||||
PreReq: coreutils
|
PreReq: coreutils
|
||||||
Autoreqprov: on
|
Autoreqprov: on
|
||||||
Version: 2.86
|
Version: 2.86
|
||||||
Release: 67
|
Release: 74
|
||||||
Summary: SysV-Style init
|
Summary: SysV-Style init
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
Source: sysvinit-2.86.tar.bz2
|
Source: sysvinit-2.86.tar.bz2
|
||||||
@ -47,6 +47,7 @@ Patch13: sysvinit-2.82-multiline.patch
|
|||||||
Patch14: startpar-0.49.dif
|
Patch14: startpar-0.49.dif
|
||||||
Patch15: sysvinit-2.86-usage-message.patch
|
Patch15: sysvinit-2.86-usage-message.patch
|
||||||
Patch16: sysvinit-2.86-full-time.patch
|
Patch16: sysvinit-2.86-full-time.patch
|
||||||
|
Patch17: sysvinit-2.86-hddown.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
System V style init programs by Miquel van Smoorenburg that control the
|
System V style init programs by Miquel van Smoorenburg that control the
|
||||||
@ -77,9 +78,10 @@ Authors:
|
|||||||
%patch -P 11 -b .race
|
%patch -P 11 -b .race
|
||||||
%patch -P 12 -b .lib64
|
%patch -P 12 -b .lib64
|
||||||
%patch -P 13 -b .multiline
|
%patch -P 13 -b .multiline
|
||||||
%patch
|
|
||||||
%patch -P 15 -b .usage
|
%patch -P 15 -b .usage
|
||||||
%patch -P 16 -b .fulltime
|
%patch -P 16 -b .fulltime
|
||||||
|
%patch -P 17 -b .hddown
|
||||||
|
%patch
|
||||||
pushd ../powerd-%{PDVER}
|
pushd ../powerd-%{PDVER}
|
||||||
%patch -P 2
|
%patch -P 2
|
||||||
popd
|
popd
|
||||||
@ -280,6 +282,9 @@ rm -rf ${RPM_BUILD_ROOT}
|
|||||||
%doc %{_mandir}/man8/startpar.8.gz
|
%doc %{_mandir}/man8/startpar.8.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jun 05 2007 - werner@suse.de
|
||||||
|
- /sbin/halt: list and powerdown all disks even SATA/SCSI
|
||||||
|
(bug #229210)
|
||||||
* Fri May 11 2007 - werner@suse.de
|
* Fri May 11 2007 - werner@suse.de
|
||||||
- startpar: Try to start more processes even on high loaded systems
|
- startpar: Try to start more processes even on high loaded systems
|
||||||
- startpar: Detect endless loops on broken systems (no SIGCHILD)
|
- startpar: Detect endless loops on broken systems (no SIGCHILD)
|
||||||
|
Loading…
Reference in New Issue
Block a user