Initial commit

This commit is contained in:
Mario Fetka 2017-04-22 15:01:27 +02:00
parent 7ea26e619b
commit 05d4ad85da
26 changed files with 1084 additions and 0 deletions

72
debian/changelog vendored Normal file
View File

@ -0,0 +1,72 @@
megactl (0.4.1+svn20090725.r6-5) unstable; urgency=medium
* Update 003-Fix_disk_enumeration_loop patch (fix issues with PERC6e).
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jan 2014 23:10:36 +0100
megactl (0.4.1+svn20090725.r6-4) unstable; urgency=medium
* Fix build on Jessie+.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Tue, 21 Jan 2014 22:54:42 +0100
megactl (0.4.1+svn20090725.r6-3) unstable; urgency=medium
* New patch by Pat Suwalski <pat@suwalski.net> to fix a bad disks
enumeration loop.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Tue, 21 Jan 2014 20:24:22 +0100
megactl (0.4.1+svn20090725.r6-2) unstable; urgency=medium
* Integrate patch by Pat Suwalski <pat@suwalski.net> to handle devices
without enclosure.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 14 Dec 2013 14:36:22 +0100
megactl (0.4.1+svn20090725.r6-1) unstable; urgency=low
* New upstream release (based on sv trunk snapshot):
- Add RAID6 support,
- Fixes for Dell PERC6 cards.
* Bump Standards-Version to 3.8.2.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jul 2009 13:23:45 +0200
megactl (0.4.1-6) unstable; urgency=low
* Merge a Gentoo (thanks) patch that drops obsolete asm/user.h.
* Add missing amd64 required gcc-multilib b-dep.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Mon, 27 Apr 2009 16:35:59 +0200
megactl (0.4.1-5) unstable; urgency=low
* Update create-devices-nodes to handle kernels 2.6.25rc2+.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Mon, 01 Sep 2008 12:03:07 +0200
megactl (0.4.1-4) unstable; urgency=low
* Add preinst script to clean obsolete initscripts used by previous
releases.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Fri, 22 Aug 2008 14:02:08 +0200
megactl (0.4.1-3) unstable; urgency=low
* Fix packaging to allow build and run on amd64.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Thu, 21 Aug 2008 18:03:39 +0200
megactl (0.4.1-2) unstable; urgency=low
* Device node creation: remove initscript, replaced by binaries wrappers.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Thu, 21 Aug 2008 13:57:02 +0200
megactl (0.4.1-1) unstable; urgency=low
* Initial release.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Wed, 26 Sep 2007 09:49:57 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
4

17
debian/control vendored Normal file
View File

@ -0,0 +1,17 @@
Source: megactl
Section: admin
Priority: optional
Maintainer: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
Build-Depends: debhelper (>= 4), dpatch
Standards-Version: 3.8.2
Homepage: http://sourceforge.net/projects/megactl
Package: megactl
Architecture: i386 amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: LSI MegaRAID SCSI/SAS reporting tool
This package contains both megactl and megasasctl tools that can be used
to query LSI's MegaRAID adapters status.
.
It reports status and informations about the adapter itself, it's
logical disks and the physical disks attached.

45
debian/copyright vendored Normal file
View File

@ -0,0 +1,45 @@
This package was debianized by Adam Cécile (Le_Vert) <gandalf@le-vert.net> on
Wed, 26 Sep 2007 09:49:57 +0200.
It was downloaded from http://sourceforge.net/projects/megactl
Upstream Author:
Jefferson Ogata <ogata@antibozo.net>
Copyright:
Copyright (C) 2007 Jefferson Ogata
License:
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL'.
The Debian packaging is Copyright (C) 2007-2009 Adam Cécile (Le_Vert)
<gandalf@le-vert.net> and is licensed under the GPL, see above.
Other files' copyright or license:
"src/schily/*" are (C) 1984-2003 J. Schilling except
"src/schily/scg/srb_os2.h" which is (C) 1998 D. Dorau, C. Wohlgemuth.
"src/kernel-2.6.9-55.0.2.EL/*" and "src/megaraid/*" are
(C) 2003-2004 LSI Logic Corporation.
All theses files are released under terms of GNU General Public License
version 2 or later.

2
debian/dirs vendored Normal file
View File

@ -0,0 +1,2 @@
usr/lib/megactl
usr/sbin

1
debian/docs vendored Normal file
View File

@ -0,0 +1 @@
README

2
debian/examples vendored Normal file
View File

@ -0,0 +1,2 @@
src/megarpt
src/megasasrpt

5
debian/install vendored Normal file
View File

@ -0,0 +1,5 @@
src/megactl usr/lib/megactl
src/megasasctl usr/lib/megactl
debian/wrappers/create-devices-nodes usr/lib/megactl
debian/wrappers/megactl usr/sbin
debian/wrappers/megasasctl usr/sbin

102
debian/man/megactl.8 vendored Normal file
View File

@ -0,0 +1,102 @@
.TH MEGACTL "8" "September 2007" "0.4.1" "User Commands"
.SH NAME
megactl - a reporting tool for LSI MegaRAID adapters and its attached disks.
.SH DESCRIPTION
.B megactl
can report diagnostics on megaraid adapters and attached disks.
.br
It permits dumping of controller log pages for inspection of error, temperature, and self-test conditions, initiates self-test diagnostics, and documents adapter and logical drive configuration.
.br
Target devices may be adapters, (e.g. a0), channels (e.g. a0c0), or individual disks (e.g. a0c0t0).
.br
If no target is specified, reports configuration and drive state on all
adapters.
.br
If a target matches a collection of disks, operations are
applied to all matching devices.
.SH REQUIREMENTS
.B megactl
requires the device file /dev/megadev0 to be present on
the system.
.br
On Debian systems, this device node will be created at boot time by megactl-makedev init script.
.br
If your system does not have this device file, you may create it either by executing Dell's "dellmgr" program once, or by locating the megadev entry in /proc/devices and creating /dev/megadev0 as a character device with suitable permissions with a matching major device number and a minor number of 0.
.SH SYNOPSIS
.B megactl
[\-vest] [\-H] [\-l log-page-nr] [\-T long|short] [target ...]
.SH OPTIONS
.TP
.I -v
Increase program verbosity.
.TP
.I -e
Dump read (0x03), write (0x02), and verify (0x05) error log pages.
.TP
.I -s
Dump self-test (0x10) log page.
.TP
.I -t
Dump temperature (0x0d) log page.
.TP
.I -l <page>
Dump the specified log page.
.br
Log page 0 documents the log pages the device supports.
.TP
.I -p
Do not report physical disks.
.br
Reports only adapters and logical drives.
.br
Useful for concisely documenting adapter configuration.
.TP
.I -T short|long
Initiate the background short or long self-test procedure.
.br
The test may take up to an hour to complete, but does not inhibit access to the device.
.br
The test may be monitored using the \-s option.
.br
The background long self test is a useful tool for diagnosing problems with individual disks.
.br
But be cautious with program usage. "megactl \-T long" with no targets will initiate a background long self test on every drive on every adapter.
.br
This may not be what you want.
.TP
.I -H
Perform an adapter health check.
.br
Inspects state of all logical and physical drives and battery backup unit and reports problem conditions.
.br
If all is well, generates no output. Useful in a cron job.
.br
By default, the health check option inspects log pages 0x02, 0x03, and 0x05 for uncorrected read, write, and verify errors, 0x0d for excess temperature conditions, and 0x10 for failed self tests.
.br
If, however, any of the log page options is specified, only the designated log pages are inspected.
.TP
.I -B
When performing health check, do not treat battery problems as failures.
.TP
.I -V
Show version.
.SH "SEE ALSO"
Homepage: http://sourceforge.net/projects/megactl
.br
Some examples scripts (Debian systems): /usr/share/doc/megactl/examples/
.br
megasasctl(8): Same tool, for SAS adapters.
.SH AUTHOR
This manual page was written by Adam Cécile (Le_Vert) <gandalf@le-vert.net> for the Debian system (but may be used by others).
.br
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation
.br
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.

102
debian/man/megasasctl.8 vendored Normal file
View File

@ -0,0 +1,102 @@
.TH MEGASASCTL "8" "September 2007" "0.4.1" "User Commands"
.SH NAME
megasasctl - a reporting tool for LSI MegaRAID SAS (Serial-Attached-SCSI) adapters and its attached disks.
.SH DESCRIPTION
.B megasasctl
can report diagnostics on megaraid adapters and attached disks.
.br
It permits dumping of controller log pages for inspection of error, temperature, and self-test conditions, initiates self-test diagnostics, and documents adapter and logical drive configuration.
.br
Target devices may be adapters, (e.g. a0), channels (e.g. a0c0), or individual disks (e.g. a0c0t0).
.br
If no target is specified, reports configuration and drive state on all
adapters.
.br
If a target matches a collection of disks, operations are
applied to all matching devices.
.SH REQUIREMENTS
.B megasasctl
requires the device file /dev/megaraid_sas_ioctl_node to be present on the system.
the system.
.br
On Debian systems, this device node will be created at boot time by megactl-makedev init script.
.br
If your system does not have this device file, you may create it either by executing LSI's "MegaCli" program once, or by locating the megadev_sas_ioctl entry in /proc/devices and creating /dev/megaraid_sas_ioctl_node as a character device with suitable permissions with a matching major device number and a minor number of 0.
.SH SYNOPSIS
.B megasasctl
[\-vest] [\-H] [\-l log-page-nr] [\-T long|short] [target ...]
.SH OPTIONS
.TP
.I -v
Increase program verbosity.
.TP
.I -e
Dump read (0x03), write (0x02), and verify (0x05) error log pages.
.TP
.I -s
Dump self-test (0x10) log page.
.TP
.I -t
Dump temperature (0x0d) log page.
.TP
.I -l <page>
Dump the specified log page.
.br
Log page 0 documents the log pages the device supports.
.TP
.I -p
Do not report physical disks.
.br
Reports only adapters and logical drives.
.br
Useful for concisely documenting adapter configuration.
.TP
.I -T short|long
Initiate the background short or long self-test procedure.
.br
The test may take up to an hour to complete, but does not inhibit access to the device.
.br
The test may be monitored using the \-s option.
.br
The background long self test is a useful tool for diagnosing problems with individual disks.
.br
But be cautious with program usage. "megactl \-T long" with no targets will initiate a background long self test on every drive on every adapter.
.br
This may not be what you want.
.TP
.I -H
Perform an adapter health check.
.br
Inspects state of all logical and physical drives and battery backup unit and reports problem conditions.
.br
If all is well, generates no output. Useful in a cron job.
.br
By default, the health check option inspects log pages 0x02, 0x03, and 0x05 for uncorrected read, write, and verify errors, 0x0d for excess temperature conditions, and 0x10 for failed self tests.
.br
If, however, any of the log page options is specified, only the designated log pages are inspected.
.TP
.I -B
When performing health check, do not treat battery problems as failures.
.TP
.I -V
Show version.
.SH "SEE ALSO"
Homepage: http://sourceforge.net/projects/megactl
.br
Some examples scripts (Debian systems): /usr/share/doc/megactl/examples/
.br
megactl(8): Same tool, for SCSI adapters.
.SH AUTHOR
This manual page was written by Adam Cécile (Le_Vert) <gandalf@le-vert.net> for the Debian system (but may be used by others).
.br
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation
.br
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.

1
debian/manpages vendored Normal file
View File

@ -0,0 +1 @@
debian/man/*

View File

@ -0,0 +1,74 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 000-No_absolute_pathes_in_examples.dpatch
## by Adam Cécile (Le_Vert) <gandalf@le-vert.net>
##
## DP: Drop all absolute pathes to binaries in megarpt and megasasrpt
## DP: example scripts.
@DPATCH@
diff -u megactl-0.4.1/src/megarpt megactl-0.4.1/src.new/megarpt
--- megactl-0.4.1/src/megarpt 2007-08-21 09:19:53.000000000 +0200
+++ megactl-0.4.1/src.new/megarpt 2007-09-26 11:07:05.584181968 +0200
@@ -9,7 +9,7 @@
# Date: 2007/08/20
VERSION='0.3'
-MEGACTL=/root/megactl
+MEGACTL=/usr/sbin/megactl
DEVICE=/dev/megadev0
DEVICENAME=megadev
DEVICEPERM=644
@@ -32,8 +32,8 @@
if [ -e "$DEVICE" ]; then
WARN=
- HOST=`/bin/uname -n`
- DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
+ HOST=`uname -n`
+ DATE=`date '+%Y/%m/%d %H:%M:%S %Z'`
HC=/tmp/megactl.$$
$MEGACTL -vH > $HC 2>/dev/null
@@ -59,7 +59,7 @@
echo "$ME version: $VERSION"
echo "megactl version: $MEGACTLVERSION"
) 2>/dev/null |
- /bin/mail -s "RAID report:$WARN $HOST $DATE" root
+ mail -s "RAID report:$WARN $HOST $DATE" root
rm -f $HC
fi
diff -u megactl-0.4.1/src/megasasrpt megactl-0.4.1/src.new/megasasrpt
--- megactl-0.4.1/src/megasasrpt 2007-08-21 09:19:53.000000000 +0200
+++ megactl-0.4.1/src.new/megasasrpt 2007-09-26 11:07:05.584181968 +0200
@@ -9,7 +9,7 @@
# Date: 2007/08/20
VERSION='0.3'
-MEGACTL=/root/megasasctl
+MEGACTL=/usr/sbin/megasasctl
DEVICE=/dev/megaraid_sas_ioctl_node
DEVICENAME=megaraid_sas_ioctl
DEVICEPERM=400
@@ -32,8 +32,8 @@
if [ -e "$DEVICE" ]; then
WARN=
- HOST=`/bin/uname -n`
- DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
+ HOST=`uname -n`
+ DATE=`date '+%Y/%m/%d %H:%M:%S %Z'`
HC=/tmp/megactl.$$
$MEGACTL -vH > $HC 2>/dev/null
@@ -59,7 +59,7 @@
echo "$ME version: $VERSION"
echo "megactl version: $MEGACTLVERSION"
) 2>/dev/null |
- /bin/mail -s "RAID report:$WARN $HOST $DATE" root
+ mail -s "RAID report:$WARN $HOST $DATE" root
rm -f $HC
fi

View File

@ -0,0 +1,29 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 001-Drop_obsolete_asm_user.h.dpatch
## by wschlich (Gentoo)
##
## DP: Stolen on Gentoo VCS, thanks a lot Gentoo guys :)
## DP: http://sources.gentoo.org:80/viewcvs.py/gentoo-x86/sys-block/megactl/files/
@DPATCH@
diff -urN megactl-0.4.1.orig/src/megatrace.c megactl-0.4.1/src/megatrace.c
--- megactl-0.4.1.orig/src/megatrace.c 2007-08-21 09:19:53.000000000 +0200
+++ megactl-0.4.1/src/megatrace.c 2008-02-10 21:27:24.416919438 +0100
@@ -49,7 +49,7 @@
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
-#include <asm/user.h>
+#include <sys/user.h>
#include <sys/syscall.h>
#include <sys/ioctl.h>
#include <sys/time.h>
@@ -250,7 +250,7 @@
len = sizeof buf;
if (printregs)
- fprintf (stderr, " ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx ebp=%08lx eax=%08lx ds=%04x __ds=%04x es=%04x __es=%04x fs=%04x __fs=%04x gs=%04x __gs=%04x orig_eax=%08lx eip=%08lx cs=%04x __cs=%04x eflags=%08lx esp=%08lx ss=%04x __ss=%04x\n", r.ebx, r.ecx, r.edx, r.esi, r.edi, r.ebp, r.eax, r.ds, r.__ds, r.es, r.__es, r.fs, r.__fs, r.gs, r.__gs, r.orig_eax, r.eip, r.cs, r.__cs, r.eflags, r.esp, r.ss, r.__ss);
+ fprintf (stderr, " ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx ebp=%08lx eax=%08lx xds=%08lx xes=%08lx xfs=%08lx xgs=%08lx orig_eax=%08lx eip=%08lx xcs=%08lx eflags=%08lx esp=%08lx xss=%08lx\n", r.ebx, r.ecx, r.edx, r.esi, r.edi, r.ebp, r.eax, r.xds, r.xes, r.xfs, r.xgs, r.orig_eax, r.eip, r.xcs, r.eflags, r.esp, r.xss);
copyout (buf, len, pid, r.edx);

View File

@ -0,0 +1,75 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 002-No_enclosure_support by Pat Suwalski <pat@suwalski.net>
##
## DP: The root of the problem is that a lot of the logic behind building
## DP: the enclosure map and printing the disk list compares directly the
## DP: adapter channel list with the physical disk enclosure number, like so:
## DP:
## DP: if (device->device[k].enclosure == a->channel[j])
## DP:
## DP: The problem is that one is a uint16_t and the other is a uint8_t.
## DP: When an enclosure is not present, the value comes back as all-ones.
## DP: So, the code was trying in numerous places to compare 0xffff with
## DP: 0xff. Adjusting the struct so both members are uint16_t fixes this.
## DP:
## DP: The patch also changes the output when no enclosure is present to
## DP: put an asterisk as the enclosure ID in the output.
## DP: The output on the same machine now looks like this:
## DP:
## DP: a0 PERC 5/i Integrated encl:1 ldrv:2 batt:good
## DP: a0d0 19GiB RAID 5 1x4 DEGRADED
## DP: a0d1 5567GiB RAID 5 1x4 DEGRADED
## DP: a0e*s0 1863GiB a0d0+ online errs: media:0 other:28
## DP: a0e*s1 1863GiB a0d0+ rebuild errs: media:0 other:26
## DP: a0e*s2 1863GiB a0d0+ online errs: media:0 other:28
## DP: a0e*s3 1863GiB a0d0+ online errs: media:0 other:28
@DPATCH@
Index: adapter.c
===================================================================
--- a/src/adapter.c (revision 6)
+++ b/src/adapter.c (working copy)
@@ -192,7 +192,10 @@
d->channel = info->enclosure;
d->id = info->slot;
- snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id);
+ if (d->channel == DISK_NOENC)
+ snprintf (d->name, sizeof (d->name), "%se*s%u", a->name, d->id);
+ else
+ snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id);
d->inquiry = info->inquiry.inq;
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
@@ -691,6 +694,7 @@
for (j = 0; j < a->num_channels; ++j)
if (device->device[k].enclosure == a->channel[j])
break;
+
if (j < a->num_channels)
continue;
Index: mega.h
===================================================================
--- a/src/mega.h (revision 6)
+++ b/src/mega.h (working copy)
@@ -114,7 +114,10 @@
#define SCSI_SELFTEST_FOREGROUND_SHORT 0x05
#define SCSI_SELFTEST_FOREGROUND_LONG 0x06
+/* Drives without enclosure report this as the enclosure ID */
+#define DISK_NOENC 0xffff
+
/* megaraid2 header file gets this wrong. */
typedef struct {
uint8_t max_commands;
@@ -545,7 +548,7 @@
uint16_t dram_size; /* size of DRAM in MB */
uint16_t rebuild_rate; /* rebuild rate as percentage */
uint16_t num_channels; /* number of channels or enclosures */
- uint8_t *channel; /* channel/enclosure map */
+ uint16_t *channel; /* channel/enclosure map */
uint16_t num_physicals;
struct physical_drive_info *physical;
struct physical_drive_info **physical_list; /* ordered list of physical devices */

View File

@ -0,0 +1,64 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 003-Fix_disk_enumeration_loop.dpatch by Pat Suwalski <pat@suwalski.net>
##
## DP: When my controller has a failed disk, megasasctl fails.
## DP:
## DP: I have tracked the problem down to a bad assumption, that the various
## DP: disk enumeration loops would use the number of currently online drives
## DP: as the basis for the iterator.
## DP:
## DP: This number decreases when a disk fails. It is not noticeable in many
## DP: cases, because on many some controllers pinfo->pd_present_count is
## DP: one higher than the actual number of disks.
## DP: However, the same situation would be encountered in a RAID1 system with
## DP: two failed disks.
## DP:
## DP: The attached one-line patch uses the number of ports
## DP: on the controller as the basis.
@DPATCH@
This patch fixes a segfault based on an incorrect assumption that the number
of physical drives to loop over is the number of currently online drives
connected to the controller. This change plays it safe and makes it use the
number of ports on the controller, with a fallback for the worst case
scenario.
Pat Suwalski <pat@suwalski.net>
diff -ur megactl-code/src/adapter.c megactl-code2/src/adapter.c
--- a/src/adapter.c 2014-01-20 11:13:48.114598462 -0500
+++ b/src/adapter.c 2014-01-20 14:33:32.950851825 -0500
@@ -706,7 +706,31 @@
}
qsort (a->channel, a->num_channels, sizeof (*a->channel), cmpChannel);
- a->num_physicals = pinfo->pd_present_count;
+ /* Some notes:
+ Different meanings on different models.
+ - FC_MAX_PHYSICAL_DEVICES used on older controllers, which is 256
+ disks (overallocation)
+ - pd_disk_present_count is number of working drives, not counting
+ missing drives
+ - pd_present_count is unclear. It is pd_disk_present_count + 1 on some
+ controllers
+ - device_interface.port_count contains number of physical ports on the
+ controller
+
+ pd_present_count was used here, but in some controllers causes segfaults
+ when there is a failed drive, and not enough space is allocated.
+
+ Since there cannot be more devices than there are ports, that is a safe
+ number to set without going overboard.
+ */
+ a->num_physicals = pinfo->device_interface.port_count;
+
+ /* On some controllers, namely the PERC6e, the controller does not know
+ how many ports there are in the enclosure. Fall back to the worst case
+ scenario. */
+ if (a->num_physicals < pinfo->pd_disk_present_count)
+ a->num_physicals = FC_MAX_PHYSICAL_DEVICES;
+
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
return "out of memory (physical drives)";
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));

View File

@ -0,0 +1,18 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 004-Fix_build_on_recent_distros.dpatch by Adam Cécile (Le_Vert) <gandalf@le-vert.net>
##
## DP: SYS_madvise1 has been renamed to SYS_madvise a long time ago (btw, it's
## DP: not used anywhere)
@DPATCH@
--- a/src/callinfo.c 2007-08-21 08:47:29.000000000 +0200
+++ b/src/callinfo.c 2014-01-21 22:51:59.788201043 +0100
@@ -255,7 +255,7 @@
{ SYS_setfsgid32, 0, "setfsgid32" },
{ SYS_pivot_root, 0, "pivot_root" },
{ SYS_mincore, 0, "mincore" },
- { SYS_madvise1, 0, "madvise1" },
+ { SYS_madvise, 0, "madvise" },
{ SYS_getdents64, 0, "getdents64" },
{ SYS_fcntl64, 0, "fcntl64" },
{ 222, 0, NULL },

33
debian/patches/005-Makefile.dpatch vendored Executable file
View File

@ -0,0 +1,33 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 004-Makefile.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
##
## DP: megatrace must be build with m32 on 64bit hosts
## DP: thx. to gentoo devs
@DPATCH@
diff -urN megactl-0.4.1.orig/src/Makefile megactl-0.4.1/src/Makefile
--- megactl-0.4.1.orig/src/Makefile 2007-08-21 09:19:53.000000000 +0200
+++ megactl-0.4.1/src/Makefile 2009-11-21 12:30:44.242501898 +0100
@@ -1,11 +1,17 @@
-SRCS= megactl.c adapter.c megaioctl.c megatrace.c callinfo.c dumpbytes.c logpage.c ntrim.c
+SRCS= megactl.c adapter.c megaioctl.c callinfo.c dumpbytes.c logpage.c ntrim.c
INC= -I./schily -Iincludes-hack
HDRS= mega.h adapter.h megaioctl.h callinfo.h logpage.h dumpbytes.h
-ARCH= -m32
-CFLAGS= -g -Wall $(INC) $(ARCH)
-LDFLAGS= -g $(ARCH)
-PROGRAMS= megactl megasasctl megatrace
+ARCH?= -m32
+CFLAGS?= -g -Wall
+CFLAGS+= $(INC) $(ARCH)
+LDFLAGS?= -g
+LDFLAGS+= $(ARCH)
+PROGRAMS= megactl megasasctl
+ifeq ($(ARCH),-m32)
+PROGRAMS+= megatrace
+SRCS+= megatrace.c
+endif
all: $(PROGRAMS)

53
debian/patches/006-gcc-fixes.dpatch vendored Executable file
View File

@ -0,0 +1,53 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 004-gcc-fixes.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
##
## DP: get it build on newer kernels
## DP: thx. to gentoo devs
@DPATCH@
diff -Nuar --exclude '*.swp' --exclude '*.o' megactl-0.4.1.orig/src/callinfo.c megactl-0.4.1/src/callinfo.c
--- megactl-0.4.1.orig/src/callinfo.c 2007-08-21 00:19:53.000000000 -0700
+++ megactl-0.4.1/src/callinfo.c 2014-07-13 22:05:06.585598812 -0700
@@ -255,7 +255,12 @@
{ SYS_setfsgid32, 0, "setfsgid32" },
{ SYS_pivot_root, 0, "pivot_root" },
{ SYS_mincore, 0, "mincore" },
+#ifdef SYS_madvise
+ { SYS_madvise, 0, "madvise" },
+#endif
+#ifdef SYS_madvise1
{ SYS_madvise1, 0, "madvise1" },
+#endif
{ SYS_getdents64, 0, "getdents64" },
{ SYS_fcntl64, 0, "fcntl64" },
{ 222, 0, NULL },
diff -Nuar --exclude '*.swp' --exclude '*.o' megactl-0.4.1.orig/src/logpage.c megactl-0.4.1/src/logpage.c
--- megactl-0.4.1.orig/src/logpage.c 2007-08-21 00:19:53.000000000 -0700
+++ megactl-0.4.1/src/logpage.c 2014-07-13 21:58:34.010848677 -0700
@@ -20,6 +20,8 @@
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
#include "megaioctl.h"
#include "logpage.h"
@@ -107,7 +109,7 @@
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024)
;
- snprintf (bytes, sizeof bytes, "%3llu%s%s", b, suffix[k], unit);
+ snprintf (bytes, sizeof bytes, "%3" PRIu64 "%s%s", b, suffix[k], unit);
return bytes;
}
@@ -378,7 +380,7 @@
default: result = "unknown result"; notice = 0; break;
}
if (verbosity > notice)
- fprintf (f, " %2d: timestamp %4ud%02uh: %10s %-30s seg:%u lba:%-8lld sk:%u asc:%u ascq:%u vs:%u\n", k, t->timestamp / 24, t->timestamp % 24, test, result, t->number, t->lba, t->sense_key, t->additional_sense_code, t->additional_sense_code_qualifier, t->vendor_specific);
+ fprintf (f, " %2d: timestamp %4ud%02uh: %10s %-30s seg:%u lba:%-8"PRIu64" sk:%u asc:%u ascq:%u vs:%u\n", k, t->timestamp / 24, t->timestamp % 24, test, result, t->number, t->lba, t->sense_key, t->additional_sense_code, t->additional_sense_code_qualifier, t->vendor_specific);
}
}
break;

239
debian/patches/007-tracefix.dpatch vendored Executable file
View File

@ -0,0 +1,239 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 004-tracefix.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
##
## DP: megatrace fixup for 64bit systems
## DP: thx. to gentoo devs
@DPATCH@
diff -Nuar megactl-0.4.1.orig/src/megactl.c megactl-0.4.1/src/megactl.c
--- megactl-0.4.1.orig/src/megactl.c 2007-08-21 00:19:53.000000000 -0700
+++ megactl-0.4.1/src/megactl.c 2014-07-14 11:15:14.538745305 -0700
@@ -45,6 +45,9 @@
********************************************************************/
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
#include "mega.h"
#include "megaioctl.h"
#include "adapter.h"
@@ -207,7 +210,7 @@
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024)
;
- snprintf (bytes, sizeof bytes, "%3llu%s%s", b, suffix[k], unit);
+ snprintf (bytes, sizeof bytes, "%3"PRIu64"%s%s", b, suffix[k], unit);
return bytes;
}
@@ -604,6 +607,8 @@
fprintf (stderr, "megaraid driver version %x too old.\n", driverVersion);
return 1;
}
+#else
+ driverVersion = 0;
#endif
if (megaGetNumAdapters (fd, &numAdapters, sas) < 0)
diff -Nuar megactl-0.4.1.orig/src/megaioctl.c megactl-0.4.1/src/megaioctl.c
--- megactl-0.4.1.orig/src/megaioctl.c 2014-07-14 11:30:03.590781305 -0700
+++ megactl-0.4.1/src/megaioctl.c 2014-07-14 11:31:36.410258930 -0700
@@ -87,7 +87,11 @@
m->cmd = cmd;
m->opcode = opcode;
m->subopcode = subopcode;
+#ifdef __x86_64__
+ m->xferaddr = (uint64_t) data;
+#else
m->xferaddr = (uint32_t) data;
+#endif
if (data)
memset (data, 0, len);
@@ -115,7 +119,11 @@
m->cmd = cmd;
m->opcode = opcode;
m->subopcode = subopcode;
+#ifdef __x86_64__
+ m->xferaddr = (uint64_t) data;
+#else
m->xferaddr = (uint32_t) data;
+#endif
if (data)
memset (data, 0, len);
@@ -178,11 +186,19 @@
u.ui.fcs.adapno = MKADAP(adapter->adapno);
u.data = data;
m->cmd = MBOXCMD_PASSTHRU;
+#ifdef __x86_64__
+ m->xferaddr = (uint64_t) p;
+#else
m->xferaddr = (uint32_t) p;
+#endif
p->timeout = 3;
p->ars = 1;
p->target = target;
- p->dataxferaddr = (uint32_t) data;
+#ifdef __x86_64__
+ p->dataxferaddr = (uint64_t) data;
+#else
+ p->dataxferaddr = (uint32_t) data;
+#endif
p->dataxferlen = len;
p->scsistatus = 239; /* HMMM */
memcpy (p->cdb, cdb, cdblen);
diff -Nuar megactl-0.4.1.orig/src/megatrace.c megactl-0.4.1/src/megatrace.c
--- megactl-0.4.1.orig/src/megatrace.c 2014-07-14 01:31:47.704312799 -0700
+++ megactl-0.4.1/src/megatrace.c 2014-07-14 11:37:20.570755832 -0700
@@ -170,7 +170,11 @@
fprintf (stderr, "ptrace:getregs: %s\n", strerror (errno));
exit (1);
}
+#ifdef __x86_64__
+ call = r.orig_rax;
+#else
call = r.orig_eax;
+#endif
/*printthis = call == SYS_ioctl;*/
if (state == INBOUND)
@@ -188,18 +192,30 @@
{
if ((call < 0) || (call > callmax) || (callinfo[call].name == NULL))
{
+#ifdef __x86_64__
+ fprintf (stderr, "= 0x%08llx\n", (unsigned long long) r.rax);
+#else
fprintf (stderr, "= 0x%08lx\n", (unsigned long) r.eax);
+#endif
}
else
{
if (callinfo[call].ptrval)
{
if (printcalls || printthis)
+#ifdef __x86_64__
+ fprintf (stderr, " = 0x%08llx\n", r.rax);
+#else
fprintf (stderr, " = 0x%08lx\n", r.eax);
+#endif
}
else
{
+#ifdef __x86_64__
+ long rv = r.rax;
+#else
long rv = r.eax;
+#endif
if (rv < 0)
{
if (printcalls || printthis)
@@ -219,16 +235,22 @@
unsigned int len = 16;
unsigned char buf[65536];
+#ifdef __x86_64__
+ unsigned long long fd = r.rbx;
+ unsigned long long ioc = r.rcx;
+ unsigned long long arg = r.rdx;
+#else
unsigned long fd = r.ebx;
-
unsigned long ioc = r.ecx;
+ unsigned long arg = r.edx;
+#endif
+
unsigned int iocdir = _IOC_DIR(ioc);
unsigned char ioctype = _IOC_TYPE(ioc);
unsigned int iocnr = _IOC_NR(ioc);
unsigned int iocsize = _IOC_SIZE(ioc);
char *iocdirname;
- unsigned long arg = r.edx;
switch (iocdir)
{
@@ -240,7 +262,11 @@
fprintf (stderr, "%s: ioctl(%ld, _IOC(\"%s\",'%c',0x%02x,0x%02x), 0x%08lx)", tbuf, fd, iocdirname, ioctype, iocnr, iocsize, arg);
if (state == OUTBOUND)
+#ifdef __x86_64__
+ fprintf (stderr, " = %lld\n", r.rax);
+#else
fprintf (stderr, " = %ld\n", r.eax);
+#endif
if (getenv ("LOG_INBOUND"))
fprintf (stderr, "\n");
@@ -249,10 +275,18 @@
if (len > sizeof buf)
len = sizeof buf;
+#ifdef __x86_64__
+ if (printregs)
+ fprintf (stderr, " rbx=%08llx rcx=%08llx rdx=%08llx rsi=%08llx rdi=%08llx rbp=%08llx rax=%08llx ds=%08llx es=%08llx fs=%08llx gs=%08llx orig_rax=%08llx rip=%08llx cs=%08llx eflags=%08llx rsp=%08llx ss=%08llx\n", r.rbx, r.rcx, r.rdx, r.rsi, r.rdi, r.rbp, r.rax, r.ds, r.es, r.fs, r.gs, r.orig_rax, r.rip, r.cs, r.eflags, r.rsp, r.ss);
+
+ copyout (buf, len, pid, r.rdx);
+#else
if (printregs)
fprintf (stderr, " ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx ebp=%08lx eax=%08lx xds=%08lx xes=%08lx xfs=%08lx xgs=%08lx orig_eax=%08lx eip=%08lx xcs=%08lx eflags=%08lx esp=%08lx xss=%08lx\n", r.ebx, r.ecx, r.edx, r.esi, r.edi, r.ebp, r.eax, r.xds, r.xes, r.xfs, r.xgs, r.orig_eax, r.eip, r.xcs, r.eflags, r.esp, r.xss);
copyout (buf, len, pid, r.edx);
+#endif
+
if ((ioctype == 'm') && (iocnr == 0) && (iocsize == sizeof (struct uioctl_t)))
{
@@ -405,7 +439,11 @@
else
{
fprintf (stderr, " host %d, off 0x%04x, count %d, sense_off 0x%08x, sense_len 0x%08x\n", iocp->host_no, iocp->sgl_off, iocp->sge_count, iocp->sense_off, iocp->sense_len);
+#ifdef __x86_64__
+ dumpbytes (stderr, buf, len, (void *) r.rdx, NULL);
+#else
dumpbytes (stderr, buf, len, (void *) r.edx, NULL);
+#endif
}
if (log)
{
@@ -427,23 +465,38 @@
}
else
{
+#ifdef __x86_64__
+ dumpbytes (stderr, buf, len, (void *) r.rdx, NULL);
+#else
dumpbytes (stderr, buf, len, (void *) r.edx, NULL);
+#endif
}
fprintf (stderr, "\n");
}
switch (state)
{
+#ifdef __x86_64__
+ static u64 lastrip = 0;
+#else
static u32 lasteip = 0;
+#endif
+
case UNTRACED:
/* We don't know whether we were inbound or outbound on the first signal; this
appears to differ between kernels. So we defer until we see the same eip in
two successive traps, at which point we know we were outbound, so the next
trap is inbound. */
+#ifdef __x86_64__
+ if (lastrip == r.rip)
+ state = INBOUND;
+ lastrip = r.rip;
+#else
if (lasteip == r.eip)
state = INBOUND;
lasteip = r.eip;
+#endif
break;
case INBOUND: state = OUTBOUND; break;
case OUTBOUND: state = INBOUND; break;

7
debian/patches/00list vendored Normal file
View File

@ -0,0 +1,7 @@
000-No_absolute_pathes_in_examples.dpatch
001-Drop_obsolete_asm_user.h.dpatch
002-No_enclosure_support.dpatch
003-Fix_disk_enumeration_loop.dpatch
005-Makefile.dpatch
006-gcc-fixes.dpatch
007-tracefix.dpatch

13
debian/preinst vendored Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh -e
# Skip if there's no previous version
if [ ! -z $2 ]; then
if dpkg --compare-versions $2 lt 0.4.1-4; then
update-rc.d -f megactl-makedev remove || true
rm -f /etc/init.d/megactl-makedev
fi
fi
#DEBHELPER#
exit 0

65
debian/rules vendored Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
include /usr/share/dpatch/dpatch.make
ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
ifeq ($(ARCH),i386)
MY_MAKEOPTS="ARCH=-m32"
else
MY_MAKEOPTS="ARCH=-m64"
endif
# $(MAKE) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/
build: build-stamp
build-stamp: patch-stamp
dh_testdir
$(MAKE) $(MY_MAKEOPTS) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/
touch $@
clean: unpatch
dh_testdir
dh_testroot
rm -f build-stamp
$(MAKE) clean -C src/
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
binary-indep: build install
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_install
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
ifeq ($(ARCH),i386)
dh_shlibdeps
endif
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

2
debian/watch vendored Normal file
View File

@ -0,0 +1,2 @@
version=3
http://sf.net/megactl/megactl-([0-9\.]+)\.tar\.gz

32
debian/wrappers/create-devices-nodes vendored Normal file
View File

@ -0,0 +1,32 @@
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
# License: Public domain
create_node() {
# Since 2.6.25rc2 linux kernel, megadev0 is created dynamically by udev
# See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=90a95af85f22c82f87e5fb714bac7ee06673b0ff
if [ ! -e /dev/megadev0 ]; then
# Not available, try to create it by hand for kernel pre 2.6.25rc2
grep -q 'megadev$' /proc/devices && MEGARAID="ok"
if [ ! -z ${MEGARAID} ]; then
MAJOR=`grep 'megadev$' /proc/devices | head -n 1 | awk '{ print $1 }'`
mknod /dev/megadev0 c $MAJOR 0
return $?
fi
fi
if [ -e /dev/megadev0 ]; then
return 0
else
return 1
fi
}
create_node_sas() {
grep -q 'megaraid_sas_ioctl$' /proc/devices && MEGARAIDSAS="ok"
if [ ! -z ${MEGARAIDSAS} ]; then
MAJOR=`grep 'megaraid_sas_ioctl$' /proc/devices | head -n 1 | awk '{ print $1 }'`
test -e /dev/megaraid_sas_ioctl_node || mknod /dev/megaraid_sas_ioctl_node c $MAJOR 0
return 0
else
return 1
fi
}

15
debian/wrappers/megactl vendored Normal file
View File

@ -0,0 +1,15 @@
#!/bin/sh
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
# License: Public domain
. /usr/lib/megactl/create-devices-nodes
create_node
if [ $? -eq 0 ]; then
/usr/lib/megactl/megactl $@
else
echo "No LSI MegaRAID cards found. You may try megasasctl instead."
exit 1
fi

15
debian/wrappers/megasasctl vendored Normal file
View File

@ -0,0 +1,15 @@
#!/bin/sh
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
# License: Public domain
. /usr/lib/megactl/create-devices-nodes
create_node_sas
if [ $? -eq 0 ]; then
/usr/lib/megactl/megasasctl $@
else
echo "No LSI MegaRAID SAS cards found. You may try megactl instead."
exit 1
fi