2 * Copyright (c) 2000 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>
36 #include <linux/dmapi_kern.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/linux/dmapi.h"
147 #define DMAPI_HDR "/usr/include/sys/dmi.h"
149 if (stat(DMAPI_HDR, &stat_buf)==-1){
151 printf( "You are missing a vital DMAPI file: %s\n", DMAPI_HDR);
154 printf( "ERROR: could not stat %s (%s)\n", DMAPI_HDR, strerror(errno));
158 if (stat_buf.st_size <= 15000) {
159 printf("You appear to have an old version of a vital DMAPI file: %s\n", DMAPI_HDR);
162 printf("(You appear to have the correct version of %s\n", DMAPI_HDR);
166 /*--------------------------
167 * RESOLVE KERNEL PRESENCE:
168 *--------------------------
170 if (dmi(CREATE_DESTROY_OPCODE, old_sid, junk, &sid) >= 0) {
171 printf("ERROR: invalid kernel create/destroy_session call "
175 else if (errno==ENOPKG) {
178 else if (errno==EINVAL){
179 if (Vflag) printf("(create/destroy_session call verifies "
180 "that you have DMAPI in kernel)\n");
183 printf("ERROR: kernel create/destroy_session call produced "
184 "unexpected errno, (%d) %s\n", errno, strerror(errno));
187 /*----------------------------------
188 * RESOLVE KERNEL STATUS IF PRESENT:
189 *----------------------------------
191 if (kernel_status==-1 &&
199 printf("ERROR: invalid kernel set_disp call suceeded!\n");
204 printf("(kernel set_disp call indicates old kernel)\n");
207 else if (errno==ENOPKG) {
209 printf("(kernel set_disp call indicates no kernel)\n");
212 else if (errno==EINVAL) {
214 printf("(kernel set_disp call indicates new kernel)\n");
218 printf("ERROR: kernel set_disp call failed: (%d) %s\n",
219 errno, strerror(errno));
225 /*-------------------------
226 * RESOLVE LIBRARY STATUS:
227 *-------------------------
229 if (dm_init_service(&name) == -1) {
230 fprintf(stderr, "ERROR: can't inititalize the DMAPI (%s).\n",
234 else if (strcmp(name, DM_VER_STR_CONTENTS)) {
236 printf("(dm_init_service suggests that "
237 "you have an old library)\n");
242 printf("(dm_init_service suggests that "
243 "you have a new library)\n");
247 if (Vflag) printf("(dm_init_service returned %s)\n", name);
249 /*-------------------------
251 *-------------------------
254 if (library_status==2 && kernel_status==2){
255 printf("DIAGNOSIS: Tests show a current version of "
256 "DMAPI is installed.\n");
258 else if (library_status==1 && kernel_status==1) {
259 printf("DIAGNOSIS: Tests show that you have an outdated "
260 "installation of DMAPI.\nUpgrades to both kernel and "
261 "library routines will be necessary.\n");
263 else if (library_status==0 && kernel_status==0) {
264 printf("DIAGNOSIS: Tests show that NO components of the DMAPI "
265 "are installed!\nUpgrades to both kernel and "
266 "library routines will be necessary.\n");
269 printf("DIAGNOSIS: Tests show that:\n"
270 "Your DMAPI kernel routines are ");
271 switch (kernel_status) {
272 case 0: printf ("missing (not installed).\n");
274 case 1: printf ("outdated.\n");
276 case 2: printf ("current.\n ");
278 default: printf("[ERROR!].\n");
280 printf("Your DMAPI library is ");
281 switch (library_status) {
282 case 0: printf ("missing (not installed).\n");
284 case 1: printf ("outdated.\n");
286 case 2: printf ("current.\n");
288 default: printf("[ERROR!].\n");
292 if (library_status!=2 || kernel_status!=2){
293 printf("Please install XFS patch 1907 (for IRIX 6.2) or "
294 "patch 2287 (for IRIX 6.4).\n");