1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
23 #include <lib/dmport.h>
29 /*---------------------------------------------------------------------------
30 Automated test of version of DMAPI libraries & kernels
36 where v is a verbose-output flag
37 ----------------------------------------------------------------------------*/
39 #define CREATE_DESTROY_OPCODE DM_DESTROY_SESSION
40 #define SET_DISP_OPCODE DM_SET_DISP
42 #define CREATE_DESTROY_OPCODE 5
43 #define SET_DISP_OPCODE 46
47 extern char *sys_errlist[];
61 fprintf(stderr, "usage:\t%s [-v]\n"
62 "\t(use the v switch for verbose output)\n", Progname);
72 dm_sessid_t old_sid = -1;
76 dm_token_t token = DM_NO_TOKEN;
79 char *junk = "test junk";
83 int library_status=-1L;
87 if (Progname = strrchr(argv[0], '/')) {
93 /* Crack and validate the command line options. */
95 while ((opt = getopt(argc, argv, "v")) != EOF) {
109 printf("You are running as user #%d. "
110 "You must be root to run this diagnostic.\n", geteuid());
114 /*--------------------------
115 * RESOLVE KERNEL PRESENCE:
116 *--------------------------
118 if (dmi(CREATE_DESTROY_OPCODE, old_sid, junk, &sid) >= 0) {
119 printf("ERROR: invalid kernel create/destroy_session call "
123 else if (errno==ENOPKG) {
126 else if (errno==EINVAL){
127 if (Vflag) printf("(create/destroy_session call verifies "
128 "that you have DMAPI in kernel)\n");
131 printf("ERROR: kernel create/destroy_session call produced "
132 "unexpected errno, (%d) %s\n", errno, strerror(errno));
135 /*----------------------------------
136 * RESOLVE KERNEL STATUS IF PRESENT:
137 *----------------------------------
139 if (kernel_status==-1 &&
147 printf("ERROR: invalid kernel set_disp call suceeded!\n");
152 printf("(kernel set_disp call indicates old kernel)\n");
155 else if (errno==ENOPKG) {
157 printf("(kernel set_disp call indicates no kernel)\n");
160 else if (errno==EINVAL) {
162 printf("(kernel set_disp call indicates new kernel)\n");
166 printf("ERROR: kernel set_disp call failed: (%d) %s\n",
167 errno, strerror(errno));
172 /*-------------------------
173 * RESOLVE LIBRARY STATUS:
174 *-------------------------
176 if (dm_init_service(&name) == -1) {
177 fprintf(stderr, "ERROR: can't initialize the DMAPI (%s).\n",
181 else if (strcmp(name, DM_VER_STR_CONTENTS)) {
183 printf("(dm_init_service suggests that "
184 "you have an old library)\n");
189 printf("(dm_init_service suggests that "
190 "you have a new library)\n");
194 if (Vflag) printf("(dm_init_service returned %s)\n", name);
196 /*-------------------------
198 *-------------------------
201 if (library_status==2 && kernel_status==2){
202 printf("DIAGNOSIS: Tests show a current version of "
203 "DMAPI is installed.\n");
205 else if (library_status==1 && kernel_status==1) {
206 printf("DIAGNOSIS: Tests show that you have an outdated "
207 "installation of DMAPI.\nUpgrades to both kernel and "
208 "library routines will be necessary.\n");
210 else if (library_status==0 && kernel_status==0) {
211 printf("DIAGNOSIS: Tests show that NO components of the DMAPI "
212 "are installed!\nUpgrades to both kernel and "
213 "library routines will be necessary.\n");
216 printf("DIAGNOSIS: Tests show that:\n"
217 "Your DMAPI kernel routines are ");
218 switch (kernel_status) {
219 case 0: printf ("missing (not installed).\n");
221 case 1: printf ("outdated.\n");
223 case 2: printf ("current.\n ");
225 default: printf("[ERROR!].\n");
227 printf("Your DMAPI library is ");
228 switch (library_status) {
229 case 0: printf ("missing (not installed).\n");
231 case 1: printf ("outdated.\n");
233 case 2: printf ("current.\n");
235 default: printf("[ERROR!].\n");
239 if (library_status!=2 || kernel_status!=2){
240 printf("Please install XFS patch 1907 (for IRIX 6.2) or "
241 "patch 2287 (for IRIX 6.4).\n");