~ubuntu-branches/ubuntu/hoary/s390-tools/hoary

« back to all changes in this revision

Viewing changes to dasdview/dasdview.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2004-06-27 18:45:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040627184515-q7lnvli1j94gr6dv
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * File...........: s390-tools/dasdview/dasdview.c
 
3
 * Author(s)......: Volker Sameske <sameske@de.ibm.com>
 
4
 * Bugreports.to..: <Linux390@de.ibm.com>
 
5
 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2001-2002
 
6
 *
 
7
 * History of changes (starts March 2002)
 
8
 * 2002-03-12 removed dependency to kernel headers
 
9
 * 2002-05-10 changed API version handling
 
10
 * 2002-07-01 added -j option to display volser
 
11
 */
 
12
 
 
13
#define _LARGEFILE64_SOURCE    /* needed for unistd.h */
 
14
#define _FILE_OFFSET_BITS 64   /* needed for unistd.h */
 
15
 
 
16
#include <string.h>
 
17
#include <stdlib.h>
 
18
#include <stdio.h>
 
19
#include <errno.h>
 
20
#include <fcntl.h>
 
21
#include <unistd.h>
 
22
#include <getopt.h>
 
23
 
 
24
#include <sys/stat.h>
 
25
#include <sys/ioctl.h>
 
26
 
 
27
 
 
28
#include "vtoc.h"
 
29
#include "dasdview.h"
 
30
 
 
31
static int api_version;
 
32
 
 
33
static void
 
34
dasdview_usage(void)
 
35
{
 
36
        printf("\nprints DASD information:\n\n");
 
37
        printf("dasdview [-b begin] [-s size] [-1|-2] \n"
 
38
               "         [-i] [-x] [-j]\n"
 
39
               "         [-l] [-t {info|f1|f4|f5|f7|all}] \n"
 
40
               "         [-h] [-?] [-v] \n"
 
41
               "         {-n devno|-f node}\n"
 
42
               "\nwhere:\n"
 
43
               "-b: prints a DASD dump from 'begin'\n"
 
44
               "-s: prints a DASD dump with size 'size'\n"
 
45
               "-1: use format 1 for the dump (default)\n"
 
46
               "-2: use format 2 for the dump\n"
 
47
               "    'begin' and 'size' can have the following format:\n"
 
48
               "    x[k|m|b|t|c]\n"
 
49
               "    for x byte, kilobyte, megabyte, blocks, tracks and\n"
 
50
               "    cylinders\n"
 
51
               "-i: prints general DASD information and geometry\n"
 
52
               "-x: prints extended DASD information\n"
 
53
               "-j: prints the volume serial number (volume identifier)\n"
 
54
               "-l: prints information about the volume label\n"
 
55
               "-t: prints the table of content (VTOC)\n"
 
56
               "-h: prints this usage text\n"
 
57
               "-?: prints this usage text\n"
 
58
               "-v: prints the version number\n"
 
59
               "-n: specifies the device by a device number (needs devfs)\n"
 
60
               "-f: specifies a device by a device node\n");
 
61
}
 
62
 
 
63
 
 
64
static void 
 
65
dasdview_error(enum dasdview_failure why) 
 
66
{
 
67
        char    error[2*LINE_LENGTH], *message = error;
 
68
 
 
69
        switch (why) 
 
70
        {
 
71
        case open_error:
 
72
                sprintf(error, "%s open error\n%s\n", 
 
73
                        DASDVIEW_ERROR, error_str);
 
74
                break;
 
75
        case seek_error:
 
76
                sprintf(error, "%s seek error\n%s\n", 
 
77
                        DASDVIEW_ERROR, error_str);
 
78
                break;
 
79
        case read_error:
 
80
                sprintf(error, "%s read error\n%s\n", 
 
81
                        DASDVIEW_ERROR, error_str);
 
82
                break;
 
83
        case ioctl_error:
 
84
                sprintf(error, "%s ioctl error\n%s\n", 
 
85
                        DASDVIEW_ERROR, error_str);
 
86
                break;
 
87
        case usage_error:
 
88
                sprintf(error, "%s usage error\n%s\n", 
 
89
                        DASDVIEW_ERROR, error_str);
 
90
                break;
 
91
        case disk_layout:
 
92
                sprintf(error, "%s disk layout error\n%s\n", 
 
93
                        DASDVIEW_ERROR, error_str);
 
94
                break;
 
95
        case vtoc_error:
 
96
                sprintf(error, "%s VTOC error\n%s\n", 
 
97
                        DASDVIEW_ERROR, error_str);
 
98
                break;
 
99
        default: 
 
100
                sprintf(error,"%s bug\n%s\n",
 
101
                        DASDVIEW_ERROR, error_str);
 
102
        }
 
103
 
 
104
        fputc('\n', stderr);
 
105
        fputs(message, stderr);
 
106
 
 
107
        exit(-1);
 
108
}
 
109
 
 
110
 
 
111
/*
 
112
 * replace special characters with dots and question marks
 
113
 */
 
114
static void 
 
115
dot (unsigned char label[16]) {
 
116
 
 
117
        int i;
 
118
        unsigned char c; 
 
119
 
 
120
        for (i = 0; i < 16; i++) {
 
121
 
 
122
                c = label[i];
 
123
                if (c <= 0x20) label[i] = '?';
 
124
                if (c == 0x00) label[i] = '.';
 
125
                if (c == 0x60) label[i] = '?';
 
126
                if (c >= 0x7f) label[i] = '?';
 
127
        }
 
128
}
 
129
 
 
130
 
 
131
static void
 
132
dasdview_init_info(dasdview_info_t *info)
 
133
{
 
134
        bzero(info->device, sizeof(info->device));
 
135
        bzero(&info->dasd_info, sizeof(info->dasd_info));
 
136
        bzero(&info->dasd_info2, sizeof(info->dasd_info2));
 
137
        info->blksize = 0;
 
138
        info->devno   = 0x0;
 
139
        bzero(&info->geo, sizeof(info->geo));
 
140
 
 
141
        info->begin   = 0;
 
142
        info->size    = 0;
 
143
        info->format1 = 0;
 
144
        info->format2 = 0;
 
145
 
 
146
        info->action_specified = 0;
 
147
        info->devno_specified  = 0;
 
148
        info->node_specified   = 0;
 
149
        info->begin_specified  = 0;
 
150
        info->size_specified   = 0;
 
151
        info->short_info       = 0;
 
152
        info->long_info        = 0;
 
153
        info->volser           = 0;
 
154
        info->vtoc             = 0;
 
155
        info->vtoc_info        = 0;
 
156
        info->vtoc_f1          = 0;
 
157
        info->vtoc_f4          = 0;
 
158
        info->vtoc_f5          = 0;
 
159
        info->vtoc_f7          = 0;
 
160
        info->vtoc_all         = 0;
 
161
        info->vlabel_info      = 0;
 
162
 
 
163
        bzero(&info->f1, NO_F1_LABELS * sizeof(format1_label_t));
 
164
        bzero(&info->f4, sizeof(format4_label_t));
 
165
        bzero(&info->f5, sizeof(format5_label_t));
 
166
        bzero(&info->f7, sizeof(format7_label_t));
 
167
        info->f1c = 0;
 
168
        info->f4c = 0;
 
169
        info->f5c = 0;
 
170
        info->f7c = 0;
 
171
}
 
172
 
 
173
static void
 
174
dasdview_get_info(dasdview_info_t *info)
 
175
{
 
176
        int f;
 
177
 
 
178
        f = open(info->device, O_RDONLY);
 
179
        if (f == -1)
 
180
        {
 
181
                sprintf(error_str,"Could not open device '%s'.\n"
 
182
                        "Maybe you are using the -n option without devfs or \n"
 
183
                        "you have specified an unknown device or \n"
 
184
                        "you are not authorized to do that.\n", 
 
185
                        info->device);
 
186
                dasdview_error(open_error);
 
187
        }
 
188
 
 
189
        // get dasd driver API version
 
190
        if (ioctl(f,DASDAPIVER,&api_version)) {
 
191
                close(f);
 
192
                sprintf(error_str, 
 
193
                        "Could not retrieve DASD_MIN_API_VERSION");
 
194
                dasdview_error(ioctl_error); 
 
195
        }
 
196
 
 
197
        // check API versions
 
198
        if (api_version < DASD_MIN_API_VERSION) {
 
199
                close(f);
 
200
                sprintf(error_str,
 
201
                        "WARNING: This API version '%d' doesn't match " \
 
202
                        "with the API version of the DASD driver '%d'!\n",
 
203
                        DASD_MIN_API_VERSION, api_version);
 
204
                dasdview_error(ioctl_error);
 
205
        }
 
206
 
 
207
        if (api_version == 1) {
 
208
                close(f);
 
209
                sprintf(error_str, "WARNING: The dasd driver API version '1' "
 
210
                        "is not supported!\n");
 
211
                dasdview_error(ioctl_error);
 
212
        }
 
213
 
 
214
 
 
215
        /* get disk geometry */
 
216
        if (ioctl(f, HDIO_GETGEO, &info->geo) != 0) 
 
217
        {
 
218
                close(f);
 
219
                sprintf(error_str, "Could not retrieve disk geometry " \
 
220
                        "information.");
 
221
                dasdview_error(ioctl_error); 
 
222
        }
 
223
 
 
224
        if (ioctl(f, BLKSSZGET, &info->blksize) != 0)
 
225
        {
 
226
                close(f);
 
227
                sprintf(error_str,
 
228
                        "Could not retrieve blocksize information!\n");
 
229
                dasdview_error(ioctl_error);
 
230
        }
 
231
 
 
232
        /* get disk information */
 
233
        if (api_version < 2) {
 
234
                if (ioctl(f, BIODASDINFO, &info->dasd_info) != 0) {
 
235
                        close(f);
 
236
                        sprintf(error_str, "Could not retrieve disk information.");
 
237
                        dasdview_error(ioctl_error);
 
238
                }
 
239
                memcpy(&info->dasd_info2, &info->dasd_info, 
 
240
                       sizeof(info->dasd_info));
 
241
        } else {
 
242
                if (ioctl(f, BIODASDINFO2, &info->dasd_info2) != 0) {
 
243
                        close(f); 
 
244
                        sprintf(error_str, "Could not retrieve disk information.");
 
245
                        dasdview_error(ioctl_error);
 
246
                }
 
247
        }
 
248
 
 
249
        close(f);
 
250
}
 
251
 
 
252
 
 
253
static void
 
254
dasdview_parse_input(unsigned long long *p, dasdview_info_t *info, char *s)
 
255
{
 
256
        unsigned long long l=0;
 
257
 
 
258
        switch (s[strlen(s)-1]) 
 
259
        {
 
260
                case 'k':
 
261
                case 'K':
 
262
                        l = 1024LL * strtoull(s, NULL, 0);
 
263
                        break;
 
264
                case 'm':
 
265
                case 'M':
 
266
                        l = 1024LL * 1024LL * strtoull(s, NULL, 0);
 
267
                        break;
 
268
                case 't':
 
269
                case 'T':
 
270
                        l = (unsigned long long) info->blksize * 
 
271
                            (unsigned long long) info->geo.sectors * 
 
272
                            strtoull(s, NULL, 0);
 
273
                        break;
 
274
                case 'b':
 
275
                case 'B':
 
276
                        l = (unsigned long long) info->blksize * 
 
277
                            strtoull(s, NULL, 0);
 
278
                        break;
 
279
                case 'c':
 
280
                case 'C':
 
281
                        l = (unsigned long long) info->blksize * 
 
282
                            (unsigned long long) info->geo.sectors *
 
283
                            (unsigned long long) info->geo.heads * 
 
284
                            strtoull(s, NULL, 0);
 
285
                        break;
 
286
                default:
 
287
                        l = strtoull(s, NULL, 0);
 
288
        }
 
289
 
 
290
        *p = l;
 
291
}
 
292
 
 
293
static void
 
294
dasdview_print_info(dasdview_info_t *info)
 
295
{
 
296
        printf("\n--- general DASD information -----------------" \
 
297
               "---------------------------------\n");
 
298
        printf("device node            : %s\n",info->device);
 
299
        printf("device number          : hex %x  \tdec %d\n", 
 
300
               info->dasd_info2.devno,
 
301
               info->dasd_info2.devno);
 
302
        printf("type                   : %4s\n", info->dasd_info2.type);
 
303
        printf("device type            : hex %x  \tdec %d\n", 
 
304
               info->dasd_info2.dev_type,
 
305
               info->dasd_info2.dev_type);
 
306
        printf("\n--- DASD geometry ----------------------------" \
 
307
               "---------------------------------\n");
 
308
        printf("number of cylinders    : hex %x  \tdec %d\n", 
 
309
               info->geo.cylinders,
 
310
               info->geo.cylinders);
 
311
        printf("tracks per cylinder    : hex %x  \tdec %d\n", 
 
312
               info->geo.heads,
 
313
               info->geo.heads);
 
314
        printf("blocks per track       : hex %x  \tdec %d\n", 
 
315
               info->geo.sectors,
 
316
               info->geo.sectors);
 
317
        printf("blocksize              : hex %x  \tdec %d\n", 
 
318
               info->blksize,
 
319
               info->blksize);
 
320
}
 
321
 
 
322
 
 
323
static void
 
324
dasdview_print_more_info(dasdview_info_t *info)
 
325
{
 
326
        int i, j, k;
 
327
        int cpl=16; /* chars per line */
 
328
        
 
329
        printf("\n--- extended DASD information ----------------" \
 
330
               "---------------------------------\n");
 
331
        printf("real device number     : hex %x  \tdec %d\n", 
 
332
               info->dasd_info2.real_devno, 
 
333
               info->dasd_info2.real_devno);
 
334
        printf("subchannel identifier  : hex %x  \tdec %d\n", 
 
335
               info->dasd_info2.schid, 
 
336
               info->dasd_info2.schid);
 
337
        printf("CU type  (SenseID)     : hex %x  \tdec %d\n", 
 
338
               info->dasd_info2.cu_type, 
 
339
               info->dasd_info2.cu_type);
 
340
        printf("CU model (SenseID)     : hex %x  \tdec %d\n", 
 
341
               info->dasd_info2.cu_model,  
 
342
               info->dasd_info2.cu_model);
 
343
        printf("device type  (SenseID) : hex %x  \tdec %d\n", 
 
344
               info->dasd_info2.dev_type, 
 
345
               info->dasd_info2.dev_type);
 
346
        printf("device model (SenseID) : hex %x  \tdec %d\n", 
 
347
               info->dasd_info2.dev_model, 
 
348
               info->dasd_info2.dev_model);
 
349
        printf("open count             : hex %x  \tdec %d\n", 
 
350
               info->dasd_info2.open_count, 
 
351
               info->dasd_info2.open_count);
 
352
        printf("req_queue_len          : hex %x  \tdec %d\n", 
 
353
               info->dasd_info2.req_queue_len, 
 
354
               info->dasd_info2.req_queue_len);
 
355
        printf("chanq_len              : hex %x  \tdec %d\n", 
 
356
               info->dasd_info2.chanq_len, 
 
357
               info->dasd_info2.chanq_len);
 
358
        printf("status                 : hex %x  \tdec %d\n", 
 
359
               info->dasd_info2.status, 
 
360
               info->dasd_info2.status);
 
361
        printf("label_block            : hex %x  \tdec %d\n", 
 
362
               info->dasd_info2.label_block, 
 
363
               info->dasd_info2.label_block);
 
364
        printf("FBA_layout             : hex %x  \tdec %d\n", 
 
365
               info->dasd_info2.FBA_layout, 
 
366
               info->dasd_info2.FBA_layout);
 
367
        printf("characteristics_size   : hex %x  \tdec %d\n", 
 
368
               info->dasd_info2.characteristics_size,
 
369
               info->dasd_info2.characteristics_size);
 
370
        printf("confdata_size          : hex %x  \tdec %d\n", 
 
371
               info->dasd_info2.confdata_size,
 
372
               info->dasd_info2.confdata_size);
 
373
 
 
374
        if (api_version > 1) {
 
375
                printf("format                 : hex %x  \tdec %d      \t%s\n", 
 
376
                       info->dasd_info2.format, 
 
377
                       info->dasd_info2.format,
 
378
                       info->dasd_info2.format == DASD_FORMAT_NONE ? "NOT formatted" :
 
379
                       info->dasd_info2.format == DASD_FORMAT_LDL  ? "LDL formatted" :
 
380
                       info->dasd_info2.format == DASD_FORMAT_CDL  ? "CDL formatted" :
 
381
                       "unknown format");
 
382
                printf("features               : hex %x  \tdec %d      \t%s\n", 
 
383
                       info->dasd_info2.features, 
 
384
                       info->dasd_info2.features,
 
385
                       info->dasd_info2.features == DASD_FEATURE_READONLY ? "ro" :
 
386
                       "default");
 
387
        }
 
388
 
 
389
        j = sizeof(info->dasd_info2.characteristics);
 
390
        for (k=0; k<(j/cpl); k++)
 
391
        {
 
392
                if (k == 0)
 
393
                        printf("\ncharacteristics        : "); 
 
394
                else
 
395
                        printf("                         ");
 
396
                for (i=0; i<cpl; i++)
 
397
                { 
 
398
                        printf("%02x",
 
399
                               info->dasd_info2.characteristics[k*cpl+i]);
 
400
                        if ((i+1)%4 == 0) printf(" ");
 
401
                        if ((i+1)%8 == 0) printf(" ");
 
402
                }
 
403
                printf("\n");
 
404
        }
 
405
 
 
406
        j = sizeof(info->dasd_info2.configuration_data);
 
407
        for (k=0; k<(j/cpl); k++)
 
408
        {
 
409
                if (k == 0)
 
410
                        printf("\nconfiguration_data     : "); 
 
411
                else
 
412
                        printf("                         ");
 
413
                for (i=0; i<cpl; i++)
 
414
                { 
 
415
                        printf("%02x",
 
416
                               info->dasd_info2.configuration_data[k*cpl+i]);
 
417
                        if ((i+1)%4 == 0) printf(" ");
 
418
                        if ((i+1)%8 == 0) printf(" ");
 
419
                }
 
420
                printf("\n");
 
421
        }
 
422
}
 
423
 
 
424
 
 
425
static void
 
426
dasdview_read_vlabel(dasdview_info_t *info, volume_label_t *vlabel)
 
427
{
 
428
        volume_label_t tmp;
 
429
        unsigned long  pos;
 
430
 
 
431
        pos = info->dasd_info2.label_block * info->blksize;
 
432
 
 
433
        bzero(vlabel, sizeof(volume_label_t));
 
434
        if ((strncmp(info->dasd_info2.type, "ECKD", 4) == 0) && 
 
435
            (!info->dasd_info2.FBA_layout)) {
 
436
                /* OS/390 and zOS compatible disk layout */
 
437
                vtoc_read_volume_label(info->device, pos, vlabel);
 
438
        }
 
439
        else {
 
440
                /* standard LINUX disk layout */
 
441
                vtoc_read_volume_label(info->device, pos, &tmp);
 
442
                memcpy(vlabel->vollbl, &tmp, sizeof(tmp)-4);
 
443
        }
 
444
}
 
445
 
 
446
 
 
447
static void
 
448
dasdview_print_vlabel(dasdview_info_t *info)
 
449
{
 
450
        volume_label_t vlabel;
 
451
 
 
452
        char s4[5], t4[5], s5[6], t5[6], s6[7], t6[7];
 
453
        char s14[15], t14[15], s29[30], t29[30];
 
454
        int i;
 
455
 
 
456
        dasdview_read_vlabel(info, &vlabel);
 
457
 
 
458
        printf("\n--- volume label -----------------------------" \
 
459
               "---------------------------------\n");
 
460
 
 
461
        bzero(s4, 5); bzero(t4, 5); strncpy(s4, vlabel.volkey, 4);
 
462
        printf("volume label key        : ascii  '%4s'\n", s4);
 
463
        vtoc_ebcdic_dec(s4, t4, 4);
 
464
        printf("                        : ebcdic '%4s'\n", t4);
 
465
        printf("                        : hex    ");
 
466
        for (i=0; i<4; i++) printf("%02x", s4[i]);
 
467
 
 
468
        bzero(s4, 5); bzero(s4, 5); strncpy(s4, vlabel.vollbl, 4);
 
469
        printf("\n\nvolume label identifier : ascii  '%4s'\n", s4);
 
470
        vtoc_ebcdic_dec(s4, t4, 4);
 
471
        printf("                        : ebcdic '%4s'\n", t4);
 
472
        printf("                        : hex    ");
 
473
        for (i=0; i<4; i++) printf("%02x", s4[i]);
 
474
 
 
475
        bzero(s6, 7); bzero(t6, 7); strncpy(s6, vlabel.volid, 6);
 
476
        printf("\n\nvolume identifier       : ascii  '%6s'\n", s6);
 
477
        vtoc_ebcdic_dec(s6, t6, 6);
 
478
        printf("                        : ebcdic '%6s'\n", t6);
 
479
        printf("                        : hex    ");
 
480
        for (i=0; i<6; i++) printf("%02x", s6[i]);
 
481
 
 
482
        printf("\n\nsecurity byte           : hex    %02x\n", vlabel.security);
 
483
 
 
484
        printf("\n\nVTOC pointer            : hex    %04x%04x%02x ",
 
485
               vlabel.vtoc.cc, vlabel.vtoc.hh, vlabel.vtoc.b);
 
486
        if ((vlabel.vtoc.cc == 0x4040) && (vlabel.vtoc.hh == 0x4040) && 
 
487
            (vlabel.vtoc.b == 0x40))
 
488
                printf("\n");
 
489
        else
 
490
                printf("\n                                 " \
 
491
                       "(cyl %d, trk %d, blk %d)\n\n", 
 
492
                       vlabel.vtoc.cc, vlabel.vtoc.hh, vlabel.vtoc.b);
 
493
 
 
494
        bzero(s5, 6); bzero(t5, 6); strncpy(s5, vlabel.res1, 5);
 
495
        printf("reserved                : ascii  '%5s'\n", s5);
 
496
        vtoc_ebcdic_dec(s5, t5, 5);
 
497
        printf("                        : ebcdic '%5s'\n", t5);
 
498
        printf("                        : hex    ");
 
499
        for (i=0; i<5; i++) printf("%02x", s5[i]);
 
500
 
 
501
        bzero(s4, 5); bzero(t4, 5); strncpy(s4, vlabel.cisize, 4);
 
502
        printf("\n\nCI size for FBA         : ascii  '%4s'\n", s4);
 
503
        vtoc_ebcdic_dec(s4, t4, 4);
 
504
        printf("                        : ebcdic '%4s'\n", t4);
 
505
        printf("                        : hex    ");
 
506
        for (i=0; i<4; i++) printf("%02x", s4[i]);
 
507
 
 
508
        bzero(s4, 5); bzero(t4,5); strncpy(s4, vlabel.blkperci, 4);
 
509
        printf("\n\nblocks per CI (FBA)     : ascii  '%4s'\n", s4);
 
510
        vtoc_ebcdic_dec(s4, t4, 4);
 
511
        printf("                        : ebcdic '%4s'\n", t4);
 
512
        printf("                        : hex    ");
 
513
        for (i=0; i<4; i++) printf("%02x", s4[i]);
 
514
 
 
515
        bzero(s4, 5); bzero(t4, 5); strncpy(s4, vlabel.labperci, 4);
 
516
        printf("\n\nlabels per CI (FBA)     : ascii  '%4s'\n", s4);
 
517
        vtoc_ebcdic_dec(s4, t4, 4);
 
518
        printf("                        : ebcdic '%4s'\n", t4);
 
519
        printf("                        : hex    ");
 
520
        for (i=0; i<4; i++) printf("%02x", s4[i]);
 
521
 
 
522
        bzero(s4, 5); bzero(t4, 5); strncpy(s4, vlabel.res2, 4);
 
523
        printf("\n\nreserved                : ascii  '%4s'\n", s4);
 
524
        vtoc_ebcdic_dec(s4, t4, 4);
 
525
        printf("                        : ebcdic '%4s'\n", t4);
 
526
        printf("                        : hex    ");
 
527
        for (i=0; i<4; i++) printf("%02x", s4[i]);
 
528
 
 
529
        bzero(s14, 15); bzero(t14, 15); strncpy(s14, vlabel.lvtoc, 14);
 
530
        printf("\n\nowner code for VTOC     : ascii  '%14s'\n", s14);
 
531
        vtoc_ebcdic_dec(s14, t14, 14);
 
532
        printf("                          ebcdic '%14s'\n", t14);
 
533
        printf("                          hex    ");
 
534
        for (i=0; i<14; i++) 
 
535
        {
 
536
                printf("%02x", s14[i]);
 
537
                if ((i+1)%4 == 0) printf(" ");
 
538
                if ((i+1)%8 == 0) printf(" ");
 
539
        }
 
540
 
 
541
        bzero(s29, 30); strncpy(s29, vlabel.res3, 29);
 
542
        printf("\n\nreserved                : ascii  '%29s'\n", s29);
 
543
        bzero(t29, 30);
 
544
        vtoc_ebcdic_dec(s29, t29, 29);
 
545
        printf("                          ebcdic '%29s'\n", t29);
 
546
        printf("                          hex    ");
 
547
        for (i=0; i<29; i++) 
 
548
        {
 
549
                printf("%02x", s29[i]);
 
550
                if ((i+1)%4 == 0) printf(" ");
 
551
                if ((i+1)%8 == 0) printf(" ");
 
552
                if ((i+1)%16 == 0) printf("\n                " \
 
553
                                          "                 ");
 
554
        }
 
555
        printf("\n");
 
556
}
 
557
 
 
558
 
 
559
static void
 
560
dasdview_print_volser(dasdview_info_t *info)
 
561
{
 
562
        volume_label_t vlabel;
 
563
        char           volser[7];
 
564
        char           vollbl[5];
 
565
 
 
566
        dasdview_read_vlabel(info, &vlabel);
 
567
 
 
568
        bzero(vollbl, 5); 
 
569
        bzero(volser, 7); 
 
570
        strncpy(vollbl, vlabel.vollbl, 4);
 
571
        vtoc_ebcdic_dec(vollbl, vollbl, 4);
 
572
 
 
573
        if ((strncmp(vollbl, "VOL1", 4) == 0)||(strncmp(vollbl, "LNX1", 4) == 0)) {
 
574
                strncpy(volser, vlabel.volid, 6);
 
575
                vtoc_ebcdic_dec(volser, volser, 6);
 
576
        } else
 
577
                strncpy(volser, "      ", 6);
 
578
 
 
579
        printf("%6.6s\n", volser);
 
580
}
 
581
 
 
582
 
 
583
static void
 
584
dasdview_read_vtoc(dasdview_info_t *info)
 
585
{
 
586
        volume_label_t vlabel;
 
587
        format1_label_t tmp;
 
588
        unsigned long pos, vtocblk, maxblk;
 
589
        int i;
 
590
 
 
591
        pos = info->dasd_info2.label_block * info->blksize;
 
592
 
 
593
        bzero(&vlabel, sizeof(vlabel));
 
594
        if ((strncmp(info->dasd_info2.type, "ECKD", 4) == 0) && 
 
595
            (!info->dasd_info2.FBA_layout))
 
596
        {
 
597
                /* OS/390 and zOS compatible disk layout */
 
598
                vtoc_read_volume_label(info->device, pos, &vlabel);
 
599
        }
 
600
        else
 
601
        {
 
602
                sprintf(error_str, "%s is not formatted with the z/OS " \
 
603
                        "compatible disk layout!\n", info->device);
 
604
                dasdview_error(disk_layout);
 
605
        }
 
606
 
 
607
        vtocblk = vlabel.vtoc.cc * info->geo.heads +
 
608
                vlabel.vtoc.hh * info->geo.sectors +
 
609
                vlabel.vtoc.b;
 
610
 
 
611
        maxblk = info->geo.cylinders * info->geo.heads * info->geo.sectors;
 
612
 
 
613
        if ((vtocblk <= 0) || (vtocblk > maxblk))
 
614
        {
 
615
                sprintf(error_str, 
 
616
                        "Volume label VTOC pointer is not valid!\n");
 
617
                dasdview_error(vtoc_error);
 
618
        } 
 
619
 
 
620
        vtoc_read_label(info->device, (vtocblk - 1) * info->blksize, 
 
621
                        NULL, &info->f4, NULL, NULL);
 
622
 
 
623
        if ((info->f4.DS4KEYCD[0] != 0x04) || 
 
624
            (info->f4.DS4KEYCD[43] != 0x04) || 
 
625
            (info->f4.DS4IDFMT != 0xf4)) 
 
626
        {
 
627
                /* format4 DSCB is invalid */
 
628
                sprintf(error_str, "Format 4 DSCB is invalid!\n");
 
629
                dasdview_error(vtoc_error);
 
630
        }
 
631
 
 
632
        info->f4c++;
 
633
        pos = (vtocblk - 1) * info->blksize;
 
634
 
 
635
        for (i=1; i<info->geo.sectors; i++)
 
636
        {
 
637
                pos += info->blksize;
 
638
                vtoc_read_label(info->device, pos, &tmp, NULL, NULL, NULL);
 
639
 
 
640
                switch (tmp.DS1FMTID)
 
641
                {
 
642
                  case 0xf1:
 
643
                          memcpy(&info->f1[info->f1c], &tmp, 
 
644
                                 sizeof(format1_label_t));
 
645
                          info->f1c++;
 
646
                          break;
 
647
                  case 0xf4:
 
648
                          info->f4c++;
 
649
                          break;
 
650
                  case 0xf5:
 
651
                          memcpy(&info->f5, &tmp, sizeof(format1_label_t));
 
652
                          info->f5c++;
 
653
                          break;
 
654
                  case 0xf7:
 
655
                          memcpy(&info->f7, &tmp, sizeof(format1_label_t));
 
656
                          info->f7c++;
 
657
                          break;
 
658
                  default:
 
659
                          printf("Unknown label in VTOC detected (id=%x)\n",
 
660
                                 tmp.DS1FMTID);
 
661
                }
 
662
        }
 
663
 
 
664
        if (info->f4c > 1)
 
665
        {
 
666
                sprintf(error_str, "More than one FMT4 DSCB!\n");
 
667
                dasdview_error(vtoc_error);
 
668
        }
 
669
 
 
670
        if (info->f5c > 1)
 
671
        {
 
672
                sprintf(error_str, "More than one FMT5 DSCB!\n");
 
673
                dasdview_error(vtoc_error);
 
674
        }
 
675
 
 
676
        if (info->f7c > 1)
 
677
        {
 
678
                sprintf(error_str, "More than one FMT7 DSCB!\n");
 
679
                dasdview_error(vtoc_error);
 
680
        }
 
681
}
 
682
 
 
683
 
 
684
static void
 
685
dasdview_print_vtoc_info(dasdview_info_t *info)
 
686
{
 
687
        int i;
 
688
        char s6[7], s13[14], s44[45];
 
689
        unsigned long l1 ,l2;
 
690
 
 
691
        printf("--- VTOC info --------------------------------" \
 
692
               "---------------------------------\n");
 
693
        printf("The VTOC contains:\n");
 
694
        printf("  %d format 1 label(s)\n", info->f1c);
 
695
        printf("  %d format 4 label(s)\n", info->f4c);
 
696
        printf("  %d format 5 label(s)\n", info->f5c);
 
697
        printf("  %d format 7 label(s)\n", info->f7c);
 
698
 
 
699
        if (info->f1c < 1)
 
700
        {
 
701
                printf("There are no partitions defined.\n");
 
702
        } else {
 
703
                printf("Other S/390 and zSeries operating systems would see " \
 
704
                       "the following data sets:\n");
 
705
                printf(" +----------------------------------------------+" \
 
706
                       "--------------+--------------+\n");
 
707
                printf(" | data set                                     |" \
 
708
                       " start        | end          |\n");
 
709
                printf(" +----------------------------------------------+" \
 
710
                       "--------------+--------------+\n");
 
711
 
 
712
                for (i=0; i<info->f1c; i++)
 
713
                {
 
714
                        bzero(s44, 45);
 
715
                        strncpy(s44, info->f1[i].DS1DSNAM, 44);
 
716
                        vtoc_ebcdic_dec(s44, s44, 44);
 
717
                        bzero(s6, 7);
 
718
                        strncpy(s6, info->f1[i].DS1DSSN, 6);
 
719
                        vtoc_ebcdic_dec(s6, s6, 6);
 
720
                        bzero(s13, 14);
 
721
                        strncpy(s13, info->f1[i].DS1SYSCD, 13);
 
722
                        vtoc_ebcdic_dec(s13, s13, 13);
 
723
 
 
724
                        l1 = (unsigned long) info->f1[i].DS1EXT1.llimit.cc *
 
725
                             (unsigned long) info->geo.heads +
 
726
                             (unsigned long) info->f1[i].DS1EXT1.llimit.hh;
 
727
                        l2 = (unsigned long) info->f1[i].DS1EXT1.ulimit.cc *
 
728
                             (unsigned long) info->geo.heads +
 
729
                             (unsigned long) info->f1[i].DS1EXT1.ulimit.hh;
 
730
 
 
731
                        printf(" | %44s |          trk |          trk |\n",
 
732
                               s44);
 
733
                        printf(" | data set serial number :" \
 
734
                               " '%6s'            |" \
 
735
                               " %12ld | %12ld |\n", s6, l1, l2);
 
736
                        printf(" | system code            :" \
 
737
                               " '%13s'     |" \
 
738
                               "      cyl/trk |      cyl/trk |\n", s13);
 
739
                        printf(" | creation date          :" \
 
740
                               "  year %4d, day %3d |" \
 
741
                               " %8d/%3d | %8d/%3d |\n",
 
742
                               info->f1[i].DS1CREDT.year + 1900,
 
743
                               info->f1[i].DS1CREDT.day,
 
744
                               info->f1[i].DS1EXT1.llimit.cc,
 
745
                               info->f1[i].DS1EXT1.llimit.hh,
 
746
                               info->f1[i].DS1EXT1.ulimit.cc,
 
747
                               info->f1[i].DS1EXT1.ulimit.hh);
 
748
                        printf(" +-----------------------------------------" \
 
749
                               "-----+--------------+--------------+\n");
 
750
                }
 
751
        }
 
752
 
 
753
}
 
754
 
 
755
 
 
756
static void
 
757
dasdview_print_vtoc_f1(dasdview_info_t *info)
 
758
{
 
759
        int i, j;
 
760
        char s6[7], s13[14], s44[45];
 
761
 
 
762
        bzero(s6, 7);
 
763
        bzero(s13, 14);
 
764
        bzero(s44, 45);
 
765
 
 
766
        printf("--- VTOC format 1 labels ----------------------" \
 
767
               "---------------------------------\n");
 
768
 
 
769
        if (info->f1c < 1)
 
770
        {
 
771
                printf("This VTOC doesn't contain a format 1 label.\n");
 
772
                return;
 
773
        }
 
774
 
 
775
        for (j=0; j<info->f1c; j++)
 
776
        {
 
777
                printf("\n--- format 1 DSCB number %d ---\n", j+1);
 
778
                strncpy(s44, info->f1[j].DS1DSNAM, 44);
 
779
                printf("DS1DSNAM    : ascii  '%44s'\n", s44);
 
780
                vtoc_ebcdic_dec(s44, s44, 44);
 
781
                printf("              ebcdic '%44s'\n", s44);
 
782
                printf("DS1FMTID    : dec %d, hex %02x\n", 
 
783
                       info->f1[j].DS1FMTID, info->f1[j].DS1FMTID);
 
784
                printf("DS1DSSN     : hex    ");
 
785
                for (i=0; i<6; i++) printf("%02x", info->f1[j].DS1DSSN[i]);
 
786
                strncpy(s6, info->f1[j].DS1DSSN, 6);
 
787
                printf("\n              ascii  '%6s'\n", s6);
 
788
                vtoc_ebcdic_dec(s6, s6, 6);
 
789
                printf("              ebcdic '%6s'\n", s6);
 
790
                printf("DS1VOLSQ    : dec %d, hex %04x\n", 
 
791
                       info->f1[j].DS1VOLSQ, info->f1[j].DS1VOLSQ);
 
792
                printf("DS1CREDT    : hex %02x%04x " \
 
793
                       "(year %d, day %d)\n", 
 
794
                       info->f1[j].DS1CREDT.year, info->f1[j].DS1CREDT.day,
 
795
                       info->f1[j].DS1CREDT.year + 1900, 
 
796
                       info->f1[j].DS1CREDT.day);
 
797
                printf("DS1EXPDT    : hex %02x%04x " \
 
798
                       "(year %d, day %d)\n", 
 
799
                       info->f1[j].DS1EXPDT.year, info->f1[j].DS1EXPDT.day,
 
800
                       info->f1[j].DS1EXPDT.year + 1900, 
 
801
                       info->f1[j].DS1EXPDT.day);
 
802
                printf("DS1NOEPV    : dec %d, hex %02x\n", 
 
803
                       info->f1[j].DS1NOEPV, info->f1[j].DS1NOEPV);
 
804
                printf("DS1NOBDB    : dec %d, hex %02x\n", 
 
805
                       info->f1[j].DS1NOBDB, info->f1[j].DS1NOBDB);
 
806
                printf("DS1FLAG1    : dec %d, hex %02x\n", 
 
807
                       info->f1[j].DS1FLAG1, info->f1[j].DS1FLAG1);
 
808
                printf("DS1SYSCD    : hex    ");
 
809
                for (i=0; i<13; i++) printf("%02x", info->f1[j].DS1SYSCD[i]);
 
810
                strncpy(s13, info->f1[j].DS1SYSCD, 13);
 
811
                printf("\n              ascii  '%13s'\n", s13);
 
812
                vtoc_ebcdic_dec(s13, s13, 13);
 
813
                printf("              ebcdic '%13s'\n", s13);
 
814
                printf("DS1REFD     : hex %02x%04x " \
 
815
                       "(year %d, day %d)\n", 
 
816
                       info->f1[j].DS1REFD.year, info->f1[j].DS1REFD.day,
 
817
                       info->f1[j].DS1REFD.year + 1900, 
 
818
                       info->f1[j].DS1REFD.day);
 
819
                printf("DS1SMSFG    : dec %d, hex %02x\n", 
 
820
                       info->f1[j].DS1SMSFG, info->f1[j].DS1SMSFG);
 
821
                printf("DS1SCXTF    : dec %d, hex %02x\n", 
 
822
                       info->f1[j].DS1SCXTF, info->f1[j].DS1SCXTF);
 
823
                printf("DS1SCXTV    : dec %d, hex %04x\n", 
 
824
                       info->f1[j].DS1SCXTV, info->f1[j].DS1SCXTV);
 
825
                printf("DS1DSRG1    : dec %d, hex %02x\n", 
 
826
                       info->f1[j].DS1DSRG1, info->f1[j].DS1DSRG1);
 
827
                printf("DS1DSRG2    : dec %d, hex %02x\n", 
 
828
                       info->f1[j].DS1DSRG2, info->f1[j].DS1DSRG2);
 
829
                printf("DS1RECFM    : dec %d, hex %02x\n", 
 
830
                       info->f1[j].DS1RECFM, info->f1[j].DS1RECFM);
 
831
                printf("DS1OPTCD    : dec %d, hex %02x\n", 
 
832
                       info->f1[j].DS1OPTCD, info->f1[j].DS1OPTCD);
 
833
                printf("DS1BLKL     : dec %d, hex %04x\n", 
 
834
                       info->f1[j].DS1BLKL, info->f1[j].DS1BLKL);
 
835
                printf("DS1LRECL    : dec %d, hex %04x\n", 
 
836
                       info->f1[j].DS1LRECL, info->f1[j].DS1LRECL);
 
837
                printf("DS1KEYL     : dec %d, hex %02x\n", 
 
838
                       info->f1[j].DS1KEYL, info->f1[j].DS1KEYL);
 
839
                printf("DS1RKP      : dec %d, hex %04x\n", 
 
840
                       info->f1[j].DS1RKP, info->f1[j].DS1RKP);
 
841
                printf("DS1DSIND    : dec %d, hex %02x\n", 
 
842
                       info->f1[j].DS1DSIND, info->f1[j].DS1DSIND);
 
843
                printf("DS1SCAL1    : dec %d, hex %02x\n", 
 
844
                       info->f1[j].DS1SCAL1, info->f1[j].DS1SCAL1);
 
845
                printf("DS1SCAL3    : hex ");
 
846
                for (i=0; i<3; i++) printf("%02x", info->f1[j].DS1SCAL3[i]);
 
847
                printf("\nDS1LSTAR    : hex %04x%02x " \
 
848
                       "(trk %d, blk %d)\n", 
 
849
                       info->f1[j].DS1LSTAR.tt, info->f1[j].DS1LSTAR.r,
 
850
                       info->f1[j].DS1LSTAR.tt, info->f1[j].DS1LSTAR.r);
 
851
                printf("DS1TRBAL    : dec %d, hex %04x\n", 
 
852
                       info->f1[j].DS1TRBAL, info->f1[j].DS1TRBAL);
 
853
                printf("reserved    : dec %d, hex %04x\n",
 
854
                       info->f1[j].res1, info->f1[j].res1);
 
855
                printf("DS1EXT1     : hex %02x%02x%04x%04x%04x%04x\n",
 
856
                       info->f1[j].DS1EXT1.typeind,   
 
857
                       info->f1[j].DS1EXT1.seqno,
 
858
                       info->f1[j].DS1EXT1.llimit.cc, 
 
859
                       info->f1[j].DS1EXT1.llimit.hh,
 
860
                       info->f1[j].DS1EXT1.ulimit.cc, 
 
861
                       info->f1[j].DS1EXT1.ulimit.hh);
 
862
                printf("              typeind    : dec %d, hex %02x\n", 
 
863
                       info->f1[j].DS1EXT1.typeind, 
 
864
                       info->f1[j].DS1EXT1.typeind);
 
865
                printf("              seqno      : dec %d, hex %02x\n", 
 
866
                       info->f1[j].DS1EXT1.seqno, info->f1[j].DS1EXT1.seqno);
 
867
                printf("              llimit     : hex %04x%04x " \
 
868
                       "(cyl %d, trk %d)\n", 
 
869
                       info->f1[j].DS1EXT1.llimit.cc, 
 
870
                       info->f1[j].DS1EXT1.llimit.hh,
 
871
                       info->f1[j].DS1EXT1.llimit.cc, 
 
872
                       info->f1[j].DS1EXT1.llimit.hh);
 
873
                printf("              ulimit     : hex %04x%04x " \
 
874
                       "(cyl %d, trk %d)\n", 
 
875
                       info->f1[j].DS1EXT1.ulimit.cc, 
 
876
                       info->f1[j].DS1EXT1.ulimit.hh,
 
877
                       info->f1[j].DS1EXT1.ulimit.cc, 
 
878
                       info->f1[j].DS1EXT1.ulimit.hh);
 
879
                printf("DS1EXT2     : hex %02x%02x%04x%04x%04x%04x\n",
 
880
                       info->f1[j].DS1EXT2.typeind,   
 
881
                       info->f1[j].DS1EXT2.seqno,
 
882
                       info->f1[j].DS1EXT2.llimit.cc, 
 
883
                       info->f1[j].DS1EXT2.llimit.hh,
 
884
                       info->f1[j].DS1EXT2.ulimit.cc, 
 
885
                       info->f1[j].DS1EXT2.ulimit.hh);
 
886
                printf("              typeind    : dec %d, hex %02x\n", 
 
887
                       info->f1[j].DS1EXT2.typeind, 
 
888
                       info->f1[j].DS1EXT2.typeind);
 
889
                printf("              seqno      : dec %d, hex %02x\n", 
 
890
                       info->f1[j].DS1EXT2.seqno, info->f1[j].DS1EXT2.seqno);
 
891
                printf("              llimit     : hex %04x%04x " \
 
892
                       "(cyl %d, trk %d)\n", 
 
893
                       info->f1[j].DS1EXT2.llimit.cc, 
 
894
                       info->f1[j].DS1EXT2.llimit.hh,
 
895
                       info->f1[j].DS1EXT2.llimit.cc, 
 
896
                       info->f1[j].DS1EXT2.llimit.hh);
 
897
                printf("              ulimit     : hex %04x%04x " \
 
898
                       "(cyl %d, trk %d)\n", 
 
899
                       info->f1[j].DS1EXT2.ulimit.cc, 
 
900
                       info->f1[j].DS1EXT2.ulimit.hh,
 
901
                       info->f1[j].DS1EXT2.ulimit.cc, 
 
902
                       info->f1[j].DS1EXT2.ulimit.hh);
 
903
                printf("DS1EXT3     : hex %02x%02x%04x%04x%04x%04x\n",
 
904
                       info->f1[j].DS1EXT3.typeind,   
 
905
                       info->f1[j].DS1EXT3.seqno,
 
906
                       info->f1[j].DS1EXT3.llimit.cc, 
 
907
                       info->f1[j].DS1EXT3.llimit.hh,
 
908
                       info->f1[j].DS1EXT3.ulimit.cc, 
 
909
                       info->f1[j].DS1EXT3.ulimit.hh);
 
910
                printf("              typeind    : dec %d, hex %02x\n", 
 
911
                       info->f1[j].DS1EXT3.typeind, 
 
912
                       info->f1[j].DS1EXT3.typeind);
 
913
                printf("              seqno      : dec %d, hex %02x\n", 
 
914
                       info->f1[j].DS1EXT3.seqno, info->f1[j].DS1EXT3.seqno);
 
915
                printf("              llimit     : hex %04x%04x " \
 
916
                       "(cyl %d, trk %d)\n", 
 
917
                       info->f1[j].DS1EXT3.llimit.cc, 
 
918
                       info->f1[j].DS1EXT3.llimit.hh,
 
919
                       info->f1[j].DS1EXT3.llimit.cc, 
 
920
                       info->f1[j].DS1EXT3.llimit.hh);
 
921
                printf("              ulimit     : hex %04x%04x " \
 
922
                       "(cyl %d, trk %d)\n", 
 
923
                       info->f1[j].DS1EXT3.ulimit.cc, 
 
924
                       info->f1[j].DS1EXT3.ulimit.hh,
 
925
                       info->f1[j].DS1EXT3.ulimit.cc, 
 
926
                       info->f1[j].DS1EXT3.ulimit.hh);
 
927
                printf("DS1PTRDS    : %04x%04x%02x " \
 
928
                       "(cyl %d, trk %d, blk %d)\n", 
 
929
                       info->f1[j].DS1PTRDS.cc, info->f1[j].DS1PTRDS.hh, 
 
930
                       info->f1[j].DS1PTRDS.b,  info->f1[j].DS1PTRDS.cc, 
 
931
                       info->f1[j].DS1PTRDS.hh, info->f1[j].DS1PTRDS.b);
 
932
        }  
 
933
}
 
934
 
 
935
static void
 
936
dasdview_print_vtoc_f4(dasdview_info_t *info)
 
937
{
 
938
        int i;
 
939
 
 
940
        printf("\n--- VTOC format 4 label ----------------------" \
 
941
               "---------------------------------\n");
 
942
 
 
943
        if (info->f4c < 1)
 
944
        {
 
945
                printf("This VTOC doesn't contain a format 4 label.\n");
 
946
                return;
 
947
        }
 
948
 
 
949
        printf("DS4KEYCD    : ");
 
950
        for (i=0; i<44; i++) printf("%02x", info->f4.DS4KEYCD[i]);
 
951
        printf("\nDS4IDFMT    : dec %d, hex %02x\n", 
 
952
               info->f4.DS4IDFMT, info->f4.DS4IDFMT);
 
953
        printf("DS4HPCHR    : %04x%04x%02x " \
 
954
               "(cyl %d, trk %d, blk %d)\n", 
 
955
               info->f4.DS4HPCHR.cc, info->f4.DS4HPCHR.hh, 
 
956
               info->f4.DS4HPCHR.b,  info->f4.DS4HPCHR.cc, 
 
957
               info->f4.DS4HPCHR.hh, info->f4.DS4HPCHR.b);
 
958
        printf("DS4DSREC    : dec %d, hex %04x\n", 
 
959
               info->f4.DS4DSREC, info->f4.DS4DSREC);
 
960
        printf("DS4HCCHH    : %04x%04x (cyl %d, trk %d)\n", 
 
961
               info->f4.DS4HCCHH.cc, info->f4.DS4HCCHH.hh, 
 
962
               info->f4.DS4HCCHH.cc, info->f4.DS4HCCHH.hh);
 
963
        printf("DS4NOATK    : dec %d, hex %04x\n", 
 
964
               info->f4.DS4NOATK, info->f4.DS4NOATK);
 
965
        printf("DS4VTOCI    : dec %d, hex %02x\n", 
 
966
               info->f4.DS4VTOCI, info->f4.DS4VTOCI);
 
967
        printf("DS4NOEXT    : dec %d, hex %02x\n", 
 
968
               info->f4.DS4NOEXT, info->f4.DS4NOEXT);
 
969
        printf("DS4SMSFG    : dec %d, hex %02x\n", 
 
970
               info->f4.DS4SMSFG, info->f4.DS4SMSFG);
 
971
        printf("DS4DEVAC    : dec %d, hex %02x\n", 
 
972
               info->f4.DS4DEVAC, info->f4.DS4DEVAC);
 
973
        printf("DS4DSCYL    : dec %d, hex %04x\n", 
 
974
               info->f4.DS4DEVCT.DS4DSCYL, info->f4.DS4DEVCT.DS4DSCYL);
 
975
        printf("DS4DSTRK    : dec %d, hex %04x\n", 
 
976
               info->f4.DS4DEVCT.DS4DSTRK, info->f4.DS4DEVCT.DS4DSTRK);
 
977
        printf("DS4DEVTK    : dec %d, hex %04x\n", 
 
978
               info->f4.DS4DEVCT.DS4DEVTK, info->f4.DS4DEVCT.DS4DEVTK);
 
979
        printf("DS4DEVI     : dec %d, hex %02x\n", 
 
980
               info->f4.DS4DEVCT.DS4DEVI, info->f4.DS4DEVCT.DS4DEVI);
 
981
        printf("DS4DEVL     : dec %d, hex %02x\n", 
 
982
               info->f4.DS4DEVCT.DS4DEVL, info->f4.DS4DEVCT.DS4DEVL);
 
983
        printf("DS4DEVK     : dec %d, hex %02x\n", 
 
984
               info->f4.DS4DEVCT.DS4DEVK, info->f4.DS4DEVCT.DS4DEVK);
 
985
        printf("DS4DEVFG    : dec %d, hex %02x\n", 
 
986
               info->f4.DS4DEVCT.DS4DEVFG, info->f4.DS4DEVCT.DS4DEVFG);
 
987
        printf("DS4DEVTL    : dec %d, hex %04x\n", 
 
988
               info->f4.DS4DEVCT.DS4DEVTL, info->f4.DS4DEVCT.DS4DEVTL);
 
989
        printf("DS4DEVDT    : dec %d, hex %02x\n", 
 
990
               info->f4.DS4DEVCT.DS4DEVDT, info->f4.DS4DEVCT.DS4DEVDT);
 
991
        printf("DS4DEVDB    : dec %d, hex %02x\n", 
 
992
               info->f4.DS4DEVCT.DS4DEVDB, info->f4.DS4DEVCT.DS4DEVDB);
 
993
        printf("DS4AMTIM    : hex ");
 
994
        for (i=0; i<8; i++) printf("%02x", info->f4.DS4AMTIM[i]);
 
995
        printf("\nDS4AMCAT    : hex ");
 
996
        for (i=0; i<3; i++) printf("%02x", info->f4.DS4AMCAT[i]);
 
997
        printf("\nDS4R2TIM    : hex ");
 
998
        for (i=0; i<8; i++) printf("%02x", info->f4.DS4R2TIM[i]);
 
999
        printf("\nres1        : hex ");
 
1000
        for (i=0; i<5; i++) printf("%02x", info->f4.res1[i]);   
 
1001
        printf("\nDS4F6PTR    : hex ");
 
1002
        for (i=0; i<5; i++) printf("%02x", info->f4.DS4F6PTR[i]);
 
1003
        printf("\nDS4VTOCE    : hex %02x%02x%04x%04x%04x%04x\n",
 
1004
               info->f4.DS4VTOCE.typeind, info->f4.DS4VTOCE.seqno,
 
1005
               info->f4.DS4VTOCE.llimit.cc, info->f4.DS4VTOCE.llimit.hh,
 
1006
               info->f4.DS4VTOCE.ulimit.cc, info->f4.DS4VTOCE.ulimit.hh);
 
1007
        printf("              typeind    : dec %d, hex %02x\n", 
 
1008
               info->f4.DS4VTOCE.typeind, info->f4.DS4VTOCE.typeind);
 
1009
        printf("              seqno      : dec %d, hex %02x\n", 
 
1010
               info->f4.DS4VTOCE.seqno, info->f4.DS4VTOCE.seqno);
 
1011
        printf("              llimit     : hex %04x%04x (cyl %d, trk %d)\n", 
 
1012
               info->f4.DS4VTOCE.llimit.cc, info->f4.DS4VTOCE.llimit.hh,
 
1013
               info->f4.DS4VTOCE.llimit.cc, info->f4.DS4VTOCE.llimit.hh);
 
1014
        printf("              ulimit     : hex %04x%04x (cyl %d, trk %d)\n", 
 
1015
               info->f4.DS4VTOCE.ulimit.cc, info->f4.DS4VTOCE.ulimit.hh,
 
1016
               info->f4.DS4VTOCE.ulimit.cc, info->f4.DS4VTOCE.ulimit.hh);
 
1017
        printf("res2        : hex ");
 
1018
        for (i=0; i<10; i++) printf("%02x", info->f4.res2[i]);
 
1019
        printf("\nDS4EFLVL    : dec %d, hex %02x\n", 
 
1020
               info->f4.DS4EFLVL, info->f4.DS4EFLVL);
 
1021
        printf("DS4EFPTR    : hex %04x%04x%02x " \
 
1022
               "(cyl %d, trk %d, blk %d)\n", 
 
1023
               info->f4.DS4EFPTR.cc, info->f4.DS4EFPTR.hh,
 
1024
               info->f4.DS4EFPTR.b,  info->f4.DS4EFPTR.cc, 
 
1025
               info->f4.DS4EFPTR.hh, info->f4.DS4EFPTR.b);
 
1026
        printf("res3        : hex ");
 
1027
        for (i=0; i<9; i++) printf("%02x", info->f4.res3[i]);
 
1028
        printf("\n");
 
1029
}
 
1030
 
 
1031
static void
 
1032
dasdview_print_vtoc_f5(dasdview_info_t *info)
 
1033
{
 
1034
        int i;
 
1035
 
 
1036
        printf("\n--- VTOC format 5 label ----------------------" \
 
1037
               "---------------------------------\n");
 
1038
 
 
1039
        if (info->f5c < 1)
 
1040
        {
 
1041
                printf("This VTOC doesn't contain a format 5 label.\n");
 
1042
                return;
 
1043
        }
 
1044
 
 
1045
        printf("key identifier\n        DS5KEYID    : ");
 
1046
        for (i=0; i<4; i++) printf("%02x", info->f5.DS5KEYID[i]);
 
1047
        printf("\nfirst extent description\n");
 
1048
        printf("        DS5AVEXT    : %04x%04x%02x " \
 
1049
               "(start trk: %d, length: %d cyl, %d trk)\n", 
 
1050
               info->f5.DS5AVEXT.t,  info->f5.DS5AVEXT.fc, 
 
1051
               info->f5.DS5AVEXT.ft, info->f5.DS5AVEXT.t, 
 
1052
               info->f5.DS5AVEXT.fc, info->f5.DS5AVEXT.ft);
 
1053
        printf("next 7 extent descriptions\n");
 
1054
        for (i=0; i<7; i++)
 
1055
        {
 
1056
                printf("        DS5EXTAV[%d] : %04x%04x%02x " \
 
1057
                       "(start trk: %d, length: %d cyl, %d trk)\n", i+2,
 
1058
                       info->f5.DS5EXTAV[i].t,  info->f5.DS5EXTAV[i].fc, 
 
1059
                       info->f5.DS5EXTAV[i].ft, info->f5.DS5EXTAV[i].t, 
 
1060
                       info->f5.DS5EXTAV[i].fc, info->f5.DS5EXTAV[i].ft);
 
1061
        }
 
1062
        printf("format identifier\n" \
 
1063
               "        DS5FMTID    : dec %d, hex %02x\n", 
 
1064
               info->f5.DS5FMTID, info->f5.DS5FMTID);
 
1065
        printf("next 18 extent descriptions\n");
 
1066
        for (i=0; i<18; i++)
 
1067
        {
 
1068
                printf("        DS5MAVET[%d] : %04x%04x%02x " \
 
1069
                       "(start trk: %d, length: %d cyl, %d trk)\n", i+9,
 
1070
                       info->f5.DS5MAVET[i].t,  info->f5.DS5MAVET[i].fc, 
 
1071
                       info->f5.DS5MAVET[i].ft, info->f5.DS5MAVET[i].t, 
 
1072
                       info->f5.DS5MAVET[i].fc, info->f5.DS5MAVET[i].ft);
 
1073
        }
 
1074
        printf("pointer to next format 5 label\n" \
 
1075
               "        DS5PTRDS    : %04x%04x%02x " \
 
1076
               "(cyl %d, trk %d, blk %d)\n", 
 
1077
               info->f5.DS5PTRDS.cc, info->f5.DS5PTRDS.hh, 
 
1078
               info->f5.DS5PTRDS.b,  info->f5.DS5PTRDS.cc, 
 
1079
               info->f5.DS5PTRDS.hh, info->f5.DS5PTRDS.b);
 
1080
}
 
1081
 
 
1082
static void
 
1083
dasdview_print_vtoc_f7(dasdview_info_t *info)
 
1084
{
 
1085
        int i;
 
1086
 
 
1087
        printf("\n--- VTOC format 7 label ----------------------" \
 
1088
               "---------------------------------\n");
 
1089
          
 
1090
        if (info->f7c < 1)
 
1091
        {
 
1092
                printf("This VTOC doesn't contain a format 7 label.\n");
 
1093
                return;
 
1094
        }
 
1095
 
 
1096
        printf("key identifier\n        DS7KEYID    : ");
 
1097
        for (i=0; i<4; i++) printf("%02x", info->f7.DS7KEYID[i]);
 
1098
        printf("\nfirst 5 extent descriptions\n");
 
1099
        for (i=0; i<5; i++)
 
1100
        {
 
1101
                printf("        DS7EXTNT[%d] : %08x %08x " \
 
1102
                       "(start trk %d, end trk %d)\n", i+1, 
 
1103
                       info->f7.DS7EXTNT[i].a, info->f7.DS7EXTNT[i].b,
 
1104
                       info->f7.DS7EXTNT[i].a, info->f7.DS7EXTNT[i].b);
 
1105
        }
 
1106
        printf("format identifier\n" \
 
1107
               "        DS7FMTID    : dec %d, hex %02x\n", 
 
1108
               info->f7.DS7FMTID, info->f7.DS7FMTID);
 
1109
        printf("next 11 extent descriptions\n");
 
1110
        for (i=0; i<11; i++)
 
1111
        {
 
1112
                printf("        DS7ADEXT[%d] : %08x %08x " \
 
1113
                       "(start trk %d, end trk %d)\n", i+6,  
 
1114
                       info->f7.DS7ADEXT[i].a, info->f7.DS7ADEXT[i].b,
 
1115
                       info->f7.DS7ADEXT[i].a, info->f7.DS7ADEXT[i].b);
 
1116
        }
 
1117
        printf("reserved field\n        res1        : ");
 
1118
        for (i=0; i<2; i++) printf("%02x", info->f7.res1[i]);
 
1119
        printf("\npointer to next format 7 label\n" \
 
1120
               "        DS7PTRDS    : %04x%04x%02x " \
 
1121
               "(cyl %d, trk %d, blk %d)\n", 
 
1122
               info->f7.DS7PTRDS.cc, info->f7.DS7PTRDS.hh, 
 
1123
               info->f7.DS7PTRDS.b, info->f7.DS7PTRDS.cc, 
 
1124
               info->f7.DS7PTRDS.hh, info->f7.DS7PTRDS.b);
 
1125
}
 
1126
 
 
1127
 
 
1128
static int
 
1129
dasdview_print_format1(unsigned int size, char *dumpstr)
 
1130
{
 
1131
        unsigned int i;
 
1132
        char asc[17], ebc[17];
 
1133
 
 
1134
        for (i = 0; i < size; i++)
 
1135
        {
 
1136
                if ((i / 16) * 16 == i) { 
 
1137
                        printf("\n|  ");
 
1138
                        strncpy(asc, dumpstr + i, 16);
 
1139
                        strncpy(ebc, dumpstr + i, 16);
 
1140
                        asc[16] = '\0';
 
1141
                        ebc[16] = '\0';
 
1142
                }
 
1143
                printf("%02X", dumpstr[i]);
 
1144
                if (((i + 1) / 4)  * 4  == i + 1) printf(" ");
 
1145
                if (((i + 1) / 8)  * 8  == i + 1) printf(" ");
 
1146
                if (((i + 1) / 16) * 16 == i + 1) {
 
1147
                        vtoc_ebcdic_dec(asc, asc, 16);
 
1148
                        dot(asc);
 
1149
                        dot(ebc);
 
1150
                        printf("| %16.16s | %16.16s |", asc, ebc);
 
1151
                }
 
1152
        }
 
1153
 
 
1154
        return 0;
 
1155
}
 
1156
 
 
1157
static int
 
1158
dasdview_print_format2(unsigned int size, 
 
1159
                       char *dumpstr,
 
1160
                       unsigned long long begin)
 
1161
{
 
1162
        unsigned int i;
 
1163
        char asc[17], ebc[17];
 
1164
 
 
1165
        for (i = 0; i < size; i++)
 
1166
        {
 
1167
                if ((i / 8) * 8 == i) {
 
1168
                        printf("\n | %13llu | %13llX |  ", 
 
1169
                               begin + (unsigned long long) i,
 
1170
                               begin + (unsigned long long) i);
 
1171
 
 
1172
                        strncpy(asc, dumpstr + i, 8);
 
1173
                        strncpy(ebc, dumpstr + i, 8);
 
1174
                }
 
1175
                printf("%02X", dumpstr[i]);
 
1176
                if (((i + 1) / 4) * 4 == i + 1) printf("  ");
 
1177
                if (((i + 1) / 8) * 8 == i + 1) {
 
1178
                        vtoc_ebcdic_dec(asc, asc, 8);
 
1179
                        dot(asc);
 
1180
                        dot(ebc);
 
1181
                        printf("| %8.8s | %8.8s |", asc, ebc);
 
1182
                }
 
1183
        }
 
1184
 
 
1185
        return 0;
 
1186
}
 
1187
 
 
1188
static int 
 
1189
dasdview_view(dasdview_info_t *info)
 
1190
{
 
1191
        char  dumpstr[DUMP_STRING_SIZE];
 
1192
        unsigned long long i=0, j=0, k=0, count=0;
 
1193
        int   fd, rc;
 
1194
 
 
1195
        unsigned long long a=0;
 
1196
        int b=0;
 
1197
 
 
1198
        k = ((info->size) % 16LL);
 
1199
 
 
1200
        if (k != 0) 
 
1201
        {
 
1202
                info->size += (16LL - k);
 
1203
        }
 
1204
 
 
1205
        fd = open(info->device, O_RDONLY);
 
1206
        if (fd == -1)
 
1207
        {
 
1208
                sprintf(error_str, "Unable to open device %s in read-only" \
 
1209
                        "mode!\n", info->device);
 
1210
                dasdview_error(open_error);
 
1211
        }
 
1212
 
 
1213
        j = (info->begin / SEEK_STEP);
 
1214
        k = (info->begin % SEEK_STEP);
 
1215
 
 
1216
        /* seek in SEEK_STEP steps */
 
1217
        for (i=1; i <= j; i++)
 
1218
        {
 
1219
                rc = lseek64(fd, SEEK_STEP, SEEK_CUR); 
 
1220
                if (rc == -1) 
 
1221
                {
 
1222
                        printf("*** rc: %d (%d) ***\n", rc, errno);
 
1223
                        printf("*** j: %llu ***\n", j);
 
1224
                        printf("*** k: %llu ***\n", k);
 
1225
                        printf("*** a: %llu ***\n", a);
 
1226
                        printf("*** b: %d ***\n", b);
 
1227
                        close(fd);
 
1228
                        sprintf(error_str, "Unable to seek in device %s!\n", 
 
1229
                                info->device);
 
1230
                        dasdview_error(seek_error);
 
1231
                }
 
1232
                b++;
 
1233
                a += SEEK_STEP;
 
1234
        }
 
1235
 
 
1236
        if (k > 0)
 
1237
        {
 
1238
                rc = lseek(fd, k, SEEK_CUR); 
 
1239
                if (rc == -1) 
 
1240
                {
 
1241
                        close(fd);
 
1242
                        sprintf(error_str, "Unable to seek in device %s!\n", 
 
1243
                                info->device);
 
1244
                        dasdview_error(seek_error);
 
1245
                }
 
1246
        }               
 
1247
 
 
1248
        j = info->size / DUMP_STRING_SIZE;
 
1249
        k = info->size % DUMP_STRING_SIZE;
 
1250
 
 
1251
 
 
1252
        if (info->format1)
 
1253
        {
 
1254
                printf("+----------------------------------------+" \
 
1255
                       "------------------+------------------+\n");
 
1256
                printf("| HEXADECIMAL                            |" \
 
1257
                       " EBCDIC           | ASCII            |\n");
 
1258
                printf("|  01....04 05....08  09....12 13....16  |" \
 
1259
                       " 1.............16 | 1.............16 |\n");
 
1260
                printf("+----------------------------------------+" \
 
1261
                       "------------------+------------------+");
 
1262
        } 
 
1263
        else if (info->format2)
 
1264
        {
 
1265
                printf(" +---------------+---------------+----------------" \
 
1266
                       "------+----------+----------+\n");
 
1267
                printf(" |     BYTE      |     BYTE      |     HEXADECIMAL" \
 
1268
                       "      |  EBCDIC  |  ASCII   |\n");
 
1269
                printf(" |    DECIMAL    |  HEXADECIMAL  |  1 2 3 4   5 6 " \
 
1270
                       "7 8   | 12345678 | 12345678 |\n");
 
1271
                printf(" +---------------+---------------+----------------" \
 
1272
                       "------+----------+----------+");
 
1273
        }
 
1274
 
 
1275
        count = info->begin;
 
1276
        for (i=1; i <= j; i++)
 
1277
        {
 
1278
                bzero(dumpstr, DUMP_STRING_SIZE);
 
1279
                rc = read(fd, &dumpstr, DUMP_STRING_SIZE);
 
1280
                if (rc != DUMP_STRING_SIZE) 
 
1281
                {
 
1282
                        close(fd);
 
1283
                        sprintf(error_str, "Unable to read from device %s!\n",
 
1284
                                info->device);
 
1285
                        dasdview_error(read_error);
 
1286
                }
 
1287
 
 
1288
                if (info->format1)
 
1289
                        dasdview_print_format1(DUMP_STRING_SIZE, dumpstr);
 
1290
                else if (info->format2)
 
1291
                        dasdview_print_format2(DUMP_STRING_SIZE, dumpstr,
 
1292
                                               count);
 
1293
                count += DUMP_STRING_SIZE;
 
1294
        }
 
1295
 
 
1296
        if (k > 0)
 
1297
        {
 
1298
                bzero(dumpstr, DUMP_STRING_SIZE);
 
1299
                rc = read(fd, &dumpstr, k);
 
1300
                if (rc != k) 
 
1301
                {
 
1302
                        close(fd);
 
1303
                        sprintf(error_str, "Unable to read from device %s!\n",
 
1304
                                info->device);
 
1305
                        dasdview_error(read_error);
 
1306
                }
 
1307
 
 
1308
                if (info->format1)
 
1309
                        dasdview_print_format1((unsigned int) k, dumpstr);
 
1310
                else if (info->format2)
 
1311
                        dasdview_print_format2((unsigned int) k, dumpstr,
 
1312
                                               count);
 
1313
        }
 
1314
 
 
1315
        close(fd);
 
1316
 
 
1317
        if (info->format1)
 
1318
        {
 
1319
                printf("\n+----------------------------------------+" \
 
1320
                       "------------------+------------------+\n\n");
 
1321
        }
 
1322
        else if (info->format2)
 
1323
        {
 
1324
                printf("\n +---------------+---------------+----------------" \
 
1325
                       "------+----------+----------+\n\n");
 
1326
        }
 
1327
        
 
1328
        return 0;
 
1329
}
 
1330
 
 
1331
 
 
1332
int main(int argc, char * argv[]) {
 
1333
 
 
1334
        dasdview_info_t info;
 
1335
        int oc, index;
 
1336
        unsigned long long max=0LL;
 
1337
 
 
1338
        char *devno_param_str = NULL;
 
1339
        char *begin_param_str = NULL;
 
1340
        char *size_param_str  = NULL;
 
1341
        char *endptr          = NULL;
 
1342
 
 
1343
        dasdview_init_info(&info);
 
1344
 
 
1345
        opterr=0;
 
1346
        while (1)
 
1347
        {
 
1348
                oc = getopt_long(argc, argv, dasdview_getopt_string,
 
1349
                                 dasdview_getopt_long_options, &index);
 
1350
                if (oc==-1) break;
 
1351
 
 
1352
                switch (oc) 
 
1353
                {
 
1354
                case '?':
 
1355
                case 'h':
 
1356
                        dasdview_usage();
 
1357
                        exit(0);
 
1358
                case ':':
 
1359
                        dasdview_usage();
 
1360
                        exit(1);
 
1361
                case 'v':
 
1362
                        printf("dasdview version %s\n", DASDVIEW_VERSION);
 
1363
                        exit(0);
 
1364
                case 'b':
 
1365
                        begin_param_str = optarg;
 
1366
                        info.action_specified = 1;
 
1367
                        info.begin_specified = 1;
 
1368
                        break;
 
1369
                case 's':
 
1370
                        size_param_str = optarg;
 
1371
                        info.action_specified = 1;
 
1372
                        info.size_specified = 1;
 
1373
                        break;
 
1374
                case '1':
 
1375
                        info.format1 = 1;
 
1376
                        info.format2 = 0;
 
1377
                        break;
 
1378
                case '2':
 
1379
                        info.format1 = 0;
 
1380
                        info.format2 = 1;
 
1381
                        break;
 
1382
                case 'n':
 
1383
                        devno_param_str = optarg;
 
1384
                        info.devno_specified = 1;
 
1385
                        break;
 
1386
                case 'f':
 
1387
                        strcpy(info.device, optarg);
 
1388
                        info.node_specified = 1;
 
1389
                        break;
 
1390
                case 'i':
 
1391
                        info.action_specified = 1;
 
1392
                        info.short_info = 1;
 
1393
                        break;
 
1394
                case 'x':
 
1395
                        info.action_specified = 1;
 
1396
                        info.long_info = 1;
 
1397
                        break;
 
1398
                case 'j':
 
1399
                        info.action_specified = 1;
 
1400
                        info.volser = 1;
 
1401
                        break;
 
1402
                case 't':
 
1403
                        if (strncmp(optarg,"info",4)==0)
 
1404
                                info.vtoc_info = 1;
 
1405
                        else if (strncmp(optarg,"f1",2)==0)
 
1406
                                info.vtoc_f1 = 1;
 
1407
                        else if (strncmp(optarg,"f4",2)==0)
 
1408
                                info.vtoc_f4 = 1;
 
1409
                        else if (strncmp(optarg,"f5",2)==0)
 
1410
                                info.vtoc_f5 = 1;
 
1411
                        else if (strncmp(optarg,"f7",2)==0)
 
1412
                                info.vtoc_f7 = 1;
 
1413
                        else if (strncmp(optarg,"all",3)==0)
 
1414
                                info.vtoc_all = 1;
 
1415
                        else
 
1416
                        {
 
1417
                                sprintf(error_str, "%s is no valid option!\n",
 
1418
                                        optarg);
 
1419
                                dasdview_error(usage_error);
 
1420
                        }
 
1421
                        info.vtoc = 1;
 
1422
                        info.action_specified = 1;
 
1423
                        break;
 
1424
                case 'l':
 
1425
                        info.action_specified = 1;
 
1426
                        info.vlabel_info = 1;
 
1427
                        break;
 
1428
                default:
 
1429
                        dasdview_usage();
 
1430
                        exit(0);
 
1431
                }
 
1432
        }
 
1433
 
 
1434
        if (info.devno_specified)
 
1435
                PARSE_PARAM_INTO(info.devno, devno_param_str, 16,
 
1436
                                 "device number");
 
1437
 
 
1438
        /* do some tests */
 
1439
        if (!(info.node_specified+info.devno_specified))
 
1440
        {
 
1441
                sprintf(error_str,"Device not specified!");
 
1442
                dasdview_error(usage_error);
 
1443
        }
 
1444
 
 
1445
        if ((info.node_specified + info.devno_specified) > 1)
 
1446
        {
 
1447
                sprintf(error_str,"Device can only specified once!");
 
1448
                dasdview_error(usage_error);
 
1449
        }
 
1450
 
 
1451
        if (info.devno_specified)
 
1452
        {
 
1453
                sprintf(info.device, "/dev/dasd/%04x/device", info.devno);
 
1454
        }
 
1455
 
 
1456
        if ((info.devno_specified) && 
 
1457
            ((info.devno < 0x0000)||(info.devno > 0xffff)))
 
1458
        {
 
1459
                sprintf(error_str,"Devno '%#04x' is not in range " \
 
1460
                        "0x0000 - 0xFFFF!", info.devno);
 
1461
                dasdview_error(usage_error);
 
1462
        }
 
1463
 
 
1464
        dasdview_get_info(&info);
 
1465
 
 
1466
        if (info.begin_specified)
 
1467
        {
 
1468
                if (strchr(begin_param_str, '-') != NULL)
 
1469
                {
 
1470
                        sprintf(error_str,"%s is not a valid begin value!",
 
1471
                                begin_param_str);                       
 
1472
                        dasdview_error(usage_error);
 
1473
                }
 
1474
                dasdview_parse_input(&info.begin, &info, begin_param_str);
 
1475
        }       
 
1476
        else 
 
1477
                info.begin = DEFAULT_BEGIN;
 
1478
 
 
1479
        max = (unsigned long long) info.geo.cylinders * 
 
1480
                (unsigned long long) info.geo.heads * 
 
1481
                (unsigned long long) info.geo.sectors * 
 
1482
                (unsigned long long) info.blksize;
 
1483
        if (info.begin > max)
 
1484
        {
 
1485
                sprintf(error_str,"'begin' value is not within disk range!");
 
1486
                dasdview_error(usage_error);
 
1487
        }
 
1488
 
 
1489
        if (info.size_specified)
 
1490
        {
 
1491
                if (strchr(size_param_str, '-') != NULL)
 
1492
                {
 
1493
                        sprintf(error_str,"%s is not a valid size value!",
 
1494
                                size_param_str);                        
 
1495
                        dasdview_error(usage_error);
 
1496
                }
 
1497
                dasdview_parse_input(&info.size, &info, size_param_str);
 
1498
        }       
 
1499
        else
 
1500
                info.size = DEFAULT_SIZE;
 
1501
 
 
1502
 
 
1503
 
 
1504
        if ((info.begin_specified || info.size_specified) && 
 
1505
            ((info.begin + info.size) > max             )   ) 
 
1506
        {
 
1507
                sprintf(error_str,"'begin' + 'size' is not within " \
 
1508
                        "disk range!");
 
1509
                dasdview_error(usage_error);
 
1510
        }
 
1511
 
 
1512
        if ((info.begin_specified || info.size_specified) && 
 
1513
            (!info.format1 && !info.format2))
 
1514
        {
 
1515
                info.format1 = 1;
 
1516
        }
 
1517
 
 
1518
        if ((info.format1 || info.format2) && 
 
1519
            (!info.size_specified && !info.begin_specified))
 
1520
        {
 
1521
                sprintf(error_str,"Options -1 or -2 make only sense with " \
 
1522
                        "options -b or -s!");
 
1523
                dasdview_error(usage_error);
 
1524
        }
 
1525
 
 
1526
        /* do the output */
 
1527
 
 
1528
        if (info.begin_specified || info.size_specified)
 
1529
                dasdview_view(&info);
 
1530
 
 
1531
        if (info.short_info || info.long_info)
 
1532
                dasdview_print_info(&info);
 
1533
 
 
1534
        if (info.long_info)
 
1535
                dasdview_print_more_info(&info);
 
1536
 
 
1537
        if (info.volser)
 
1538
                dasdview_print_volser(&info);
 
1539
 
 
1540
        if (info.vlabel_info)
 
1541
                dasdview_print_vlabel(&info);
 
1542
 
 
1543
        if (info.vtoc)
 
1544
        {
 
1545
                dasdview_read_vtoc(&info);
 
1546
        }
 
1547
 
 
1548
        if (info.vtoc_info || info.vtoc_all)
 
1549
        {
 
1550
                dasdview_print_vtoc_info(&info);
 
1551
        }
 
1552
 
 
1553
        if (info.vtoc_f4 || info.vtoc_all)
 
1554
        {
 
1555
                dasdview_print_vtoc_f4(&info);
 
1556
        }
 
1557
 
 
1558
        if (info.vtoc_f5 || info.vtoc_all)
 
1559
        {
 
1560
                dasdview_print_vtoc_f5(&info);
 
1561
        }
 
1562
 
 
1563
        if (info.vtoc_f7 || info.vtoc_all)
 
1564
        {
 
1565
                dasdview_print_vtoc_f7(&info);
 
1566
        }
 
1567
 
 
1568
        if (info.vtoc_f1 || info.vtoc_all)
 
1569
        {
 
1570
                dasdview_print_vtoc_f1(&info);
 
1571
        }
 
1572
 
 
1573
        if (!info.action_specified)
 
1574
        {
 
1575
                printf("No action specified.\n");
 
1576
        }
 
1577
                
 
1578
        return 0;
 
1579
}
 
1580
 
 
1581
 
 
1582
 
 
1583
 
 
1584
 
 
1585
 
 
1586
 
 
1587
 
 
1588
 
 
1589
 
 
1590
 
 
1591
 
 
1592
 
 
1593
 
 
1594
 
 
1595
 
 
1596
 
 
1597
 
 
1598
 
 
1599
 
 
1600
 
 
1601
 
 
1602
 
 
1603
 
 
1604
 
 
1605
 
 
1606
 
 
1607
 
 
1608
 
 
1609
 
 
1610
 
 
1611
 
 
1612
 
 
1613
 
 
1614
 
 
1615
 
 
1616
 
 
1617
 
 
1618
 
 
1619
 
 
1620
 
 
1621
 
 
1622
 
 
1623
 
 
1624
 
 
1625
 
 
1626
 
 
1627
 
 
1628
 
 
1629