Only in mpt-status-1.1.4: contrib diff -ur mpt-status-1.1.3-ratz/doc/AUTHORS mpt-status-1.1.4/doc/AUTHORS --- mpt-status-1.1.3-ratz/doc/AUTHORS 2005-11-12 00:56:17.084082160 +0100 +++ mpt-status-1.1.4/doc/AUTHORS 2005-11-12 01:27:22.448181130 +0100 @@ -2,4 +2,4 @@ Matthew Braithwaite Additions (see Changelog): -Roberto Nibali, ratz +Roberto Nibali, ratz diff -ur mpt-status-1.1.3-ratz/doc/Changelog mpt-status-1.1.4/doc/Changelog --- mpt-status-1.1.3-ratz/doc/Changelog 2005-11-12 00:56:17.631978410 +0100 +++ mpt-status-1.1.4/doc/Changelog 2005-11-12 01:41:44.774788457 +0100 @@ -1,4 +1,41 @@ -2005-07-15, ratz [ratz@tac.ch]: +2005-11-11, ratz [ratz@drugphish.ch]: + o doc/DeveloperNotes + - Added information from the mpt(4) man page of OpenBSD + o mpt-status.h + - Fixed VERSION string + o mpt-status.c + - Merged patch by Thomas Richer to allow setting the ioc unit + - Added Copyright note + - Removed the modprobe call since this is braindead. Not all + people have mpt loaded as module. Making it easy to use does + not mean making it dumb. + - Rewrote the primitive parameter passing on command line to + more sophisticated GNU style option parsing. + - Added some more switches, check them out with --help + The --nietzsche_kills switch is only so I won't forget how + to use long options without short options. + - Reorganized include headers to have a legimit C code ;). + --> Check news://comp.std.c for some crazy stuff on C + - Style cleanup + - Function prototypes are static now, since we're using it only + in one context. + - Added the '-v' parameter which can be used after a Houston + problem to get some more output on the warnings. + - Added the '-q' flag to really quiet down things. + +2005-07-16, ratz [ratz@drugphish.ch]: + o Makefile + - Incorporated patch to auto-detect redhat, done by Matti + Hiljanen + o doc/INSTALL + - Removed RH specific entry, since RH is now auto-detected + o doc/THANKS + - Matti earned his stars ;) + o contrib/mpt-status.spec + - Added preliminary support for RPM building, work done by + Jean-Philippe Civade. + +2005-07-15, ratz [ratz@drugphish.ch]: * Version: 1.1.3 [released] o mpt-status.h - incorporated compile fixes for redhat based distros from @@ -28,7 +65,7 @@ - initial import: I consider them important, even though it's just a very simple tool ... so far ;) -2005-06-16, ratz [ratz@tac.ch]: +2005-06-16, ratz [ratz@drugphish.ch]: * Version: 1.1.3 o doc/Changelog - corrected date format @@ -40,7 +77,7 @@ - Lindent'ed - added comment regarding compilation warning -2005-06-09, ratz [ratz@tac.ch]: +2005-06-09, ratz [ratz@drugphish.ch]: * Version: 1.1.2 o mpt-status.c - removed some local headers and put into mpt-status.h Only in mpt-status-1.1.4/doc: DeveloperNotes diff -ur mpt-status-1.1.3-ratz/doc/INSTALL mpt-status-1.1.4/doc/INSTALL --- mpt-status-1.1.3-ratz/doc/INSTALL 2005-11-12 00:56:18.795758031 +0100 +++ mpt-status-1.1.4/doc/INSTALL 2005-11-11 23:51:20.498774638 +0100 @@ -8,11 +8,6 @@ make KERNEL_PATH=/path/to/your/kernel/src -if you happen to be on a Redhat based distro and you can't compile the biest, -try: - - make DFLAGS="-DREDHAT" - If this does not work, send me (Roberto Nibali) an email with the output and I try to fix it. You might also need to minor tweak the Makefile shipped with this package. diff -ur mpt-status-1.1.3-ratz/doc/README mpt-status-1.1.4/doc/README --- mpt-status-1.1.3-ratz/doc/README 2005-11-12 00:56:19.394644619 +0100 +++ mpt-status-1.1.4/doc/README 2005-11-12 02:12:51.114831830 +0100 @@ -1,28 +1,26 @@ Intro ----- -This is quite a modified version to the original mpt-status-1.0 package. I hope -to be able to merge efforts with the original author soon enough and to get in -contact with LSI for further debugging and development aid. - -I don't want to take credits for this work in any way, I just like this little -nifty tool to get widespread and a more professional touch so maybe distros can -include it as well. My motivation is towards CGL (carrier grade linux) -compliance and every little contribution towards this goal is a little step -towards a calm future for sysadmins. - -Yes, I know this document is not structured, nor is it finished. It's a start -though. +This is a heavily modified version to the original mpt-status-1.0 tool. +mpt-status is a query tool to access the running configuration of a (currently) +LSI 1030 RAID controller. Where can I get this -------------------- -Homepage of original version: http://www.red-bean.com/~mab/mpt-status.html Homepage of modified version: http://www.drugphish.ch/~ratz/mpt-status/ +Homepage of original version: http://www.red-bean.com/~mab/mpt-status.html + +The original version will not work on 2.6.x kernels and is also not maintained +anymore. The author has never replied to any of my emails, though, so it's only +an assumption. How can I compile, install or uninstall mpt-status -------------------------------------------------- -Read doc/INSTALL for further information on building mpt-status. +Read doc/INSTALL for further information on building mpt-status. Basically you +should be fine invoking + + make What does it do (Matt Braithwaite) @@ -103,22 +101,30 @@ to compile the stuff for 64bit architectures. The key is the -m64 switch in gcc. +NEW (1.1.4): + Also supported are various RedHat based distributions. I got word of + success from a Gentoo user and various Debian Sarge users. Time for people + to submit some specs and debs. + Directory structure ------------------- -./Makefile : Used to build the mpt-status binary -./doc/AUTHORS : This file lists the authors of the mpt-status code -./doc/Changelog : Keeps track of the changes in prosa -./doc/COPYING : The GNU v2 License copy -./doc/INSTALL : The installation documents -./doc/README : This document -./doc/THANKS : A small thank you endroit for the contributors -./doc/TODO : Stuff that needs to be done -./incl/config.h : Include file from pciutils -./incl/header.h : Include file from pciutils -./incl/pci.h : Include file from pciutils -./mpt-status.c : The mighty tool itself -./mpt-status.h : The main include file for mpt-status +./doc/AUTHORS : This file lists the authors of the mpt-status code +./doc/Changelog : Keeps track of the changes in prosa +./doc/COPYING : The GNU v2 License copy +./doc/INSTALL : The installation documents +./doc/README : This document +./doc/ReleaseNotes : The actual release notes, read them carefully +./doc/TODO : Stuff that needs to be done +./doc/THANKS : A small thank you endroit for the contributors +./doc/DeveloperNotes : Some information on the message API of mpt +./incl/config.h : Include file from pciutils +./incl/header.h : Include file from pciutils +./incl/pci.h : Include file from pciutils +./Makefile : Used to build the mpt-status binary +./mpt-status.c : The mighty tool itself +./mpt-status.h : The main include file for mpt-status +./contrib/mpt-status.spec --- +-- Roberto Nibali, ratz (ratz at drugphish dot ch) diff -ur mpt-status-1.1.3-ratz/doc/ReleaseNotes mpt-status-1.1.4/doc/ReleaseNotes --- mpt-status-1.1.3-ratz/doc/ReleaseNotes 2005-11-12 00:56:20.114508295 +0100 +++ mpt-status-1.1.4/doc/ReleaseNotes 2005-11-12 02:01:38.616474508 +0100 @@ -1,27 +1,45 @@ -Release Notes mpt-status 1.1.3 (2005-07-15) +Release Notes mpt-status 1.1.4 (2005-11-12) ============================== General Information ------------------- -This release is a compile fix release. Substantial work has been put into -getting this mess compiled on most distibutions and all reasonable kernels. -Thanks to Jean-Philippe Civade for the Redhat, Fedora input and Klaus Ade -Johnstad for granting me access to his hardware to test the code. +This release mainly brings you sort of a workaround for the annoying and much +reported mismatch output: -Please read the doc/Changelog for detailed information on the changes. + Version mismatch on pagetype 8, page number 0: expected 5, got 1 -For Redhat and Fedora based derivates you can try following compile command: +It's not exactly clear how to properly address this but the modus operandi is +to simply ignore it since mpt-status only accesses those pages read-only and +thus cannot harm your hardware configuration. - make DFLAGS="-DREDHAT" +The option parsing on command line has been completely reworked and you will +get a new overview by calling --help. -The rest of the world can stick to: +Thomas Richter sent in a patch to support the selection of different IOC units, +meaning controllers. Many thanks. - make +Please read the doc/Changelog for detailed information on the changes. Redhat and Fedora based derivates don't have to use the following line anymore + + make DFLAGS="-DREDHAT" + +since we have simple autodetection of those distros no in the Makefile. Note, +that this release was pre-tested by following fearless people: + + Darren Dittrich + Warren Howard + +Otherwise I have not been able to test it since our company has shipped all +remaining hardware based on the MPT SCSI controller. Upgrade ------- -There shouldn't be an issue with upgrading from the previous (1.1.2) version. +There shouldn't be an issue with upgrading from the previous (1.1.3) version. Note, however, that the command line options might be changed at any time of the development. This will be documented accordingly in the release notes, so your scripts using mpt-status will not break. + +With the addition of new parameters, notably the IOC unit, some cleanup has +been done regarding the output based on the parameters '-q' and '-v'. This means +that you should double check the output generated of the 1.1.3 version with the +released 1.1.4 version and add appropriate flags if it changed for you. diff -ur mpt-status-1.1.3-ratz/doc/THANKS mpt-status-1.1.4/doc/THANKS --- mpt-status-1.1.3-ratz/doc/THANKS 2005-11-12 00:56:20.464442025 +0100 +++ mpt-status-1.1.4/doc/THANKS 2005-11-12 01:32:13.606828583 +0100 @@ -2,7 +2,11 @@ specific order or preference, it's a silly little tool anyway ;). -Klaus Ade Johnstad: Offered me remote access to hardware to develop and test - mpt-status. -Jean-Philippe Civade: Various little fixes regarding Redhat based distros and - a small document contribution on kernel source building +Klaus Ade Johnstad: - Offered me remote access to hardware to develop and + test mpt-status. +Jean-Philippe Civade: - Various little fixes regarding Redhat based distros + and a small document contribution on kernel source + building + - Initial RPM spec +Matti Hiljanen: - Added Redhat auto-detection +Stefan Richter: - Patch to allow setting IOC unit. diff -ur mpt-status-1.1.3-ratz/doc/TODO mpt-status-1.1.4/doc/TODO --- mpt-status-1.1.3-ratz/doc/TODO 2005-11-12 00:56:19.759575511 +0100 +++ mpt-status-1.1.4/doc/TODO 2005-11-12 01:45:17.726414572 +0100 @@ -4,7 +4,6 @@ Ratz' ideas ----------- -o maybe switch to argp parsing (libc) for GNU style parameter passing o find out the remaining pieces of magic around the kernel structs and document them accordingly o get in contact with LSI for feedback and support diff -ur mpt-status-1.1.3-ratz/Makefile mpt-status-1.1.4/Makefile --- mpt-status-1.1.3-ratz/Makefile 2005-11-12 00:56:23.263911833 +0100 +++ mpt-status-1.1.4/Makefile 2005-11-11 23:51:25.039889042 +0100 @@ -6,6 +6,12 @@ CC := gcc INSTALL := install ARCH := $(shell uname -m) +REDHAT := $(shell if [ -e /etc/redhat-release ]; \ + then echo "true"; else echo "false"; fi) + +ifeq "${REDHAT}" "true" + DFLAGS := ${FLAGS} -DREDHAT +endif ifeq "${ARCH}" "sparc64" CFLAGS :=-I${KERNEL_PATH}/drivers/message/fusion -Iincl -Wall -W -O2 \ -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow diff -ur mpt-status-1.1.3-ratz/mpt-status.c mpt-status-1.1.4/mpt-status.c --- mpt-status-1.1.3-ratz/mpt-status.c 2005-11-12 00:56:23.853800107 +0100 +++ mpt-status-1.1.4/mpt-status.c 2005-11-12 01:44:36.078489983 +0100 @@ -2,6 +2,7 @@ This is a program to print the status of an LSI 1030 RAID controller. Copyright (C) 2004 CNET Networks, Inc. +Copyright (C) 2005 Roberto Nibali This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,19 +21,66 @@ */ -#include -#include -#include -#include +#include #include +#include #include #include -#include +#include +#include +#include + #include #include #include "mpt-status.h" +#define ARG_N_K 0x0001 + static int m = 0; +static int quiet_mode = 0; +static int verbose_mode = 0; +static int debug = 0; +static int debug_level = 0; + +static int sel; +static const struct option long_options[] = { + { "debug", optional_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, + { "set_id", required_argument, NULL, 'i' }, + { "nietzsche_kills", no_argument, &sel, ARG_N_K }, + { "quiet", no_argument, NULL, 'q' }, + { "print_status", no_argument, NULL, 's' }, + { "controller", required_argument, NULL, 'u' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { 0, no_argument, NULL, 0 }, +}; +static const char* const short_options = "dhi:qsu:vV"; +static const char* const usage_template = + "Usage: %s [ options ]\n" + "\n" + " -d, --debug [] Enable debugging and set level optionally\n" + " NOTE: This is not implemented yet\n" + " -h, --help Print this help information page\n" + " -i, --set_id Set id of primary device (check README)\n" + " -q, --quiet Do not display any warnings or boring info\n" + " -s, --print_status Only print the status information. This can\n" + " be used for easy scripting\n" + " -u, --controller Set the IOC unit (controller)\n" + " -v, --verbose Print verbose information, such as warnings\n" + " -V, --version Print version information\n" + "\n" + " You can write ``-o arg'' or ``--option arg'' or ``--option=arg''\n" + " Note that for some parameters only the long format is supported.\n" + "\n"; + +static void print_usage(const char *progname) { + printf(usage_template, progname); +} + +static void print_version(void) { + printf("Version: %s\n", VERSION); +} /* pagetype: pagewhich: @@ -57,13 +105,14 @@ \______ Array: Primary Disk */ -void *read_page(unsigned int pagetype, unsigned int pagewhich, - unsigned int pagenumber, int address, unsigned int version) -{ +static void *read_page(unsigned int pagetype, unsigned int pagewhich, + unsigned int pagenumber, int address, unsigned int version, + int ioc_unit) { char command[REALLYBIG]; char reply[REALLYBIG]; char sense[REALLYBIG]; char *in; + unsigned int warnings; struct mpt_ioctl_command *cmd; Config_t *config_request; ConfigReply_t *config_reply; @@ -73,6 +122,7 @@ exit(EXIT_FAILURE); } + warnings = 0; cmd = (struct mpt_ioctl_command *)command; config_request = (Config_t *) cmd->MF; config_reply = (ConfigReply_t *) reply; @@ -82,7 +132,7 @@ memset((void *)sense, 0, sizeof(sense)); memset((void *)in, 0, sizeof(in)); - cmd->hdr.iocnum = 0; /* XXX maybe you have more than one controller? */ + cmd->hdr.iocnum = ioc_unit; cmd->hdr.port = 0; cmd->hdr.maxDataSize = BIG; cmd->timeout = 10; @@ -110,11 +160,13 @@ } if (version != config_reply->Header.PageVersion) { - fprintf(stderr, - "Version mismatch on pagetype %u, page number %u: expected %d, got %d\n", - pagetype, pagenumber, version, - config_reply->Header.PageVersion); - exit(EXIT_FAILURE); + if (verbose_mode > 0) { + fprintf(stderr, + "Version mismatch on pagetype %u, page number %u: expected %d, got %d\n", + pagetype, pagenumber, version, + config_reply->Header.PageVersion); + } + warnings++; } config_request->Action = pagewhich; @@ -133,24 +185,18 @@ perror("MPI_FUNCTION_CONFIG (get page)"); exit(EXIT_FAILURE); } + if (warnings > 0 && quiet_mode == 0 && verbose_mode != 0) { + fprintf(stderr, "\nHouston, we have got a problem!" + " If you're interested in the warnings or you" + " were asked to send verbose information, add" + " the '-v' switch to your command line\n"); + } return in; } -void print_usage(const char *prog) -{ - printf("Usage:\n"); - printf("%s [-i ]\n", prog); - exit(EXIT_SUCCESS); -} - -void print_version(void) -{ - printf("Version: %s\n", VERSION); - exit(EXIT_SUCCESS); -} -void print_information(int id_of_primary_device, int print_status_only) -{ +static void print_information(int id_of_primary_device, int print_status_only, + int ioc_unit) { RaidVolumePage0_t *page; RaidPhysDiskPage0_t *phys; char *VolumeTypes[] = { "IS", "IME", "IM" }; @@ -165,7 +211,9 @@ page = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, MPI_CONFIG_ACTION_PAGE_READ_CURRENT, ioc, - id_of_primary_device, MPI_RAIDVOLPAGE0_PAGEVERSION); + id_of_primary_device, + MPI_RAIDVOLPAGE0_PAGEVERSION, + ioc_unit); if (1 == print_status_only) { printf("log_id %d", page->VolumeID); } else { @@ -173,9 +221,8 @@ page->VolumeIOC, page->VolumeID, page->VolumeType < - sizeof(VolumeTypes) ? VolumeTypes[page-> - VolumeType] : - "unknown", page->NumPhysDisks, + sizeof(VolumeTypes) ? VolumeTypes[page-> VolumeType] : + "unknown", page->NumPhysDisks, page->MaxLBA / (2 * 1024 * 1024)); printf(", state"); } @@ -228,7 +275,8 @@ MPI_CONFIG_ACTION_PAGE_READ_CURRENT, 0, page->PhysDisk[i].PhysDiskNum, - MPI_RAIDPHYSDISKPAGE0_PAGEVERSION); + MPI_RAIDPHYSDISKPAGE0_PAGEVERSION, + ioc_unit); memset(vendor, 0, sizeof(vendor)); memset(productid, 0, sizeof(productid)); memset(rev, 0, sizeof(rev)); @@ -290,15 +338,7 @@ } } -void do_init(void) -{ - if (0 != getuid()) { - fprintf(stderr, " You need to be root to run this program\n"); - exit(EXIT_FAILURE); - } - - system("/sbin/modprobe mptctl"); - +static void do_init(void) { m = open("/dev/mptctl", O_RDWR); if (-1 == m) { int save_errno = errno; @@ -312,36 +352,65 @@ fprintf(stderr, " Are you sure your controller is supported by mptlinux?\n"); } + fprintf(stderr, "Also make sure mptctl is loaded into the kernel\n"); exit(EXIT_FAILURE); } } -int main(int argc, char *argv[]) -{ - int ch; +int main(int argc, char *argv[]) { + int next_option; + int option_index; int print_status_only = PRINT_STATUS_ONLY; int id_of_primary_device = 0; + int ioc_unit = 0; + char *progname = argv[0]; - while ((ch = getopt(argc, argv, "i:hsv")) != EOF) { - switch (ch) { + do { + next_option = getopt_long(argc, argv, + short_options, long_options, &option_index); + switch (next_option) { + case 'd': + debug = 1; + debug_level = strtoul(optarg, NULL, 10); + break; case 'i': id_of_primary_device = strtoul(optarg, NULL, 10); break; case 'h': - print_usage(argv[0]); + print_usage(progname); + exit(EXIT_SUCCESS); + break; + case 'q': + quiet_mode = 1; break; case 's': print_status_only = 1; break; + case 'u': + ioc_unit = strtoul(optarg, NULL, 10); + break; case 'v': + verbose_mode = 1; + break; + case 'V': print_version(); + exit(EXIT_SUCCESS); + break; + case 0: + if (sel == ARG_N_K) { + printf("Nietzsche kills your mind\n"); + } + break; + case -1: + // Done with options break; default: + print_usage(progname); + exit(EXIT_SUCCESS); break; } - } - + } while (next_option != -1); do_init(); - print_information(id_of_primary_device, print_status_only); + print_information(id_of_primary_device, print_status_only, ioc_unit); exit(EXIT_SUCCESS); } diff -ur mpt-status-1.1.3-ratz/mpt-status.h mpt-status-1.1.4/mpt-status.h --- mpt-status-1.1.3-ratz/mpt-status.h 2005-11-12 00:56:24.897602403 +0100 +++ mpt-status-1.1.4/mpt-status.h 2005-11-12 00:46:36.300734049 +0100 @@ -13,16 +13,17 @@ #include "lsi/mpi_ioc.h" #include "lsi/mpi_cnfg.h" -#define VERSION "1.1.2" +#define VERSION "1.1.4" #define BIG 1024 #define REALLYBIG 10240 #define PRINT_STATUS_ONLY 0 -void *read_page(unsigned int, unsigned int, unsigned int, int, unsigned int); -void print_usage(const char *); -void print_version(void); -void print_information(int, int); -void do_init(void); +static void *read_page(unsigned int, unsigned int, unsigned int, int, + unsigned int, int); +static void print_usage(const char *); +static void print_version(void); +static void print_information(int, int, int); +static void do_init(void); #endif /* End of mpt-status.h */