diff -Naur mpt-status-1.1.2-ratz/Makefile mpt-status-1.1.3-ratz/Makefile --- mpt-status-1.1.2-ratz/Makefile 2005-07-14 23:16:27.000000000 -0700 +++ mpt-status-1.1.3-ratz/Makefile 2005-07-15 01:00:33.000000000 -0700 @@ -1,21 +1,29 @@ KERNEL_PATH := /usr/src/linux PREFIX := /usr -CFLAGS :=-I${KERNEL_PATH}/drivers/message/fusion -Iincl -W -Wall -O2 +DFLAGS := LDFLAGS := -s -static PROG := mpt-status CC := gcc +INSTALL := install +ARCH := $(shell uname -m) +ifeq "${ARCH}" "sparc64" + CFLAGS :=-I${KERNEL_PATH}/drivers/message/fusion -Iincl -Wall -W -O2 \ + -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow +else + CFLAGS :=-I${KERNEL_PATH}/drivers/message/fusion -Iincl -Wall -W -O2 +endif ${PROG}: ${PROG}.c ${PROG}.h - ${CC} ${CFLAGS} -o $@ $< ${LDFLAGS} + ${CC} ${DFLAGS} ${CFLAGS} -o $@ $< ${LDFLAGS} install: ${PROG} - install -o root -g root -m 0500 ${PREFIX}/sbin + ${INSTALL} -o root -g root -m 0500 $< ${PREFIX}/sbin -uninstall: ${PREFIX}/sbin/${PROG} - rm -f $< +uninstall: + \rm -f ${PREFIX}/sbin/${PROG} clean: - rm -f ${PROG} + \rm -f ${PROG} distclean: clean diff -Naur mpt-status-1.1.2-ratz/doc/Changelog mpt-status-1.1.3-ratz/doc/Changelog --- mpt-status-1.1.2-ratz/doc/Changelog 2005-06-11 07:55:51.000000000 -0700 +++ mpt-status-1.1.3-ratz/doc/Changelog 2005-07-15 01:04:14.000000000 -0700 @@ -1,4 +1,47 @@ -2005-09-06, ratz [ratz@tac.ch]: +2005-07-15, ratz [ratz@tac.ch]: + * Version: 1.1.3 [released] + o mpt-status.h + - incorporated compile fixes for redhat based distros from + Jean-Philippe Civade. Added the REDHAT define because only + redhat distros seem to expose the undefined __user and + __kernel problem. The impact on the correct ioctl passing + is unknown. I should sanitize the LSI related headers and + create user space headers. It's not like they change their + API like their underwear. + o Makefile + - added DFLAGS for redhat parameter passing + - fixed install target, bug found by Jean-Philippe Civade + - fixed uninstall target + - added preliminary support for compiling on 64bit platforms. + Tested only on sparc64. + o doc/README + - proper split between README and INSTALL + o doc/INSTALL + - added redhat related compilation instructions + - added "howto install redhat kernel sources rpm" document + written by Jean-Philippe Civade. + - explained the install and uninstall process + o doc/THANKS + - initial import: this is to thank all the people contributing + to this software. + o doc/ReleaseNotes + - initial import: I consider them important, even though it's + just a very simple tool ... so far ;) + +2005-06-16, ratz [ratz@tac.ch]: + * Version: 1.1.3 + o doc/Changelog + - corrected date format + o mpt-status.h + - added for better 2.6.x compilation + support + - Lindent'ed + o mpt-status.c + - Lindent'ed + - added comment regarding compilation warning + +2005-06-09, ratz [ratz@tac.ch]: + * Version: 1.1.2 o mpt-status.c - removed some local headers and put into mpt-status.h o mpt-status.h @@ -8,6 +51,7 @@ command, so no more editing is needed. Use as follows: make KERNEL_PATH=/path/to/kernel/source + - introduced PREFIX which is a pseudo prefix semantics as seen with autoconf tools for install and uninstall targets - added install and uninstall targets. @@ -17,7 +61,8 @@ o doc/INSTALL - added to shortly document the installation procedure -2005-19-05, ratz [ratz@tac.ch]: +2005-05-19, ratz [ratz@tac.ch]: + * Version: 1.1.1 o incl - created directory and moved pci-utils related header files o Makefile @@ -32,7 +77,8 @@ o AUTHORS - created and added my name ;). -2005-18-05, ratz [ratz@tac.ch]: +2005-05-18, ratz [ratz@tac.ch]: + * Version: 1.1.0 o mpt-status.c - impoved output handling - documented scsi id issue for address parameter in read_page() diff -Naur mpt-status-1.1.2-ratz/doc/INSTALL mpt-status-1.1.3-ratz/doc/INSTALL --- mpt-status-1.1.2-ratz/doc/INSTALL 2005-06-11 07:55:51.000000000 -0700 +++ mpt-status-1.1.3-ratz/doc/INSTALL 2005-07-15 00:28:50.000000000 -0700 @@ -1,15 +1,78 @@ -How can I compile it --------------------- +How can I compile mpt-status +---------------------------- Simply go with + make + +and if your kernel sources are not located at /usr/src/linux, try + 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. As long as I'm developing the kernel path should be set by you as it -will most probably not be /usr/src/linux per default. I will change this once -I've resolved some linking issues. +package. + + +How can I install mpt-status +---------------------------- +Simply go with (as user root) + + make install + +This will install the mpt-status binary into /usr/sbin. If you need another +path, you can prefix the installation path by setting PREFIX like follows: + + make PREFIX=/my/prefix/path + +To check if the mpt-status binary is installed into the correct path, invoke + + make -n install + +and carefully check the output. + + +How can I uninstall mpt-status +------------------------------ +Simply go with (as user root) + + make uninstall + +If you previously installed mpt-status into a prefixed directory you also have +to provide this prefix to the uninstall target, like so: + + make PREFIX=/my/prefix/path uninstall + +Since this is only one simple binary, the uninstall target is almost ridiculous +so for real hardcore hackers, you might also use ... rm: + + \rm -f /path/to/mpt-status + +or if you so wish: + + make -n uninstall | sh + + +If you don't have the kernel sources package installed (Redhat based info) +-------------------------------------------------------------------------- +This applies to FC3/FC4 and RH ES4 (*). + +1. Do "up2date --get-source kernel" +2. Kernel src rpm is now in /var/spool/up2date. Install it with + "rpm -Uvh /var/spool/up2date/kernel-.src.rpm" +3. Do "cd /usr/src/redhat/SPECS/" +4. Do "rpmbuild -bp --target=i686 kernel-2.6.spec" +5. Last, you can move the source in the /usr/src/redhat/BUILD/kernel- + directory to the /usr/src tree; while not strictly necessary, we suggest that + you do this to match the generally-available documentation. +6. cd /usr/src/redhat/BUILD/kernel- /usr/src/ +7. mv linux- /usr/src/ +8. cd /usr/src +9. ln -s ./linux- linux -So for now you should most probably be fine with: +[* http://fedora.redhat.com/docs/release-notes/fc4/errata/#sn-kernel] - make KERNEL_PATH=/usr/src/linux diff -Naur mpt-status-1.1.2-ratz/doc/README mpt-status-1.1.3-ratz/doc/README --- mpt-status-1.1.2-ratz/doc/README 2005-06-11 07:55:51.000000000 -0700 +++ mpt-status-1.1.3-ratz/doc/README 2005-07-15 01:03:28.000000000 -0700 @@ -20,17 +20,9 @@ Homepage of modified version: http://www.drugphish.ch/~ratz/mpt-status/ -How can I compile it --------------------- -Simply go with - - make KERNEL_PATH=/path/to/your/kernel/src - -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. As long as I'm developing the kernel path should be set by you as it -will most probably not be /usr/src/linux per default. I will change this once -I've resolved some linking issues. +How can I compile, install or uninstall mpt-status +-------------------------------------------------- +Read doc/INSTALL for further information on building mpt-status. What does it do (Matt Braithwaite) @@ -106,19 +98,27 @@ have the kernel includes in your buildroot. Static and dynamic linking is possible. +NEW: It also compiles on all Redhat derivates to my avail. And preliminary + support for ultra-sparc has been added. It's only so I don't forget how + to compile the stuff for 64bit architectures. The key is the -m64 switch + in gcc. + Directory structure ------------------- -./Makefile -./mpt-status.c -./incl/config.h -./incl/header.h -./incl/pci.h -./doc/Changelog -./doc/AUTHORS -./doc/COPYING -./doc/TODO -./README +./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 -- Roberto Nibali, ratz (ratz at drugphish dot ch) diff -Naur mpt-status-1.1.2-ratz/doc/ReleaseNotes mpt-status-1.1.3-ratz/doc/ReleaseNotes --- mpt-status-1.1.2-ratz/doc/ReleaseNotes 1969-12-31 16:00:00.000000000 -0800 +++ mpt-status-1.1.3-ratz/doc/ReleaseNotes 2005-07-15 01:02:19.000000000 -0700 @@ -0,0 +1,27 @@ +Release Notes mpt-status 1.1.3 (2005-07-15) +============================== + +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. + +Please read the doc/Changelog for detailed information on the changes. + +For Redhat and Fedora based derivates you can try following compile command: + + make DFLAGS="-DREDHAT" + +The rest of the world can stick to: + + make + + +Upgrade +------- +There shouldn't be an issue with upgrading from the previous (1.1.2) 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. diff -Naur mpt-status-1.1.2-ratz/doc/THANKS mpt-status-1.1.3-ratz/doc/THANKS --- mpt-status-1.1.2-ratz/doc/THANKS 1969-12-31 16:00:00.000000000 -0800 +++ mpt-status-1.1.3-ratz/doc/THANKS 2005-07-15 00:23:20.000000000 -0700 @@ -0,0 +1,8 @@ +This file is to thank all the contributors of this software. There is no +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 diff -Naur mpt-status-1.1.2-ratz/doc/TODO mpt-status-1.1.3-ratz/doc/TODO --- mpt-status-1.1.2-ratz/doc/TODO 2005-06-11 07:55:51.000000000 -0700 +++ mpt-status-1.1.3-ratz/doc/TODO 2005-07-15 00:17:51.000000000 -0700 @@ -1,7 +1,19 @@ +This file is a wishlist compiled out of various people's ideas. It should +eventually be prioritized into "important, normal, nice to have". + + +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 o support for spare disk status output -o rewrite Makefile to proper support packaging and specifying CFLAGS o restructure and cleanup code (it's a mess and not readable) +o sanitize kernel headers and remove the __user and __kernel stuff +o test 64bit + + +User contributed +---------------- +o [Klaus Ade Johnstad] add raid status line diff -Naur mpt-status-1.1.2-ratz/mpt-status.c mpt-status-1.1.3-ratz/mpt-status.c --- mpt-status-1.1.2-ratz/mpt-status.c 2005-06-17 02:22:12.000000000 -0700 +++ mpt-status-1.1.3-ratz/mpt-status.c 2005-07-14 23:28:21.000000000 -0700 @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -*/ +*/ #include #include @@ -57,234 +57,291 @@ \______ Array: Primary Disk */ -void *read_page(unsigned pagetype, unsigned pagewhich, unsigned pagenumber, - int address, unsigned version) { - char command[REALLYBIG]; - char reply[REALLYBIG]; - char sense[REALLYBIG]; - char *in; - struct mpt_ioctl_command *cmd; - Config_t *config_request; - ConfigReply_t *config_reply; - - if(NULL == (in = calloc(REALLYBIG, 1))) { - perror("calloc"); - exit(EXIT_FAILURE); - } - - cmd = (struct mpt_ioctl_command *) command; - config_request = (Config_t *) cmd->MF; - config_reply = (ConfigReply_t *) reply; - - memset((void *) command, 0, sizeof(command)); - memset((void *) reply, 0, sizeof(reply)); - 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.port = 0; - cmd->hdr.maxDataSize = BIG; - cmd->timeout = 10; - cmd->dataSgeOffset = (((char *) &config_request->PageBufferSGE) - ((char *) config_request)) / 4; - cmd->senseDataPtr = (void *) sense; - cmd->replyFrameBufPtr = (void *) config_reply; - cmd->dataInBufPtr = (void *) in; - cmd->maxSenseBytes = BIG; - cmd->maxReplyBytes = BIG; - cmd->dataInSize = BIG; - - config_request->Function = MPI_FUNCTION_CONFIG; - config_request->Action = MPI_CONFIG_ACTION_PAGE_HEADER; - config_request->Header.PageType = pagetype; - config_request->Header.PageNumber = pagenumber; - config_request->Header.PageLength = 0; - config_request->Header.PageVersion = 0; - config_request->PageAddress = address; - - if(-1 == ioctl(m, MPTCOMMAND, cmd)) { - perror("MPI_FUNCTION_CONFIG (get page header)"); - exit(EXIT_FAILURE); - } - - 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); - } - - config_request->Action = pagewhich; - config_request->Header.PageLength = config_reply->Header.PageLength; - - /* is this check really necessary (255 is max anyway)? --ratz */ - if(config_reply->Header.PageLength > UINT8_MAX) { - fprintf(stderr, "reply too big\n"); - exit(EXIT_FAILURE); - } - - if(-1 == ioctl(m, MPTCOMMAND, cmd)) { - perror("MPI_FUNCTION_CONFIG (get page)"); - exit(EXIT_FAILURE); - } - return in; +void *read_page(unsigned int pagetype, unsigned int pagewhich, + unsigned int pagenumber, int address, unsigned int version) +{ + char command[REALLYBIG]; + char reply[REALLYBIG]; + char sense[REALLYBIG]; + char *in; + struct mpt_ioctl_command *cmd; + Config_t *config_request; + ConfigReply_t *config_reply; + + if (NULL == (in = calloc(REALLYBIG, 1))) { + perror("calloc"); + exit(EXIT_FAILURE); + } + + cmd = (struct mpt_ioctl_command *)command; + config_request = (Config_t *) cmd->MF; + config_reply = (ConfigReply_t *) reply; + + memset((void *)command, 0, sizeof(command)); + memset((void *)reply, 0, sizeof(reply)); + 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.port = 0; + cmd->hdr.maxDataSize = BIG; + cmd->timeout = 10; + cmd->dataSgeOffset = + (((char *)&config_request->PageBufferSGE) - + ((char *)config_request)) / 4; + cmd->senseDataPtr = (void *)sense; + cmd->replyFrameBufPtr = (void *)config_reply; + cmd->dataInBufPtr = (void *)in; + cmd->maxSenseBytes = BIG; + cmd->maxReplyBytes = BIG; + cmd->dataInSize = BIG; + + config_request->Function = MPI_FUNCTION_CONFIG; + config_request->Action = MPI_CONFIG_ACTION_PAGE_HEADER; + config_request->Header.PageType = pagetype; + config_request->Header.PageNumber = pagenumber; + config_request->Header.PageLength = 0; + config_request->Header.PageVersion = 0; + config_request->PageAddress = address; + + if (-1 == ioctl(m, MPTCOMMAND, cmd)) { + perror("MPI_FUNCTION_CONFIG (get page header)"); + exit(EXIT_FAILURE); + } + + 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); + } + + config_request->Action = pagewhich; + config_request->Header.PageLength = config_reply->Header.PageLength; + + /* is this check really necessary (255 is max anyway)? --ratz + * config_reply->Header.PageLength is U8. I don't know why the compiler + * is barking here about the comparison. + */ + if (config_reply->Header.PageLength > UINT8_MAX) { + fprintf(stderr, "reply too big\n"); + exit(EXIT_FAILURE); + } + + if (-1 == ioctl(m, MPTCOMMAND, cmd)) { + perror("MPI_FUNCTION_CONFIG (get page)"); + exit(EXIT_FAILURE); + } + return in; } -void print_usage(const char * prog) { - printf("Usage:\n"); - printf("%s [-i ]\n", prog); - exit(EXIT_SUCCESS); +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_version(void) +{ + printf("Version: %s\n", VERSION); + exit(EXIT_SUCCESS); } -void print_information(int id_of_primary_device, int print_status_only) { - RaidVolumePage0_t *page; - RaidPhysDiskPage0_t *phys; - char *VolumeTypes[] = { "IS", "IME", "IM" }; - int i; - int ioc = 0; - - /* XXX I don't know how it would work if you had multiple RAID volumes. - Would those be separate pages? And if so, how would I specify that I - wanted a different page? - - If it's anything like physical disks, you would tweek `Address'. */ - page = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, - MPI_CONFIG_ACTION_PAGE_READ_CURRENT, - ioc, - id_of_primary_device, - MPI_RAIDVOLPAGE0_PAGEVERSION); - if (1 == print_status_only) { - printf("log_id %d", page->VolumeID); - } else { - printf("ioc%d vol_id %d type %s, %d phy, %d GB", - page->VolumeIOC, - page->VolumeID, - page->VolumeType < sizeof(VolumeTypes) ? VolumeTypes[page->VolumeType] : "unknown", - page->NumPhysDisks, - page->MaxLBA / (2 * 1024 * 1024)); - printf(", state"); - } - if(page->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_OPTIMAL) printf(" OPTIMAL"); - if(page->VolumeStatus.State & MPI_RAIDVOL0_STATUS_STATE_DEGRADED) printf(" DEGRADED"); - if(page->VolumeStatus.State & MPI_RAIDVOL0_STATUS_STATE_FAILED) printf(" FAILED"); - if (1 != print_status_only) { - printf(", flags"); - if(page->VolumeStatus.Flags != 0) { - if(page->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED) printf(" ENABLED"); - if(page->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_QUIESCED) printf(" QUIESCED"); - if(page->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS) printf(" RESYNC_IN_PROGRESS"); - if(page->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE) printf(" VOLUME_INACTIVE"); - } else { - printf(" NONE"); - } - } - printf("\n"); - - /* go through all physical disk of a found array */ - for(i = 0; i < page->NumPhysDisks; ++i) { - char vendor[BIG]; - char productid[BIG]; - char rev[BIG]; - phys = read_page(MPI_CONFIG_PAGETYPE_RAID_PHYSDISK, - MPI_CONFIG_ACTION_PAGE_READ_CURRENT, - 0, - page->PhysDisk[i].PhysDiskNum, - MPI_RAIDPHYSDISKPAGE0_PAGEVERSION); - memset(vendor, 0, sizeof(vendor)); - memset(productid, 0, sizeof(productid)); - memset(rev, 0, sizeof(rev)); - strncpy(vendor, phys->InquiryData.VendorID, sizeof(phys->InquiryData.VendorID)); - strncpy(productid, phys->InquiryData.ProductID, sizeof(phys->InquiryData.ProductID)); - strncpy(rev, phys->InquiryData.ProductRevLevel, sizeof(phys->InquiryData.ProductRevLevel)); - - if (1 == print_status_only) { - printf("phys_id %d", phys->PhysDiskNum); - } else { - printf("ioc%d phy %d scsi_id %d %s %s %s, %d GB", - phys->PhysDiskIOC, - phys->PhysDiskNum, - phys->PhysDiskID, - vendor, - productid, - rev, - phys->MaxLBA / (2 * 1024 * 1024)); - printf(", state"); - } - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_ONLINE) printf(" ONLINE"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_MISSING) printf(" MISSING"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_NOT_COMPATIBLE) printf(" NOT_COMPATIBLE"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_FAILED) printf(" FAILED"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_INITIALIZING) printf(" INITIALIZING"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_OFFLINE_REQUESTED) printf(" OFFLINE_REQUESTED"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_FAILED_REQUESTED) printf(" FAILED_REQUESTED"); - if(phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_OTHER_OFFLINE) printf(" OTHER_OFFLINE"); - if (1 != print_status_only) { - printf(", flags"); - if(phys->PhysDiskStatus.Flags) { - if(phys->PhysDiskStatus.Flags & MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC) printf(" OUT_OF_SYNC"); - if(phys->PhysDiskStatus.Flags & MPI_PHYSDISK0_STATUS_FLAG_QUIESCED) printf(" QUIESCED"); - } else { - printf(" NONE"); - } - } - printf("\n"); - } +void print_information(int id_of_primary_device, int print_status_only) +{ + RaidVolumePage0_t *page; + RaidPhysDiskPage0_t *phys; + char *VolumeTypes[] = { "IS", "IME", "IM" }; + int i; + int ioc = 0; + + /* XXX I don't know how it would work if you had multiple RAID volumes. + Would those be separate pages? And if so, how would I specify that I + wanted a different page? + + If it's anything like physical disks, you would tweek `Address'. */ + page = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, + MPI_CONFIG_ACTION_PAGE_READ_CURRENT, + ioc, + id_of_primary_device, MPI_RAIDVOLPAGE0_PAGEVERSION); + if (1 == print_status_only) { + printf("log_id %d", page->VolumeID); + } else { + printf("ioc%d vol_id %d type %s, %d phy, %d GB", + page->VolumeIOC, + page->VolumeID, + page->VolumeType < + sizeof(VolumeTypes) ? VolumeTypes[page-> + VolumeType] : + "unknown", page->NumPhysDisks, + page->MaxLBA / (2 * 1024 * 1024)); + printf(", state"); + } + if (page->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_OPTIMAL) + printf(" OPTIMAL"); + if (page->VolumeStatus.State & MPI_RAIDVOL0_STATUS_STATE_DEGRADED) + printf(" DEGRADED"); + if (page->VolumeStatus.State & MPI_RAIDVOL0_STATUS_STATE_FAILED) + printf(" FAILED"); + if (1 != print_status_only) { + printf(", flags"); + if (page->VolumeStatus.Flags != 0) { + if (page->VolumeStatus. + Flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED) + printf(" ENABLED"); + if (page->VolumeStatus. + Flags & MPI_RAIDVOL0_STATUS_FLAG_QUIESCED) + printf(" QUIESCED"); + if (page->VolumeStatus. + Flags & MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS) + printf(" RESYNC_IN_PROGRESS"); + if (page->VolumeStatus. + Flags & MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE) + printf(" VOLUME_INACTIVE"); + } else { + printf(" NONE"); + } + } + printf("\n"); + + /* this will eventually become the hot spare information extraction + * code. + phys = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, + MPI_CONFIG_ACTION_PAGE_READ_CURRENT, + 0, + 5, + MPI_IOCPAGE5_PAGEVERSION); + + if (page->NumHotSpares) { + printf("num of hotspares: %d", page->NumHotSpares); + } + */ + + /* go through all physical disk of a found array */ + for (i = 0; i < page->NumPhysDisks; ++i) { + char vendor[BIG]; + char productid[BIG]; + char rev[BIG]; + phys = read_page(MPI_CONFIG_PAGETYPE_RAID_PHYSDISK, + MPI_CONFIG_ACTION_PAGE_READ_CURRENT, + 0, + page->PhysDisk[i].PhysDiskNum, + MPI_RAIDPHYSDISKPAGE0_PAGEVERSION); + memset(vendor, 0, sizeof(vendor)); + memset(productid, 0, sizeof(productid)); + memset(rev, 0, sizeof(rev)); + strncpy(vendor, phys->InquiryData.VendorID, + sizeof(phys->InquiryData.VendorID)); + strncpy(productid, phys->InquiryData.ProductID, + sizeof(phys->InquiryData.ProductID)); + strncpy(rev, phys->InquiryData.ProductRevLevel, + sizeof(phys->InquiryData.ProductRevLevel)); + + if (1 == print_status_only) { + printf("phys_id %d", phys->PhysDiskNum); + } else { + printf("ioc%d phy %d scsi_id %d %s %s %s, %d GB", + phys->PhysDiskIOC, + phys->PhysDiskNum, + phys->PhysDiskID, + vendor, + productid, + rev, phys->MaxLBA / (2 * 1024 * 1024)); + printf(", state"); + } + if (phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_ONLINE) + printf(" ONLINE"); + if (phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_MISSING) + printf(" MISSING"); + if (phys->PhysDiskStatus.State == + MPI_PHYSDISK0_STATUS_NOT_COMPATIBLE) + printf(" NOT_COMPATIBLE"); + if (phys->PhysDiskStatus.State == MPI_PHYSDISK0_STATUS_FAILED) + printf(" FAILED"); + if (phys->PhysDiskStatus.State == + MPI_PHYSDISK0_STATUS_INITIALIZING) + printf(" INITIALIZING"); + if (phys->PhysDiskStatus.State == + MPI_PHYSDISK0_STATUS_OFFLINE_REQUESTED) + printf(" OFFLINE_REQUESTED"); + if (phys->PhysDiskStatus.State == + MPI_PHYSDISK0_STATUS_FAILED_REQUESTED) + printf(" FAILED_REQUESTED"); + if (phys->PhysDiskStatus.State == + MPI_PHYSDISK0_STATUS_OTHER_OFFLINE) + printf(" OTHER_OFFLINE"); + if (1 != print_status_only) { + printf(", flags"); + if (phys->PhysDiskStatus.Flags) { + if (phys->PhysDiskStatus. + Flags & + MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC) + printf(" OUT_OF_SYNC"); + if (phys->PhysDiskStatus. + Flags & MPI_PHYSDISK0_STATUS_FLAG_QUIESCED) + printf(" QUIESCED"); + } else { + printf(" NONE"); + } + } + printf("\n"); + } } -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"); - - m = open("/dev/mptctl", O_RDWR); - if(-1 == m) { - int save_errno = errno; - perror("open /dev/mptctl"); - if(save_errno == EACCES) { - fprintf(stderr, " You need to be root to run this program\n"); - } else if(save_errno == ENOENT) { - fprintf(stderr, " Try: mknod /dev/mptctl c 10 220\n"); - } else if(save_errno == ENODEV) { - fprintf(stderr, " Are you sure your controller is supported by mptlinux?\n"); - } - exit(EXIT_FAILURE); - } +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"); + + m = open("/dev/mptctl", O_RDWR); + if (-1 == m) { + int save_errno = errno; + perror("open /dev/mptctl"); + if (save_errno == EACCES) { + fprintf(stderr, + " You need to be root to run this program\n"); + } else if (save_errno == ENOENT) { + fprintf(stderr, " Try: mknod /dev/mptctl c 10 220\n"); + } else if (save_errno == ENODEV) { + fprintf(stderr, + " Are you sure your controller is supported by mptlinux?\n"); + } + exit(EXIT_FAILURE); + } } -int main(int argc, char *argv[]) { - int ch; - int print_status_only = PRINT_STATUS_ONLY; - int id_of_primary_device = 0; - - while ((ch = getopt(argc, argv, "i:hsv")) != EOF) { - switch(ch) { - case 'i': - id_of_primary_device = strtoul(optarg, NULL, 10); - break; - case 'h': - print_usage(argv[0]); - break; - case 's': - print_status_only = 1; - break; - case 'v': - print_version(); - break; - default: - break; - } - } - - do_init(); - print_information(id_of_primary_device, print_status_only); - exit(EXIT_SUCCESS); +int main(int argc, char *argv[]) +{ + int ch; + int print_status_only = PRINT_STATUS_ONLY; + int id_of_primary_device = 0; + + while ((ch = getopt(argc, argv, "i:hsv")) != EOF) { + switch (ch) { + case 'i': + id_of_primary_device = strtoul(optarg, NULL, 10); + break; + case 'h': + print_usage(argv[0]); + break; + case 's': + print_status_only = 1; + break; + case 'v': + print_version(); + break; + default: + break; + } + } + + do_init(); + print_information(id_of_primary_device, print_status_only); + exit(EXIT_SUCCESS); } diff -Naur mpt-status-1.1.2-ratz/mpt-status.h mpt-status-1.1.3-ratz/mpt-status.h --- mpt-status-1.1.2-ratz/mpt-status.h 2005-06-11 07:55:51.000000000 -0700 +++ mpt-status-1.1.3-ratz/mpt-status.h 2005-07-14 23:35:13.000000000 -0700 @@ -1,7 +1,12 @@ #ifndef _MPT_STATUS_H #define _MPT_STATUS_H -#include "pci.h" /* along with config.h and header.h from pciutils package */ +#ifdef REDHAT +# define __user +# define __kernel +#endif + +#include "pci.h" /* config.h and header.h from pciutils package */ #include "mptctl.h" #include "lsi/mpi_type.h" #include "lsi/mpi.h" @@ -14,11 +19,10 @@ #define REALLYBIG 10240 #define PRINT_STATUS_ONLY 0 -void *read_page(unsigned, unsigned, unsigned, int, unsigned); +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); -#endif /* End of mpt-status.h */ - +#endif /* End of mpt-status.h */