Compare commits

...

10 Commits

Author SHA1 Message Date
geos_one
03a2fc0bb1 Bump 2025-08-12 15:35:58 +02:00
Petter Reinholdtsen
3dc6bb2bb7 Import Debian changes 0.4.5-1
megactl (0.4.5-1) unstable; urgency=medium
.
  [ Petter Reinholdtsen ]
  * New upstream version 0.4.5
    - Dropped all patches now applied upstream.
.
megactl (0.4.4-4) unstable; urgency=medium
.
  * Fixed typo in patch metadata.
  * Added 0040-hardening.patch to use CPPFLAGS for hardening during build.
.
megactl (0.4.4-3) unstable; urgency=medium
.
  [ Petter Reinholdtsen ]
  * Added some patches fetched from upstream to improve appstrea
    metainfo and compiler warnings.
  * Updated Standards-Version from 4.6.2 to 4.7.0.
.
megactl (0.4.4-2) unstable; urgency=medium
.
  * Description: mention megacli. Reformat. Closes: .
.
megactl (0.4.4-1) unstable; urgency=medium
.
  * New upstream version 0.4.4
  * Drop applied patches
.
megactl (0.4.3+git20240307.6b1fdab-1) unstable; urgency=medium
.
  * Initial release (Closes: ).
2025-08-12 15:35:30 +02:00
geos_one
3ef804dba4 Switch to quilt 2025-08-06 17:01:19 +02:00
geos_one
cfe47daa9a Import Upstream version 0.4.5 2025-08-06 16:36:24 +02:00
Mario Fetka
64807cf811 update compat 2023-07-01 12:04:23 +02:00
Mario Fetka
fa0d36dc5b Merge tag 'upstream/0.4.1.1'
Upstream version 0.4.1.1
2017-04-22 17:55:53 +02:00
Mario Fetka
191eba7834 Imported Upstream version 0.4.1.1 2017-04-22 17:55:53 +02:00
Mario Fetka
5874481e38 Bump 2017-04-22 17:55:48 +02:00
Mario Fetka
0795bec8ef add device id patch 2017-04-22 17:21:07 +02:00
Mario Fetka
43e942c2b5 force m32 2017-04-22 16:58:36 +02:00
126 changed files with 617 additions and 1191 deletions

1
.github/FUNDING.yml vendored Normal file

@ -0,0 +1 @@
custom: [https://www.buymeacoffee.com/namiltd]

62
.github/workflows/codeql-analysis.yml vendored Normal file

@ -0,0 +1,62 @@
name: "CodeQL"
on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 20 * * 6'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['cpp']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

4
.gitignore vendored Normal file

@ -0,0 +1,4 @@
*.o
/megatrace
/megactl
/megasasctl

@ -1,11 +1,17 @@
DESTDIR:=
PREFIX:= /usr
BINDIR:= $(PREFIX)/bin
METAINFODIR:= $(PREFIX)/share/metainfo/
INSTALL= install
SRCS= megactl.c adapter.c megaioctl.c megatrace.c callinfo.c dumpbytes.c logpage.c ntrim.c SRCS= megactl.c adapter.c megaioctl.c megatrace.c callinfo.c dumpbytes.c logpage.c ntrim.c
INC= -I./schily -Iincludes-hack INC= -I./schily -Iincludes-hack
HDRS= mega.h adapter.h megaioctl.h callinfo.h logpage.h dumpbytes.h HDRS= mega.h adapter.h megaioctl.h callinfo.h logpage.h dumpbytes.h
ARCH= -m32 CPPFLAGS+=
CFLAGS= -g -Wall $(INC) $(ARCH) CFLAGS+= -g -Wall $(INC) $(ARCH) $(CPPFLAGS)
LDFLAGS= -g $(ARCH) LDFLAGS+= -g $(ARCH)
PROGRAMS= megactl megasasctl megatrace PROGRAMS= megactl megasasctl
all: $(PROGRAMS) all: $(PROGRAMS)
@ -24,6 +30,12 @@ megasasctl.o: megactl.c
%.o: Makefile.bak %.c %.o: Makefile.bak %.c
$(CC) $(CFLAGS) -c -o $@ $*.c $(CC) $(CFLAGS) -c -o $@ $*.c
install: $(PROGRAMS)
$(INSTALL) -d $(DESTDIR)$(BINDIR)/
$(INSTALL) $(PROGRAMS) $(DESTDIR)$(BINDIR)
$(INSTALL) -d $(DESTDIR)$(METAINFODIR)/
$(INSTALL) -m644 megactl.metainfo.xml $(DESTDIR)$(METAINFODIR)/
clean: clean:
$(RM) $(PROGRAMS) *.o $(RM) $(PROGRAMS) *.o

@ -57,7 +57,8 @@ static void batteryStatus5 (struct adapter_config *a)
a->battery.module_missing = !(a->q.v5.adapinfo.hw_present.bbu); a->battery.module_missing = !(a->q.v5.adapinfo.hw_present.bbu);
a->battery.pack_missing = b->type == MEGA_BATTERY_TYPE_NONE; a->battery.pack_missing = b->type == MEGA_BATTERY_TYPE_NONE;
a->battery.low_voltage = b->remaining_capacity_alarm || b->remaining_time_alarm || b->fully_discharged; /*a->battery.low_voltage = b->remaining_capacity_alarm || b->remaining_time_alarm || b->fully_discharged;*/
a->battery.low_voltage = !b->fully_charged && (b->remaining_time_alarm || b->remaining_capacity_alarm || b->fully_discharged) ;
a->battery.high_temperature = b->over_temperature != 0; a->battery.high_temperature = b->over_temperature != 0;
a->battery.over_charged = b->over_charged != 0; a->battery.over_charged = b->over_charged != 0;
switch (b->charger_status) switch (b->charger_status)
@ -69,7 +70,7 @@ static void batteryStatus5 (struct adapter_config *a)
} }
a->battery.voltage = b->voltage; a->battery.voltage = b->voltage;
a->battery.temperature = b->temperature; a->battery.temperature = b->temperature;
a->battery.healthy = !(a->battery.module_missing || a->battery.pack_missing || a->battery.low_voltage || a->battery.high_temperature || a->battery.cycles_exceeded || (a->battery.charger_state != ChargerStateComplete) || (!b->health)); a->battery.healthy = !(a->battery.module_missing || a->battery.pack_missing || a->battery.low_voltage || a->battery.high_temperature /*|| a->battery.cycles_exceeded */|| (a->battery.charger_state != ChargerStateComplete) || (!b->health));
} }
@ -136,7 +137,7 @@ struct log_page_list *getDriveLogPage (struct physical_drive_info *d, uint8_t pa
} }
int cmpPhysical (const void *a, const void *b) static int cmpPhysical (const void *a, const void *b)
{ {
struct physical_drive_info *x = *((struct physical_drive_info **) a); struct physical_drive_info *x = *((struct physical_drive_info **) a);
struct physical_drive_info *y = *((struct physical_drive_info **) b); struct physical_drive_info *y = *((struct physical_drive_info **) b);
@ -192,7 +193,10 @@ struct physical_drive_info *getPhysicalDriveInfo (struct adapter_config *a, uint
d->channel = info->enclosure; d->channel = info->enclosure;
d->id = info->slot; 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; d->inquiry = info->inquiry.inq;
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1); strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
@ -369,7 +373,7 @@ static char *getAdapterConfig2 (struct adapter_config *a)
return "invalid number of logical drives"; return "invalid number of logical drives";
a->num_channels = pinfo->nchannels; a->num_channels = pinfo->nchannels;
if ((a->channel = (uint8_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL) if ((a->channel = (uint16_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL)
return "out of memory (channels)"; return "out of memory (channels)";
for (k = 0; k < a->num_channels; ++k) for (k = 0; k < a->num_channels; ++k)
a->channel[k] = k; a->channel[k] = k;
@ -503,7 +507,7 @@ static char *getAdapterConfig3 (struct adapter_config *a)
case 4: break; case 4: break;
default: return "invalid number of channels"; default: return "invalid number of channels";
} }
strncpy (a->product, (char *) pinfo->product_name, sizeof (pinfo->product_name)); strncpy (a->product, (char *) pinfo->product_name, sizeof (a->product));
a->product[sizeof (a->product) - 1] = '\0'; a->product[sizeof (a->product) - 1] = '\0';
ntrim (a->product); ntrim (a->product);
strncpy (a->bios, (char *) pinfo->bios_version, sizeof (a->bios)); strncpy (a->bios, (char *) pinfo->bios_version, sizeof (a->bios));
@ -519,7 +523,7 @@ static char *getAdapterConfig3 (struct adapter_config *a)
return "invalid number of logical drives"; return "invalid number of logical drives";
a->num_channels = pinfo->nchannels; a->num_channels = pinfo->nchannels;
if ((a->channel = (uint8_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL) if ((a->channel = (uint16_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL)
return "out of memory (channels)"; return "out of memory (channels)";
for (k = 0; k < a->num_channels; ++k) for (k = 0; k < a->num_channels; ++k)
a->channel[k] = k; a->channel[k] = k;
@ -630,7 +634,7 @@ static char *getAdapterConfig3 (struct adapter_config *a)
} }
int cmpChannel (const void *a, const void *b) static int cmpChannel (const void *a, const void *b)
{ {
int x = (int) *((uint8_t *) a); int x = (int) *((uint8_t *) a);
int y = (int) *((uint8_t *) b); int y = (int) *((uint8_t *) b);
@ -661,7 +665,7 @@ static char *getAdapterConfig5 (struct adapter_config *a)
a->dram_size = pinfo->memory_size; a->dram_size = pinfo->memory_size;
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno); snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
strncpy (a->product, (char *) pinfo->product_name, sizeof (pinfo->product_name)); strncpy (a->product, (char *) pinfo->product_name, sizeof (a->product));
a->product[sizeof (a->product) - 1] = '\0'; a->product[sizeof (a->product) - 1] = '\0';
ntrim (a->product); ntrim (a->product);
@ -696,13 +700,37 @@ static char *getAdapterConfig5 (struct adapter_config *a)
/* Didn't find this enclosure; extend the map */ /* Didn't find this enclosure; extend the map */
++a->num_channels; ++a->num_channels;
if ((a->channel = (uint8_t *) realloc (a->channel, a->num_channels * sizeof (*a->channel))) == NULL) if ((a->channel = (uint16_t *) realloc (a->channel, a->num_channels * sizeof (*a->channel))) == NULL)
return "out of memory (channels)"; return "out of memory (channels)";
a->channel[a->num_channels - 1] = device->device[k].enclosure; a->channel[a->num_channels - 1] = device->device[k].enclosure;
} }
qsort (a->channel, a->num_channels, sizeof (*a->channel), cmpChannel); 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) if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
return "out of memory (physical drives)"; return "out of memory (physical drives)";
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical)); memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));

86
debian/changelog vendored

@ -1,78 +1,42 @@
megactl (0.4.1-6) unstable; urgency=medium megactl (0.4.5-1) unstable; urgency=medium
* Update 003-Fix_disk_enumeration_loop patch (fix issues with PERC6e). [ Petter Reinholdtsen ]
* New upstream version 0.4.5
- Dropped all patches now applied upstream.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jan 2014 23:10:36 +0100 -- Petter Reinholdtsen <pere@debian.org> Fri, 16 Aug 2024 22:58:24 +0200
megactl (0.4.1+svn20090725.r6-5) unstable; urgency=medium megactl (0.4.4-4) unstable; urgency=medium
* Update 003-Fix_disk_enumeration_loop patch (fix issues with PERC6e). * Fixed typo in patch metadata.
* Added 0040-hardening.patch to use CPPFLAGS for hardening during build.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jan 2014 23:10:36 +0100 -- Petter Reinholdtsen <pere@debian.org> Wed, 08 May 2024 18:38:44 +0200
megactl (0.4.1+svn20090725.r6-4) unstable; urgency=medium megactl (0.4.4-3) unstable; urgency=medium
* Fix build on Jessie+. [ Petter Reinholdtsen ]
* Added some patches fetched from upstream to improve appstrea
metainfo and compiler warnings.
* Updated Standards-Version from 4.6.2 to 4.7.0.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Tue, 21 Jan 2014 22:54:42 +0100 -- Jérémy Lal <kapouer@melix.org> Wed, 17 Apr 2024 13:39:31 +0200
megactl (0.4.1+svn20090725.r6-3) unstable; urgency=medium megactl (0.4.4-2) unstable; urgency=medium
* New patch by Pat Suwalski <pat@suwalski.net> to fix a bad disks * Description: mention megacli. Reformat. Closes: #1069175.
enumeration loop.
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Tue, 21 Jan 2014 20:24:22 +0100 -- Jérémy Lal <kapouer@melix.org> Wed, 17 Apr 2024 13:37:56 +0200
megactl (0.4.1+svn20090725.r6-2) unstable; urgency=medium megactl (0.4.4-1) unstable; urgency=medium
* Integrate patch by Pat Suwalski <pat@suwalski.net> to handle devices * New upstream version 0.4.4
without enclosure. * Drop applied patches
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 14 Dec 2013 14:36:22 +0100 -- Jérémy Lal <kapouer@melix.org> Mon, 15 Apr 2024 11:18:11 +0200
megactl (0.4.1+svn20090725.r6-1) unstable; urgency=low megactl (0.4.3+git20240307.6b1fdab-1) unstable; urgency=medium
* New upstream release (based on sv trunk snapshot): * Initial release (Closes: #1065322).
- 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 -- Petter Reinholdtsen <pere@debian.org> Thu, 07 Mar 2024 15:41:23 +0100
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

@ -1 +0,0 @@
5

42
debian/control vendored

@ -1,27 +1,25 @@
Source: megactl Source: megactl
Section: admin Section: admin
Priority: optional Priority: optional
Maintainer: Adam Cécile (Le_Vert) <gandalf@le-vert.net> Maintainer: Jérémy Lal <kapouer@melix.org>
Build-Depends: debhelper (>= 4), dpatch, libc6-dev-i386 [amd64], gcc-multilib [amd64] | libc6-dev-i386 (<< 2.7) [amd64] Uploaders: Petter Reinholdtsen <pere@debian.org>
Standards-Version: 3.8.2 Rules-Requires-Root: no
Homepage: http://sourceforge.net/projects/megactl Build-Depends: debhelper-compat (= 12)
Standards-Version: 4.7.0
Homepage: https://github.com/namiltd/megactl/
Vcs-Browser: https://salsa.debian.org/debian/megactl
Vcs-Git: https://salsa.debian.org/debian/megactl.git
Package: megactl Package: megactl
Architecture: i386 amd64 Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends} Depends: ${misc:Depends}, ${shlibs:Depends}
Description: LSI MegaRAID SCSI/SAS reporting tool Description: LSI Megaraid Control and Monitoring Tools
This package contains both megactl and megasasctl tools that can be used Reports diagnostics on megaraid and megaraid_sas adapters and
to query LSI's MegaRAID adapters status. attached disks, similar to the original "megacli" tool.
. The adapters are also known as Dell PERC2, PERC3, PERC4 and PERC5.
It reports status and informations about the adapter itself, it's Permits dumping of controller log pages for inspection of error,
logical disks and the physical disks attached. temperature, and self-test conditions, initiates self-test
diagnostics, and documents adapter and logical drive configuration.
Package: megatrace Target devices may be adapters, (e.g. a0), enclosures (e.g. a0e0),
Architecture: i386 amd64 or individual disks (e.g. a0e0s0). If no target is specified,
Depends: ${shlibs:Depends}, ${misc:Depends}, libc6-i386 [amd64], megactl reports configuration and drive state on all adapters.
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.

81
debian/copyright vendored

@ -1,45 +1,46 @@
This package was debianized by Adam Cécile (Le_Vert) <gandalf@le-vert.net> on Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Wed, 26 Sep 2007 09:49:57 +0200. Source: https://github.com/namiltd/megactl/
Upstream-Name: megactl
It was downloaded from http://sourceforge.net/projects/megactl Upstream-Contact: Mieczyslaw Nalewaj
Upstream Author:
Jefferson Ogata <ogata@antibozo.net>
Files: *
Copyright: Copyright:
1984-2003 J. Schilling
1998 D. Dorau, C. Wohlgemuth
2003-2005 LSI Logic Corporation.
2007 Jefferson Ogata
License: GPL-2.0+
Copyright (C) 2007 Jefferson Ogata Files: megactl.metainfo.xml
Copyright: 2024 Petter Reinholdtsen
License: CC0-1.0
To the extent possible under law, the author(s) have dedicated all
copyright and related and neighboring rights to this software to the
public domain worldwide. This software is distributed without any
warranty.
.
A copy of the CC0 1.0 Universal license can be found in
/usr/share/common-licenses/CC0-1.0.
License: Files: debian/*
Copyright:
2024 Petter Reinholdtsen <pere@debian.org>
License: GPL-2.0+
This package is free software; you can redistribute it and/or modify License: GPL-2.0+
it under the terms of the GNU General Public License as published by This program is free software; you can redistribute it and/or modify
the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
(at your option) any later version. the Free Software Foundation; either version 2, 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 This program is distributed in the hope that it will be useful,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details. 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 You should have received a copy of the GNU General Public License along with
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA this program; see the file COPYING. 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'. On Debian systems, the complete text of the GNU General Public License
Version 2 can be found in `/usr/share/common-licenses/GPL-2'.
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

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

1
debian/docs vendored

@ -1 +0,0 @@
README

2
debian/examples vendored

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

2
debian/gbp.conf vendored Normal file

@ -0,0 +1,2 @@
[DEFAULT]
pristine-tar = True

@ -1,102 +0,0 @@
.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.

@ -1,102 +0,0 @@
.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,39 +0,0 @@
.TH MEGATRACE "8" "September 2007" "0.4.1" "User Commands"
.SH NAME
megatrace - a debugging program which can be used to trace LSI MegaRAID-related ioctl() system calls.
.SH DESCRIPTION
.B megatrace
is debugging program which can be used to trace LSI MegaRAID-related ioctl() system calls.
.br
You won't need that unless you're trying to add features to megactl, or are exceptionally curious.
.br
This program uses ptrace(2) and can inspect and modify data structures to help you suss out what's going on in dellmgr and MegaCli.
.PP
If you're not developer, please check megactl(8) or megactlsas(8).
.SH SYNOPSIS
.B megatrace
<command_to_trace>
.PP
You may really consider tracing a command that access MegaRAID card, like Dell's dellmgr or LSI's megacli.
.SH OPTIONS
.B megatrace
has no options.
.SH "SEE ALSO"
Homepage: http://sourceforge.net/projects/megactl
.br
Some examples scripts (Debian systems): /usr/share/doc/megactl/examples/
.br
megactl(8): Reporting tool for SCSI adapters.
megasasctl(8): Reporting 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.

@ -1,5 +0,0 @@
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

@ -1 +1,2 @@
debian/man/megactl/* megactl.1
megasasctl.1

@ -1,13 +0,0 @@
#!/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

@ -1,2 +0,0 @@
src/megatrace usr/lib/megactl
debian/wrappers/megatrace usr/sbin

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

@ -1,74 +0,0 @@
#! /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

@ -1,29 +0,0 @@
#! /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);

@ -1,75 +0,0 @@
#! /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 */

@ -1,64 +0,0 @@
#! /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));

@ -1,18 +0,0 @@
#! /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 },

@ -1,33 +0,0 @@
#! /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)

@ -1,53 +0,0 @@
#! /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;

@ -1,239 +0,0 @@
#! /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;

@ -1,7 +0,0 @@
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

3
debian/patches/README vendored Normal file

@ -0,0 +1,3 @@
0xxx: Grabbed from upstream development.
1xxx: Possibly relevant for upstream adoption.
2xxx: Only relevant for official Debian release.

74
debian/rules vendored

@ -1,69 +1,15 @@
#!/usr/bin/make -f #!/usr/bin/make -f
# Uncomment this to turn on verbose mode. export DH_VERBOSE = 1
#export DH_VERBOSE=1
include /usr/share/dpatch/dpatch.make # See FEATURE AREAS in dpkg-buildflags(1).
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH) # See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
CFLAGS = -Wall -g %:
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) dh $@
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) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/ megatrace
mv src/megatrace src/megatrace.i386
$(MAKE) clean -C src/
$(MAKE) $(MY_MAKEOPTS) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/
mv src/megatrace.i386 src/megatrace
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

11
debian/salsa-ci.yml vendored Normal file

@ -0,0 +1,11 @@
# For more information on what jobs are run see:
# https://salsa.debian.org/salsa-ci-team/pipeline
#
# To enable the jobs, go to your repository (at salsa.debian.org)
# and click over Settings > CI/CD > Expand (in General pipelines).
# In "CI/CD configuration file" write debian/salsa-ci.yml and click
# in "Save Changes". The CI tests will run after the next commit.
---
include:
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml

1
debian/source/format vendored Normal file

@ -0,0 +1 @@
3.0 (quilt)

5
debian/upstream/metadata vendored Normal file

@ -0,0 +1,5 @@
Bug-Database: https://github.com/namiltd/megactl/issues
Bug-Submit: https://github.com/namiltd/megactl/issues/new
Documentation: https://github.com/<user>/megactl/wiki
Repository-Browse: https://github.com/namiltd/megactl/
Repository: https://github.com/namiltd/megactl.git

10
debian/watch vendored

@ -1,2 +1,8 @@
version=3 # See uscan(1) for format.
http://sf.net/megactl/megactl-([0-9\.]+)\.tar\.gz
# Compulsory line, this is a version 4 file.
version=4
opts="filenamemangle=s%(?:.*?)?v?(@ANY_VERSION@@ARCHIVE_EXT@)%@PACKAGE@-$1%" \
https://github.com/namiltd/megactl/tags \
(?:.*?/)v?@ANY_VERSION@@ARCHIVE_EXT@

@ -1,32 +0,0 @@
# 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
}

@ -1,15 +0,0 @@
#!/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

@ -1,15 +0,0 @@
#!/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

@ -1,11 +0,0 @@
#!/bin/sh
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
# License: Public domain
. /usr/lib/megactl/create-devices-nodes
create_node
create_node_sas
/usr/lib/megactl/megatrace $@

@ -107,23 +107,12 @@ static char *friendlySize (uint64_t b, char *unit)
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024) 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, "%3llu%s%s",
(long long unsigned int)b, suffix[k], unit);
return bytes; return bytes;
} }
static uint32_t blocksToGB (uint32_t blocks)
{
return (long) (((uint64_t) blocks) * 512 / 1000000000);
}
static uint32_t blocksToGiB (uint32_t blocks)
{
return blocks / 2 / 1024 / 1024;
}
static uint64_t extractInt64 (void *u, size_t len) static uint64_t extractInt64 (void *u, size_t len)
{ {
uint64_t x; uint64_t x;
@ -378,7 +367,8 @@ void dumpLogPage (FILE *f, struct logData *x, void *log, size_t len, int verbosi
default: result = "unknown result"; notice = 0; break; default: result = "unknown result"; notice = 0; break;
} }
if (verbosity > notice) 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:%-8lld sk:%u asc:%u ascq:%u vs:%u\n", k, t->timestamp / 24, t->timestamp % 24, test, result, t->number,
(long long int)t->lba, t->sense_key, t->additional_sense_code, t->additional_sense_code_qualifier, t->vendor_specific);
} }
} }
break; break;

@ -114,6 +114,8 @@ struct list_head {
#define SCSI_SELFTEST_FOREGROUND_SHORT 0x05 #define SCSI_SELFTEST_FOREGROUND_SHORT 0x05
#define SCSI_SELFTEST_FOREGROUND_LONG 0x06 #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. */ /* megaraid2 header file gets this wrong. */
typedef struct { typedef struct {
@ -545,7 +547,7 @@ struct adapter_config
uint16_t dram_size; /* size of DRAM in MB */ uint16_t dram_size; /* size of DRAM in MB */
uint16_t rebuild_rate; /* rebuild rate as percentage */ uint16_t rebuild_rate; /* rebuild rate as percentage */
uint16_t num_channels; /* number of channels or enclosures */ 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; uint16_t num_physicals;
struct physical_drive_info *physical; struct physical_drive_info *physical;
struct physical_drive_info **physical_list; /* ordered list of physical devices */ struct physical_drive_info **physical_list; /* ordered list of physical devices */

83
megactl.1 Normal file

@ -0,0 +1,83 @@
.\" Text automatically generated by txt2man
.TH megactl 1 "03 March 2024" ""
.SH NAME
megactl \- diagnostics on megaraid adapters and attached disks.
.SH SYNOPSIS
megactl [\fB-vest\fP] [\fB-H\fP] [\fB-l\fP log-page-nr] [\fB-T\fP long|short] [target \.\.\.]
.PP
Reports diagnostics on megaraid adapters and attached disks. 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. Target devices may be adapters,
(e.g. a0), channels (e.g. a0c0), or individual disks (e.g. a0c0t0). If
no target is specified, reports configuration and drive state on all
adapters. If a target matches a collection of disks, operations are
applied to all matching devices. Options are:
.TP
.B
\fB-v\fP
Increase program verbosity.
.TP
.B
\fB-e\fP
Dump read (0x03), write (0x02), and verify (0x05) error log
pages.
.TP
.B
\fB-s\fP
Dump self-test (0x10) log page.
.TP
.B
\fB-t\fP
Dump temperature (0x0d) log page.
.TP
.B
\fB-l\fP page
Dump the specified log page. Log page 0 documents the log pages
the device supports.
.TP
.B
\fB-p\fP
Do not report physical disks. Reports only adapters and logical
drives. Useful for concisely documenting adapter configuration.
.TP
.B
\fB-T\fP test
Initiate the background short or long self-test procedure. The
test may take up to an hour to complete, but does not inhibit
access to the device. The test may be monitored using the \fB-s\fP
option.
.TP
.B
\fB-H\fP
Perform an adapter health check. Inspects state of all logical
and physical drives and battery backup unit and reports problem
conditions. If all is well, generates no output. Useful in a
cron job.
.TP
.B
\fB-B\fP
When performing health check, do not treat battery problems as
failures.
.TP
.B
\fB-V\fP
Show version.
.PP
N.B. The background long self test is a useful tool for diagnosing
problems with individual disks. But be cautious with program usage.
"megactl \fB-T\fP long" with no targets will initiate a background long self
test on every drive on every adapter. This may not be what you want.
.PP
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. If, however, any
of the log page options is specified, only the designated log pages are
inspected.
.PP
This program requires the device file /dev/megadev0 to be present on
the system. 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.

@ -43,6 +43,8 @@ Cleaner log page output.
Fixes for 64-bit systems. Currently builds only with -m32. Fixes for 64-bit systems. Currently builds only with -m32.
Fetch TTY logs.
********************************************************************/ ********************************************************************/
#include "mega.h" #include "mega.h"
@ -61,6 +63,8 @@ Fixes for 64-bit systems. Currently builds only with -m32.
#include <signal.h> #include <signal.h>
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <scg/scsireg.h> #include <scg/scsireg.h>
@ -72,17 +76,19 @@ Fixes for 64-bit systems. Currently builds only with -m32.
#ifdef MEGA_SAS_CTL #ifdef MEGA_SAS_CTL
#define MEGA_DEVICE "/dev/megaraid_sas_ioctl_node" #define MEGA_DEVICE "/dev/megaraid_sas_ioctl_node"
#define MEGA_NAME "megaraid_sas_ioctl"
#else #else
#define MEGA_DEVICE "/dev/megadev0" #define MEGA_DEVICE "/dev/megadev0"
#define MEGA_NAME "megadev"
#define MEGA_MIN_VERSION 0x118c #define MEGA_MIN_VERSION 0x118c
#endif /* defined(MEGA_SAS_CTL) */ #endif /* defined(MEGA_SAS_CTL) */
static char *version = "0.4.1"; static char *version = "0.4.3-hmage";
static int verbosity = 0; static int verbosity = 0;
@ -155,7 +161,7 @@ MEGA_DEVICE " as a character device with suitable",
}; };
void usage (const int ec, const char *format, ...) static void usage (const int ec, const char *format, ...)
{ {
char **u; char **u;
va_list ap; va_list ap;
@ -205,14 +211,14 @@ static char *friendlySize (uint64_t b, char *unit)
int k; int k;
static char bytes[128]; static char bytes[128];
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024) for (k = 0; (b >= 10000) && (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, "%4"PRIu64"%s%s", b, suffix[k], unit);
return bytes; return bytes;
} }
void describePhysicalDrive (FILE *f, struct physical_drive_info *d, int verbosity) static void describePhysicalDrive (FILE *f, struct physical_drive_info *d, int verbosity)
{ {
char *state; char *state;
@ -235,7 +241,7 @@ void describePhysicalDrive (FILE *f, struct physical_drive_info *d, int verbosit
fprintf (f, " %8s %-16s", d->vendor, d->model); fprintf (f, " %8s %-16s", d->vendor, d->model);
if (verbosity > 1) if (verbosity > 1)
fprintf (f, " rev:%-4s s/n:%-20s", d->revision, d->serial); fprintf (f, " rev:%-4s s/n:%-20s", d->revision, d->serial);
fprintf (f, " %7s", friendlySize (d->blocks << 9, "B")); fprintf (f, " %8s", friendlySize (d->blocks << 9, "B"));
fprintf (f, " %5s%c", d->span && d->span->num_logical_drives ? d->span->logical_drive[0]->name : "", d->span && (d->span->num_logical_drives > 1) ? '+' : ' '); fprintf (f, " %5s%c", d->span && d->span->num_logical_drives ? d->span->logical_drive[0]->name : "", d->span && (d->span->num_logical_drives > 1) ? '+' : ' ');
fprintf (f, " %-8s", state); fprintf (f, " %-8s", state);
if (d->media_errors || d->other_errors) if (d->media_errors || d->other_errors)
@ -248,7 +254,7 @@ void describePhysicalDrive (FILE *f, struct physical_drive_info *d, int verbosit
} }
void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity) static void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity)
{ {
char *state; char *state;
uint64_t blocks; uint64_t blocks;
@ -273,11 +279,12 @@ void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity)
case 0: blocks += r->blocks_per_disk * r->span->num_disks; break; case 0: blocks += r->blocks_per_disk * r->span->num_disks; break;
case 1: blocks += r->blocks_per_disk * r->span->num_disks / 2; break; case 1: blocks += r->blocks_per_disk * r->span->num_disks / 2; break;
case 5: blocks += r->blocks_per_disk * (r->span->num_disks - 1); break; case 5: blocks += r->blocks_per_disk * (r->span->num_disks - 1); break;
case 6: blocks += r->blocks_per_disk * (r->span->num_disks - 2); break;
} }
} }
fprintf (f, "%-8s", l->name); fprintf (f, "%-8s", l->name);
fprintf (f, " %s", friendlySize (blocks << 9, "B")); fprintf (f, " %8s", friendlySize (blocks << 9, "B"));
fprintf (f, " RAID %u%s", l->raid_level, l->num_spans > 1 ? "0" : " "); fprintf (f, " RAID %u%s", l->raid_level, l->num_spans > 1 ? "0" : " ");
fprintf (f, " %2ux%-2u", l->num_spans, l->span_size); fprintf (f, " %2ux%-2u", l->num_spans, l->span_size);
fprintf (f, " %s", state); fprintf (f, " %s", state);
@ -290,7 +297,7 @@ void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity)
int j; int j;
r = &l->span[k]; r = &l->span[k];
fprintf (f, " row %2d:", k); fprintf (f, " row %2d:", k);
for (j = 0, p = r->span->disk; j < r->span->num_disks; ++j, ++p) for (j = 0, p = r->span->disk; j < r->span->num_disks; ++j, ++p)
{ {
char *flag = (*p)->state != PdStateOnline ? "*" : " "; char *flag = (*p)->state != PdStateOnline ? "*" : " ";
@ -302,7 +309,7 @@ void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity)
} }
void describeBattery (FILE *f, struct adapter_config *a, int verbosity) static void describeBattery (FILE *f, struct adapter_config *a, int verbosity)
{ {
if (a->battery.healthy) if (a->battery.healthy)
fprintf (f, "good"); fprintf (f, "good");
@ -339,7 +346,7 @@ void describeBattery (FILE *f, struct adapter_config *a, int verbosity)
} }
void describeAdapter (FILE *f, struct adapter_config *a, int verbosity) static void describeAdapter (FILE *f, struct adapter_config *a, int verbosity)
{ {
fprintf (f, "%-8s %-24s", a->name, a->product); fprintf (f, "%-8s %-24s", a->name, a->product);
if (verbosity > 0) if (verbosity > 0)
@ -359,8 +366,8 @@ int main (int argc, char **argv)
{ {
int k; int k;
int fd; int fd;
uint32_t driverVersion = 0;
uint32_t numAdapters; uint32_t numAdapters;
uint32_t driverVersion;
int startSelfTest = -1; int startSelfTest = -1;
int healthCheck = 0; int healthCheck = 0;
int checkBattery = 1; int checkBattery = 1;
@ -374,6 +381,11 @@ int main (int argc, char **argv)
uint8_t readLog[LOG_PAGE_MAX] = { 0, }; uint8_t readLog[LOG_PAGE_MAX] = { 0, };
int reportPhysical = 1; int reportPhysical = 1;
int showVersion = 0; int showVersion = 0;
FILE *fp;
char *line = NULL;
int major;
size_t len = 0;
char lf;
#ifdef MEGA_SAS_CTL #ifdef MEGA_SAS_CTL
int sas = 1; int sas = 1;
#else #else
@ -588,8 +600,33 @@ int main (int argc, char **argv)
if ((fd = open (device, O_RDONLY)) < 0) if ((fd = open (device, O_RDONLY)) < 0)
{ {
fprintf (stderr, "unable to open device %s: %s\n", device, strerror (errno)); if ((fp = fopen ("/proc/devices", "r")) == NULL)
return 1; {
fprintf (stderr, "file /proc/devices access error\n");
return 1;
} else {
while (getline(&line, &len, fp) != -1)
{
if ((sscanf(line, "%d "MEGA_NAME"%c", &major, &lf) == 2) && (lf = 10))
{
mknod(device, S_IFCHR /*| 0666*/, makedev(major, 0));
free(line);
break;
}
if (line)
{
free(line);
line = NULL;
}
}
fclose(fp);
}
if ((fd = open (device, O_RDONLY)) < 0)
{
fprintf (stderr, "unable to open device %s: %s\n", device, strerror (errno));
return 1;
}
} }
#ifndef MEGA_SAS_CTL #ifndef MEGA_SAS_CTL
@ -608,7 +645,7 @@ int main (int argc, char **argv)
if (megaGetNumAdapters (fd, &numAdapters, sas) < 0) if (megaGetNumAdapters (fd, &numAdapters, sas) < 0)
{ {
fprintf (stderr, "unable to determine number of adapters: %s\n", megaErrorString ()); fprintf (stderr, "unable to find any adapters: %s\n", megaErrorString ());
return 1; return 1;
} }
@ -806,9 +843,9 @@ int main (int argc, char **argv)
if (d->state == PdStateHotspare) if (d->state == PdStateHotspare)
{ {
if (x == 0) if (x == 0)
fprintf (stdout, "hot spares :"); fprintf (stdout, "hot spares :");
else if ((x % 8) == 0) else if ((x % 8) == 0)
fprintf (stdout, " :"); fprintf (stdout, " :");
fprintf (stdout, " %-8s", d->name); fprintf (stdout, " %-8s", d->name);
if (((++x) % 8) == 0) if (((++x) % 8) == 0)
fprintf (stdout, "\n"); fprintf (stdout, "\n");
@ -830,9 +867,9 @@ int main (int argc, char **argv)
if ((!(d->span)) && (d->state != PdStateHotspare)) if ((!(d->span)) && (d->state != PdStateHotspare))
{ {
if (x == 0) if (x == 0)
fprintf (stdout, "unconfigured :"); fprintf (stdout, "unconfigured:");
else if ((x % 8) == 0) else if ((x % 8) == 0)
fprintf (stdout, " :"); fprintf (stdout, " :");
fprintf (stdout, " %-8s", d->name); fprintf (stdout, " %-8s", d->name);
if (((++x) % 8) == 0) if (((++x) % 8) == 0)
fprintf (stdout, "\n"); fprintf (stdout, "\n");

53
megactl.metainfo.xml Normal file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<id>com.github.namiltd.megactl</id>
<metadata_license>CC0-1.0</metadata_license>
<name>megactl</name>
<summary>LSI Megaraid Control and Monitoring Tools</summary>
<description>
<p>
Provide tools to query hard drive and RAID volume status from
PERC2, PERC3, PERC4 and PERC5 adapters.
</p>
</description>
<url type="homepage">https://github.com/namiltd/megactl/</url>
<developer_name>Mieczyslaw Nalewaj</developer_name>
<provides>
<modalias>lkmodule:megaraid</modalias>
<modalias>lkmodule:megaraid_sas</modalias>
<modalias>pci:v00001000d000010E7sv*</modalias>
<modalias>pci:v00001000d000010E4sv*</modalias>
<modalias>pci:v00001000d000010E3sv*</modalias>
<modalias>pci:v00001000d000010E0sv*</modalias>
<modalias>pci:v00001000d000010E6sv*</modalias>
<modalias>pci:v00001000d000010E5sv*</modalias>
<modalias>pci:v00001000d000010E2sv*</modalias>
<modalias>pci:v00001000d000010E1sv*</modalias>
<modalias>pci:v00001000d0000001Csv*</modalias>
<modalias>pci:v00001000d0000001Bsv*</modalias>
<modalias>pci:v00001000d00000017sv*</modalias>
<modalias>pci:v00001000d00000016sv*</modalias>
<modalias>pci:v00001000d00000015sv*</modalias>
<modalias>pci:v00001000d00000014sv*</modalias>
<modalias>pci:v00001000d00000053sv*</modalias>
<modalias>pci:v00001000d00000052sv*</modalias>
<modalias>pci:v00001000d000000CFsv*</modalias>
<modalias>pci:v00001000d000000CEsv*</modalias>
<modalias>pci:v00001000d0000005Fsv*</modalias>
<modalias>pci:v00001000d0000005Dsv*</modalias>
<modalias>pci:v00001000d0000002Fsv*</modalias>
<modalias>pci:v00001000d0000005Bsv*</modalias>
<modalias>pci:v00001028d00000015sv*</modalias>
<modalias>pci:v00001000d00000413sv*</modalias>
<modalias>pci:v00001000d00000071sv*</modalias>
<modalias>pci:v00001000d00000073sv*</modalias>
<modalias>pci:v00001000d00000079sv*</modalias>
<modalias>pci:v00001000d00000078sv*</modalias>
<modalias>pci:v00001000d0000007Csv*</modalias>
<modalias>pci:v00001000d00000060sv*</modalias>
<modalias>pci:v00001000d00000411sv*</modalias>
<modalias>pci:v00008086d00001960sv*</modalias>
<modalias>pci:v0000101Ed00009060sv*</modalias>
<modalias>pci:v0000101Ed00009010sv*</modalias>
</provides>
</component>

@ -25,6 +25,7 @@
/* Don't include <sys/types.h> */ /* Don't include <sys/types.h> */
#include <assert.h>
#include <memory.h> #include <memory.h>
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
@ -32,9 +33,30 @@
#include <scsi/scsi.h> #include <scsi/scsi.h>
/* This is arbitrary. */
#define MEGA_MAX_ADAPTERS 16
struct mega_adapter_map
{
uint8_t count; /* number of adapters found */
uint8_t host[MEGA_MAX_ADAPTERS]; /* map of adapter index to host number */
};
static struct mega_adapter_map *adapterMap = NULL;
int megaErrno = 0; int megaErrno = 0;
static u16 hostMap (u16 adapno)
{
if ((adapterMap == NULL) || (adapno >= adapterMap->count))
return 0;
return adapterMap->host[adapno];
}
static int doIoctl (struct mega_adapter_path *adapter, void *u) static int doIoctl (struct mega_adapter_path *adapter, void *u)
{ {
switch (adapter->type) switch (adapter->type)
@ -49,7 +71,7 @@ static int doIoctl (struct mega_adapter_path *adapter, void *u)
} }
static int driverQuery (int fd, uint16_t adap, void *data, uint32_t len, uint8_t subop) static int driverQuery (int fd, void *data, uint32_t len, uint8_t subop)
{ {
struct uioctl_t u; struct uioctl_t u;
struct mega_adapter_path adapter; struct mega_adapter_path adapter;
@ -64,6 +86,7 @@ static int driverQuery (int fd, uint16_t adap, void *data, uint32_t len, uint8_t
memset (data, 0, len); memset (data, 0, len);
adapter.fd = fd; adapter.fd = fd;
adapter.adapno = 0;
adapter.type = MEGA_ADAPTER_V34; adapter.type = MEGA_ADAPTER_V34;
if (doIoctl (&adapter, &u) < 0) if (doIoctl (&adapter, &u) < 0)
{ {
@ -82,11 +105,12 @@ static int oldCommand (struct mega_adapter_path *adapter, void *data, uint32_t l
memset (&u, 0, sizeof u); memset (&u, 0, sizeof u);
u.outlen = len; u.outlen = len;
u.ui.fcs.opcode = M_RD_IOCTL_CMD; u.ui.fcs.opcode = M_RD_IOCTL_CMD;
u.ui.fcs.adapno = MKADAP(adapter->adapno); u.ui.fcs.adapno = MKADAP(hostMap (adapter->adapno));
u.data = data; u.data = data;
m->cmd = cmd; m->cmd = cmd;
m->opcode = opcode; m->opcode = opcode;
m->subopcode = subopcode; m->subopcode = subopcode;
assert(UINT32_MAX > (uint32_t) data);
m->xferaddr = (uint32_t) data; m->xferaddr = (uint32_t) data;
if (data) if (data)
memset (data, 0, len); memset (data, 0, len);
@ -108,13 +132,14 @@ static int newCommand (struct mega_adapter_path *adapter, void *data, uint32_t l
memset (&u, 0, sizeof u); memset (&u, 0, sizeof u);
u.outlen = len; u.outlen = len;
u.ui.fcs.opcode = M_RD_IOCTL_CMD_NEW; u.ui.fcs.opcode = M_RD_IOCTL_CMD_NEW;
u.ui.fcs.adapno = MKADAP(adapter->adapno); u.ui.fcs.adapno = MKADAP(hostMap (adapter->adapno));
u.ui.fcs.buffer = data; u.ui.fcs.buffer = data;
u.ui.fcs.length = len; u.ui.fcs.length = len;
u.data = data; u.data = data;
m->cmd = cmd; m->cmd = cmd;
m->opcode = opcode; m->opcode = opcode;
m->subopcode = subopcode; m->subopcode = subopcode;
assert(UINT32_MAX > (uint32_t) data);
m->xferaddr = (uint32_t) data; m->xferaddr = (uint32_t) data;
if (data) if (data)
memset (data, 0, len); memset (data, 0, len);
@ -134,7 +159,7 @@ static int sasCommand (struct mega_adapter_path *adapter, void *data, uint32_t l
struct megasas_dcmd_frame *f = (struct megasas_dcmd_frame *) &u.frame; struct megasas_dcmd_frame *f = (struct megasas_dcmd_frame *) &u.frame;
memset (&u, 0, sizeof u); memset (&u, 0, sizeof u);
u.host_no = (u16) adapter->adapno; u.host_no = hostMap (adapter->adapno);
f->cmd = MFI_CMD_DCMD; f->cmd = MFI_CMD_DCMD;
f->flags = (u16) flags; f->flags = (u16) flags;
@ -147,6 +172,7 @@ static int sasCommand (struct mega_adapter_path *adapter, void *data, uint32_t l
u.sgl[0].iov_base = data; u.sgl[0].iov_base = data;
u.sgl[0].iov_len = len; u.sgl[0].iov_len = len;
f->sge_count = 1; f->sge_count = 1;
assert(UINT32_MAX > (uint32_t) data);
f->data_xfer_len = (u32) len; f->data_xfer_len = (u32) len;
f->sgl.sge32[0].phys_addr = (u32) data; f->sgl.sge32[0].phys_addr = (u32) data;
f->sgl.sge32[0].length = (u32) len; f->sgl.sge32[0].length = (u32) len;
@ -175,13 +201,15 @@ static int passthruCommand (struct mega_adapter_path *adapter, void *data, uint3
memset (&u, 0, sizeof u); memset (&u, 0, sizeof u);
u.outlen = len; u.outlen = len;
u.ui.fcs.opcode = M_RD_IOCTL_CMD; u.ui.fcs.opcode = M_RD_IOCTL_CMD;
u.ui.fcs.adapno = MKADAP(adapter->adapno); u.ui.fcs.adapno = MKADAP(hostMap (adapter->adapno));
u.data = data; u.data = data;
m->cmd = MBOXCMD_PASSTHRU; m->cmd = MBOXCMD_PASSTHRU;
assert(UINT32_MAX > (uint32_t) p);
m->xferaddr = (uint32_t) p; m->xferaddr = (uint32_t) p;
p->timeout = 3; p->timeout = 3;
p->ars = 1; p->ars = 1;
p->target = target; p->target = target;
assert(UINT32_MAX > (uint32_t) data);
p->dataxferaddr = (uint32_t) data; p->dataxferaddr = (uint32_t) data;
p->dataxferlen = len; p->dataxferlen = len;
p->scsistatus = 239; /* HMMM */ p->scsistatus = 239; /* HMMM */
@ -219,7 +247,7 @@ static int passthruCommand (struct mega_adapter_path *adapter, void *data, uint3
struct megasas_pthru_frame *f = (struct megasas_pthru_frame *) &u.frame; struct megasas_pthru_frame *f = (struct megasas_pthru_frame *) &u.frame;
memset (&u, 0, sizeof u); memset (&u, 0, sizeof u);
u.host_no = (u16) adapter->adapno; u.host_no = hostMap (adapter->adapno);
f->cmd = MFI_CMD_PD_SCSI_IO; f->cmd = MFI_CMD_PD_SCSI_IO;
f->target_id = target; f->target_id = target;
@ -235,6 +263,7 @@ static int passthruCommand (struct mega_adapter_path *adapter, void *data, uint3
u.sgl[0].iov_len = len; u.sgl[0].iov_len = len;
f->sge_count = 1; f->sge_count = 1;
assert(UINT32_MAX > (uint32_t) len);
f->data_xfer_len = (u32) len; f->data_xfer_len = (u32) len;
f->sgl.sge32[0].phys_addr = (u32) data; f->sgl.sge32[0].phys_addr = (u32) data;
f->sgl.sge32[0].length = (u32) len; f->sgl.sge32[0].length = (u32) len;
@ -386,7 +415,7 @@ int megaGetDriveErrorCount (struct mega_adapter_path *adapter, uint8_t target, s
int megaSasGetDeviceList (struct mega_adapter_path *adapter, struct mega_device_list_sas **data) int megaSasGetDeviceList (struct mega_adapter_path *adapter, struct mega_device_list_sas **data)
{ {
unsigned char buf[0x20]; unsigned char buf[sizeof(struct mega_device_list_sas)];
uint32_t len; uint32_t len;
if (sasCommand (adapter, buf, sizeof buf, 0x02010000, MFI_FRAME_DIR_READ, NULL, 0) < 0) if (sasCommand (adapter, buf, sizeof buf, 0x02010000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
@ -451,23 +480,55 @@ int megaSasGetBatteryInfo (struct mega_adapter_path *adapter, struct mega_batter
int megaGetDriverVersion (int fd, uint32_t *version) int megaGetDriverVersion (int fd, uint32_t *version)
{ {
return driverQuery (fd, 0, version, sizeof (*version), 'e'); return driverQuery (fd, version, sizeof (*version), 'e');
} }
int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas) int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas)
{ {
static struct mega_adapter_map realMap;
uint8_t k;
uint8_t count;
if (sas) if (sas)
{ {
uint8_t k; if (adapterMap == NULL)
for (k = 0; k < 16; ++k) {
if (megaSasAdapterPing (fd, k) < 0) struct mega_adapter_map fakeMap;
break;
*numAdapters = k; /* initialize fake map to 1-to-1 map */
return 0; for (k = 0; k < MEGA_MAX_ADAPTERS; ++k)
fakeMap.host[k] = k;
fakeMap.count = k;
adapterMap = &fakeMap;
/* ping all possible adapters to build real map */
count = 0;
for (k = 0; k < MEGA_MAX_ADAPTERS; ++k)
if (megaSasAdapterPing (fd, k) >= 0)
realMap.host[count++] = k;
realMap.count = count;
adapterMap = &realMap;
}
} }
else else
return driverQuery (fd, 0, numAdapters, sizeof (*numAdapters), 'm'); {
if (adapterMap == NULL)
{
if (driverQuery (fd, &count, sizeof (count), 'm') < 0)
return -1;
if (count > MEGA_MAX_ADAPTERS)
count = MEGA_MAX_ADAPTERS;
for (k = 0; k < count; ++k)
realMap.host[k] = k;
realMap.count = count;
adapterMap = &realMap;
}
}
*numAdapters = adapterMap->count;
return 0;
} }

@ -60,6 +60,10 @@ struct uioctl_t {
#pragma pack() #pragma pack()
/* Timestamps in the megaraid_sas event log are offset by this quantity. This is the epoch time of 2000-01-01T00:00:00 +0000. */
#define MEGA_SAS_TIME_OFFSET 0x386d4380
extern int megaErrno; extern int megaErrno;
extern int megaScsiDriveInquiry (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageCode, uint8_t evpd); extern int megaScsiDriveInquiry (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageCode, uint8_t evpd);
@ -80,7 +84,10 @@ extern int megaSasGetArrayConfig (struct mega_adapter_path *adapter, struct mega
extern int megaSasGetBatteryInfo (struct mega_adapter_path *adapter, struct mega_battery_info_sas *data); extern int megaSasGetBatteryInfo (struct mega_adapter_path *adapter, struct mega_battery_info_sas *data);
extern int megaGetDriverVersion (int fd, uint32_t *version); extern int megaGetDriverVersion (int fd, uint32_t *version);
/* You must call megaGetNumAdapters() before you issue any other inquiries, other than megaGetDriverVersion(). */
extern int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas); extern int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas);
extern int megaGetAdapterProductInfo (int fd, uint8_t adapno, mraid_pinfo_t *info); extern int megaGetAdapterProductInfo (int fd, uint8_t adapno, mraid_pinfo_t *info);
extern int megaSasGetAdapterProductInfo (int fd, uint8_t adapno, struct megasas_ctrl_info *info); extern int megaSasGetAdapterProductInfo (int fd, uint8_t adapno, struct megasas_ctrl_info *info);
extern int megaSasAdapterPing (int fd, uint8_t adapno); extern int megaSasAdapterPing (int fd, uint8_t adapno);

83
megasasctl.1 Normal file

@ -0,0 +1,83 @@
.\" Text automatically generated by txt2man
.TH megasasctl 1 "03 March 2024" ""
.SH NAME
megasasctl \- diagnostics on megaraid adapters and attached disks.
.SH SYNOPSIS
megasasctl [\fB-vest\fP] [\fB-H\fP] [\fB-l\fP log-page-nr] [\fB-T\fP long|short] [target \.\.\.]
.PP
Reports diagnostics on megaraid adapters and attached disks. 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. Target devices may be adapters,
(e.g. a0), enclosures (e.g. a0e0), or individual disks (e.g. a0e0s0). If
no target is specified, reports configuration and drive state on all
adapters. If a target matches a collection of disks, operations are
applied to all matching devices. Options are:
.TP
.B
\fB-v\fP
Increase program verbosity.
.TP
.B
\fB-e\fP
Dump read (0x03), write (0x02), and verify (0x05) error log
pages.
.TP
.B
\fB-s\fP
Dump self-test (0x10) log page.
.TP
.B
\fB-t\fP
Dump temperature (0x0d) log page.
.TP
.B
\fB-l\fP page
Dump the specified log page. Log page 0 documents the log pages
the device supports.
.TP
.B
\fB-p\fP
Do not report physical disks. Reports only adapters and logical
drives. Useful for concisely documenting adapter configuration.
.TP
.B
\fB-T\fP test
Initiate the background short or long self-test procedure. The
test may take up to an hour to complete, but does not inhibit
access to the device. The test may be monitored using the \fB-s\fP
option.
.TP
.B
\fB-H\fP
Perform an adapter health check. Inspects state of all logical
and physical drives and battery backup unit and reports problem
conditions. If all is well, generates no output. Useful in a
cron job.
.TP
.B
\fB-B\fP
When performing health check, do not treat battery problems as
failures.
.TP
.B
\fB-V\fP
Show version.
.PP
N.B. The background long self test is a useful tool for diagnosing
problems with individual disks. But be cautious with program usage.
"megasasctl \fB-T\fP long" with no targets will initiate a background long self
test on every drive on every adapter. This may not be what you want.
.PP
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. If, however, any
of the log page options is specified, only the designated log pages are
inspected.
.PP
This program requires the device file /dev/megaraid_sas_ioctl_node to be
present on the system. 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.

@ -63,7 +63,7 @@ Fixes for 64-bit systems.
enum state { UNTRACED, INBOUND, OUTBOUND }; enum state { UNTRACED, INBOUND, OUTBOUND };
void copyout (void *buf, size_t len, pid_t pid, uint32_t addr) static inline void copyout (void *buf, size_t len, pid_t pid, uint32_t addr)
{ {
off_t k; off_t k;
uint32_t *z = (uint32_t *) buf; uint32_t *z = (uint32_t *) buf;
@ -77,7 +77,7 @@ void copyout (void *buf, size_t len, pid_t pid, uint32_t addr)
} }
void copyin (void *buf, size_t len, pid_t pid, uint32_t addr) static inline void copyin (void *buf, size_t len, pid_t pid, uint32_t addr)
{ {
off_t k; off_t k;
uint32_t *z = (uint32_t *) buf; uint32_t *z = (uint32_t *) buf;

Some files were not shown because too many files have changed in this diff Show More