File: serror.c

package info (click to toggle)
lcgdm 1.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 14,044 kB
  • sloc: ansic: 149,126; sh: 13,441; perl: 11,498; python: 5,778; cpp: 5,113; sql: 1,805; makefile: 1,388; fortran: 113
file content (613 lines) | stat: -rw-r--r-- 20,375 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
/*
 * Copyright (C) 1990-2008 by CERN/IT/PDP/DM 
 * All rights reserved
 */

#ifndef lint
static char sccsid[] =  "@(#)$RCSfile: serror.c,v $ $Revision: 1.6 $ $Date: 2008/01/29 15:04:42 $ CERN IT-PDP/DM Olof Barring";
#endif /* not lint */

/* serror.c     Global error reporting routines                         */

#include <stdio.h>      /* standard input/output                        */
#include <errno.h>      /* error numbers and codes                      */

#include <serrno.h>     /* special error numbers and codes              */
#include <log.h>        /* logger functions                             */
#include <Cglobals.h>
#include <string.h>

#if ! defined(linux) && ! defined( __APPLE__)
extern int      sys_nerr;       /* number of system error messages      */
#endif

#include <net.h>                /*     networking specifics             */

char    *sys_serrlist[SEMAXERR-SEBASEOFF+2]=
        {"Error 0",
         "Host not known",
         "Service unknown",
         "Not a remote file",
         "Timed out",
         "Unsupported FORTRAN format",
         "Unknown FORTRAN option",
         "Incompatible FORTRAN options",
         "File name too long",
         "Can't open configuration file",
         "Version ID mismatch",
         "User buffer too small",
         "Invalid reply number",
         "User message too long",
         "Entry not found",
         "Internal error",
         "Connection closed by remote end",
         "Can't find interface name",
         "Communication error",
         "Can't open mapping database",
         "No user mapping",
         "Retry count exhausted",
         "Operation not supported",
         "Resource temporarily unavailable",
         "Operation now in progress",
         "Cthread initialization error",
         "Thread interface call error",
         "System error",
         "adns_init() error",
         "adns_submit() error",
         "adns resolving error",
         "adns returned more than one entry",
         "requestor is not administrator",
         "User unknown",
         "Duplicate key value",
         "Entry already exists",
         "Group unknown",
         "Bad checksum",
         "Too many symbolic links encountered",
         "BAD ERROR NUMBER"
        };
/*
 * Package specific error messages (don't forget to update h/serrno.h)
 */

/*
 *------------------------------------------------------------------------
 * COPYTAPE specific error messages
 *------------------------------------------------------------------------
 */
char *sys_cerrlist[ECMAXERR-ECBASEOFF+2] =
        {"Error 0",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * DB specific error messages
 *------------------------------------------------------------------------
 */
char *sys_dberrlist[EDBMAXERR-EDBBASEOFF+2] = 
        {"Error 0",
         "Cdb api : invalid Cdb_sess_t parameter",
         "Cdb api : invalid Cdb_db_t parameter",
         "Cdb api : invalid value",
         "Cdb api : Cdb server hostname resolution error (Cgethostbyname)",
         "Cdb api : data size rejected (exceeds theorical value)",
         "Cdb api system : socket() error",
         "Cdb api system : [set/get]sockopt() error",
         "Cdb api system : malloc() error",
         "Cdb api        : no last error",
         "Cdb api : interface invalid value",
         "Cdb api system : bind() error",
         "Cdb api system : listen() error",
         "Cdb api system : getsockname() error",
         "Cdb api system : accept() error",
         "Cdb api system : getpeername() error",
         "Cdb api : connection back from bad host",
         "Error 17",
         "Error 18",
         "Error 19",
         "Cdb daemon : invalid value",
         "Cdb daemon : yet done",
         "Cdb daemon : unauthorized",
         "Cdb daemon : login refused",
         "Cdb daemon : password file corrupted",
         "Cdb daemon : database description analysis error",
         "Cdb daemon : bad hash size",
         "Cdb daemon : unknown database/table/key",
         "Cdb daemon : a lock is required",
         "Cdb daemon : datatabase (probably) corrupted",
         "Cdb daemon : data size rejected (exceeds theorical value)",
         "Cdb daemon : no entry",
         "Cdb daemon : unknown record member type",
         "Cdb daemon : unknown record member val",
         "Cdb daemon : null record member value",
         "Cdb daemon : lock deny",
         "Cdb daemon : attempt to free something Cdb claims it is of zero size",
         "Cdb daemon : shutdown in progress",
         "Cdb daemon : deadlock detected",
         "Cdb daemon : yet exists",
         "Cdb daemon : no more space",
         "Cdb daemon : end of dump",
         "Cdb daemon : uniqued key yet exists",
         "Cdb daemon : end of list",
         "Cdb daemon : not in dump mode",
         "Cdb daemon : double DNS check error",
         "Cdb daemon : Connection rejected (not authorised)",
         "Cdb daemon : init in progress",
         "Cdb daemon : inconsistent request (unstop and no previous stop, unfreeze and no previous freeze)",
         "Cdb daemon : bad free hash size",
         "Cdb daemon system : malloc() error",
         "Cdb daemon system : calloc() error",
         "Cdb daemon system : realloc() error",
         "Cdb daemon system : open() error",
         "Cdb daemon system : fstat() error",
         "Cdb daemon system : lseek() error",
         "Cdb daemon system : read() error",
         "Cdb daemon system : write() error",
         "Cdb daemon system : rename() error",
         "Cdb daemon system : ftruncate() error",
         "Cdb daemon system : tmpnam() error",
         "Cdb daemon system : fcntl() error",
         "Cdb daemon system : mkdir() error",
         "Cdb daemon system : times() error",
         "Cdb daemon system : sysconf() err/unav",
         "Cdb daemon system : Cdb client hostname resolution error (Cgethostbyname)",
         "Cdb daemon system : getpeername() error",
         "Cdb daemon system : inet_ntoa() error",
         "Cdb daemon system : remove() error",
         "Cdb daemon system : sigaction() error",
         "Cdb daemon system : getsockname() error",
         "Cdb daemon system : bind() error",
         "Cdb daemon system : listen() error",
         "Cdb daemon system : connect() error",
         "Cdb daemon system : socket() error",
         "Cdb daemon system : [set/get]socketopt() error",
         "Cdb daemon : Host resolution error",
         "Cdb daemon : Request too big",
         "Error 78",
         "Error 79",
         "Cdb config : invalid configuration value",
         "Cdb config : configuration error",
         "Cdb config : configuration value rejected (exceeds maximum size)",
         "Cdb config system : gethostname() error",
         "Error 84",
         "Error 85",
         "Error 86",
         "Error 87",
         "Error 88",
         "Error 89",
         "Cdb : nomoredb",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * MSG daemon specific error messages
 *------------------------------------------------------------------------
 */
char *sys_mserrlist[EMSMAXERR-EMSBASEOFF+2] =
        {"Error 0",
         "Message daemon unable to reply",
         "Message daemon system error",
         "Permission denied",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * NS (Name Server) specific error messages
 *------------------------------------------------------------------------
 */
char *sys_nserrlist[ENSMAXERR-ENSBASEOFF+2] = 
        {"Error 0",
	 "Name server not active",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * RFIO specific error messages
 *------------------------------------------------------------------------
 */
char *sys_rferrlist[ERFMAXERR-ERFBASEOFF+2] =
        {"Error 0",
         "Host did not return error number",
         "Host is not on local network and no mapping found",
         "Cannot create linked file across hosts",
         "Protocol not supported",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * RTCOPY specific error messages
 *------------------------------------------------------------------------
 */
char *sys_rterrlist[ERTMAXERR-ERTBASEOFF+2] = 
        {"Error 0",
         "TMS error",
         "Blocks skipped in file",
         "Blocks skipped and file limited by size",
         "Too many skipped blocks",
         "File limited by size",
         "Request interrupted by user",
         "Request interrupted by operator",
         "Request list is not circular",
         "Bad request structure", 
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * STAGE specific error messages
 *------------------------------------------------------------------------
 */
char *sys_sterrlist[ESTMAXERR-ESTBASEOFF+2] = 
        {"Error 0",
         "Aborted by stageclr",
         "Enough free space",
         "Symbolic link not created",
         "Symbolic link not supported",
         "Stager not active",
         "Your group is invalid",
         "No GRPUSER in configuration",
         "Invalid user",
         "HSM HOST not specified",
         "tmscheck error",
         "User link name processing error",
         "User path in a non-writable directory",
         "Request killed",
         "Request too long (socket buffer size)",
         "Stage configuration error",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * SYSREQ specific error messages
 *------------------------------------------------------------------------
 */
char *sys_sqerrlist[ESQMAXERR-ESQBASEOFF+2] =
        {"Error 0",
         "TMS not active",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * TAPE specific error messages
 *------------------------------------------------------------------------
 */
char *sys_terrlist[ETMAXERR-ETBASEOFF+2] = 
        {"Error 0",
	 "Tape daemon not available",
	 "System error",
	 "Bad parameter",
	 "Reserve already issued",
	 "Too many drives requested",
	 "Invalid device group name",
	 "Reserve not done",
	 "No drive with requested name/characteristics",
	 "Bad label structure",
	 "Bad file sequence number",
	 "Interrupted by user",
	 "EOV found in multivolume set",
	 "Release pending",
	 "Blank tape",
	 "Compatibility problem",
	 "Device malfunction",
	 "Parity error",
	 "Unrecoverable media error",
	 "No sense",
	 "Reselect server",
	 "Volume busy or inaccessible",
	 "Drive currently assigned",
	 "Drive not ready",
	 "Volume absent",
	 "Volume archived",
	 "Volume held or disabled",
	 "File not expired",
	 "Operator cancel",
	 "Volume unknown",
	 "Wrong label type",
	 "Cartridge write protected",
	 "Wrong vsn",
         "Tape has a bad MIR",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * VAL (Volume Allocator) specific error messages
 *------------------------------------------------------------------------
 */
char *sys_vaerrlist[EVMMAXERR-EVMBASEOFF+2] = 
        {"Error 0",
	 "Volume manager not active",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * UPV (User Privilege Validator) specific error messages
 *------------------------------------------------------------------------
 */
char *sys_uperrlist[EUPMAXERR-EUPBASEOFF+2] = 
        {"Error 0",
	 "UPV not active",
         "BAD ERROR NUMBER"
        };


/*
 *------------------------------------------------------------------------
 * DLF (Distributed Logging Facility) specific error messages
 *------------------------------------------------------------------------
 */
char *sys_dlferrlist[EDLFMAXERR-EDLFBASEOFF+2] =
        {"Error 0",
         "DLF server not active",
	 "Facility was not found in the database",
	 "Can not delete or update parent row: references exist",
	 "Row was not found in the database",
	 "Log file format error",
         "BAD ERROR NUMBER"
        };


/*
 *------------------------------------------------------------------------
 * VDQM (Volume & Drive Queue Manager) specific error messages
 *------------------------------------------------------------------------
 */
char *sys_vqerrlist[EVQMAXERR-EVQBASEOFF+2] = 
        {"Error 0",
         "Failed system call",
         "Internal DB inconsistency",
         "DB replication failed",
         "No volume request queued",
         "No free drive available",
         "Specified vol. req. not found",
         "Specified drv. req. not found",
         "Specified vol. req. already exists",
         "Unit not up",
         "Bad unit status request",
         "Incorrect vol.req or job ID",
         "Incorrect job ID",
         "Unit not assigned",
         "Attempt to mount with wrong VOLID",
         "Attempt to delete an assigned request",
         "Request for non-existing DGN",
         "Replication pipe is full",
         "Server is held",
         "End of query reached",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * RMC (Remote SCSI Media Changer server) specific error messages
 *------------------------------------------------------------------------
 */
char *sys_rmerrlist[ERMMAXERR-ERMBASEOFF+2] = 
        {"Error 0",
	 "Remote SCSI media changer server not active",
	 "Remote SCSI media changer error",
	 "Remote SCSI media changer unrec. error",
	 "Remote SCSI media changer error (slow retry)",
	 "Remote SCSI media changer error (fast retry)",
	 "Remote SCSI media changer error (demount force)",
	 "Remote SCSI media changer error (drive down)",
	 "Remote SCSI media changer error (ops message)",
	 "Remote SCSI media changer error (ops message + retry)",
	 "Remote SCSI media changer error (ops message + wait)",
	 "Remote SCSI media changer error (unload + demount)",
         "BAD ERROR NUMBER"
        };


/*
 *------------------------------------------------------------------------
 * Monitor specific error messages
 *------------------------------------------------------------------------
 */
char *sys_monerrlist[EMONMAXERR - EMONBASEOFF +2] = 
        {"Error 0",
         "System Error",
	 "Monitor Host not specified",
         "Monitor Port not specified",
         "Client port not specified",
         "BAD ERROR NUMBER"
        };

/*
 *------------------------------------------------------------------------
 * Security package errors
 *------------------------------------------------------------------------
 */
char *sys_secerrlist[ESECMAXERR-ESECBASEOFF+2] = 
         {"Error 0",
	  "System error",
          "Bad credentials",
          "Could not secure the connection",
          "Bad magic number",
          "Could not map username to uid/gid",
          "Could not map principal to username",
          "Could not load a security plugin",
          "Context not initialized",
          "Security protocol not supported",
	  "Could not set service name",
	  "Service type not set",
	  "Could not lookup security protocol",
	  "Csec incompatability",
	  "Unexpected response from peer",
          "BAD ERROR NUMBER"
         };

/*
 *------------------------------------------------------------------------
 * Disk Pool Manager package errors
 *------------------------------------------------------------------------
 */
char *sys_dpmerrlist[EDPMMAXERR-EDPMBASEOFF+2] = 
	 {"Error 0",
	  "Disk Pool Manager not active",
	  "BAD ERROR NUMBER"
         };


/*
 *------------------------------------------------------------------------
 * End of package specific error messages
 *------------------------------------------------------------------------
 */

char DLL_DECL *  sstrerror_r(n,buf,buflen)
int     n;
char    *buf;
size_t  buflen;
{
    size_t msglen;
    char *tmpstr;
    if ( buf == NULL || buflen <= 0 ) return(NULL);
    memset(buf,'\0',buflen);
    tmpstr = NULL;

    if ((n>SEBASEOFF) && (n<=SEMAXERR))   {
        /*
         * COMMON error messages
         */
        tmpstr = sys_serrlist[n-SEBASEOFF];
    } else if ((n>ECBASEOFF) && (n<=ECMAXERR))   {
        /*
         * COPYTAPE specific error messages
         */
        tmpstr = sys_cerrlist[n-ECBASEOFF];
    } else if ((n>EDBBASEOFF) && (n<=EDBMAXERR))   {
        /*
         * DB specific error messages
         */
        tmpstr = sys_dberrlist[n-EDBBASEOFF];
    } else if ((n>EMSBASEOFF) && (n<=EMSMAXERR)) {
        /*
         * MSG specific error messages
         */
        tmpstr = sys_mserrlist[n-EMSBASEOFF];
    } else if ((n>ENSBASEOFF) && (n<=ENSMAXERR)) {
        /*
         * NS (Name server) specific error messages
         */
        tmpstr = sys_nserrlist[n-ENSBASEOFF];
    } else if ((n>ERFBASEOFF) && (n<=ERFMAXERR)) {
        /*
         * RFIO specific error messages
         */
        tmpstr = sys_rferrlist[n-ERFBASEOFF];
    } else if ((n>ERTBASEOFF) && (n<=ERTMAXERR)) {
        /*
         * RTCOPY specific error messages
         */
        tmpstr = sys_rterrlist[n-ERTBASEOFF];
    } else if ((n>ESTBASEOFF) && (n<=ESTMAXERR)) {
        /*
         * STAGE specific error messages
         */
        tmpstr = sys_sterrlist[n-ESTBASEOFF];
    } else if ((n>ESQBASEOFF) && (n<=ESQMAXERR)) {
        /*
         * SYSREQ specific error messages
         */
        tmpstr = sys_sqerrlist[n-ESQBASEOFF];
    } else if ((n>ETBASEOFF) && (n<=ETMAXERR)) {
        /*
         * TAPE specific error messages
         */
        tmpstr = sys_terrlist[n-ETBASEOFF];
    } else if ((n>EVMBASEOFF) && (n<=EVMMAXERR)) {
        /*
         * VMGR (Volume manager) specific error messages
         */
        tmpstr = sys_vaerrlist[n-EVMBASEOFF];
    } else if ((n>EUPBASEOFF) && (n<=EUPMAXERR)) {
        /*
         * UPV specific error messages
         */
        tmpstr = sys_uperrlist[n-EUPBASEOFF];
    } else if ((n>EDLFBASEOFF) && (n<=EDLFMAXERR)) {
        /*
         * DLF specific error messages
         */
        tmpstr = sys_dlferrlist[n-EDLFBASEOFF];
     } else if ((n>EVQBASEOFF) && (n<=EVQMAXERR)) {
        /*
         * VDQM (Volume & Drive Queue Manager) specific error messages
         */
        tmpstr = sys_vqerrlist[n-EVQBASEOFF];
    } else if ((n>ERMBASEOFF) && (n<=ERMMAXERR)) {
        /*
         * RMC (Remote SCSI media changer server) specific error messages
         */
        tmpstr = sys_rmerrlist[n-ERMBASEOFF];
    } else if ((n>EMONBASEOFF) && (n<=EMONMAXERR)) {
        /*
         * Monitor specific error messages
         */
        tmpstr = sys_monerrlist[n-EMONBASEOFF];
    } else if ((n>EDPMBASEOFF) && (n<=EDPMMAXERR)) {
        /*
         * DPM (Disk Pool Manager) specific error messages
         */
        tmpstr = sys_dpmerrlist[n-EDPMBASEOFF];
    } else if ((n>ESECBASEOFF) && (n<=ESECMAXERR)) {
        /*
         * Security  specific error messages
         */
        tmpstr = sys_secerrlist[n-ESECBASEOFF];
    } else if ((n>0)
#ifndef linux
			   && (n<sys_nerr)
#endif
		) {
        /*
         * SYSTEM error messages
         */
        tmpstr = (char *) strerror(n);
    } 

    if ( tmpstr != NULL ) {
        msglen = strlen(tmpstr);
        if ( msglen >= buflen ) strncpy(buf,tmpstr,buflen-1);
        else strcpy(buf,tmpstr);
    } else {
        /*
         * Unknown error message
         */
        tmpstr = sys_serrlist[SEMAXERR+1-SEBASEOFF];
        msglen = strlen(tmpstr);
        if ( msglen+15 >= buflen ) strncpy(buf,tmpstr,buflen-1);
        else (void) sprintf(buf,"%s: %d", tmpstr,n);
    }
    return(buf);
}

void DLL_DECL sperror(msg)
char    *msg;
{    
    char buf[80];
    if (serrno)     {
        fprintf(stderr,"%s: %s\n",msg,sstrerror_r(serrno,buf,80));
    } else    {
        perror(msg);
    }
}

static int sstrerror_key = -1;

char DLL_DECL *sstrerror(n)
int n;
{
    char *buf = NULL;
    int buflen = 80;

    Cglobals_get(&sstrerror_key,(void **)&buf,buflen);
    return(sstrerror_r(n,buf,buflen));
}