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 * RESOLVE KERNEL PRESENCE:
128 *--------------------------
130 if (dmi(CREATE_DESTROY_OPCODE, old_sid, junk, &sid) >= 0) {
131 printf("ERROR: invalid kernel create/destroy_session call "
135 else if (errno==ENOPKG) {
138 else if (errno==EINVAL){
139 if (Vflag) printf("(create/destroy_session call verifies "
140 "that you have DMAPI in kernel)\n");
143 printf("ERROR: kernel create/destroy_session call produced "
144 "unexpected errno, (%d) %s\n", errno, strerror(errno));
147 /*----------------------------------
148 * RESOLVE KERNEL STATUS IF PRESENT:
149 *----------------------------------
151 if (kernel_status==-1 &&
159 printf("ERROR: invalid kernel set_disp call suceeded!\n");
164 printf("(kernel set_disp call indicates old kernel)\n");
167 else if (errno==ENOPKG) {
169 printf("(kernel set_disp call indicates no kernel)\n");
172 else if (errno==EINVAL) {
174 printf("(kernel set_disp call indicates new kernel)\n");
178 printf("ERROR: kernel set_disp call failed: (%d) %s\n",
179 errno, strerror(errno));
184 /*-------------------------
185 * RESOLVE LIBRARY STATUS:
186 *-------------------------
188 if (dm_init_service(&name) == -1) {
189 fprintf(stderr, "ERROR: can't initialize the DMAPI (%s).\n",
193 else if (strcmp(name, DM_VER_STR_CONTENTS)) {
195 printf("(dm_init_service suggests that "
196 "you have an old library)\n");
201 printf("(dm_init_service suggests that "
202 "you have a new library)\n");
206 if (Vflag) printf("(dm_init_service returned %s)\n", name);
208 /*-------------------------
210 *-------------------------
213 if (library_status==2 && kernel_status==2){
214 printf("DIAGNOSIS: Tests show a current version of "
215 "DMAPI is installed.\n");
217 else if (library_status==1 && kernel_status==1) {
218 printf("DIAGNOSIS: Tests show that you have an outdated "
219 "installation of DMAPI.\nUpgrades to both kernel and "
220 "library routines will be necessary.\n");
222 else if (library_status==0 && kernel_status==0) {
223 printf("DIAGNOSIS: Tests show that NO components of the DMAPI "
224 "are installed!\nUpgrades to both kernel and "
225 "library routines will be necessary.\n");
228 printf("DIAGNOSIS: Tests show that:\n"
229 "Your DMAPI kernel routines are ");
230 switch (kernel_status) {
231 case 0: printf ("missing (not installed).\n");
233 case 1: printf ("outdated.\n");
235 case 2: printf ("current.\n ");
237 default: printf("[ERROR!].\n");
239 printf("Your DMAPI library is ");
240 switch (library_status) {
241 case 0: printf ("missing (not installed).\n");
243 case 1: printf ("outdated.\n");
245 case 2: printf ("current.\n");
247 default: printf("[ERROR!].\n");
251 if (library_status!=2 || kernel_status!=2){
252 printf("Please install XFS patch 1907 (for IRIX 6.2) or "
253 "patch 2287 (for IRIX 6.4).\n");