2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 #include <sys/types.h>
49 #include <lib/dmport.h>
55 /*---------------------------------------------------------------------------
56 Automated test of version of DMAPI libraries & kernels
62 where v is a verbose-output flag
63 ----------------------------------------------------------------------------*/
65 #define CREATE_DESTROY_OPCODE DM_DESTROY_SESSION
66 #define SET_DISP_OPCODE DM_SET_DISP
68 #define CREATE_DESTROY_OPCODE 5
69 #define SET_DISP_OPCODE 46
73 extern char *sys_errlist[];
87 fprintf(stderr, "usage:\t%s [-v]\n"
88 "\t(use the v switch for verbose output)\n", Progname);
98 dm_sessid_t old_sid = -1;
102 dm_token_t token = DM_NO_TOKEN;
105 char *junk = "test junk";
108 int kernel_status=-1;
109 int library_status=-1L;
111 struct stat stat_buf;
113 if (Progname = strrchr(argv[0], '/')) {
119 /* Crack and validate the command line options. */
121 while ((opt = getopt(argc, argv, "v")) != EOF) {
135 printf("You are running as user #%d. "
136 "You must be root to run this diagnostic.\n", geteuid());
140 /*--------------------------------
141 * EXAMINE /usr/include/sys/dmi.h:
142 *--------------------------------
145 #define DMAPI_HDR "/usr/include/sys/dmi.h"
147 if (stat(DMAPI_HDR, &stat_buf)==-1){
149 printf( "You are missing a vital DMAPI file: %s\n", DMAPI_HDR);
152 printf( "ERROR: could not stat %s (%s)\n", DMAPI_HDR, strerror(errno));
156 if (stat_buf.st_size <= 15000) {
157 printf("You appear to have an old version of a vital DMAPI file: %s\n", DMAPI_HDR);
160 printf("(You appear to have the correct version of %s\n", DMAPI_HDR);
165 /*--------------------------
166 * RESOLVE KERNEL PRESENCE:
167 *--------------------------
169 if (dmi(CREATE_DESTROY_OPCODE, old_sid, junk, &sid) >= 0) {
170 printf("ERROR: invalid kernel create/destroy_session call "
174 else if (errno==ENOPKG) {
177 else if (errno==EINVAL){
178 if (Vflag) printf("(create/destroy_session call verifies "
179 "that you have DMAPI in kernel)\n");
182 printf("ERROR: kernel create/destroy_session call produced "
183 "unexpected errno, (%d) %s\n", errno, strerror(errno));
186 /*----------------------------------
187 * RESOLVE KERNEL STATUS IF PRESENT:
188 *----------------------------------
190 if (kernel_status==-1 &&
198 printf("ERROR: invalid kernel set_disp call suceeded!\n");
203 printf("(kernel set_disp call indicates old kernel)\n");
206 else if (errno==ENOPKG) {
208 printf("(kernel set_disp call indicates no kernel)\n");
211 else if (errno==EINVAL) {
213 printf("(kernel set_disp call indicates new kernel)\n");
217 printf("ERROR: kernel set_disp call failed: (%d) %s\n",
218 errno, strerror(errno));
223 /*-------------------------
224 * RESOLVE LIBRARY STATUS:
225 *-------------------------
227 if (dm_init_service(&name) == -1) {
228 fprintf(stderr, "ERROR: can't initialize the DMAPI (%s).\n",
232 else if (strcmp(name, DM_VER_STR_CONTENTS)) {
234 printf("(dm_init_service suggests that "
235 "you have an old library)\n");
240 printf("(dm_init_service suggests that "
241 "you have a new library)\n");
245 if (Vflag) printf("(dm_init_service returned %s)\n", name);
247 /*-------------------------
249 *-------------------------
252 if (library_status==2 && kernel_status==2){
253 printf("DIAGNOSIS: Tests show a current version of "
254 "DMAPI is installed.\n");
256 else if (library_status==1 && kernel_status==1) {
257 printf("DIAGNOSIS: Tests show that you have an outdated "
258 "installation of DMAPI.\nUpgrades to both kernel and "
259 "library routines will be necessary.\n");
261 else if (library_status==0 && kernel_status==0) {
262 printf("DIAGNOSIS: Tests show that NO components of the DMAPI "
263 "are installed!\nUpgrades to both kernel and "
264 "library routines will be necessary.\n");
267 printf("DIAGNOSIS: Tests show that:\n"
268 "Your DMAPI kernel routines are ");
269 switch (kernel_status) {
270 case 0: printf ("missing (not installed).\n");
272 case 1: printf ("outdated.\n");
274 case 2: printf ("current.\n ");
276 default: printf("[ERROR!].\n");
278 printf("Your DMAPI library is ");
279 switch (library_status) {
280 case 0: printf ("missing (not installed).\n");
282 case 1: printf ("outdated.\n");
284 case 2: printf ("current.\n");
286 default: printf("[ERROR!].\n");
290 if (library_status!=2 || kernel_status!=2){
291 printf("Please install XFS patch 1907 (for IRIX 6.2) or "
292 "patch 2287 (for IRIX 6.4).\n");