File: lsdasd

package info (click to toggle)
s390-tools 2.3.0-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 6,176 kB
  • sloc: ansic: 87,755; sh: 8,398; cpp: 8,384; perl: 3,783; makefile: 1,476; asm: 654
file content (801 lines) | stat: -rwxr-xr-x 19,255 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
#!/bin/bash
#
# lsdasd - Tool to list information about DASDs
#
# Copyright IBM Corp. 2003, 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#

CMD=$(basename $0)
SYSFSDIR="/sys"

#------------------------------------------------------------------------------
# Print usage
#------------------------------------------------------------------------------
function PrintUsage() {
	cat <<-EOD
		Usage: $(basename $0) <options> [<device>]

		<options> ::=
		 	-a|--offline
		 		Include devices that are currently offline.
		 	-b|--base
		 		Include only base devices.
		 	-h|--help
		 		Print this text and exit.
		 	-s|--short
		 		Strip leading 0.0. from bus IDs.
		 	-u|--uid
		 		Print and sort by uid.
		 	-c|--compat
		 		Print old version of lsdasd output.
		 	-l|--long
		 		Print extended information about DASDs.
		 	-H|--host-access-list
		 		Print information about hosts accessing DASDs.
		 	-v|--verbose
		 		For compatibility/future use. Currently ignored.
		 	--version
		 		Show tools and command version.

		<device> ::= <bus ID>
		 	Limit output to one or more devices which are given as a bus ID.
	EOD
}

function PrintVersion()
{
	cat <<-EOD
	$CMD: version %S390_TOOLS_VERSION%
	Copyright IBM Corp. 2003, 2017
	EOD
}

#------------------------------------------------------------------------------
# Helper function to check a device string.
#------------------------------------------------------------------------------
function CheckDeviceString() {
	local X

	X=$(
		echo "$1" |
		awk --posix -F. '
			function PrintBusID(css, grp, devno) {
				while(length(devno) < 4)
					devno = "0" devno
				print css "\\." grp "\\." devno "$"
			}
			NF == 1 && $1 ~ /^[0-9a-fA-F]{1,4}$/ {
				PrintBusID("0","0", $1)
				next
			}
			NF != 3 || $1 !~ /^[0-9a-fA-F]{1,2}$/ {
				next
			}
			$2 !~ /^[0-9a-fA-F]{1,2}$/ {
				next
			}
			$3 !~ /^[0-9a-fA-F]{1,4}$/ {
				next
			}
			{
				PrintBusID($1, $2, $3)
			}
		'
		)

	if [ "$X" != "" ]; then
		echo $X
		return 0
	fi

	return 1
}

#------------------------------------------------------------------------------
# Generate list of DASDs
#------------------------------------------------------------------------------
function listDASDDeviceDirectories() {
    DRIVERECKD="$SYSFSDIR/bus/ccw/drivers/dasd-eckd/"
    DRIVERFBA="$SYSFSDIR/bus/ccw/drivers/dasd-fba/"
    SEARCHDIRS=

    if [[ -d "$DRIVERECKD" ]]; then
	SEARCHDIRS="$DRIVERECKD"
    fi
    if [[ -d "$DRIVERFBA" ]]; then
	SEARCHDIRS="$SEARCHDIRS $DRIVERFBA"
    fi
    if [[ -n "$SEARCHDIRS" ]]; then
        find $SEARCHDIRS -type l -printf "%h/%l\n" 2> /dev/null
    else
        # The above paths may become invalid in the future, so we keep the
        # following query as backup:
        find "$SYSFSDIR/devices" -type l -name "driver" -lname "*/dasd*" \
		    -printf "%h\n" 2> /dev/null
    fi
    return 0
}

#------------------------------------------------------------------------------
# find dasd directory in debugfs
#------------------------------------------------------------------------------
function findDASDDebugfsDirectorie() {
    local mntentries

    while read -a mntentries
    do
	if [[ "${mntentries[2]}" == "debugfs" ]]
	then
	    DASD_DBF_DIR="${mntentries[1]}"
	    break;
	fi
    done < /etc/mtab
    if [[ "$DASD_DBF_DIR" == "" ]]
    then
	echo "$CMD: No debugfs mount point found" >&2
	exit 1
    fi
    DASD_DBF_DIR="$DASD_DBF_DIR/dasd"
    if [[ ! -d "$DASD_DBF_DIR" ]]
    then
	echo "$CMD: Default DASD debugfs directory $DASD_DBF_DIR does not exist" >&2
	exit 1
    fi
}

#------------------------------------------------------------------------------
# gather device data and call appropriate output function
#------------------------------------------------------------------------------
function gatherDeviceData() {
	while read DEVPATH
	do
		#-------------------------------------------#
		# gather information from device attributes #
		#-------------------------------------------#
		read ONLINE 2> /dev/null < $DEVPATH/online || continue
		if [[ "$ONLINE" == 0 ]] &&
			[[ "$PRINTOFFLINE" == "false" ]]; then
			continue
		fi
		read ALIAS 2> /dev/null < $DEVPATH/alias || continue
		read DEV_UID 2> /dev/null < $DEVPATH/uid || continue
		read READONLY 2> /dev/null < $DEVPATH/readonly || continue
		read DISCIPLINE 2> /dev/null < $DEVPATH/discipline || continue

		# Block device specific information is only available for
		# devices that are online and not a PAV alias
		if [[ ! "$ONLINE" == 0 ]] && [[ ! "$ALIAS" == 1 ]]; then
			#find device Path to the block device
			if [[ -d "$DEVPATH/block" ]]; then
				set - "$DEVPATH"/block/dasd*
			else
				set - "$DEVPATH"/block:dasd*
			fi
			MAJMIN=
			MAJOR=
			MINOR=
			SIZE=
			SSIZE=
			if [[ -d "$1" ]]; then
				cd -P "$1"
				BLOCKPATH=$PWD
				BLOCKNAME=${BLOCKPATH##*/}
				read MAJMIN 2> /dev/null < $BLOCKPATH/dev || continue
				MAJOR=${MAJMIN%%:*}
				MINOR=${MAJMIN##*:}
				read SIZE 2> /dev/null < $BLOCKPATH/size || continue
				read SSIZE 2> /dev/null < $BLOCKPATH/queue/hw_sector_size
				if [[ -z $SSIZE ]] && [[ -b "/dev/$BLOCKNAME" ]]; then
					SSIZE=$(blockdev --getss /dev/$BLOCKNAME 2>/dev/null)
				fi
			fi
		else
			# BLOCKNAME for offline and alias devices will not be
			# printed, it's just a key for sorting
			if [[ "$ONLINE" == 0 ]]; then
				BLOCKNAME=""
			else
				BLOCKNAME="a"
			fi
			MAJMIN=
			MAJOR=
			MINOR=
			SIZE=
		fi

		# busid is the base name of the device path
		if [[ "$SHORTID" == "true" ]]; then
			BUSID=${DEVPATH##*.}
		else
			BUSID=${DEVPATH##*/}
		fi

		if [[ "$PRINTUID" == "true" ]]; then
			SORTKEYLEN=${#DEV_UID}
			SORTKEY=$DEV_UID
			FORMATTED_UID="$DEV_UID"
		else
			SORTKEYLEN=${#BLOCKNAME}
			SORTKEY=$BLOCKNAME
			FORMATTED_UID=""
		fi

		if [[ "$OUTPUT" == "old" ]]; then
			oldoutput
		elif [[ "$OUTPUT" == "extended" ]]; then
			extended
		elif [[ "$PRINTUID" == "true" ]]; then
			uid
		elif [[ "$OUTPUT" == "host" ]]; then
			host
		else
			newoutput
		fi
    done
}

function newoutput()
{
	#-------------------------------------------#
	# format data for output                    #
	#-------------------------------------------#

	if [[ "$ONLINE" == 0 ]]; then
		printf "%s:%s:%-8s   offline\n" \
			"$SORTKEYLEN" "$SORTKEY" \
			"$BUSID" ;
		return
	fi

	if [[ "$ALIAS" == 1 ]]; then
		if [[ "$BASEONLY" == "false" ]]; then
			printf "%s:%s:%-8s   alias %28s\n" \
				"$SORTKEYLEN" "$SORTKEY" \
				"$BUSID" \
				"$DISCIPLINE"
		fi
		return
	fi

	if [[ "$READONLY" == 0 ]]; then
		ROSTRING=""
	else
		ROSTRING="(ro)"
	fi

	if [[ -z "$BLOCKNAME" ]] || [[ -z "$SIZE" ]]; then
		ACTIVE="active"
		BLOCKCOUNT=""
		MBSIZE=""
	elif [[ "$SIZE" == 0 ]]; then
		ACTIVE="n/f"
		BLOCKCOUNT=""
		MBSIZE=""
		SSIZE=""
	else
		if [[ -n "$SSIZE" ]] && [[ "$SSIZE" > 0 ]]; then
				BLOCKCOUNT=$(( SIZE / (SSIZE / 512) ))
		else
			SSIZE="???"
			BLOCKCOUNT="???"
		fi
		MBSIZE=$(( SIZE / 2048 ))MB
		ACTIVE="active"
	fi

	printf "%s:%s:%-8s   %-6s%-4s  %-8s  %-2s:%-2s   %-4s  %-4s   %-8s  %s\n" \
		"$SORTKEYLEN" "$SORTKEY" \
		"$BUSID" \
		"$ACTIVE" \
		"$ROSTRING" \
		"$BLOCKNAME" \
		"$MAJOR" \
		"$MINOR" \
		"$DISCIPLINE" \
		"$SSIZE" \
		"$MBSIZE" \
		"$BLOCKCOUNT" ;
}

function oldoutput()
{
	#-------------------------------------------#
	# format data for output                    #
	#-------------------------------------------#

	if [[ "$ONLINE" == 0 ]]; then
		printf "%s:%s:%s(%s)%s : offline\n" \
			"$SORTKEYLEN" "$SORTKEY" \
			"$BUSID" \
			"$DISCIPLINE" \
			"$FORMATTED_UID"
		return
	fi

	if [[ "$ALIAS" == 1 ]]; then
		if [[ "$BASEONLY" == "false" ]]; then
			printf "%s:%s:%s(%s)%s : alias\n" \
				"$SORTKEYLEN" "$SORTKEY" \
				"$BUSID" \
				"$DISCIPLINE" \
				"$FORMATTED_UID"
		fi
		return
	fi

	if [[ "$READONLY" == 0 ]]; then
		ROSTRING=""
	else
		ROSTRING="(ro)"
	fi

	printf "%s:%s:%s(%-4s)%s at (%3i:%3i) is %-7s%4s: " \
		"$SORTKEYLEN" "$SORTKEY" \
		"$BUSID" \
		"$DISCIPLINE" \
		"$FORMATTED_UID" \
		"$MAJOR" \
		"$MINOR" \
		"$BLOCKNAME" \
		"$ROSTRING" ;

	if [[ -z "$BLOCKNAME" ]] || [[ -z "$SIZE" ]]; then
		printf "active\n"
	elif [[ "$SIZE" == 0 ]]; then
		printf "n/f\n"
	else
		if [[ -n "$SSIZE" ]] && [[ "$SSIZE" > 0 ]]; then
				BLOCKCOUNT=$(( SIZE / (SSIZE / 512) ))
		else
			SSIZE="???"
			BLOCKCOUNT="???"
		fi
		MBSIZE=$(( SIZE / 2048 ))
		printf "active at blocksize %s, %s blocks, %i MB\n" \
			"$SSIZE" "$BLOCKCOUNT" "$MBSIZE"
	fi
}

function extended()
{
	PIM=0
	OPM=0
	NPPM=0
	CABLEPM=0
	CUIRPM=0
	HPFPM=0
	IFCCPM=0

	# additional information
	read DIAG 2> /dev/null < $DEVPATH/use_diag
	read EER 2> /dev/null < $DEVPATH/eer_enabled
	read ERP 2> /dev/null < $DEVPATH/erplog
	read HPF 2> /dev/null < $DEVPATH/hpf
        # in case the path_masks do not exist simply ignore it
	read OPM NPPM CABLEPM CUIRPM HPFPM IFCCPM 2> /dev/null < $DEVPATH/path_masks
	read -a C 2> /dev/null < $DEVPATH/../chpids
	read PIM PAM POM 2> /dev/null < $DEVPATH/../pimpampom

	# convert to hexadecimal values
	PIM=0x$PIM
	OPM=0x$OPM
	NPPM=0x$NPPM
	CABLEPM=0x$CABLEPM
	CUIRPM=0x$CUIRPM
	HPFPM=0x$HPFPM
	IFCCPM=0x$IFCCPM

       	#-----------------------------------------------------------#
       	# aggregate chpids and path mask to useful information      #
       	#-----------------------------------------------------------#

        # initialise chpid lists
        INSTALLED_PATHS=(" " " " " " " " " " " " " " " ")
	USED_PATHS=(" " " " " " " " " " " " " " " ")
	NP_PATHS=(" " " " " " " " " " " " " " " ")
        CUIR_PATHS=(" " " " " " " " " " " " " " " ")
        CABLE_PATHS=(" " " " " " " " " " " " " " " ")
        HPF_PATHS=(" " " " " " " " " " " " " " " ")
        IFCC_PATHS=(" " " " " " " " " " " " " " " ")

	# installed paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($PIM&$mask))
	    if [ $PM -gt 0 ] ;then
		INSTALLED_PATHS[$j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

	# used paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($OPM&$mask))
	    if [ $PM -gt 0 ] ;then
		USED_PATHS[$j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

	# non preffered paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($NPPM&$mask))
	    if [ $PM -gt 0 ] ;then
		NP_PATHS[j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

	# cuir quiesced paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($CUIRPM&$mask))
	    if [ $PM -gt 0 ] ;then
		CUIR_PATHS[j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

	# mis cabled paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($CABLEPM&$mask))
	    if [ $PM -gt 0 ] ;then
		CABLE_PATHS[j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

	# HPF unusable paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($HPFPM&$mask))
	    if [ $PM  -gt 0 ] ;then
		HPF_PATHS[j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

	# IFCC unusable paths
	j=0
	mask=0x80
	for (( i=0; i<8; i++ )) ;do
	    PM=$(($IFCCPM&$mask))
	    if [ $PM  -gt 0 ] ;then
		IFCC_PATHS[j]=${C[$i]} ;
		((j++)) ;
	    fi
	    (( mask>>=1 ))
	done

       	#-------------------------------------------#
       	# format data for output                    #
       	#-------------------------------------------#

	if [[ "$ONLINE" == 0 ]]; then
		ACTIVE="offline"
		printf "%s:%s:%s#  status:\t\t\t\t%s#  use_diag:\t\t\t\t%s#  readonly:\t\t\t\t%s#  eer_enabled:\t\t\t\t%s#  erplog:\t\t\t\t%s#  hpf:\t\t\t\t\t%s#  uid:  \t\t\t\t%s#  paths_installed: \t\t\t%s %s %s %s %s %s %s %s#  paths_in_use: \t\t\t%s %s %s %s %s %s %s %s#  paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s#  paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s#  paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s#  paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s#  paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s#\n" \
			"$SORTKEYLEN" "$SORTKEY" \
			"$BUSID" \
			"$ACTIVE" \
			"$DIAG" \
			"$READONLY" \
			"$EER" \
			"$ERP" \
			"$HPF" \
			"$DEV_UID" \
		        "${INSTALLED_PATHS[@]}" \
		        "${USED_PATHS[@]}" \
		        "${NP_PATHS[@]}" \
		        "${CABLE_PATHS[@]}" \
		        "${CUIR_PATHS[@]}" \
		        "${HPF_PATHS[@]}" \
		        "${IFCC_PATHS[@]}" ;
		return
	elif [[ "$ALIAS" == 1 ]]; then
		if [[ "$BASEONLY" == "false" ]]; then
			ACTIVE="alias"
			printf "%s:%s:%s#  status:\t\t\t\t%s#  type: \t\t\t\t%s#  use_diag:\t\t\t\t%s#  readonly:\t\t\t\t%s#  eer_enabled:\t\t\t\t%s#  erplog:\t\t\t\t%s#  hpf:\t\t\t\t\t%s #  uid:  \t\t\t\t%s#  paths_installed: \t\t\t%s %s %s %s %s %s %s %s#  paths_in_use: \t\t\t%s %s %s %s %s %s %s %s#  paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s#  paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s#  paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s#  paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s#  paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s#\n" \
				"$SORTKEYLEN" "$SORTKEY" \
				"$BUSID" \
				"$ACTIVE" \
				"$DISCIPLINE" \
				"$DIAG" \
				"$READONLY" \
				"$EER" \
				"$ERP" \
				"$HPF" \
				"$DEV_UID" \
			        "${INSTALLED_PATHS[@]}" \
			        "${USED_PATHS[@]}" \
			        "${NP_PATHS[@]}" \
			        "${CABLE_PATHS[@]}" \
			        "${CUIR_PATHS[@]}" \
			        "${HPF_PATHS[@]}" \
		                "${IFCC_PATHS[@]}" ;
		fi
		return
	elif [[ -z "$BLOCKNAME" ]] || [[ -z "$SIZE" ]]; then
		ACTIVE="active"
		COLON=""
	elif [[ "$SIZE" == 0 ]]; then
		ACTIVE="n/f"
		COLON=""
	else
		if [[ -n "$SSIZE" ]] && [[ "$SSIZE" > 0 ]]; then
			BLOCKCOUNT=$(( SIZE / (SSIZE / 512) ))
		else
			SSIZE="???"
			BLOCKCOUNT="???"
		fi
		MBSIZE=$(( SIZE / 2048 ))MB
		ACTIVE="active"
		COLON=":"
	fi

	printf "%s:%s:%s/%s/%s%s%s#  status:\t\t\t\t%s#  type: \t\t\t\t%s#  blksz:\t\t\t\t%s#  size: \t\t\t\t%s#  blocks:\t\t\t\t%s#  use_diag:\t\t\t\t%s#  readonly:\t\t\t\t%s#  eer_enabled:\t\t\t\t%s#  erplog:\t\t\t\t%s#  hpf:\t\t\t\t\t%s#  uid:  \t\t\t\t%s#  paths_installed: \t\t\t%s %s %s %s %s %s %s %s#  paths_in_use: \t\t\t%s %s %s %s %s %s %s %s#  paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s#  paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s#  paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s#  paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s#  paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s#\n" \
		"$SORTKEYLEN" "$SORTKEY" \
		"$BUSID" \
		"$BLOCKNAME" \
		"$MAJOR" \
		"$COLON" \
		"$MINOR" \
		"$ACTIVE" \
		"$DISCIPLINE" \
		"$SSIZE" \
		"$MBSIZE" \
		"$BLOCKCOUNT" \
		"$DIAG" \
		"$READONLY" \
		"$EER" \
		"$ERP" \
		"$HPF" \
		"$DEV_UID" \
	        "${INSTALLED_PATHS[@]}" \
	        "${USED_PATHS[@]}" \
	        "${NP_PATHS[@]}" \
	        "${CABLE_PATHS[@]}" \
	        "${CUIR_PATHS[@]}" \
	        "${HPF_PATHS[@]}"  \
	        "${IFCC_PATHS[@]}" ;
}

function host()
{
findDASDDebugfsDirectorie

if [[ ! -f "$DASD_DBF_DIR/$BUSID/host_access_list" ]]
then
    printf "\n%s: hosts access information not available\n" "$BUSID"
    return
fi

local temp=`mktemp /tmp/lsdasd.XXXXXX`
if test -w $temp ; then :; else
	printf "\nCreating temporary file failed\n"
	return
fi

cat $DASD_DBF_DIR/$BUSID/host_access_list > $temp 2> /dev/null
ret=$?
if [[ $ret -ne 0 ]]
then
    printf "%s: hosts access information not available\n" "$BUSID"
    rm -f $temp
    return $ret
fi

unset index
unset array
declare -a array

index=(pgid status_flags sysplex_name supported_cylinder timestamp)

for element in ${index[@]}
do
	count=0

	declare -a $element
	OLDIFS=$IFS
	IFS=$'\n'
	for value in `grep $element $temp`
	do
		(( ++count ))
		value=$(echo -e $value | cut -d ' ' -f2)
		eval $element[$count]=$value
	done
	IFS=$OLDIFS
done

printf "Host information for %s\n" "$BUSID";
printf "Path-Group-ID          LPAR  CPU   FL  Status  Sysplex      Max_Cyls        Time\n";
printf "================================================================================\n";

# mask bits for online and reserved state
online_reserved_mask=0xE0

# print name value lists
for i in `seq 1 $count`;
do
    # get flags field
    value=${status_flags[$i]}
    # mark as hex value
    value=0x$value
    # mask online and reserved bits
    value=$(($value & $online_reserved_mask))

    case $value in
	0 ) # 0x00
	    STATE="OFF"
	    ;;
	32 ) # 0x20
	    STATE="OFF-RSV"
	    ;;
	64 ) # 0x40
	    STATE="ON"
	    ;;
	96 ) # 0x60
	    STATE="ON-RSV"
	    ;;
	* )
	    STATE="-"
	    ;;
    esac

    printf "%22s %02s %07s  %02s  %-6s  %-8s  %11u  %10lu\n" \
	"${pgid[$i]}" \
	"${pgid[$i]:4:2}" \
	"${pgid[$i]:6:4}" \
	"${status_flags[$i]}" \
	"$STATE" \
	"${sysplex_name[$i]}" \
	"${supported_cylinder[$i]}" \
	"${timestamp[$i]}" \
	;
done
printf "\n";

rm -f $temp
}

function uid()
{
	#-------------------------------------------#
	# format data for output                    #
	#-------------------------------------------#

	if [[ "$ONLINE" == 0 ]]; then
		BLOCKNAME="offline"
	elif [[ "$ALIAS" == 1 ]]; then
		if [[ "$BASEONLY" == "true" ]]; then
			return
		else
			BLOCKNAME="alias"
		fi
	fi

	printf "%s:%s:%-8s  %-8s  %s\n" \
		"$SORTKEYLEN" "$SORTKEY" \
		"$BUSID" \
		"$BLOCKNAME" \
		"$FORMATTED_UID" ;
}

SHORTID=false
PRINTOFFLINE=false
VERBOSE=false
PRINTUID=false
BASEONLY=false
OUTPUT="new"
#------------------------------------------------------------------------------
# Evaluating command line options
#------------------------------------------------------------------------------
while [ $# -gt 0 ]; do
	case $1 in
	--help|-h)
		PrintUsage
		exit 0
		;;
	--verbose|-v)
		VERBOSE=true
		;;
	--offline|-a)
		PRINTOFFLINE=true
		;;
	--short|-s)
		SHORTID=true
		;;
	--uid|-u)
		PRINTUID=true
		;;
	--base|-b)
		BASEONLY=true
		;;
	--compat|-c)
		OUTPUT="old"
		;;
	--long|-l)
		OUTPUT="extended"
		;;
	--host-access-list|-H)
		OUTPUT="host"
		;;
	--version)
		PrintVersion
		exit 0
		;;
	-*)
		echo "$CMD: Invalid option $1"
		echo "Try 'lsdasd --help' for more information."
		exit 1
		;;
	*)
		DEV="$(CheckDeviceString $1)"
		if [ "$DEV" = "" ]; then
			echo "$CMD: ERROR: $1 no device format"
			exit 1
		fi
		if [ "$DEVLIST" == "" ]; then
			DEVLIST="$DEV"
		else
			DEVLIST="$DEVLIST\|$DEV"
		fi
		;;
	esac
	shift
	if [[ $OUTPUT == "extended" ]]; then
		if [[ $PRINTUID == true ]]; then
			echo "$CMD: ERROR: invalid options specified"
			exit 1
		fi
	fi
done


PROCESSING="listDASDDeviceDirectories "
# if there is a DEVLIST remove all elements not in the DEVLIST
if [ "$DEVLIST" != "" ]; then
	PROCESSING=" $PROCESSING | grep \"$DEVLIST\" "
fi

# gather information on devices in list
PROCESSING=" $PROCESSING | gatherDeviceData "

# sort resulting list
if [[ "$OUTPUT" == "host" ]]; then
    PROCESSING=" $PROCESSING"
else
    PROCESSING=" $PROCESSING | sort -t: -k1n -k2 | cut -d: -f3- "
fi

if  [[ "$PRINTUID" == "true" ]] && [[ "$OUTPUT" != "old" ]]; then
	printf "Bus-ID    Name      UID\n"
	printf "==============================================================================\n"
elif [[ "$OUTPUT" == "new" ]]; then
	printf "Bus-ID     Status      Name      Device  Type  BlkSz  Size      Blocks\n"
	printf "==============================================================================\n"
elif [[ "$OUTPUT" == "extended" ]]; then
	PROCESSING=" $PROCESSING | sed 's/#/\n/g' "
fi

#execute all steps
eval "$PROCESSING"

exit 0