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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
|
--- mtx.h.orig 2023-06-08 15:05:44 UTC
+++ mtx.h
@@ -7,7 +7,7 @@
$Date: 2008-08-19 03:03:38 -0700 (Tue, 19 Aug 2008) $
$Revision: 193 $
- See mtx.c for licensing information.
+ See mtx.c for licensing information.
*/
@@ -68,6 +68,9 @@
# include <sys/param.h>
#endif
+#if HAVE_STDBOOL_H
+#include <stdbool.h>
+#endif
/* Now greatly modified to use GNU Autoconf stuff: */
/* If we use the 'sg' interface, like Linux, do this: */
#if HAVE_SCSI_SG_H
@@ -148,7 +151,7 @@ typedef dsreq_t *DEVICE_TYPE; /* 64-bit pointers/32bit
#endif /* VMS protect. */
/* Do a test for LITTLE_ENDIAN_BITFIELDS. Use WORDS_BIGENDIAN as set
- * by configure:
+ * by configure:
*/
#if WORDS_BIGENDIAN
@@ -183,7 +186,7 @@ typedef dsreq_t *DEVICE_TYPE; /* 64-bit pointers/32bit
#undef S_VOLUME_OVERFLOW
#endif
-/* Note: These are only used for defaults for when we don't have
+/* Note: These are only used for defaults for when we don't have
* the element assignment mode page to tell us real amount...
*/
#define MAX_STORAGE_ELEMENTS 64 /* for the BIG jukeboxes! */
@@ -212,18 +215,11 @@ typedef struct SCSI_Flags_Struct
} SCSI_Flags_T;
#ifdef _MSC_VER
-typedef unsigned char boolean;
-
-#define false 0
-#define true 1
-
typedef unsigned char Direction_T;
#define Input 0
#define Output 1
#else
-typedef enum { false, true } boolean;
-
typedef enum { Input, Output } Direction_T;
#endif
@@ -237,66 +233,66 @@ typedef struct Inquiry
unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */
unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */
unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */
- boolean RMB:1; /* Byte 1 Bit 7 */
+ bool RMB:1; /* Byte 1 Bit 7 */
unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */
unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */
unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */
unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */
unsigned char :2; /* Byte 3 Bits 4-5 */
- boolean TrmIOP:1; /* Byte 3 Bit 6 */
- boolean AENC:1; /* Byte 3 Bit 7 */
+ bool TrmIOP:1; /* Byte 3 Bit 6 */
+ bool AENC:1; /* Byte 3 Bit 7 */
#else
unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */
unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */
- boolean RMB:1; /* Byte 1 Bit 7 */
+ bool RMB:1; /* Byte 1 Bit 7 */
unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */
unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */
unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */
unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */
- boolean AENC:1; /* Byte 3 Bit 7 */
- boolean TrmIOP:1; /* Byte 3 Bit 6 */
+ bool AENC:1; /* Byte 3 Bit 7 */
+ bool TrmIOP:1; /* Byte 3 Bit 6 */
unsigned char :2; /* Byte 3 Bits 4-5 */
unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */
#endif
unsigned char AdditionalLength; /* Byte 4 */
unsigned char :8; /* Byte 5 */
#ifdef LITTLE_ENDIAN_BITFIELDS
- boolean ADDR16:1; /* Byte 6 bit 0 */
- boolean Obs6_1:1; /* Byte 6 bit 1 */
- boolean Obs6_2:1; /* obsolete */ /* Byte 6 bit 2 */
- boolean MChngr:1; /* Media Changer */ /* Byte 6 bit 3 */
- boolean MultiP:1; /* Byte 6 bit 4 */
- boolean VS:1; /* Byte 6 bit 5 */
- boolean EncServ:1; /* Byte 6 bit 6 */
- boolean BQue:1; /* Byte 6 bit 7 */
+ bool ADDR16:1; /* Byte 6 bit 0 */
+ bool Obs6_1:1; /* Byte 6 bit 1 */
+ bool Obs6_2:1; /* obsolete */ /* Byte 6 bit 2 */
+ bool MChngr:1; /* Media Changer */ /* Byte 6 bit 3 */
+ bool MultiP:1; /* Byte 6 bit 4 */
+ bool VS:1; /* Byte 6 bit 5 */
+ bool EncServ:1; /* Byte 6 bit 6 */
+ bool BQue:1; /* Byte 6 bit 7 */
#else
- boolean BQue:1; /* Byte 6 bit 7 */
- boolean EncServ:1; /* Byte 6 bit 6 */
- boolean VS:1; /* Byte 6 bit 5 */
- boolean MultiP:1; /* Byte 6 bit 4 */
- boolean MChngr:1; /* Media Changer */ /* Byte 6 bit 3 */
- boolean Obs6_2:1; /* obsolete */ /* Byte 6 bit 2 */
- boolean Obs6_1:1; /* Byte 6 bit 1 */
- boolean ADDR16:1; /* Byte 6 bit 0 */
+ bool BQue:1; /* Byte 6 bit 7 */
+ bool EncServ:1; /* Byte 6 bit 6 */
+ bool VS:1; /* Byte 6 bit 5 */
+ bool MultiP:1; /* Byte 6 bit 4 */
+ bool MChngr:1; /* Media Changer */ /* Byte 6 bit 3 */
+ bool Obs6_2:1; /* obsolete */ /* Byte 6 bit 2 */
+ bool Obs6_1:1; /* Byte 6 bit 1 */
+ bool ADDR16:1; /* Byte 6 bit 0 */
#endif
#ifdef LITTLE_ENDIAN_BITFIELDS
- boolean SftRe:1; /* Byte 7 Bit 0 */
- boolean CmdQue:1; /* Byte 7 Bit 1 */
- boolean :1; /* Byte 7 Bit 2 */
- boolean Linked:1; /* Byte 7 Bit 3 */
- boolean Sync:1; /* Byte 7 Bit 4 */
- boolean WBus16:1; /* Byte 7 Bit 5 */
- boolean WBus32:1; /* Byte 7 Bit 6 */
- boolean RelAdr:1; /* Byte 7 Bit 7 */
+ bool SftRe:1; /* Byte 7 Bit 0 */
+ bool CmdQue:1; /* Byte 7 Bit 1 */
+ bool :1; /* Byte 7 Bit 2 */
+ bool Linked:1; /* Byte 7 Bit 3 */
+ bool Sync:1; /* Byte 7 Bit 4 */
+ bool WBus16:1; /* Byte 7 Bit 5 */
+ bool WBus32:1; /* Byte 7 Bit 6 */
+ bool RelAdr:1; /* Byte 7 Bit 7 */
#else
- boolean RelAdr:1; /* Byte 7 Bit 7 */
- boolean WBus32:1; /* Byte 7 Bit 6 */
- boolean WBus16:1; /* Byte 7 Bit 5 */
- boolean Sync:1; /* Byte 7 Bit 4 */
- boolean Linked:1; /* Byte 7 Bit 3 */
- boolean :1; /* Byte 7 Bit 2 */
- boolean CmdQue:1; /* Byte 7 Bit 1 */
- boolean SftRe:1; /* Byte 7 Bit 0 */
+ bool RelAdr:1; /* Byte 7 Bit 7 */
+ bool WBus32:1; /* Byte 7 Bit 6 */
+ bool WBus16:1; /* Byte 7 Bit 5 */
+ bool Sync:1; /* Byte 7 Bit 4 */
+ bool Linked:1; /* Byte 7 Bit 3 */
+ bool :1; /* Byte 7 Bit 2 */
+ bool CmdQue:1; /* Byte 7 Bit 1 */
+ bool SftRe:1; /* Byte 7 Bit 0 */
#endif
unsigned char VendorIdentification[8]; /* Bytes 8-15 */
unsigned char ProductIdentification[16]; /* Bytes 16-31 */
@@ -319,22 +315,22 @@ typedef struct RequestSense
{
#ifdef LITTLE_ENDIAN_BITFIELDS
unsigned char ErrorCode:7; /* Byte 0 Bits 0-6 */
- boolean Valid:1; /* Byte 0 Bit 7 */
+ bool Valid:1; /* Byte 0 Bit 7 */
#else
- boolean Valid:1; /* Byte 0 Bit 7 */
+ bool Valid:1; /* Byte 0 Bit 7 */
unsigned char ErrorCode:7; /* Byte 0 Bits 0-6 */
#endif
unsigned char SegmentNumber; /* Byte 1 */
#ifdef LITTLE_ENDIAN_BITFIELDS
unsigned char SenseKey:4; /* Byte 2 Bits 0-3 */
unsigned char :1; /* Byte 2 Bit 4 */
- boolean ILI:1; /* Byte 2 Bit 5 */
- boolean EOM:1; /* Byte 2 Bit 6 */
- boolean Filemark:1; /* Byte 2 Bit 7 */
+ bool ILI:1; /* Byte 2 Bit 5 */
+ bool EOM:1; /* Byte 2 Bit 6 */
+ bool Filemark:1; /* Byte 2 Bit 7 */
#else
- boolean Filemark:1; /* Byte 2 Bit 7 */
- boolean EOM:1; /* Byte 2 Bit 6 */
- boolean ILI:1; /* Byte 2 Bit 5 */
+ bool Filemark:1; /* Byte 2 Bit 7 */
+ bool EOM:1; /* Byte 2 Bit 6 */
+ bool ILI:1; /* Byte 2 Bit 5 */
unsigned char :1; /* Byte 2 Bit 4 */
unsigned char SenseKey:4; /* Byte 2 Bits 0-3 */
#endif
@@ -346,15 +342,15 @@ typedef struct RequestSense
unsigned char :8; /* Byte 14 */
#ifdef LITTLE_ENDIAN_BITFIELDS
unsigned char BitPointer:3; /* Byte 15 */
- boolean BPV:1;
+ bool BPV:1;
unsigned char :2;
- boolean CommandData :1;
- boolean SKSV:1;
+ bool CommandData :1;
+ bool SKSV:1;
#else
- boolean SKSV:1;
- boolean CommandData :1;
+ bool SKSV:1;
+ bool CommandData :1;
unsigned char :2;
- boolean BPV:1;
+ bool BPV:1;
unsigned char BitPointer:3; /* Byte 15 */
#endif
unsigned char FieldData[2]; /* Byte 16,17 */
@@ -436,11 +432,11 @@ typedef struct ElementStatusPage
ElementTypeCode_T ElementTypeCode:8; /* Byte 0 */
#ifdef LITTLE_ENDIAN_BITFIELDS
unsigned char :6; /* Byte 1 Bits 0-5 */
- boolean AVolTag:1; /* Byte 1 Bit 6 */
- boolean PVolTag:1; /* Byte 1 Bit 7 */
+ bool AVolTag:1; /* Byte 1 Bit 6 */
+ bool PVolTag:1; /* Byte 1 Bit 7 */
#else
- boolean PVolTag:1; /* Byte 1 Bit 7 */
- boolean AVolTag:1; /* Byte 1 Bit 6 */
+ bool PVolTag:1; /* Byte 1 Bit 7 */
+ bool AVolTag:1; /* Byte 1 Bit 6 */
unsigned char :6; /* Byte 1 Bits 0-5 */
#endif
unsigned char ElementDescriptorLength[2]; /* Bytes 2-3 */
@@ -467,15 +463,15 @@ typedef struct TransportElementDescriptorShort
{
unsigned char ElementAddress[2]; /* Bytes 0-1 */
#ifdef LITTLE_ENDIAN_BITFIELDS
- boolean Full:1; /* Byte 2 Bit 0 */
+ bool Full:1; /* Byte 2 Bit 0 */
unsigned char :1; /* Byte 2 Bit 1 */
- boolean Except:1; /* Byte 2 Bit 2 */
+ bool Except:1; /* Byte 2 Bit 2 */
unsigned char :5; /* Byte 2 Bits 3-7 */
#else
unsigned char :5; /* Byte 2 Bits 3-7 */
- boolean Except:1; /* Byte 2 Bit 2 */
+ bool Except:1; /* Byte 2 Bit 2 */
unsigned char :1; /* Byte 2 Bit 1 */
- boolean Full:1; /* Byte 2 Bit 0 */
+ bool Full:1; /* Byte 2 Bit 0 */
#endif
unsigned char :8; /* Byte 3 */
unsigned char AdditionalSenseCode; /* Byte 4 */
@@ -485,11 +481,11 @@ typedef struct TransportElementDescriptorShort
unsigned char :8; /* Byte 8 */
#ifdef LITTLE_ENDIAN_BITFIELDS
unsigned char :6; /* Byte 9 Bits 0-5 */
- boolean SValid:1; /* Byte 9 Bit 6 */
- boolean Invert:1; /* Byte 9 Bit 7 */
+ bool SValid:1; /* Byte 9 Bit 6 */
+ bool Invert:1; /* Byte 9 Bit 7 */
#else
- boolean Invert:1; /* Byte 9 Bit 7 */
- boolean SValid:1; /* Byte 9 Bit 6 */
+ bool Invert:1; /* Byte 9 Bit 7 */
+ bool SValid:1; /* Byte 9 Bit 6 */
unsigned char :6; /* Byte 9 Bits 0-5 */
#endif
unsigned char SourceStorageElementAddress[2]; /* Bytes 10-11 */
@@ -504,15 +500,15 @@ typedef struct TransportElementDescriptor
{
unsigned char ElementAddress[2]; /* Bytes 0-1 */
#ifdef LITTLE_ENDIAN_BITFIELDS
- boolean Full:1; /* Byte 2 Bit 0 */
+ bool Full:1; /* Byte 2 Bit 0 */
unsigned char :1; /* Byte 2 Bit 1 */
- boolean Except:1; /* Byte 2 Bit 2 */
+ bool Except:1; /* Byte 2 Bit 2 */
unsigned char :5; /* Byte 2 Bits 3-7 */
#else
unsigned char :5; /* Byte 2 Bits 3-7 */
- boolean Except:1; /* Byte 2 Bit 2 */
+ bool Except:1; /* Byte 2 Bit 2 */
unsigned char :1; /* Byte 2 Bit 1 */
- boolean Full:1; /* Byte 2 Bit 0 */
+ bool Full:1; /* Byte 2 Bit 0 */
#endif
unsigned char :8; /* Byte 3 */
unsigned char AdditionalSenseCode; /* Byte 4 */
@@ -522,20 +518,20 @@ typedef struct TransportElementDescriptor
unsigned char :8; /* Byte 8 */
#ifdef LITTLE_ENDIAN_BITFIELDS
unsigned char :6; /* Byte 9 Bits 0-5 */
- boolean SValid:1; /* Byte 9 Bit 6 */
- boolean Invert:1; /* Byte 9 Bit 7 */
+ bool SValid:1; /* Byte 9 Bit 6 */
+ bool Invert:1; /* Byte 9 Bit 7 */
#else
- boolean Invert:1; /* Byte 9 Bit 7 */
- boolean SValid:1; /* Byte 9 Bit 6 */
+ bool Invert:1; /* Byte 9 Bit 7 */
+ bool SValid:1; /* Byte 9 Bit 6 */
unsigned char :6; /* Byte 9 Bits 0-5 */
#endif
unsigned char SourceStorageElementAddress[2]; /* Bytes 10-11 */
unsigned char PrimaryVolumeTag[36]; /* barcode */
- unsigned char AlternateVolumeTag[36];
+ unsigned char AlternateVolumeTag[36];
#ifdef HAS_LONG_DESCRIPTORS
unsigned char Reserved[4]; /* 4 extra bytes? */
#endif
-
+
}
TransportElementDescriptor_T;
@@ -558,12 +554,12 @@ typedef struct ElementStatus {
barcode *PrimaryVolumeTag; /* array */
barcode *AlternateVolumeTag; /* array */
int *StorageElementAddress; /* array */
- boolean *StorageElementIsImportExport; /* array */
+ bool *StorageElementIsImportExport; /* array */
int TransportElementAddress; /* assume only one of those... */
- boolean *DataTransferElementFull; /* array */
- boolean *StorageElementFull; /* array */
+ bool *DataTransferElementFull; /* array */
+ bool *StorageElementFull; /* array */
} ElementStatus_T;
@@ -577,7 +573,7 @@ typedef struct scsi_id {
#define MEDIUM_CHANGER_TYPE 8 /* what type bits are set for medium changers. */
/* The following two structs are used for the brain-dead functions of the
- * NSM jukebox.
+ * NSM jukebox.
*/
typedef struct NSM_Param {
@@ -592,7 +588,7 @@ typedef struct NSM_Param {
unsigned char command_params[2048]; /* egregious overkill. */
} NSM_Param_T;
-extern RequestSense_T scsi_error_sense;
+extern RequestSense_T scsi_error_sense;
typedef struct NSM_Result {
unsigned char page_code;
@@ -600,7 +596,7 @@ typedef struct NSM_Result {
unsigned char page_len_msb;
unsigned char page_len_lsb;
unsigned char command_code[4];
- unsigned char ces_code[2];
+ unsigned char ces_code[2];
unsigned char return_data[0xffff]; /* egregioius overkill */
} NSM_Result_T;
--- mtxl.c.orig 2023-06-08 15:12:53 UTC
+++ mtxl.c
@@ -23,7 +23,7 @@
/*
* FatalError: changed Feb. 2000 elg@badtux.org to eliminate a buffer
- * overflow :-(. That could be important if mtxl is SUID for some reason.
+ * overflow :-(. That could be important if mtxl is SUID for some reason.
*/
#include "mtx.h"
@@ -34,7 +34,7 @@
/* #define DEBUG_MODE_SENSE 1 */
/* #define DEBUG */
/* #define DEBUG_SCSI */
-#define __WEIRD_CHAR_SUPPRESS 1
+#define __WEIRD_CHAR_SUPPRESS 1
/* zap the following define when we finally add real import/export support */
#define IMPORT_EXPORT_HACK 1 /* for the moment, import/export == storage */
@@ -97,7 +97,7 @@ Inquiry_T *RequestInquiry(DEVICE_TYPE fd, RequestSense
Inquiry_T *Inquiry;
CDB_T CDB;
- Inquiry = (Inquiry_T *) xmalloc(sizeof(Inquiry_T));
+ Inquiry = (Inquiry_T *) xmalloc(sizeof(Inquiry_T));
CDB[0] = 0x12; /* INQUIRY */
CDB[1] = 0; /* EVPD = 0 */
@@ -277,10 +277,10 @@ int max(int x, int y)
/* Okay, this is a hack for the NSM modular jukebox series, which
- * uses the "SEND DIAGNOSTIC" command to do shit.
+ * uses the "SEND DIAGNOSTIC" command to do shit.
*/
-int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command,
+int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command,
int param_len, int timeout)
{
CDB_T CDB;
@@ -359,7 +359,7 @@ NSM_Result_T *RecNSMHack( DEVICE_TYPE MediumChangerFD,
/* Routine to inventory the library. Needed by, e.g., some Breece Hill
* loaders. Sends an INITIALIZE_ELEMENT_STATUS command. This command
- * has no parameters, such as a range to scan :-(.
+ * has no parameters, such as a range to scan :-(.
*/
int Inventory(DEVICE_TYPE MediumChangerFD)
@@ -367,7 +367,7 @@ int Inventory(DEVICE_TYPE MediumChangerFD)
CDB_T CDB;
/* okay, now for the command: */
- CDB[0] = 0x07;
+ CDB[0] = 0x07;
CDB[1] = CDB[2] = CDB[3] = CDB[4] = CDB[5] = 0;
/* set us a very long timeout, sigh... */
@@ -391,8 +391,8 @@ int Inventory(DEVICE_TYPE MediumChangerFD)
/* Routine to read the Mode Sense Element Address Assignment Page */
/* We try to read the page. If we can't read the page, we return NULL.
* Our caller really isn't too worried about why we could not read the
- * page, it will simply default to some kind of default values.
- */
+ * page, it will simply default to some kind of default values.
+ */
ElementModeSense_T *ReadAssignmentPage(DEVICE_TYPE MediumChangerFD)
{
CDB_T CDB;
@@ -402,7 +402,7 @@ ElementModeSense_T *ReadAssignmentPage(DEVICE_TYPE Med
/* okay, now for the command: */
CDB[0] = 0x1A; /* Mode Sense(6) */
- CDB[1] = 0x08;
+ CDB[1] = 0x08;
CDB[2] = 0x1D; /* Mode Sense Element Address Assignment Page */
CDB[3] = 0;
CDB[4] = 136; /* allocation_length... */
@@ -479,7 +479,7 @@ ElementModeSense_T *ReadAssignmentPage(DEVICE_TYPE Med
((int)sense_page->NumStorageHi << 8) + sense_page->NumStorageLo;
retval->ImportExportStart =
- ((int)sense_page->ImportExportStartHi << 8) + sense_page->ImportExportStartLo;
+ ((int)sense_page->ImportExportStartHi << 8) + sense_page->ImportExportStartLo;
retval->NumImportExport =
((int)sense_page->NumImportExportHi << 8) + sense_page->NumImportExportLo;
@@ -491,7 +491,7 @@ ElementModeSense_T *ReadAssignmentPage(DEVICE_TYPE Med
((int)sense_page->NumDataTransferHi << 8) + sense_page->NumDataTransferLo;
/* allocate a couple spares 'cause some HP autochangers and maybe others
- * don't properly report the robotics arm(s) count here...
+ * don't properly report the robotics arm(s) count here...
*/
retval->NumElements =
retval->NumStorage+retval->NumImportExport +
@@ -546,7 +546,7 @@ static ElementStatus_T *AllocateElementData(ElementMod
retval->DataTransferElementAddress =
(int *)xzmalloc(sizeof(int) * (mode_sense->NumDataTransfer + 1));
- retval->DataTransferElementSourceStorageElementNumber =
+ retval->DataTransferElementSourceStorageElementNumber =
(int *)xzmalloc(sizeof(int) * (mode_sense->NumDataTransfer + 1));
retval->DataTransferPrimaryVolumeTag =
(barcode *)xzmalloc(sizeof(barcode) * (mode_sense->NumDataTransfer + 1));
@@ -559,11 +559,11 @@ static ElementStatus_T *AllocateElementData(ElementMod
retval->StorageElementAddress =
(int *)xzmalloc(sizeof(int) * (mode_sense->NumStorage + 1));
retval->StorageElementIsImportExport =
- (boolean *)xzmalloc(sizeof(boolean) * (mode_sense->NumStorage + 1));
+ (bool *)xzmalloc(sizeof(bool) * (mode_sense->NumStorage + 1));
retval->StorageElementFull =
- (boolean *)xzmalloc(sizeof(boolean) * (mode_sense->NumStorage + 1));
+ (bool *)xzmalloc(sizeof(bool) * (mode_sense->NumStorage + 1));
retval->DataTransferElementFull =
- (boolean *)xzmalloc(sizeof(boolean) * (mode_sense->NumDataTransfer + 1));
+ (bool *)xzmalloc(sizeof(bool) * (mode_sense->NumDataTransfer + 1));
return retval; /* sigh! */
}
@@ -584,14 +584,14 @@ void copy_barcode(unsigned char *src, unsigned char *d
dest++;
}
- *dest = 0; /* null-terminate */
+ *dest = 0; /* null-terminate */
}
/* This #%!@# routine has more parameters than I can count! */
static unsigned char *SendElementStatusRequestActual(
DEVICE_TYPE MediumChangerFD,
RequestSense_T *RequestSense,
- Inquiry_T *inquiry_info,
+ Inquiry_T *inquiry_info,
SCSI_Flags_T *flags,
int ElementStart,
int NumElements,
@@ -599,14 +599,14 @@ static unsigned char *SendElementStatusRequestActual(
)
{
CDB_T CDB;
- boolean is_attached = false;
+ bool is_attached = false;
unsigned char *DataBuffer; /* size of data... */
#ifdef HAVE_GET_ID_LUN
scsi_id_t *scsi_id;
#endif
- if (inquiry_info->MChngr &&
+ if (inquiry_info->MChngr &&
inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)
{
is_attached = true;
@@ -614,7 +614,7 @@ static unsigned char *SendElementStatusRequestActual(
if (flags->no_attached)
{
- /* override, sigh */
+ /* override, sigh */
is_attached = false;
}
@@ -630,11 +630,11 @@ static unsigned char *SendElementStatusRequestActual(
if (is_attached)
{
- CDB[0] = 0xB4; /* whoops, READ_ELEMENT_STATUS_ATTACHED! */
+ CDB[0] = 0xB4; /* whoops, READ_ELEMENT_STATUS_ATTACHED! */
}
#ifdef HAVE_GET_ID_LUN
- CDB[1] = (scsi_id->lun << 5) | ((flags->no_barcodes) ?
+ CDB[1] = (scsi_id->lun << 5) | ((flags->no_barcodes) ?
0 : 0x10) | flags->elementtype; /* Lun + VolTag + Type code */
free(scsi_id);
#else
@@ -674,7 +674,7 @@ static unsigned char *SendElementStatusRequestActual(
/*
First see if we have sense key of 'illegal request',
- additional sense code of '24', additional sense qualfier of
+ additional sense code of '24', additional sense qualfier of
'0', and field in error of '4'. This means that we issued a request
w/bar code reader and did not have one, thus must re-issue the request
w/out barcode :-(.
@@ -719,14 +719,14 @@ static unsigned char *SendElementStatusRequestActual(
PrintRequestSense(RequestSense); /* see what it sez :-(. */
fprintf(stderr,"Data:\n");
PrintHex(2, DataBuffer, 40);
-#endif
+#endif
return DataBuffer; /* we succeeded! */
}
unsigned char *SendElementStatusRequest(DEVICE_TYPE MediumChangerFD,
RequestSense_T *RequestSense,
- Inquiry_T *inquiry_info,
+ Inquiry_T *inquiry_info,
SCSI_Flags_T *flags,
int ElementStart,
int NumElements,
@@ -747,7 +747,7 @@ unsigned char *SendElementStatusRequest(DEVICE_TYPE Me
/*
One weird loader wants either 8 or BYTE_COUNT_OF_REPORT
values for the ALLOCATION_LENGTH. Give it what it wants
- if we get an Sense Key of 05 Illegal Request with a
+ if we get an Sense Key of 05 Illegal Request with a
CDB position of 7 as the field in error.
*/
@@ -879,7 +879,7 @@ static void ParseElementStatus( int *EmptyStorageEleme
{
/* TransportElementDescriptor =
(TransportElementDescriptor_T *) DataPointer; */
- memcpy(&TEBuf, DataPointer,
+ memcpy(&TEBuf, DataPointer,
(TransportElementDescriptorLength <= sizeof(TEBuf)) ?
TransportElementDescriptorLength :
sizeof(TEBuf));
@@ -906,7 +906,7 @@ static void ParseElementStatus( int *EmptyStorageEleme
case MediumTransportElement:
ElementStatus->TransportElementAddress = BigEndian16(TransportElementDescriptor->ElementAddress);
#ifdef DEBUG
- fprintf(stderr,"TransportElementAddress=%d\n",ElementStatus->TransportElementAddress);
+ fprintf(stderr,"TransportElementAddress=%d\n",ElementStatus->TransportElementAddress);
#endif
break;
@@ -933,7 +933,7 @@ static void ParseElementStatus( int *EmptyStorageEleme
ElementStatus->StorageElementFull[ImportExportIndex] =
TransportElementDescriptor->Full;
- if ( (TransportElementDescriptorLength > 11) &&
+ if ( (TransportElementDescriptorLength > 11) &&
(ElementStatusPage->VolBits & E2_AVOLTAG))
{
copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
@@ -942,8 +942,8 @@ static void ParseElementStatus( int *EmptyStorageEleme
else
{
ElementStatus->AlternateVolumeTag[ImportExportIndex][0] = 0; /* null string. */;
- }
- if ((TransportElementDescriptorLength > 11) &&
+ }
+ if ((TransportElementDescriptorLength > 11) &&
(ElementStatusPage->VolBits & E2_PVOLTAG))
{
copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
@@ -964,8 +964,8 @@ static void ParseElementStatus( int *EmptyStorageEleme
fprintf(stderr,"StorageElementCount=%d ElementAddress = %d ",ElementStatus->StorageElementCount,BigEndian16(TransportElementDescriptor->ElementAddress));
#endif
/* ATL/Exabyte kludge -- skip slots that aren't installed :-( */
- if (TransportElementDescriptor->AdditionalSenseCode==0x83 &&
- TransportElementDescriptor->AdditionalSenseCodeQualifier==0x02)
+ if (TransportElementDescriptor->AdditionalSenseCode==0x83 &&
+ TransportElementDescriptor->AdditionalSenseCodeQualifier==0x02)
continue;
ElementStatus->StorageElementAddress[ElementStatus->StorageElementCount] =
@@ -983,7 +983,7 @@ static void ParseElementStatus( int *EmptyStorageEleme
ElementStatus->StorageElementCount; /* slot idx. */
/* ElementStatus->StorageElementAddress[ElementStatus->StorageElementCount]; */
}
- if ((TransportElementDescriptorLength > 11) &&
+ if ((TransportElementDescriptorLength > 11) &&
(ElementStatusPage->VolBits & E2_AVOLTAG))
{
copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
@@ -992,8 +992,8 @@ static void ParseElementStatus( int *EmptyStorageEleme
else
{
ElementStatus->AlternateVolumeTag[ElementStatus->StorageElementCount][0]=0; /* null string. */;
- }
- if ((TransportElementDescriptorLength > 11) &&
+ }
+ if ((TransportElementDescriptorLength > 11) &&
(ElementStatusPage->VolBits & E2_PVOLTAG))
{
copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
@@ -1006,9 +1006,9 @@ static void ParseElementStatus( int *EmptyStorageEleme
ElementStatus->StorageElementCount++;
/*
- Note that the original mtx had no check here for
+ Note that the original mtx had no check here for
buffer overflow, though some drives might mistakingly
- do one...
+ do one...
*/
if (ElementStatus->StorageElementCount > mode_sense->NumStorage)
@@ -1030,33 +1030,33 @@ static void ParseElementStatus( int *EmptyStorageEleme
report that they have a 2nd tape drive when they don't. We
could generalize this in an ideal world, but my attempt to
do so failed with dual-drive Exabyte tape libraries that
- *DID* have the second drive. Sigh.
+ *DID* have the second drive. Sigh.
*/
- if (TransportElementDescriptor->AdditionalSenseCode==0x83 &&
+ if (TransportElementDescriptor->AdditionalSenseCode==0x83 &&
TransportElementDescriptor->AdditionalSenseCodeQualifier==0x04)
{
continue;
}
/* generalize it. Does it work? Let's try it! */
- /*
+ /*
No, dammit, following does not work on dual-drive Exabyte
'cause if a tape is in the drive, it sets the AdditionalSense
code to something (sigh).
*/
/* if (TransportElementDescriptor->AdditionalSenseCode!=0)
continue;
- */
+ */
ElementStatus->DataTransferElementAddress[ElementStatus->DataTransferElementCount] =
BigEndian16(TransportElementDescriptor->ElementAddress);
- ElementStatus->DataTransferElementFull[ElementStatus->DataTransferElementCount] =
+ ElementStatus->DataTransferElementFull[ElementStatus->DataTransferElementCount] =
TransportElementDescriptor->Full;
ElementStatus->DataTransferElementSourceStorageElementNumber[ElementStatus->DataTransferElementCount] =
BigEndian16(TransportElementDescriptor->SourceStorageElementAddress);
#if DEBUG
- fprintf(stderr, "%d: ElementAddress = %d, Full = %d, SourceElement = %d\n",
+ fprintf(stderr, "%d: ElementAddress = %d, Full = %d, SourceElement = %d\n",
ElementStatus->DataTransferElementCount,
ElementStatus->DataTransferElementAddress[ElementStatus->DataTransferElementCount],
ElementStatus->DataTransferElementFull[ElementStatus->DataTransferElementCount],
@@ -1115,17 +1115,17 @@ static void ParseElementStatus( int *EmptyStorageEleme
/*
* We no longer do the funky trick to figure out ALLOCATION_LENGTH.
* Instead, we use the SCSI Generic command rather than SEND_SCSI_COMMAND
- * under Linux, which gets around the @#%@ 4k buffer size in Linux.
+ * under Linux, which gets around the @#%@ 4k buffer size in Linux.
* We still have the restriction that Linux cuts off the last two
* bytes of the SENSE DATA (Q#@$%@#$^ Linux!). Which means that the
- * verbose widget won't work :-(.
-
+ * verbose widget won't work :-(.
+
* We now look for that "attached" bit in the inquiry_info to see whether
* to use READ_ELEMENT_ATTACHED or plain old READ_ELEMENT. In addition, we
* look at the device type in the inquiry_info to see whether it is a media
* changer or tape device, and if it's a media changer device, we ignore the
* attached bit (one beta tester found an old 4-tape DAT changer that set
- * the attached bit for both the tape device AND the media changer device).
+ * the attached bit for both the tape device AND the media changer device).
*/
@@ -1139,7 +1139,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
int *EmptyStorageElementAddress; /* [MAX_STORAGE_ELEMENTS]; */
int empty_idx = 0;
- boolean is_attached = false;
+ bool is_attached = false;
int i,j;
ElementModeSense_T *mode_sense = NULL;
@@ -1151,7 +1151,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
if (flags->no_attached)
{
- /* override, sigh */
+ /* override, sigh */
is_attached = false;
}
@@ -1181,7 +1181,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
ElementStatus->DataTransferElementCount = 0;
/* first, allocate some empty storage stuff: Note that we pass this
- * down to ParseElementStatus (sigh!)
+ * down to ParseElementStatus (sigh!)
*/
EmptyStorageElementAddress = (int *)xzmalloc((mode_sense->NumStorage+1)*sizeof(int));
@@ -1198,7 +1198,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
for (i = 0; i < mode_sense->NumDataTransfer; i++)
{
/* initialize them to an illegal # so that we can fix later... */
- ElementStatus->DataTransferElementSourceStorageElementNumber[i] = -1;
+ ElementStatus->DataTransferElementSourceStorageElementNumber[i] = -1;
}
if (flags->querytype == MTX_ELEMENTSTATUS_ORIGINAL)
@@ -1224,7 +1224,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
PrintRequestSense(RequestSense);
#endif
FreeElementData(ElementStatus);
- return NULL;
+ return NULL;
}
#ifdef DEBUG
@@ -1294,7 +1294,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
PrintRequestSense(RequestSense);
#endif
FreeElementData(ElementStatus);
- return NULL;
+ return NULL;
}
#ifdef DEBUG
@@ -1309,7 +1309,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
/* grr, damned brain dead HP doesn't report that it has any! */
if (!mode_sense->NumMediumTransport)
- {
+ {
ElementStatus->TransportElementAddress = 0; /* default it sensibly :-(. */
}
else
@@ -1333,8 +1333,8 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
PrintRequestSense(RequestSense);
#endif
FreeElementData(ElementStatus);
- return NULL;
- }
+ return NULL;
+ }
#ifdef DEBUG
fprintf(stderr,"Parsing robot arm data\n");
#endif
@@ -1352,8 +1352,8 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
fprintf(stderr,"Using alternative element status polling method (all elements)\n");
#endif
/* ----------------- ALL Elements ---------------------- */
- /* Just keep asking for elements till no more are returned
- - increment our starting address as we go acording to the
+ /* Just keep asking for elements till no more are returned
+ - increment our starting address as we go acording to the
number of elements returned from the last call
*/
@@ -1370,7 +1370,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
mode_sense->MaxReadElementStatusData);
if (!DataBuffer)
{
- if (RequestSense->AdditionalSenseCode == 0x21 &&
+ if (RequestSense->AdditionalSenseCode == 0x21 &&
RequestSense->AdditionalSenseCodeQualifier == 0x01)
{
/* Error is invalid element address, we've probably just hit the end */
@@ -1379,8 +1379,8 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
/* darn. Free up stuff and return. */
FreeElementData(ElementStatus);
- return NULL;
- }
+ return NULL;
+ }
nLastEl = nNextEl;
@@ -1409,7 +1409,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
*
* Pass1:
* Translate from raw element # to our translated # (if possible).
- * First, check the SourceStorageElementNumbers against the list of
+ * First, check the SourceStorageElementNumbers against the list of
* filled slots. If the slots indicated are empty, we accept that list as
* valid. Otherwise decide the SourceStorageElementNumbers are invalid.
*
@@ -1418,7 +1418,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
* then we must search for free slots, and assign SourceStorageElementNumbers
* to those free slots. We happen to already built a list of free
* slots as part of the process of reading the storage element numbers
- * from the tape. So that's easy enough to do!
+ * from the tape. So that's easy enough to do!
*/
#ifdef DEBUG_TAPELIST
@@ -1434,7 +1434,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
/*
* Now we re-assign origin slots if the "real" origin slot
- * is obviously defective:
+ * is obviously defective:
*/
/* pass one: */
for (i = 0; i < ElementStatus->DataTransferElementCount; i++)
@@ -1472,12 +1472,12 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumC
* drives will be assigned a -1 (see the initialization loop for
* EmptyStorageElementAddress above), which will be reported as "slot 0"
* by the user interface. This is an invalid value, but more useful for us
- * to have than just crapping out here :-(.
+ * to have than just crapping out here :-(.
*/
empty_idx=0;
for (i = 0; i < ElementStatus->DataTransferElementCount; i++)
{
- if (ElementStatus->DataTransferElementFull[i] &&
+ if (ElementStatus->DataTransferElementFull[i] &&
ElementStatus->DataTransferElementSourceStorageElementNumber[i] < 0)
{
#ifdef DEBUG_TAPELIST
@@ -1529,7 +1529,7 @@ RequestSense_T *PositionElement(DEVICE_TYPE MediumChan
/* Now the actual media movement routine! */
RequestSense_T *MoveMedium( DEVICE_TYPE MediumChangerFD, int SourceAddress,
- int DestinationAddress,
+ int DestinationAddress,
ElementStatus_T *ElementStatus,
Inquiry_T *inquiry_info, SCSI_Flags_T *flags)
{
@@ -1632,7 +1632,7 @@ RequestSense_T *ExchangeMedium( DEVICE_TYPE MediumChan
#ifdef DEBUG_EXCHANGE
dump_cdb(&CDB,12);
-#endif
+#endif
if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 12,
NULL, 0, RequestSense) != 0)
@@ -1676,8 +1676,8 @@ RequestSense_T *Erase(DEVICE_TYPE MediumChangerFD)
return NULL; /* Success! */
}
-/* Routine to send an LOAD/UNLOAD from the MMC/SSC spec to a device.
- * For tapes and changers this can be used either to eject a tape
+/* Routine to send an LOAD/UNLOAD from the MMC/SSC spec to a device.
+ * For tapes and changers this can be used either to eject a tape
* or to eject a magazine (on some Seagate changers, when sent to LUN 1 ).
* For CD/DVDs this is used to Load or Unload a disc which is required by
* some media changers.
@@ -1707,8 +1707,8 @@ int LoadUnload(DEVICE_TYPE fd, int bLoad)
return 0; /* did do! */
}
-/* Routine to send an START/STOP from the MMC/SSC spec to a device.
- * For tape drives this may be required prior to using the changer
+/* Routine to send an START/STOP from the MMC/SSC spec to a device.
+ * For tape drives this may be required prior to using the changer
* Load or Unload commands.
* For CD/DVD drives this is used to Load or Unload a disc which may be
* required by some media changers.
@@ -1732,9 +1732,9 @@ int StartStop(DEVICE_TYPE fd, int bStart)
return 0; /* did do! */
}
-/* Routine to send a LOCK/UNLOCK from the SSC/MMC spec to a device.
+/* Routine to send a LOCK/UNLOCK from the SSC/MMC spec to a device.
* This can be used to prevent or allow the Tape or CD/DVD from being
- * removed.
+ * removed.
*/
int LockUnlock(DEVICE_TYPE fd, int bLock)
@@ -1862,7 +1862,7 @@ void PrintRequestSense(RequestSense_T *RequestSense)
fprintf(stderr, "mtx: Request Sense: Valid Residual=%s\n", RequestSense->Valid ? Yes : No);
if (RequestSense->ErrorCode == 0x70)
- {
+ {
msg = "Current" ;
}
else if (RequestSense->ErrorCode == 0x71)
|