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
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
13
#define _LARGEFILE64_SOURCE /* needed for unistd.h */
14
#define _FILE_OFFSET_BITS 64 /* needed for unistd.h */
25
#include <sys/ioctl.h>
31
static int api_version;
36
printf("\nprints DASD information:\n\n");
37
printf("dasdview [-b begin] [-s size] [-1|-2] \n"
39
" [-l] [-t {info|f1|f4|f5|f7|all}] \n"
41
" {-n devno|-f node}\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"
49
" for x byte, kilobyte, megabyte, blocks, tracks and\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");
65
dasdview_error(enum dasdview_failure why)
67
char error[2*LINE_LENGTH], *message = error;
72
sprintf(error, "%s open error\n%s\n",
73
DASDVIEW_ERROR, error_str);
76
sprintf(error, "%s seek error\n%s\n",
77
DASDVIEW_ERROR, error_str);
80
sprintf(error, "%s read error\n%s\n",
81
DASDVIEW_ERROR, error_str);
84
sprintf(error, "%s ioctl error\n%s\n",
85
DASDVIEW_ERROR, error_str);
88
sprintf(error, "%s usage error\n%s\n",
89
DASDVIEW_ERROR, error_str);
92
sprintf(error, "%s disk layout error\n%s\n",
93
DASDVIEW_ERROR, error_str);
96
sprintf(error, "%s VTOC error\n%s\n",
97
DASDVIEW_ERROR, error_str);
100
sprintf(error,"%s bug\n%s\n",
101
DASDVIEW_ERROR, error_str);
105
fputs(message, stderr);
112
* replace special characters with dots and question marks
115
dot (unsigned char label[16]) {
120
for (i = 0; i < 16; 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] = '?';
132
dasdview_init_info(dasdview_info_t *info)
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));
139
bzero(&info->geo, sizeof(info->geo));
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;
161
info->vlabel_info = 0;
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));
174
dasdview_get_info(dasdview_info_t *info)
178
f = open(info->device, O_RDONLY);
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",
186
dasdview_error(open_error);
189
// get dasd driver API version
190
if (ioctl(f,DASDAPIVER,&api_version)) {
193
"Could not retrieve DASD_MIN_API_VERSION");
194
dasdview_error(ioctl_error);
197
// check API versions
198
if (api_version < DASD_MIN_API_VERSION) {
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);
207
if (api_version == 1) {
209
sprintf(error_str, "WARNING: The dasd driver API version '1' "
210
"is not supported!\n");
211
dasdview_error(ioctl_error);
215
/* get disk geometry */
216
if (ioctl(f, HDIO_GETGEO, &info->geo) != 0)
219
sprintf(error_str, "Could not retrieve disk geometry " \
221
dasdview_error(ioctl_error);
224
if (ioctl(f, BLKSSZGET, &info->blksize) != 0)
228
"Could not retrieve blocksize information!\n");
229
dasdview_error(ioctl_error);
232
/* get disk information */
233
if (api_version < 2) {
234
if (ioctl(f, BIODASDINFO, &info->dasd_info) != 0) {
236
sprintf(error_str, "Could not retrieve disk information.");
237
dasdview_error(ioctl_error);
239
memcpy(&info->dasd_info2, &info->dasd_info,
240
sizeof(info->dasd_info));
242
if (ioctl(f, BIODASDINFO2, &info->dasd_info2) != 0) {
244
sprintf(error_str, "Could not retrieve disk information.");
245
dasdview_error(ioctl_error);
254
dasdview_parse_input(unsigned long long *p, dasdview_info_t *info, char *s)
256
unsigned long long l=0;
258
switch (s[strlen(s)-1])
262
l = 1024LL * strtoull(s, NULL, 0);
266
l = 1024LL * 1024LL * strtoull(s, NULL, 0);
270
l = (unsigned long long) info->blksize *
271
(unsigned long long) info->geo.sectors *
272
strtoull(s, NULL, 0);
276
l = (unsigned long long) info->blksize *
277
strtoull(s, NULL, 0);
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);
287
l = strtoull(s, NULL, 0);
294
dasdview_print_info(dasdview_info_t *info)
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",
310
info->geo.cylinders);
311
printf("tracks per cylinder : hex %x \tdec %d\n",
314
printf("blocks per track : hex %x \tdec %d\n",
317
printf("blocksize : hex %x \tdec %d\n",
324
dasdview_print_more_info(dasdview_info_t *info)
327
int cpl=16; /* chars per line */
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);
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" :
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" :
389
j = sizeof(info->dasd_info2.characteristics);
390
for (k=0; k<(j/cpl); k++)
393
printf("\ncharacteristics : ");
396
for (i=0; i<cpl; i++)
399
info->dasd_info2.characteristics[k*cpl+i]);
400
if ((i+1)%4 == 0) printf(" ");
401
if ((i+1)%8 == 0) printf(" ");
406
j = sizeof(info->dasd_info2.configuration_data);
407
for (k=0; k<(j/cpl); k++)
410
printf("\nconfiguration_data : ");
413
for (i=0; i<cpl; i++)
416
info->dasd_info2.configuration_data[k*cpl+i]);
417
if ((i+1)%4 == 0) printf(" ");
418
if ((i+1)%8 == 0) printf(" ");
426
dasdview_read_vlabel(dasdview_info_t *info, volume_label_t *vlabel)
431
pos = info->dasd_info2.label_block * info->blksize;
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);
440
/* standard LINUX disk layout */
441
vtoc_read_volume_label(info->device, pos, &tmp);
442
memcpy(vlabel->vollbl, &tmp, sizeof(tmp)-4);
448
dasdview_print_vlabel(dasdview_info_t *info)
450
volume_label_t vlabel;
452
char s4[5], t4[5], s5[6], t5[6], s6[7], t6[7];
453
char s14[15], t14[15], s29[30], t29[30];
456
dasdview_read_vlabel(info, &vlabel);
458
printf("\n--- volume label -----------------------------" \
459
"---------------------------------\n");
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);
466
for (i=0; i<4; i++) printf("%02x", s4[i]);
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);
473
for (i=0; i<4; i++) printf("%02x", s4[i]);
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);
480
for (i=0; i<6; i++) printf("%02x", s6[i]);
482
printf("\n\nsecurity byte : hex %02x\n", vlabel.security);
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))
491
"(cyl %d, trk %d, blk %d)\n\n",
492
vlabel.vtoc.cc, vlabel.vtoc.hh, vlabel.vtoc.b);
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);
499
for (i=0; i<5; i++) printf("%02x", s5[i]);
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);
506
for (i=0; i<4; i++) printf("%02x", s4[i]);
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);
513
for (i=0; i<4; i++) printf("%02x", s4[i]);
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);
520
for (i=0; i<4; i++) printf("%02x", s4[i]);
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);
527
for (i=0; i<4; i++) printf("%02x", s4[i]);
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);
536
printf("%02x", s14[i]);
537
if ((i+1)%4 == 0) printf(" ");
538
if ((i+1)%8 == 0) printf(" ");
541
bzero(s29, 30); strncpy(s29, vlabel.res3, 29);
542
printf("\n\nreserved : ascii '%29s'\n", s29);
544
vtoc_ebcdic_dec(s29, t29, 29);
545
printf(" ebcdic '%29s'\n", t29);
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 " \
560
dasdview_print_volser(dasdview_info_t *info)
562
volume_label_t vlabel;
566
dasdview_read_vlabel(info, &vlabel);
570
strncpy(vollbl, vlabel.vollbl, 4);
571
vtoc_ebcdic_dec(vollbl, vollbl, 4);
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);
577
strncpy(volser, " ", 6);
579
printf("%6.6s\n", volser);
584
dasdview_read_vtoc(dasdview_info_t *info)
586
volume_label_t vlabel;
588
unsigned long pos, vtocblk, maxblk;
591
pos = info->dasd_info2.label_block * info->blksize;
593
bzero(&vlabel, sizeof(vlabel));
594
if ((strncmp(info->dasd_info2.type, "ECKD", 4) == 0) &&
595
(!info->dasd_info2.FBA_layout))
597
/* OS/390 and zOS compatible disk layout */
598
vtoc_read_volume_label(info->device, pos, &vlabel);
602
sprintf(error_str, "%s is not formatted with the z/OS " \
603
"compatible disk layout!\n", info->device);
604
dasdview_error(disk_layout);
607
vtocblk = vlabel.vtoc.cc * info->geo.heads +
608
vlabel.vtoc.hh * info->geo.sectors +
611
maxblk = info->geo.cylinders * info->geo.heads * info->geo.sectors;
613
if ((vtocblk <= 0) || (vtocblk > maxblk))
616
"Volume label VTOC pointer is not valid!\n");
617
dasdview_error(vtoc_error);
620
vtoc_read_label(info->device, (vtocblk - 1) * info->blksize,
621
NULL, &info->f4, NULL, NULL);
623
if ((info->f4.DS4KEYCD[0] != 0x04) ||
624
(info->f4.DS4KEYCD[43] != 0x04) ||
625
(info->f4.DS4IDFMT != 0xf4))
627
/* format4 DSCB is invalid */
628
sprintf(error_str, "Format 4 DSCB is invalid!\n");
629
dasdview_error(vtoc_error);
633
pos = (vtocblk - 1) * info->blksize;
635
for (i=1; i<info->geo.sectors; i++)
637
pos += info->blksize;
638
vtoc_read_label(info->device, pos, &tmp, NULL, NULL, NULL);
640
switch (tmp.DS1FMTID)
643
memcpy(&info->f1[info->f1c], &tmp,
644
sizeof(format1_label_t));
651
memcpy(&info->f5, &tmp, sizeof(format1_label_t));
655
memcpy(&info->f7, &tmp, sizeof(format1_label_t));
659
printf("Unknown label in VTOC detected (id=%x)\n",
666
sprintf(error_str, "More than one FMT4 DSCB!\n");
667
dasdview_error(vtoc_error);
672
sprintf(error_str, "More than one FMT5 DSCB!\n");
673
dasdview_error(vtoc_error);
678
sprintf(error_str, "More than one FMT7 DSCB!\n");
679
dasdview_error(vtoc_error);
685
dasdview_print_vtoc_info(dasdview_info_t *info)
688
char s6[7], s13[14], s44[45];
689
unsigned long l1 ,l2;
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);
701
printf("There are no partitions defined.\n");
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 |" \
709
printf(" +----------------------------------------------+" \
710
"--------------+--------------+\n");
712
for (i=0; i<info->f1c; i++)
715
strncpy(s44, info->f1[i].DS1DSNAM, 44);
716
vtoc_ebcdic_dec(s44, s44, 44);
718
strncpy(s6, info->f1[i].DS1DSSN, 6);
719
vtoc_ebcdic_dec(s6, s6, 6);
721
strncpy(s13, info->f1[i].DS1SYSCD, 13);
722
vtoc_ebcdic_dec(s13, s13, 13);
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;
731
printf(" | %44s | trk | trk |\n",
733
printf(" | data set serial number :" \
735
" %12ld | %12ld |\n", s6, l1, l2);
736
printf(" | system code :" \
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");
757
dasdview_print_vtoc_f1(dasdview_info_t *info)
760
char s6[7], s13[14], s44[45];
766
printf("--- VTOC format 1 labels ----------------------" \
767
"---------------------------------\n");
771
printf("This VTOC doesn't contain a format 1 label.\n");
775
for (j=0; j<info->f1c; j++)
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);
936
dasdview_print_vtoc_f4(dasdview_info_t *info)
940
printf("\n--- VTOC format 4 label ----------------------" \
941
"---------------------------------\n");
945
printf("This VTOC doesn't contain a format 4 label.\n");
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]);
1032
dasdview_print_vtoc_f5(dasdview_info_t *info)
1036
printf("\n--- VTOC format 5 label ----------------------" \
1037
"---------------------------------\n");
1041
printf("This VTOC doesn't contain a format 5 label.\n");
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");
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);
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++)
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);
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);
1083
dasdview_print_vtoc_f7(dasdview_info_t *info)
1087
printf("\n--- VTOC format 7 label ----------------------" \
1088
"---------------------------------\n");
1092
printf("This VTOC doesn't contain a format 7 label.\n");
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");
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);
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++)
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);
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);
1129
dasdview_print_format1(unsigned int size, char *dumpstr)
1132
char asc[17], ebc[17];
1134
for (i = 0; i < size; i++)
1136
if ((i / 16) * 16 == i) {
1138
strncpy(asc, dumpstr + i, 16);
1139
strncpy(ebc, dumpstr + i, 16);
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);
1150
printf("| %16.16s | %16.16s |", asc, ebc);
1158
dasdview_print_format2(unsigned int size,
1160
unsigned long long begin)
1163
char asc[17], ebc[17];
1165
for (i = 0; i < size; i++)
1167
if ((i / 8) * 8 == i) {
1168
printf("\n | %13llu | %13llX | ",
1169
begin + (unsigned long long) i,
1170
begin + (unsigned long long) i);
1172
strncpy(asc, dumpstr + i, 8);
1173
strncpy(ebc, dumpstr + i, 8);
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);
1181
printf("| %8.8s | %8.8s |", asc, ebc);
1189
dasdview_view(dasdview_info_t *info)
1191
char dumpstr[DUMP_STRING_SIZE];
1192
unsigned long long i=0, j=0, k=0, count=0;
1195
unsigned long long a=0;
1198
k = ((info->size) % 16LL);
1202
info->size += (16LL - k);
1205
fd = open(info->device, O_RDONLY);
1208
sprintf(error_str, "Unable to open device %s in read-only" \
1209
"mode!\n", info->device);
1210
dasdview_error(open_error);
1213
j = (info->begin / SEEK_STEP);
1214
k = (info->begin % SEEK_STEP);
1216
/* seek in SEEK_STEP steps */
1217
for (i=1; i <= j; i++)
1219
rc = lseek64(fd, SEEK_STEP, SEEK_CUR);
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);
1228
sprintf(error_str, "Unable to seek in device %s!\n",
1230
dasdview_error(seek_error);
1238
rc = lseek(fd, k, SEEK_CUR);
1242
sprintf(error_str, "Unable to seek in device %s!\n",
1244
dasdview_error(seek_error);
1248
j = info->size / DUMP_STRING_SIZE;
1249
k = info->size % DUMP_STRING_SIZE;
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
"------------------+------------------+");
1263
else if (info->format2)
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
"------+----------+----------+");
1275
count = info->begin;
1276
for (i=1; i <= j; i++)
1278
bzero(dumpstr, DUMP_STRING_SIZE);
1279
rc = read(fd, &dumpstr, DUMP_STRING_SIZE);
1280
if (rc != DUMP_STRING_SIZE)
1283
sprintf(error_str, "Unable to read from device %s!\n",
1285
dasdview_error(read_error);
1289
dasdview_print_format1(DUMP_STRING_SIZE, dumpstr);
1290
else if (info->format2)
1291
dasdview_print_format2(DUMP_STRING_SIZE, dumpstr,
1293
count += DUMP_STRING_SIZE;
1298
bzero(dumpstr, DUMP_STRING_SIZE);
1299
rc = read(fd, &dumpstr, k);
1303
sprintf(error_str, "Unable to read from device %s!\n",
1305
dasdview_error(read_error);
1309
dasdview_print_format1((unsigned int) k, dumpstr);
1310
else if (info->format2)
1311
dasdview_print_format2((unsigned int) k, dumpstr,
1319
printf("\n+----------------------------------------+" \
1320
"------------------+------------------+\n\n");
1322
else if (info->format2)
1324
printf("\n +---------------+---------------+----------------" \
1325
"------+----------+----------+\n\n");
1332
int main(int argc, char * argv[]) {
1334
dasdview_info_t info;
1336
unsigned long long max=0LL;
1338
char *devno_param_str = NULL;
1339
char *begin_param_str = NULL;
1340
char *size_param_str = NULL;
1341
char *endptr = NULL;
1343
dasdview_init_info(&info);
1348
oc = getopt_long(argc, argv, dasdview_getopt_string,
1349
dasdview_getopt_long_options, &index);
1362
printf("dasdview version %s\n", DASDVIEW_VERSION);
1365
begin_param_str = optarg;
1366
info.action_specified = 1;
1367
info.begin_specified = 1;
1370
size_param_str = optarg;
1371
info.action_specified = 1;
1372
info.size_specified = 1;
1383
devno_param_str = optarg;
1384
info.devno_specified = 1;
1387
strcpy(info.device, optarg);
1388
info.node_specified = 1;
1391
info.action_specified = 1;
1392
info.short_info = 1;
1395
info.action_specified = 1;
1399
info.action_specified = 1;
1403
if (strncmp(optarg,"info",4)==0)
1405
else if (strncmp(optarg,"f1",2)==0)
1407
else if (strncmp(optarg,"f4",2)==0)
1409
else if (strncmp(optarg,"f5",2)==0)
1411
else if (strncmp(optarg,"f7",2)==0)
1413
else if (strncmp(optarg,"all",3)==0)
1417
sprintf(error_str, "%s is no valid option!\n",
1419
dasdview_error(usage_error);
1422
info.action_specified = 1;
1425
info.action_specified = 1;
1426
info.vlabel_info = 1;
1434
if (info.devno_specified)
1435
PARSE_PARAM_INTO(info.devno, devno_param_str, 16,
1439
if (!(info.node_specified+info.devno_specified))
1441
sprintf(error_str,"Device not specified!");
1442
dasdview_error(usage_error);
1445
if ((info.node_specified + info.devno_specified) > 1)
1447
sprintf(error_str,"Device can only specified once!");
1448
dasdview_error(usage_error);
1451
if (info.devno_specified)
1453
sprintf(info.device, "/dev/dasd/%04x/device", info.devno);
1456
if ((info.devno_specified) &&
1457
((info.devno < 0x0000)||(info.devno > 0xffff)))
1459
sprintf(error_str,"Devno '%#04x' is not in range " \
1460
"0x0000 - 0xFFFF!", info.devno);
1461
dasdview_error(usage_error);
1464
dasdview_get_info(&info);
1466
if (info.begin_specified)
1468
if (strchr(begin_param_str, '-') != NULL)
1470
sprintf(error_str,"%s is not a valid begin value!",
1472
dasdview_error(usage_error);
1474
dasdview_parse_input(&info.begin, &info, begin_param_str);
1477
info.begin = DEFAULT_BEGIN;
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)
1485
sprintf(error_str,"'begin' value is not within disk range!");
1486
dasdview_error(usage_error);
1489
if (info.size_specified)
1491
if (strchr(size_param_str, '-') != NULL)
1493
sprintf(error_str,"%s is not a valid size value!",
1495
dasdview_error(usage_error);
1497
dasdview_parse_input(&info.size, &info, size_param_str);
1500
info.size = DEFAULT_SIZE;
1504
if ((info.begin_specified || info.size_specified) &&
1505
((info.begin + info.size) > max ) )
1507
sprintf(error_str,"'begin' + 'size' is not within " \
1509
dasdview_error(usage_error);
1512
if ((info.begin_specified || info.size_specified) &&
1513
(!info.format1 && !info.format2))
1518
if ((info.format1 || info.format2) &&
1519
(!info.size_specified && !info.begin_specified))
1521
sprintf(error_str,"Options -1 or -2 make only sense with " \
1522
"options -b or -s!");
1523
dasdview_error(usage_error);
1528
if (info.begin_specified || info.size_specified)
1529
dasdview_view(&info);
1531
if (info.short_info || info.long_info)
1532
dasdview_print_info(&info);
1535
dasdview_print_more_info(&info);
1538
dasdview_print_volser(&info);
1540
if (info.vlabel_info)
1541
dasdview_print_vlabel(&info);
1545
dasdview_read_vtoc(&info);
1548
if (info.vtoc_info || info.vtoc_all)
1550
dasdview_print_vtoc_info(&info);
1553
if (info.vtoc_f4 || info.vtoc_all)
1555
dasdview_print_vtoc_f4(&info);
1558
if (info.vtoc_f5 || info.vtoc_all)
1560
dasdview_print_vtoc_f5(&info);
1563
if (info.vtoc_f7 || info.vtoc_all)
1565
dasdview_print_vtoc_f7(&info);
1568
if (info.vtoc_f1 || info.vtoc_all)
1570
dasdview_print_vtoc_f1(&info);
1573
if (!info.action_specified)
1575
printf("No action specified.\n");