From cfe47daa9ae77d5e777566b575f93b3080878d4c Mon Sep 17 00:00:00 2001 From: geos_one Date: Wed, 6 Aug 2025 16:36:24 +0200 Subject: [PATCH] Import Upstream version 0.4.5 --- .github/FUNDING.yml | 1 + .github/workflows/codeql-analysis.yml | 62 +++++ .gitignore | 4 + src/Makefile => Makefile | 20 +- src/adapter.c => adapter.c | 50 +++- src/adapter.h => adapter.h | 0 src/callinfo.c => callinfo.c | 0 src/callinfo.h => callinfo.h | 0 debian/changelog | 85 ------- debian/compat | 1 - debian/control | 27 -- debian/copyright | 45 ---- debian/dirs | 2 - debian/docs | 1 - debian/examples | 2 - debian/man/megactl/megactl.8 | 102 -------- debian/man/megactl/megasasctl.8 | 102 -------- debian/man/megatrace/megatrace.8 | 39 --- debian/megactl.install | 5 - debian/megactl.manpages | 1 - debian/megactl.preinst | 13 - debian/megatrace.install | 2 - debian/megatrace.manpages | 1 - .../000-No_absolute_pathes_in_examples.dpatch | 74 ------ .../001-Drop_obsolete_asm_user.h.dpatch | 29 --- .../patches/002-No_enclosure_support.dpatch | 75 ------ .../003-Fix_disk_enumeration_loop.dpatch | 64 ----- .../004-Fix_build_on_recent_distros.dpatch | 18 -- debian/patches/005-Makefile.dpatch | 33 --- debian/patches/006-gcc-fixes.dpatch | 53 ---- debian/patches/007-tracefix.dpatch | 239 ------------------ debian/patches/008-device_id.dpatch | 21 -- debian/patches/00list | 8 - debian/rules | 71 ------ debian/watch | 2 - debian/wrappers/create-devices-nodes | 32 --- debian/wrappers/megactl | 15 -- debian/wrappers/megasasctl | 15 -- debian/wrappers/megatrace | 11 - src/dumpbytes.c => dumpbytes.c | 0 src/dumpbytes.h => dumpbytes.h | 0 .../asm/semaphore.h | 0 .../megaraid | 0 .../megaraid-2.20.4.6-rh2/mbox_defs.h | 0 .../megaraid-2.20.4.6-rh2/mega_common.h | 0 .../megaraid-2.20.4.6-rh2/megaraid_ioctl.h | 0 .../megaraid-2.20.4.6-rh2/megaraid_mbox.c | 0 .../megaraid-2.20.4.6-rh2/megaraid_mbox.h | 0 .../megaraid-2.20.4.6-rh2/megaraid_mm.c | 0 .../megaraid-2.20.4.6-rh2/megaraid_mm.h | 0 .../megaraid-2.20.4.6-rh2/megaraid_sas.c | 0 .../megaraid-2.20.4.6-rh2/megaraid_sas.h | 0 src/logpage.c => logpage.c | 18 +- src/logpage.h => logpage.h | 0 src/mega.h => mega.h | 4 +- megactl.1 | 83 ++++++ src/megactl.c => megactl.c | 75 ++++-- megactl.metainfo.xml | 53 ++++ src/megaioctl.c => megaioctl.c | 91 +++++-- src/megaioctl.h => megaioctl.h | 7 + src/megaraid => megaraid | 0 src/megarpt => megarpt | 0 megasasctl.1 | 83 ++++++ src/megasasrpt => megasasrpt | 0 src/megatrace.c => megatrace.c | 4 +- src/modepage.c => modepage.c | 0 src/modepage.h => modepage.h | 0 src/ntrim.c => ntrim.c | 0 src/ntrim.h => ntrim.h | 0 {src/schily => schily}/allocax.h | 0 {src/schily => schily}/btorder.h | 0 {src/schily => schily}/btorder.h.endian | 0 {src/schily => schily}/ccomdefs.h | 0 {src/schily => schily}/deflts.h | 0 {src/schily => schily}/device.h | 0 {src/schily => schily}/dirdefs.h | 0 {src/schily => schily}/fctldefs.h | 0 {src/schily => schily}/getargs.h | 0 {src/schily => schily}/getcwd.h | 0 {src/schily => schily}/intcvt.h | 0 {src/schily => schily}/jmpdefs.h | 0 {src/schily => schily}/libport.h | 0 {src/schily => schily}/librmt.h | 0 {src/schily => schily}/maxpath.h | 0 {src/schily => schily}/mconfig.h | 0 {src/schily => schily}/mmapdefs.h | 0 {src/schily => schily}/mtiodefs.h | 0 {src/schily => schily}/patmatch.h | 0 {src/schily => schily}/prototyp.h | 0 {src/schily => schily}/rmtio.h | 0 {src/schily => schily}/scg/aspi-dos.h | 0 {src/schily => schily}/scg/aspi-win32.h | 0 {src/schily => schily}/scg/scgcmd.h | 0 {src/schily => schily}/scg/scgio.h | 0 {src/schily => schily}/scg/scgops.h | 0 {src/schily => schily}/scg/scsicdb.h | 0 {src/schily => schily}/scg/scsidefs.h | 0 {src/schily => schily}/scg/scsireg.h | 0 {src/schily => schily}/scg/scsisense.h | 0 {src/schily => schily}/scg/scsitransp.h | 0 {src/schily => schily}/scg/spti-wnt.h | 0 {src/schily => schily}/scg/srb_os2.h | 0 {src/schily => schily}/schily.h | 0 {src/schily => schily}/sigblk.h | 0 {src/schily => schily}/sigdefs.h | 0 {src/schily => schily}/standard.h | 0 {src/schily => schily}/statdefs.h | 0 {src/schily => schily}/stdxlib.h | 0 {src/schily => schily}/stkframe.h | 0 {src/schily => schily}/strdefs.h | 0 {src/schily => schily}/termcap.h | 0 {src/schily => schily}/timedefs.h | 0 {src/schily => schily}/ttydefs.h | 0 {src/schily => schily}/unixstd.h | 0 {src/schily => schily}/unls.h | 0 {src/schily => schily}/unls.h.utf8 | 0 {src/schily => schily}/utimdefs.h | 0 {src/schily => schily}/utypes.h | 0 {src/schily => schily}/vadefs.h | 0 {src/schily => schily}/waitdefs.h | 0 {src/schily => schily}/xconfig.h | 0 {src/schily => schily}/xmconfig.h | 0 122 files changed, 489 insertions(+), 1254 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .gitignore rename src/Makefile => Makefile (73%) rename src/adapter.c => adapter.c (92%) rename src/adapter.h => adapter.h (100%) rename src/callinfo.c => callinfo.c (100%) rename src/callinfo.h => callinfo.h (100%) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/docs delete mode 100644 debian/examples delete mode 100644 debian/man/megactl/megactl.8 delete mode 100644 debian/man/megactl/megasasctl.8 delete mode 100644 debian/man/megatrace/megatrace.8 delete mode 100644 debian/megactl.install delete mode 100644 debian/megactl.manpages delete mode 100644 debian/megactl.preinst delete mode 100644 debian/megatrace.install delete mode 100644 debian/megatrace.manpages delete mode 100755 debian/patches/000-No_absolute_pathes_in_examples.dpatch delete mode 100755 debian/patches/001-Drop_obsolete_asm_user.h.dpatch delete mode 100755 debian/patches/002-No_enclosure_support.dpatch delete mode 100755 debian/patches/003-Fix_disk_enumeration_loop.dpatch delete mode 100755 debian/patches/004-Fix_build_on_recent_distros.dpatch delete mode 100755 debian/patches/005-Makefile.dpatch delete mode 100755 debian/patches/006-gcc-fixes.dpatch delete mode 100755 debian/patches/007-tracefix.dpatch delete mode 100755 debian/patches/008-device_id.dpatch delete mode 100644 debian/patches/00list delete mode 100755 debian/rules delete mode 100644 debian/watch delete mode 100644 debian/wrappers/create-devices-nodes delete mode 100644 debian/wrappers/megactl delete mode 100644 debian/wrappers/megasasctl delete mode 100644 debian/wrappers/megatrace rename src/dumpbytes.c => dumpbytes.c (100%) rename src/dumpbytes.h => dumpbytes.h (100%) rename {src/includes-hack => includes-hack}/asm/semaphore.h (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/mbox_defs.h (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/mega_common.h (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_ioctl.h (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_mbox.c (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_mbox.h (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_mm.c (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_mm.h (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_sas.c (100%) rename {src/kernel-2.6.9-55.0.2.EL => kernel-2.6.9-55.0.2.EL}/megaraid-2.20.4.6-rh2/megaraid_sas.h (100%) rename src/logpage.c => logpage.c (96%) rename src/logpage.h => logpage.h (100%) rename src/mega.h => mega.h (99%) create mode 100644 megactl.1 rename src/megactl.c => megactl.c (91%) create mode 100644 megactl.metainfo.xml rename src/megaioctl.c => megaioctl.c (86%) rename src/megaioctl.h => megaioctl.h (92%) rename src/megaraid => megaraid (100%) rename src/megarpt => megarpt (100%) create mode 100644 megasasctl.1 rename src/megasasrpt => megasasrpt (100%) rename src/megatrace.c => megatrace.c (98%) rename src/modepage.c => modepage.c (100%) rename src/modepage.h => modepage.h (100%) rename src/ntrim.c => ntrim.c (100%) rename src/ntrim.h => ntrim.h (100%) rename {src/schily => schily}/allocax.h (100%) rename {src/schily => schily}/btorder.h (100%) rename {src/schily => schily}/btorder.h.endian (100%) rename {src/schily => schily}/ccomdefs.h (100%) rename {src/schily => schily}/deflts.h (100%) rename {src/schily => schily}/device.h (100%) rename {src/schily => schily}/dirdefs.h (100%) rename {src/schily => schily}/fctldefs.h (100%) rename {src/schily => schily}/getargs.h (100%) rename {src/schily => schily}/getcwd.h (100%) rename {src/schily => schily}/intcvt.h (100%) rename {src/schily => schily}/jmpdefs.h (100%) rename {src/schily => schily}/libport.h (100%) rename {src/schily => schily}/librmt.h (100%) rename {src/schily => schily}/maxpath.h (100%) rename {src/schily => schily}/mconfig.h (100%) rename {src/schily => schily}/mmapdefs.h (100%) rename {src/schily => schily}/mtiodefs.h (100%) rename {src/schily => schily}/patmatch.h (100%) rename {src/schily => schily}/prototyp.h (100%) rename {src/schily => schily}/rmtio.h (100%) rename {src/schily => schily}/scg/aspi-dos.h (100%) rename {src/schily => schily}/scg/aspi-win32.h (100%) rename {src/schily => schily}/scg/scgcmd.h (100%) rename {src/schily => schily}/scg/scgio.h (100%) rename {src/schily => schily}/scg/scgops.h (100%) rename {src/schily => schily}/scg/scsicdb.h (100%) rename {src/schily => schily}/scg/scsidefs.h (100%) rename {src/schily => schily}/scg/scsireg.h (100%) rename {src/schily => schily}/scg/scsisense.h (100%) rename {src/schily => schily}/scg/scsitransp.h (100%) rename {src/schily => schily}/scg/spti-wnt.h (100%) rename {src/schily => schily}/scg/srb_os2.h (100%) rename {src/schily => schily}/schily.h (100%) rename {src/schily => schily}/sigblk.h (100%) rename {src/schily => schily}/sigdefs.h (100%) rename {src/schily => schily}/standard.h (100%) rename {src/schily => schily}/statdefs.h (100%) rename {src/schily => schily}/stdxlib.h (100%) rename {src/schily => schily}/stkframe.h (100%) rename {src/schily => schily}/strdefs.h (100%) rename {src/schily => schily}/termcap.h (100%) rename {src/schily => schily}/timedefs.h (100%) rename {src/schily => schily}/ttydefs.h (100%) rename {src/schily => schily}/unixstd.h (100%) rename {src/schily => schily}/unls.h (100%) rename {src/schily => schily}/unls.h.utf8 (100%) rename {src/schily => schily}/utimdefs.h (100%) rename {src/schily => schily}/utypes.h (100%) rename {src/schily => schily}/vadefs.h (100%) rename {src/schily => schily}/waitdefs.h (100%) rename {src/schily => schily}/xconfig.h (100%) rename {src/schily => schily}/xmconfig.h (100%) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e7abe8b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: [https://www.buymeacoffee.com/namiltd] diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..3992571 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f7bcab --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.o +/megatrace +/megactl +/megasasctl diff --git a/src/Makefile b/Makefile similarity index 73% rename from src/Makefile rename to Makefile index 6bd185c..e0abeb8 100644 --- a/src/Makefile +++ b/Makefile @@ -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 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 +CPPFLAGS+= +CFLAGS+= -g -Wall $(INC) $(ARCH) $(CPPFLAGS) +LDFLAGS+= -g $(ARCH) +PROGRAMS= megactl megasasctl all: $(PROGRAMS) @@ -24,6 +30,12 @@ megasasctl.o: megactl.c %.o: Makefile.bak %.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: $(RM) $(PROGRAMS) *.o diff --git a/src/adapter.c b/adapter.c similarity index 92% rename from src/adapter.c rename to adapter.c index bd1b0cb..e3fd1e4 100644 --- a/src/adapter.c +++ b/adapter.c @@ -57,7 +57,8 @@ static void batteryStatus5 (struct adapter_config *a) a->battery.module_missing = !(a->q.v5.adapinfo.hw_present.bbu); 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.over_charged = b->over_charged != 0; switch (b->charger_status) @@ -69,7 +70,7 @@ static void batteryStatus5 (struct adapter_config *a) } a->battery.voltage = b->voltage; 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 *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->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); @@ -369,7 +373,7 @@ static char *getAdapterConfig2 (struct adapter_config *a) return "invalid number of logical drives"; 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)"; for (k = 0; k < a->num_channels; ++k) a->channel[k] = k; @@ -503,7 +507,7 @@ static char *getAdapterConfig3 (struct adapter_config *a) case 4: break; 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'; ntrim (a->product); 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"; 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)"; for (k = 0; k < a->num_channels; ++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 y = (int) *((uint8_t *) b); @@ -661,7 +665,7 @@ static char *getAdapterConfig5 (struct adapter_config *a) a->dram_size = pinfo->memory_size; 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'; ntrim (a->product); @@ -696,13 +700,37 @@ static char *getAdapterConfig5 (struct adapter_config *a) /* Didn't find this enclosure; extend the map */ ++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)"; a->channel[a->num_channels - 1] = device->device[k].enclosure; } 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)); diff --git a/src/adapter.h b/adapter.h similarity index 100% rename from src/adapter.h rename to adapter.h diff --git a/src/callinfo.c b/callinfo.c similarity index 100% rename from src/callinfo.c rename to callinfo.c diff --git a/src/callinfo.h b/callinfo.h similarity index 100% rename from src/callinfo.h rename to callinfo.h diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index a9fd9e9..0000000 --- a/debian/changelog +++ /dev/null @@ -1,85 +0,0 @@ -megactl (0.4.1.1-1) UNRELEASED; urgency=medium - - * Non-maintainer upload. - * megatrace in own package - - -- Mario Fetka Sat, 22 Apr 2017 16:52:02 +0200 - -megactl (0.4.1-6) unstable; urgency=medium - - * Update 003-Fix_disk_enumeration_loop patch (fix issues with PERC6e). - - -- Adam Cécile (Le_Vert) Sat, 25 Jan 2014 23:10:36 +0100 - -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) 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) Tue, 21 Jan 2014 22:54:42 +0100 - -megactl (0.4.1+svn20090725.r6-3) unstable; urgency=medium - - * New patch by Pat Suwalski to fix a bad disks - enumeration loop. - - -- Adam Cécile (Le_Vert) Tue, 21 Jan 2014 20:24:22 +0100 - -megactl (0.4.1+svn20090725.r6-2) unstable; urgency=medium - - * Integrate patch by Pat Suwalski to handle devices - without enclosure. - - -- Adam Cécile (Le_Vert) 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) 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) 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) 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) 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) 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) Thu, 21 Aug 2008 13:57:02 +0200 - -megactl (0.4.1-1) unstable; urgency=low - - * Initial release. - - -- Adam Cécile (Le_Vert) Wed, 26 Sep 2007 09:49:57 +0200 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7f8f011..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/debian/control b/debian/control deleted file mode 100644 index 1196e0c..0000000 --- a/debian/control +++ /dev/null @@ -1,27 +0,0 @@ -Source: megactl -Section: admin -Priority: optional -Maintainer: Adam Cécile (Le_Vert) -Build-Depends: debhelper (>= 4), dpatch, libc6-dev-i386 [amd64], gcc-multilib [amd64] | libc6-dev-i386 (<< 2.7) [amd64] -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. - -Package: megatrace -Architecture: i386 amd64 -Depends: ${shlibs:Depends}, ${misc:Depends}, libc6-i386 [amd64], megactl -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. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 4d4f1a2..0000000 --- a/debian/copyright +++ /dev/null @@ -1,45 +0,0 @@ -This package was debianized by Adam Cécile (Le_Vert) on -Wed, 26 Sep 2007 09:49:57 +0200. - -It was downloaded from http://sourceforge.net/projects/megactl - -Upstream Author: - - Jefferson Ogata - -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) - 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. diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index 81bb60c..0000000 --- a/debian/dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib/megactl -usr/sbin diff --git a/debian/docs b/debian/docs deleted file mode 100644 index e845566..0000000 --- a/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README diff --git a/debian/examples b/debian/examples deleted file mode 100644 index 141c692..0000000 --- a/debian/examples +++ /dev/null @@ -1,2 +0,0 @@ -src/megarpt -src/megasasrpt diff --git a/debian/man/megactl/megactl.8 b/debian/man/megactl/megactl.8 deleted file mode 100644 index 9e92d07..0000000 --- a/debian/man/megactl/megactl.8 +++ /dev/null @@ -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 -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) 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. diff --git a/debian/man/megactl/megasasctl.8 b/debian/man/megactl/megasasctl.8 deleted file mode 100644 index 434ea13..0000000 --- a/debian/man/megactl/megasasctl.8 +++ /dev/null @@ -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 -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) 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. diff --git a/debian/man/megatrace/megatrace.8 b/debian/man/megatrace/megatrace.8 deleted file mode 100644 index 45c41dc..0000000 --- a/debian/man/megatrace/megatrace.8 +++ /dev/null @@ -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 - -.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) 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. diff --git a/debian/megactl.install b/debian/megactl.install deleted file mode 100644 index 46bd7ad..0000000 --- a/debian/megactl.install +++ /dev/null @@ -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 diff --git a/debian/megactl.manpages b/debian/megactl.manpages deleted file mode 100644 index 45fd002..0000000 --- a/debian/megactl.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/man/megactl/* diff --git a/debian/megactl.preinst b/debian/megactl.preinst deleted file mode 100644 index b7c8231..0000000 --- a/debian/megactl.preinst +++ /dev/null @@ -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 diff --git a/debian/megatrace.install b/debian/megatrace.install deleted file mode 100644 index 19178ad..0000000 --- a/debian/megatrace.install +++ /dev/null @@ -1,2 +0,0 @@ -src/megatrace usr/lib/megactl -debian/wrappers/megatrace usr/sbin diff --git a/debian/megatrace.manpages b/debian/megatrace.manpages deleted file mode 100644 index a153fb4..0000000 --- a/debian/megatrace.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/man/megatrace/* diff --git a/debian/patches/000-No_absolute_pathes_in_examples.dpatch b/debian/patches/000-No_absolute_pathes_in_examples.dpatch deleted file mode 100755 index 2200bbc..0000000 --- a/debian/patches/000-No_absolute_pathes_in_examples.dpatch +++ /dev/null @@ -1,74 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 000-No_absolute_pathes_in_examples.dpatch -## by Adam Cécile (Le_Vert) -## -## 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 diff --git a/debian/patches/001-Drop_obsolete_asm_user.h.dpatch b/debian/patches/001-Drop_obsolete_asm_user.h.dpatch deleted file mode 100755 index eda81e2..0000000 --- a/debian/patches/001-Drop_obsolete_asm_user.h.dpatch +++ /dev/null @@ -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 - #include - #include --#include -+#include - #include - #include - #include -@@ -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); - diff --git a/debian/patches/002-No_enclosure_support.dpatch b/debian/patches/002-No_enclosure_support.dpatch deleted file mode 100755 index 630d912..0000000 --- a/debian/patches/002-No_enclosure_support.dpatch +++ /dev/null @@ -1,75 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 002-No_enclosure_support by Pat Suwalski -## -## 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 */ diff --git a/debian/patches/003-Fix_disk_enumeration_loop.dpatch b/debian/patches/003-Fix_disk_enumeration_loop.dpatch deleted file mode 100755 index 6ff80f3..0000000 --- a/debian/patches/003-Fix_disk_enumeration_loop.dpatch +++ /dev/null @@ -1,64 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 003-Fix_disk_enumeration_loop.dpatch by Pat Suwalski -## -## 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 - -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)); diff --git a/debian/patches/004-Fix_build_on_recent_distros.dpatch b/debian/patches/004-Fix_build_on_recent_distros.dpatch deleted file mode 100755 index 50491a7..0000000 --- a/debian/patches/004-Fix_build_on_recent_distros.dpatch +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 004-Fix_build_on_recent_distros.dpatch by Adam Cécile (Le_Vert) -## -## 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 }, diff --git a/debian/patches/005-Makefile.dpatch b/debian/patches/005-Makefile.dpatch deleted file mode 100755 index 196971f..0000000 --- a/debian/patches/005-Makefile.dpatch +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 004-Makefile.dpatch by Mario Fetka (geos_one) -## -## 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) - diff --git a/debian/patches/006-gcc-fixes.dpatch b/debian/patches/006-gcc-fixes.dpatch deleted file mode 100755 index 6d5c0e1..0000000 --- a/debian/patches/006-gcc-fixes.dpatch +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 004-gcc-fixes.dpatch by Mario Fetka (geos_one) -## -## 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 - - #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; diff --git a/debian/patches/007-tracefix.dpatch b/debian/patches/007-tracefix.dpatch deleted file mode 100755 index 20887e0..0000000 --- a/debian/patches/007-tracefix.dpatch +++ /dev/null @@ -1,239 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 004-tracefix.dpatch by Mario Fetka (geos_one) -## -## 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 -+ - #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; diff --git a/debian/patches/008-device_id.dpatch b/debian/patches/008-device_id.dpatch deleted file mode 100755 index 7a6074a..0000000 --- a/debian/patches/008-device_id.dpatch +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 008-device_id.dpatch by Mario Fetka (geos_one) -## -## DP: add device_id to output -## DP: thx. to gentoo devs - -@DPATCH@ ---- megactl/src/adapter.c.orig 2017-04-22 17:15:55.068000000 +0200 -+++ megactl/src/adapter.c 2017-04-22 17:17:17.624000000 +0200 -@@ -193,9 +193,9 @@ - d->id = info->slot; - - if (d->channel == DISK_NOENC) -- snprintf (d->name, sizeof (d->name), "%se*s%u", a->name, d->id); -+ snprintf (d->name, sizeof (d->name), "d%u%se*s%u", info->device_id, a->name, d->id); - else -- snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id); -+ snprintf (d->name, sizeof (d->name), "d%u%se%us%u", info->device_id, a->name, d->channel, d->id); - - d->inquiry = info->inquiry.inq; - strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1); diff --git a/debian/patches/00list b/debian/patches/00list deleted file mode 100644 index 7597b38..0000000 --- a/debian/patches/00list +++ /dev/null @@ -1,8 +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 -008-device_id.dpatch diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 2f85709..0000000 --- a/debian/rules +++ /dev/null @@ -1,71 +0,0 @@ -#!/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" - MT_MAKEOPTS="ARCH=-m32" -else - MY_MAKEOPTS="ARCH=-m64" - MT_MAKEOPTS="ARCH=-m32" -endif -# $(MAKE) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/ - -build: build-stamp -build-stamp: patch-stamp - dh_testdir - $(MAKE) $(MT_MAKEOPTS) 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 diff --git a/debian/watch b/debian/watch deleted file mode 100644 index eece36d..0000000 --- a/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=3 -http://sf.net/megactl/megactl-([0-9\.]+)\.tar\.gz diff --git a/debian/wrappers/create-devices-nodes b/debian/wrappers/create-devices-nodes deleted file mode 100644 index 6363f79..0000000 --- a/debian/wrappers/create-devices-nodes +++ /dev/null @@ -1,32 +0,0 @@ -# Author: Adam Cécile (Le_Vert) -# 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 -} diff --git a/debian/wrappers/megactl b/debian/wrappers/megactl deleted file mode 100644 index d028753..0000000 --- a/debian/wrappers/megactl +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Author: Adam Cécile (Le_Vert) -# 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 diff --git a/debian/wrappers/megasasctl b/debian/wrappers/megasasctl deleted file mode 100644 index 7b31042..0000000 --- a/debian/wrappers/megasasctl +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Author: Adam Cécile (Le_Vert) -# 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 diff --git a/debian/wrappers/megatrace b/debian/wrappers/megatrace deleted file mode 100644 index 4cf9729..0000000 --- a/debian/wrappers/megatrace +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Author: Adam Cécile (Le_Vert) -# License: Public domain - -. /usr/lib/megactl/create-devices-nodes - -create_node -create_node_sas - -/usr/lib/megactl/megatrace $@ diff --git a/src/dumpbytes.c b/dumpbytes.c similarity index 100% rename from src/dumpbytes.c rename to dumpbytes.c diff --git a/src/dumpbytes.h b/dumpbytes.h similarity index 100% rename from src/dumpbytes.h rename to dumpbytes.h diff --git a/src/includes-hack/asm/semaphore.h b/includes-hack/asm/semaphore.h similarity index 100% rename from src/includes-hack/asm/semaphore.h rename to includes-hack/asm/semaphore.h diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid b/kernel-2.6.9-55.0.2.EL/megaraid similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid rename to kernel-2.6.9-55.0.2.EL/megaraid diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mbox_defs.h b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mbox_defs.h similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mbox_defs.h rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mbox_defs.h diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mega_common.h b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mega_common.h similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mega_common.h rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mega_common.h diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_ioctl.h b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_ioctl.h similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_ioctl.h rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_ioctl.h diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.c b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.c similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.c rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.c diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.h b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.h similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.h rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.h diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.c b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.c similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.c rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.c diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.h b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.h similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.h rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.h diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.c b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.c similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.c rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.c diff --git a/src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.h b/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.h similarity index 100% rename from src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.h rename to kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.h diff --git a/src/logpage.c b/logpage.c similarity index 96% rename from src/logpage.c rename to logpage.c index 39a7ff1..193f269 100644 --- a/src/logpage.c +++ b/logpage.c @@ -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) ; - 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; } -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) { 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; } 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; diff --git a/src/logpage.h b/logpage.h similarity index 100% rename from src/logpage.h rename to logpage.h diff --git a/src/mega.h b/mega.h similarity index 99% rename from src/mega.h rename to mega.h index 51889b9..bd78a53 100644 --- a/src/mega.h +++ b/mega.h @@ -114,6 +114,8 @@ struct list_head { #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 { @@ -545,7 +547,7 @@ struct adapter_config 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 */ diff --git a/megactl.1 b/megactl.1 new file mode 100644 index 0000000..ecb1bcd --- /dev/null +++ b/megactl.1 @@ -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. diff --git a/src/megactl.c b/megactl.c similarity index 91% rename from src/megactl.c rename to megactl.c index 6976580..25ab3b7 100644 --- a/src/megactl.c +++ b/megactl.c @@ -43,6 +43,8 @@ Cleaner log page output. Fixes for 64-bit systems. Currently builds only with -m32. +Fetch TTY logs. + ********************************************************************/ #include "mega.h" @@ -61,6 +63,8 @@ Fixes for 64-bit systems. Currently builds only with -m32. #include #include #include +#include +#include #include @@ -72,17 +76,19 @@ Fixes for 64-bit systems. Currently builds only with -m32. #ifdef MEGA_SAS_CTL #define MEGA_DEVICE "/dev/megaraid_sas_ioctl_node" +#define MEGA_NAME "megaraid_sas_ioctl" #else #define MEGA_DEVICE "/dev/megadev0" +#define MEGA_NAME "megadev" #define MEGA_MIN_VERSION 0x118c #endif /* defined(MEGA_SAS_CTL) */ -static char *version = "0.4.1"; +static char *version = "0.4.3-hmage"; 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; va_list ap; @@ -205,14 +211,14 @@ static char *friendlySize (uint64_t b, char *unit) int k; 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; } -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; @@ -235,7 +241,7 @@ void describePhysicalDrive (FILE *f, struct physical_drive_info *d, int verbosit fprintf (f, " %8s %-16s", d->vendor, d->model); if (verbosity > 1) 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, " %-8s", state); 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; 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 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 6: blocks += r->blocks_per_disk * (r->span->num_disks - 2); break; } } 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, " %2ux%-2u", l->num_spans, l->span_size); fprintf (f, " %s", state); @@ -290,7 +297,7 @@ void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity) int j; 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) { 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) 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); if (verbosity > 0) @@ -359,8 +366,8 @@ int main (int argc, char **argv) { int k; int fd; + uint32_t driverVersion = 0; uint32_t numAdapters; - uint32_t driverVersion; int startSelfTest = -1; int healthCheck = 0; int checkBattery = 1; @@ -374,6 +381,11 @@ int main (int argc, char **argv) uint8_t readLog[LOG_PAGE_MAX] = { 0, }; int reportPhysical = 1; int showVersion = 0; + FILE *fp; + char *line = NULL; + int major; + size_t len = 0; + char lf; #ifdef MEGA_SAS_CTL int sas = 1; #else @@ -588,8 +600,33 @@ int main (int argc, char **argv) if ((fd = open (device, O_RDONLY)) < 0) { - fprintf (stderr, "unable to open device %s: %s\n", device, strerror (errno)); - return 1; + if ((fp = fopen ("/proc/devices", "r")) == NULL) + { + 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 @@ -608,7 +645,7 @@ int main (int argc, char **argv) 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; } @@ -806,9 +843,9 @@ int main (int argc, char **argv) if (d->state == PdStateHotspare) { if (x == 0) - fprintf (stdout, "hot spares :"); + fprintf (stdout, "hot spares :"); else if ((x % 8) == 0) - fprintf (stdout, " :"); + fprintf (stdout, " :"); fprintf (stdout, " %-8s", d->name); if (((++x) % 8) == 0) fprintf (stdout, "\n"); @@ -830,9 +867,9 @@ int main (int argc, char **argv) if ((!(d->span)) && (d->state != PdStateHotspare)) { if (x == 0) - fprintf (stdout, "unconfigured :"); + fprintf (stdout, "unconfigured:"); else if ((x % 8) == 0) - fprintf (stdout, " :"); + fprintf (stdout, " :"); fprintf (stdout, " %-8s", d->name); if (((++x) % 8) == 0) fprintf (stdout, "\n"); diff --git a/megactl.metainfo.xml b/megactl.metainfo.xml new file mode 100644 index 0000000..4c54e35 --- /dev/null +++ b/megactl.metainfo.xml @@ -0,0 +1,53 @@ + + + com.github.namiltd.megactl + CC0-1.0 + megactl + LSI Megaraid Control and Monitoring Tools + +

+ Provide tools to query hard drive and RAID volume status from + PERC2, PERC3, PERC4 and PERC5 adapters. +

+
+ https://github.com/namiltd/megactl/ + Mieczyslaw Nalewaj + + lkmodule:megaraid + lkmodule:megaraid_sas + pci:v00001000d000010E7sv* + pci:v00001000d000010E4sv* + pci:v00001000d000010E3sv* + pci:v00001000d000010E0sv* + pci:v00001000d000010E6sv* + pci:v00001000d000010E5sv* + pci:v00001000d000010E2sv* + pci:v00001000d000010E1sv* + pci:v00001000d0000001Csv* + pci:v00001000d0000001Bsv* + pci:v00001000d00000017sv* + pci:v00001000d00000016sv* + pci:v00001000d00000015sv* + pci:v00001000d00000014sv* + pci:v00001000d00000053sv* + pci:v00001000d00000052sv* + pci:v00001000d000000CFsv* + pci:v00001000d000000CEsv* + pci:v00001000d0000005Fsv* + pci:v00001000d0000005Dsv* + pci:v00001000d0000002Fsv* + pci:v00001000d0000005Bsv* + pci:v00001028d00000015sv* + pci:v00001000d00000413sv* + pci:v00001000d00000071sv* + pci:v00001000d00000073sv* + pci:v00001000d00000079sv* + pci:v00001000d00000078sv* + pci:v00001000d0000007Csv* + pci:v00001000d00000060sv* + pci:v00001000d00000411sv* + pci:v00008086d00001960sv* + pci:v0000101Ed00009060sv* + pci:v0000101Ed00009010sv* + +
diff --git a/src/megaioctl.c b/megaioctl.c similarity index 86% rename from src/megaioctl.c rename to megaioctl.c index d696049..8e9faaf 100644 --- a/src/megaioctl.c +++ b/megaioctl.c @@ -25,6 +25,7 @@ /* Don't include */ +#include #include #include #include @@ -32,9 +33,30 @@ #include +/* 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; +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) { 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 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); adapter.fd = fd; + adapter.adapno = 0; adapter.type = MEGA_ADAPTER_V34; 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); u.outlen = len; 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; m->cmd = cmd; m->opcode = opcode; m->subopcode = subopcode; + assert(UINT32_MAX > (uint32_t) data); m->xferaddr = (uint32_t) data; if (data) 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); u.outlen = len; 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.length = len; u.data = data; m->cmd = cmd; m->opcode = opcode; m->subopcode = subopcode; + assert(UINT32_MAX > (uint32_t) data); m->xferaddr = (uint32_t) data; if (data) 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; memset (&u, 0, sizeof u); - u.host_no = (u16) adapter->adapno; + u.host_no = hostMap (adapter->adapno); f->cmd = MFI_CMD_DCMD; 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_len = len; f->sge_count = 1; + assert(UINT32_MAX > (uint32_t) data); f->data_xfer_len = (u32) len; f->sgl.sge32[0].phys_addr = (u32) data; 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); u.outlen = len; 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; m->cmd = MBOXCMD_PASSTHRU; + assert(UINT32_MAX > (uint32_t) p); m->xferaddr = (uint32_t) p; p->timeout = 3; p->ars = 1; p->target = target; + assert(UINT32_MAX > (uint32_t) data); p->dataxferaddr = (uint32_t) data; p->dataxferlen = len; 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; 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->target_id = target; @@ -235,6 +263,7 @@ static int passthruCommand (struct mega_adapter_path *adapter, void *data, uint3 u.sgl[0].iov_len = len; f->sge_count = 1; + assert(UINT32_MAX > (uint32_t) len); f->data_xfer_len = (u32) len; f->sgl.sge32[0].phys_addr = (u32) data; 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) { - unsigned char buf[0x20]; + unsigned char buf[sizeof(struct mega_device_list_sas)]; uint32_t len; 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) { - return driverQuery (fd, 0, version, sizeof (*version), 'e'); + return driverQuery (fd, version, sizeof (*version), 'e'); } int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas) { + static struct mega_adapter_map realMap; + uint8_t k; + uint8_t count; + if (sas) { - uint8_t k; - for (k = 0; k < 16; ++k) - if (megaSasAdapterPing (fd, k) < 0) - break; - *numAdapters = k; - return 0; + if (adapterMap == NULL) + { + struct mega_adapter_map fakeMap; + + /* initialize fake map to 1-to-1 map */ + 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 - 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; } diff --git a/src/megaioctl.h b/megaioctl.h similarity index 92% rename from src/megaioctl.h rename to megaioctl.h index 37fd31f..1e90b3e 100644 --- a/src/megaioctl.h +++ b/megaioctl.h @@ -60,6 +60,10 @@ struct uioctl_t { #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 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 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 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 megaSasAdapterPing (int fd, uint8_t adapno); diff --git a/src/megaraid b/megaraid similarity index 100% rename from src/megaraid rename to megaraid diff --git a/src/megarpt b/megarpt similarity index 100% rename from src/megarpt rename to megarpt diff --git a/megasasctl.1 b/megasasctl.1 new file mode 100644 index 0000000..181db1f --- /dev/null +++ b/megasasctl.1 @@ -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. diff --git a/src/megasasrpt b/megasasrpt similarity index 100% rename from src/megasasrpt rename to megasasrpt diff --git a/src/megatrace.c b/megatrace.c similarity index 98% rename from src/megatrace.c rename to megatrace.c index b4cfd0a..4ee12ac 100644 --- a/src/megatrace.c +++ b/megatrace.c @@ -63,7 +63,7 @@ Fixes for 64-bit systems. 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; 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; uint32_t *z = (uint32_t *) buf; diff --git a/src/modepage.c b/modepage.c similarity index 100% rename from src/modepage.c rename to modepage.c diff --git a/src/modepage.h b/modepage.h similarity index 100% rename from src/modepage.h rename to modepage.h diff --git a/src/ntrim.c b/ntrim.c similarity index 100% rename from src/ntrim.c rename to ntrim.c diff --git a/src/ntrim.h b/ntrim.h similarity index 100% rename from src/ntrim.h rename to ntrim.h diff --git a/src/schily/allocax.h b/schily/allocax.h similarity index 100% rename from src/schily/allocax.h rename to schily/allocax.h diff --git a/src/schily/btorder.h b/schily/btorder.h similarity index 100% rename from src/schily/btorder.h rename to schily/btorder.h diff --git a/src/schily/btorder.h.endian b/schily/btorder.h.endian similarity index 100% rename from src/schily/btorder.h.endian rename to schily/btorder.h.endian diff --git a/src/schily/ccomdefs.h b/schily/ccomdefs.h similarity index 100% rename from src/schily/ccomdefs.h rename to schily/ccomdefs.h diff --git a/src/schily/deflts.h b/schily/deflts.h similarity index 100% rename from src/schily/deflts.h rename to schily/deflts.h diff --git a/src/schily/device.h b/schily/device.h similarity index 100% rename from src/schily/device.h rename to schily/device.h diff --git a/src/schily/dirdefs.h b/schily/dirdefs.h similarity index 100% rename from src/schily/dirdefs.h rename to schily/dirdefs.h diff --git a/src/schily/fctldefs.h b/schily/fctldefs.h similarity index 100% rename from src/schily/fctldefs.h rename to schily/fctldefs.h diff --git a/src/schily/getargs.h b/schily/getargs.h similarity index 100% rename from src/schily/getargs.h rename to schily/getargs.h diff --git a/src/schily/getcwd.h b/schily/getcwd.h similarity index 100% rename from src/schily/getcwd.h rename to schily/getcwd.h diff --git a/src/schily/intcvt.h b/schily/intcvt.h similarity index 100% rename from src/schily/intcvt.h rename to schily/intcvt.h diff --git a/src/schily/jmpdefs.h b/schily/jmpdefs.h similarity index 100% rename from src/schily/jmpdefs.h rename to schily/jmpdefs.h diff --git a/src/schily/libport.h b/schily/libport.h similarity index 100% rename from src/schily/libport.h rename to schily/libport.h diff --git a/src/schily/librmt.h b/schily/librmt.h similarity index 100% rename from src/schily/librmt.h rename to schily/librmt.h diff --git a/src/schily/maxpath.h b/schily/maxpath.h similarity index 100% rename from src/schily/maxpath.h rename to schily/maxpath.h diff --git a/src/schily/mconfig.h b/schily/mconfig.h similarity index 100% rename from src/schily/mconfig.h rename to schily/mconfig.h diff --git a/src/schily/mmapdefs.h b/schily/mmapdefs.h similarity index 100% rename from src/schily/mmapdefs.h rename to schily/mmapdefs.h diff --git a/src/schily/mtiodefs.h b/schily/mtiodefs.h similarity index 100% rename from src/schily/mtiodefs.h rename to schily/mtiodefs.h diff --git a/src/schily/patmatch.h b/schily/patmatch.h similarity index 100% rename from src/schily/patmatch.h rename to schily/patmatch.h diff --git a/src/schily/prototyp.h b/schily/prototyp.h similarity index 100% rename from src/schily/prototyp.h rename to schily/prototyp.h diff --git a/src/schily/rmtio.h b/schily/rmtio.h similarity index 100% rename from src/schily/rmtio.h rename to schily/rmtio.h diff --git a/src/schily/scg/aspi-dos.h b/schily/scg/aspi-dos.h similarity index 100% rename from src/schily/scg/aspi-dos.h rename to schily/scg/aspi-dos.h diff --git a/src/schily/scg/aspi-win32.h b/schily/scg/aspi-win32.h similarity index 100% rename from src/schily/scg/aspi-win32.h rename to schily/scg/aspi-win32.h diff --git a/src/schily/scg/scgcmd.h b/schily/scg/scgcmd.h similarity index 100% rename from src/schily/scg/scgcmd.h rename to schily/scg/scgcmd.h diff --git a/src/schily/scg/scgio.h b/schily/scg/scgio.h similarity index 100% rename from src/schily/scg/scgio.h rename to schily/scg/scgio.h diff --git a/src/schily/scg/scgops.h b/schily/scg/scgops.h similarity index 100% rename from src/schily/scg/scgops.h rename to schily/scg/scgops.h diff --git a/src/schily/scg/scsicdb.h b/schily/scg/scsicdb.h similarity index 100% rename from src/schily/scg/scsicdb.h rename to schily/scg/scsicdb.h diff --git a/src/schily/scg/scsidefs.h b/schily/scg/scsidefs.h similarity index 100% rename from src/schily/scg/scsidefs.h rename to schily/scg/scsidefs.h diff --git a/src/schily/scg/scsireg.h b/schily/scg/scsireg.h similarity index 100% rename from src/schily/scg/scsireg.h rename to schily/scg/scsireg.h diff --git a/src/schily/scg/scsisense.h b/schily/scg/scsisense.h similarity index 100% rename from src/schily/scg/scsisense.h rename to schily/scg/scsisense.h diff --git a/src/schily/scg/scsitransp.h b/schily/scg/scsitransp.h similarity index 100% rename from src/schily/scg/scsitransp.h rename to schily/scg/scsitransp.h diff --git a/src/schily/scg/spti-wnt.h b/schily/scg/spti-wnt.h similarity index 100% rename from src/schily/scg/spti-wnt.h rename to schily/scg/spti-wnt.h diff --git a/src/schily/scg/srb_os2.h b/schily/scg/srb_os2.h similarity index 100% rename from src/schily/scg/srb_os2.h rename to schily/scg/srb_os2.h diff --git a/src/schily/schily.h b/schily/schily.h similarity index 100% rename from src/schily/schily.h rename to schily/schily.h diff --git a/src/schily/sigblk.h b/schily/sigblk.h similarity index 100% rename from src/schily/sigblk.h rename to schily/sigblk.h diff --git a/src/schily/sigdefs.h b/schily/sigdefs.h similarity index 100% rename from src/schily/sigdefs.h rename to schily/sigdefs.h diff --git a/src/schily/standard.h b/schily/standard.h similarity index 100% rename from src/schily/standard.h rename to schily/standard.h diff --git a/src/schily/statdefs.h b/schily/statdefs.h similarity index 100% rename from src/schily/statdefs.h rename to schily/statdefs.h diff --git a/src/schily/stdxlib.h b/schily/stdxlib.h similarity index 100% rename from src/schily/stdxlib.h rename to schily/stdxlib.h diff --git a/src/schily/stkframe.h b/schily/stkframe.h similarity index 100% rename from src/schily/stkframe.h rename to schily/stkframe.h diff --git a/src/schily/strdefs.h b/schily/strdefs.h similarity index 100% rename from src/schily/strdefs.h rename to schily/strdefs.h diff --git a/src/schily/termcap.h b/schily/termcap.h similarity index 100% rename from src/schily/termcap.h rename to schily/termcap.h diff --git a/src/schily/timedefs.h b/schily/timedefs.h similarity index 100% rename from src/schily/timedefs.h rename to schily/timedefs.h diff --git a/src/schily/ttydefs.h b/schily/ttydefs.h similarity index 100% rename from src/schily/ttydefs.h rename to schily/ttydefs.h diff --git a/src/schily/unixstd.h b/schily/unixstd.h similarity index 100% rename from src/schily/unixstd.h rename to schily/unixstd.h diff --git a/src/schily/unls.h b/schily/unls.h similarity index 100% rename from src/schily/unls.h rename to schily/unls.h diff --git a/src/schily/unls.h.utf8 b/schily/unls.h.utf8 similarity index 100% rename from src/schily/unls.h.utf8 rename to schily/unls.h.utf8 diff --git a/src/schily/utimdefs.h b/schily/utimdefs.h similarity index 100% rename from src/schily/utimdefs.h rename to schily/utimdefs.h diff --git a/src/schily/utypes.h b/schily/utypes.h similarity index 100% rename from src/schily/utypes.h rename to schily/utypes.h diff --git a/src/schily/vadefs.h b/schily/vadefs.h similarity index 100% rename from src/schily/vadefs.h rename to schily/vadefs.h diff --git a/src/schily/waitdefs.h b/schily/waitdefs.h similarity index 100% rename from src/schily/waitdefs.h rename to schily/waitdefs.h diff --git a/src/schily/xconfig.h b/schily/xconfig.h similarity index 100% rename from src/schily/xconfig.h rename to schily/xconfig.h diff --git a/src/schily/xmconfig.h b/schily/xmconfig.h similarity index 100% rename from src/schily/xmconfig.h rename to schily/xmconfig.h