2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include <sys/types.h>
35 #include <lib/dmport.h>
41 /*---------------------------------------------------------------------------
42 Automated test of version of DMAPI libraries & kernels
48 where v is a verbose-output flag
49 ----------------------------------------------------------------------------*/
51 #define CREATE_DESTROY_OPCODE DM_DESTROY_SESSION
52 #define SET_DISP_OPCODE DM_SET_DISP
54 #define CREATE_DESTROY_OPCODE 5
55 #define SET_DISP_OPCODE 46
59 extern char *sys_errlist[];
73 fprintf(stderr, "usage:\t%s [-v]\n"
74 "\t(use the v switch for verbose output)\n", Progname);
84 dm_sessid_t old_sid = -1;
88 dm_token_t token = DM_NO_TOKEN;
91 char *junk = "test junk";
95 int library_status=-1L;
99 if (Progname = strrchr(argv[0], '/')) {
105 /* Crack and validate the command line options. */
107 while ((opt = getopt(argc, argv, "v")) != EOF) {
121 printf("You are running as user #%d. "
122 "You must be root to run this diagnostic.\n", geteuid());
126 /*--------------------------------
127 * EXAMINE /usr/include/sys/dmi.h:
128 *--------------------------------
131 #define DMAPI_HDR "/usr/include/sys/dmi.h"
133 if (stat(DMAPI_HDR, &stat_buf)==-1){
135 printf( "You are missing a vital DMAPI file: %s\n", DMAPI_HDR);
138 printf( "ERROR: could not stat %s (%s)\n", DMAPI_HDR, strerror(errno));
142 if (stat_buf.st_size <= 15000) {
143 printf("You appear to have an old version of a vital DMAPI file: %s\n", DMAPI_HDR);
146 printf("(You appear to have the correct version of %s\n", DMAPI_HDR);
151 /*--------------------------
152 * RESOLVE KERNEL PRESENCE:
153 *--------------------------
155 if (dmi(CREATE_DESTROY_OPCODE, old_sid, junk, &sid) >= 0) {
156 printf("ERROR: invalid kernel create/destroy_session call "
160 else if (errno==ENOPKG) {
163 else if (errno==EINVAL){
164 if (Vflag) printf("(create/destroy_session call verifies "
165 "that you have DMAPI in kernel)\n");
168 printf("ERROR: kernel create/destroy_session call produced "
169 "unexpected errno, (%d) %s\n", errno, strerror(errno));
172 /*----------------------------------
173 * RESOLVE KERNEL STATUS IF PRESENT:
174 *----------------------------------
176 if (kernel_status==-1 &&
184 printf("ERROR: invalid kernel set_disp call suceeded!\n");
189 printf("(kernel set_disp call indicates old kernel)\n");
192 else if (errno==ENOPKG) {
194 printf("(kernel set_disp call indicates no kernel)\n");
197 else if (errno==EINVAL) {
199 printf("(kernel set_disp call indicates new kernel)\n");
203 printf("ERROR: kernel set_disp call failed: (%d) %s\n",
204 errno, strerror(errno));
209 /*-------------------------
210 * RESOLVE LIBRARY STATUS:
211 *-------------------------
213 if (dm_init_service(&name) == -1) {
214 fprintf(stderr, "ERROR: can't initialize the DMAPI (%s).\n",
218 else if (strcmp(name, DM_VER_STR_CONTENTS)) {
220 printf("(dm_init_service suggests that "
221 "you have an old library)\n");
226 printf("(dm_init_service suggests that "
227 "you have a new library)\n");
231 if (Vflag) printf("(dm_init_service returned %s)\n", name);
233 /*-------------------------
235 *-------------------------
238 if (library_status==2 && kernel_status==2){
239 printf("DIAGNOSIS: Tests show a current version of "
240 "DMAPI is installed.\n");
242 else if (library_status==1 && kernel_status==1) {
243 printf("DIAGNOSIS: Tests show that you have an outdated "
244 "installation of DMAPI.\nUpgrades to both kernel and "
245 "library routines will be necessary.\n");
247 else if (library_status==0 && kernel_status==0) {
248 printf("DIAGNOSIS: Tests show that NO components of the DMAPI "
249 "are installed!\nUpgrades to both kernel and "
250 "library routines will be necessary.\n");
253 printf("DIAGNOSIS: Tests show that:\n"
254 "Your DMAPI kernel routines are ");
255 switch (kernel_status) {
256 case 0: printf ("missing (not installed).\n");
258 case 1: printf ("outdated.\n");
260 case 2: printf ("current.\n ");
262 default: printf("[ERROR!].\n");
264 printf("Your DMAPI library is ");
265 switch (library_status) {
266 case 0: printf ("missing (not installed).\n");
268 case 1: printf ("outdated.\n");
270 case 2: printf ("current.\n");
272 default: printf("[ERROR!].\n");
276 if (library_status!=2 || kernel_status!=2){
277 printf("Please install XFS patch 1907 (for IRIX 6.2) or "
278 "patch 2287 (for IRIX 6.4).\n");