forked from cdrdao/cdrdao
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscsilib.patch
More file actions
1150 lines (1105 loc) · 37.4 KB
/
scsilib.patch
File metadata and controls
1150 lines (1105 loc) · 37.4 KB
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
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/.cvsignore scsilib/.cvsignore
--- scsilib.orig/.cvsignore 1969-12-31 16:00:00.000000000 -0800
+++ scsilib/.cvsignore 2004-04-05 12:00:08.000000000 -0700
@@ -0,0 +1,3 @@
+Gmake.linux
+Makefile
+rc.pp
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/DEFAULTS/Defaults.linux scsilib/DEFAULTS/Defaults.linux
--- scsilib.orig/DEFAULTS/Defaults.linux 2003-02-15 16:01:48.000000000 -0800
+++ scsilib/DEFAULTS/Defaults.linux 2004-05-17 15:46:33.000000000 -0700
@@ -18,7 +18,7 @@
###########################################################################
CWARNOPTS=
-DEFINCDIRS= $(SRCROOT)/include /usr/src/linux/include
+DEFINCDIRS= $(SRCROOT)/include
LDPATH= -L/opt/schily/lib
RUNPATH= -R $(INS_BASE)/lib -R /opt/schily/lib -R $(OLIBSDIR)
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/export/Makefile scsilib/export/Makefile
--- scsilib.orig/export/Makefile 1969-12-31 16:00:00.000000000 -0800
+++ scsilib/export/Makefile 2004-04-12 19:03:25.000000000 -0700
@@ -0,0 +1,46 @@
+#ident %W% %E% %Q%
+###########################################################################
+# Written 1999 by Andreas Mueller
+###########################################################################
+# Makefile for local dynamic configuration
+###########################################################################
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+###########################################################################
+SRCROOT= ..
+RULESDIR= RULES
+include $(SRCROOT)/$(RULESDIR)/rules.top
+###########################################################################
+
+all: clobber
+ $(LN) -s $(SRCROOT)/include libschily
+ $(LN) -s $(SRCROOT)/libscg/scg scg
+ $(LN) -s $(SRCROOT)/incs/$(OARCH)/xconfig.h xconfig.h
+ $(LN) -s $(SRCROOT)/libs/$(OARCH)/libschily.a libschily.a
+ $(LN) -s $(SRCROOT)/libs/$(OARCH)/libscg.a libscg.a
+ $(LN) -s $(SRCROOT)/libs/$(OARCH)/librscg.a librscg.a
+
+clobber:
+ $(RM_F) -r libschily scg xconfig.h libschily.a libscg.a librscg.a
+
+distclean: clobber
+
+clean: clobber
+
+OTHERTARGETS= install ibins depend rmdep \
+ TAGS tags rmtarget relink
+
+$(OTHERTARGETS):
+ @echo "$@: nothing to make"
+
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/libscg/scsi-linux-sg.c scsilib/libscg/scsi-linux-sg.c
--- scsilib.orig/libscg/scsi-linux-sg.c 2004-01-14 09:54:01.000000000 -0800
+++ scsilib/libscg/scsi-linux-sg.c 2004-04-29 11:17:22.000000000 -0700
@@ -65,6 +65,14 @@
#if LINUX_VERSION_CODE >= 0x01031a /* <linux/scsi.h> introduced in 1.3.26 */
#if LINUX_VERSION_CODE >= 0x020000 /* <scsi/scsi.h> introduced somewhere. */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
+ #define __KERNEL__
+ #include <asm/types.h>
+ #include <asm/byteorder.h>
+ #undef __KERNEL__
+#endif
+
/* Need to fine tune the ifdef so we get the transition point right. */
#include <scsi/scsi.h>
#else
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/Makefile scsilib/Makefile
--- scsilib.orig/Makefile 1998-09-20 15:58:30.000000000 -0700
+++ scsilib/Makefile 2004-04-12 18:56:23.000000000 -0700
@@ -13,3 +13,13 @@
#
include $(SRCROOT)/$(RULESDIR)/rules.rdi
###########################################################################
+
+install:
+ @
+
+check:
+
+uninstall:
+ @
+
+distclean: clean
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a31/README.cdrdao scsilib/README.cdrdao
--- scsilib.orig/README.cdrdao 1969-12-31 16:00:00.000000000 -0800
+++ scsilib/README.cdrdao 2004-06-03 18:51:10.000000000 -0700
@@ -0,0 +1,7 @@
+This is a snapshot of Joerg Schilling's SCSI library from cdrtools-2.01a31.
+
+The additional directory 'export' is used to hold some links to include
+files and built libraries for easy access by the remaining cdrdao package.
+
+It is also possible to use an installed SCSI library. See "INSTALL" in the
+main directory for more information.
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/RULES/rules1.dir scsilib/RULES/rules1.dir
--- scsilib.orig/RULES/rules1.dir 2002-10-23 10:48:08.000000000 -0700
+++ scsilib/RULES/rules1.dir 2004-04-29 17:10:44.000000000 -0700
@@ -29,14 +29,12 @@
list=`echo TARGETS/[0-9][0-9]* | sed -e 's;TARGETS/[0-9][0-9];;g' | sed -e 's;!@!;/;g'`;\
for DIR in $${list} ; \
do \
- ( \
- echo " ==> MAKING \"$@\" ON SUBDIRECTORY \"$(CURDIR)/$$DIR\"";\
- if [ -d ./$$DIR -a -r ./$$DIR/Makefile ] ; then \
- cd ./$$DIR;"$(MAKE)" $(MAKEMACS) XARCH=$(XARCH) DIRNAME=$(CURDIR)/$$DIR $@; \
+ echo " ==> MAKING \"$@\" ON SUBDIRECTORY \"$(CURDIR)/$$DIR\""; \
+ if [ -d ./$$DIR -a -r ./$$DIR/Makefile ] ; then \
+ "$(MAKE)" -C ./$$DIR $(MAKEMACS) XARCH=$(XARCH) DIRNAME=$(CURDIR)/$$DIR $@ || exit -1 ; \
else \
echo "NOTICE: Partial source ($(CURDIR)/$$DIR) missing";\
- fi \
- ); \
+ fi ; \
done
tinfo:
diff -ru --unidirectional-new-file /home/denis/packages/cdrtools-2.01a25/TARGETS/99export scsilib/TARGETS/99export
--- scsilib.orig/TARGETS/99export 1969-12-31 16:00:00.000000000 -0800
+++ scsilib/TARGETS/99export 2003-03-01 10:53:25.000000000 -0800
@@ -0,0 +1 @@
+Export
--- scsilib/RULES/mk-gmake.id.old 2004-09-08 09:10:02.000000000 -0700
+++ scsilib/RULES/mk-gmake.id 2005-04-26 14:15:21.000000000 -0700
@@ -37,9 +37,7 @@
ifndef ARCH_DONE
-__gmake_warn:= $(shell cat $(SRCROOT)/$(RULESDIR)/gmake.wrn 1>&2; sleep 5)
-
-_MACHCMD= (mach || uname -p || true) 2> /dev/null
+_MACHCMD= (uname -p || true) 2> /dev/null
_ARCHCMD= (arch || /usr/ucb/arch || true) 2> /dev/null
XP_ARCH:= $(shell $(_MACHCMD) | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',-')
--- scsilib/RULES.orig/ppc64-linux-cc.rul 1970-01-01 00:00:00.000000000 +0000
+++ scsilib/RULES/ppc64-linux-cc.rul 2004-12-23 16:02:37.343901376 +0000
@@ -0,0 +1,70 @@
+#ident "@(#)i586-linux-cc.rul 1.5 02/10/15 "
+###########################################################################
+# Written 1996 by J. Schilling
+###########################################################################
+#
+# Platform dependent MACROS for Linux
+#
+###########################################################################
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+###########################################################################
+include $(SRCROOT)/$(RULESDIR)/rules.prg
+###########################################################################
+
+CPPFLAGS= $(CPPOPTS) $(CPPOPTX)
+CFLAGS= $(COPTS) $(CWARNOPTS) $(COPTOPT) $(GCCOPTOPT) $(COPTX)
+
+CPPOPTS= -I. -I$(ARCHDIR) -I$(OINCSDIR) $(INCDIRS:%=-I%) $(OSDEFS)
+COPTS=
+CWOPTS= -Wall -Wtraditional \
+ -Wshadow -Wmissing-prototypes -Wstrict-prototypes
+COPTOPT= -O
+KDEFINES= -DKERNEL -D_KERNEL
+COPTDYN= -fpic
+COPTGPROF= -pg
+
+LIB_PREFIX= lib
+LIB_SUFFIX= .a
+SHL_SUFFIX= .so.1.0
+
+#LIB_SOCKET= -lsocket -lnsl -ldl
+LIB_SOCKET=
+LIB_MATH= -lm
+#LIB_KVM= -lkvm
+LIB_KVM=
+
+LIBS_PATH= -L$(OLIBSDIR)
+
+LDFLAGS= $(LDOPTS) $(LDOPTX)
+LDLIBS= $(LIBS) $(LIBX)
+
+#LDOPTS= $(LIBS_PATH) $(LDPATH) $(RUNPATH)
+LDOPTS= $(LIBS_PATH) $(LDPATH)
+LDOPTDYN= -shared -Wl,-soname,$(TARGET)
+LNDYNLIB= @$(SYMLINK) $(TARGET) $(PTARGET_BASE).so
+
+FLOAT_OPTIONS=
+
+CC= @echo " ==> COMPILING \"$@\""; gcc
+LDCC= @echo " ==> LINKING \"$@\""; gcc
+DYNLD= @echo " ==> LINKING dynamic library \"$@\""; gcc
+RANLIB= @echo " ==> RANDOMIZING ARCHIVE \"$@\""; true
+ARFLAGS= cr
+LORDER= echo
+TSORT= cat
+
+RMDEP= :
+MKDEP= @echo " ==> MAKING DEPENDENCIES \"$@\""; $(RMDEP); gcc -M
+MKDEP_OUT=
diff -ruN --recursive scsilib/RULES.orig/ppc64-linux-gcc.rul scsilib/RULES/ppc64-linux-gcc.rul
--- scsilib/RULES.orig/ppc64-linux-gcc.rul 1970-01-01 00:00:00.000000000 +0000
+++ scsilib/RULES/ppc64-linux-gcc.rul 2004-12-23 16:02:43.008978904 +0000
@@ -0,0 +1,70 @@
+#ident "@(#)i586-linux-gcc.rul 1.5 02/10/15 "
+###########################################################################
+# Written 1996 by J. Schilling
+###########################################################################
+#
+# Platform dependent MACROS for Linux
+#
+###########################################################################
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+###########################################################################
+include $(SRCROOT)/$(RULESDIR)/rules.prg
+###########################################################################
+
+CPPFLAGS= $(CPPOPTS) $(CPPOPTX)
+CFLAGS= $(COPTS) $(CWARNOPTS) $(COPTOPT) $(GCCOPTOPT) $(COPTX)
+
+CPPOPTS= -I. -I$(ARCHDIR) -I$(OINCSDIR) $(INCDIRS:%=-I%) $(OSDEFS)
+COPTS=
+CWOPTS= -Wall -Wtraditional \
+ -Wshadow -Wmissing-prototypes -Wstrict-prototypes
+COPTOPT= -O
+KDEFINES= -DKERNEL -D_KERNEL
+COPTDYN= -fpic
+COPTGPROF= -pg
+
+LIB_PREFIX= lib
+LIB_SUFFIX= .a
+SHL_SUFFIX= .so.1.0
+
+#LIB_SOCKET= -lsocket -lnsl -ldl
+LIB_SOCKET=
+LIB_MATH= -lm
+#LIB_KVM= -lkvm
+LIB_KVM=
+
+LIBS_PATH= -L$(OLIBSDIR)
+
+LDFLAGS= $(LDOPTS) $(LDOPTX)
+LDLIBS= $(LIBS) $(LIBX)
+
+#LDOPTS= $(LIBS_PATH) $(LDPATH) $(RUNPATH)
+LDOPTS= $(LIBS_PATH) $(LDPATH)
+LDOPTDYN= -shared -Wl,-soname,$(TARGET)
+LNDYNLIB= @$(SYMLINK) $(TARGET) $(PTARGET_BASE).so
+
+FLOAT_OPTIONS=
+
+CC= @echo " ==> COMPILING \"$@\""; gcc
+LDCC= @echo " ==> LINKING \"$@\""; gcc
+DYNLD= @echo " ==> LINKING dynamic library \"$@\""; gcc
+RANLIB= @echo " ==> RANDOMIZING ARCHIVE \"$@\""; true
+ARFLAGS= cr
+LORDER= echo
+TSORT= cat
+
+RMDEP= :
+MKDEP= @echo " ==> MAKING DEPENDENCIES \"$@\""; $(RMDEP); gcc -M
+MKDEP_OUT=
--- scsilib/libscg/scsi-linux-ata.c.scan 2005-02-05 22:45:03.422964296 +0100
+++ scsilib/libscg/scsi-linux-ata.c 2005-02-05 22:39:59.748129888 +0100
@@ -689,7 +689,7 @@ sg_amapdev(scgp, f, device, schillybus,
return (FALSE);
result = lstat(device, &buf);
- if (!result && S_ISLNK(buf.st_mode)) {
+ if (0 && !result && S_ISLNK(buf.st_mode)) {
result = readlink(device, tmp, LOCAL_MAX_PATH);
if (result > 0 && result < LOCAL_MAX_PATH) {
tmp[result] = '\0';
--- scsilib/libscg/scsi-linux-sg.c.scan 2004-09-22 12:57:24.313986568 +0200
+++ scsilib/libscg/scsi-linux-sg.c 2004-09-22 12:57:24.327984440 +0200
@@ -287,6 +287,8 @@
return (0);
}
+#include <glob.h>
+
LOCAL int
scgo_open(scgp, device)
SCSI *scgp;
@@ -301,8 +303,9 @@
register int t;
register int l;
register int nopen = 0;
- char devname[64];
- BOOL use_ata = FALSE;
+ char *devname;
+ BOOL use_ata = FALSE;
+ glob_t globbuf;
if (busno >= MAX_SCG || tgt >= MAX_TGT || tlun >= MAX_LUN) {
errno = EINVAL;
@@ -383,103 +386,86 @@
* look silly but there may be users that did boot from a SCSI hdd
* and connected 4 CD/DVD writers to both IDE cables in the PC.
*/
- if (use_ata) for (i = 0; i <= 25; i++) {
- js_snprintf(devname, sizeof (devname), "/dev/hd%c", i+'a');
- /* O_NONBLOCK is dangerous */
- f = open(devname, O_RDWR | O_NONBLOCK);
- if (f < 0) {
- /*
- * Set up error string but let us clear it later
- * if at least one open succeeded.
- */
- if (scgp->errstr)
- js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '/dev/hd*'");
- if (errno != ENOENT && errno != ENXIO && errno != ENODEV) {
+ if (use_ata) {
+ glob("/dev/hd[a-z]", GLOB_NOSORT, NULL, &globbuf);
+
+ for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
+ devname = globbuf.gl_pathv[i];
+ f = open(devname, O_RDWR | O_NONBLOCK);
+ if (f < 0) {
+ /*
+ * Set up error string but let us clear it later
+ * if at least one open succeeded.
+ */
if (scgp->errstr)
js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '%s'", devname);
- return (0);
- }
- } else {
- int iparm;
-
- if (ioctl(f, SG_GET_TIMEOUT, &iparm) < 0) {
- if (scgp->errstr)
- js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "SCSI unsupported with '/dev/hd*'");
- close(f);
- continue;
+ "Cannot open '/dev/hd*'");
+ if (errno != ENOENT && errno != ENXIO && errno != ENODEV && errno != EACCES) {
+ if (scgp->errstr)
+ js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
+ "Cannot open '%s'", devname);
+ globfree(&globbuf);
+ return (0);
+ }
+ } else {
+ int iparm;
+
+ if (ioctl(f, SG_GET_TIMEOUT, &iparm) < 0) {
+ if (scgp->errstr)
+ js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
+ "SCSI unsupported with '/dev/hd*'");
+ close(f);
+ continue;
+ }
+ sg_clearnblock(f); /* Be very proper about this */
+ if (sg_setup(scgp, f, busno, tgt, tlun, devname[7]-'a')) {
+ globfree(&globbuf);
+ return (++nopen);
+ }
+ if (busno < 0 && tgt < 0 && tlun < 0)
+ nopen++;
}
- sg_clearnblock(f); /* Be very proper about this */
- if (sg_setup(scgp, f, busno, tgt, tlun, i))
- return (++nopen);
- if (busno < 0 && tgt < 0 && tlun < 0)
- nopen++;
}
+ globfree(&globbuf);
}
if (use_ata && nopen == 0)
return (0);
if (nopen > 0 && scgp->errstr)
scgp->errstr[0] = '\0';
- if (nopen == 0) for (i = 0; i < 32; i++) {
- js_snprintf(devname, sizeof (devname), "/dev/sg%d", i);
- /* O_NONBLOCK is dangerous */
- f = open(devname, O_RDWR | O_NONBLOCK);
- if (f < 0) {
- /*
- * Set up error string but let us clear it later
- * if at least one open succeeded.
- */
- if (scgp->errstr)
- js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '/dev/sg*'");
- if (errno != ENOENT && errno != ENXIO && errno != ENODEV) {
+ if (nopen == 0) {
+ glob("/dev/scd[0-9]", GLOB_NOSORT, NULL, &globbuf);
+ glob("/dev/scd[0-9][0-9]", GLOB_NOSORT|GLOB_APPEND, NULL, &globbuf);
+ glob("/dev/sg[a-z]", GLOB_NOSORT|GLOB_APPEND, NULL, &globbuf);
+ glob("/dev/sg[0-9]", GLOB_NOSORT|GLOB_APPEND, NULL, &globbuf);
+ glob("/dev/sr[0-9]", GLOB_NOSORT|GLOB_APPEND, NULL, &globbuf);
+
+ for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
+ devname = globbuf.gl_pathv[i];
+
+ f = open(devname, O_RDWR | O_NONBLOCK);
+ if (f < 0) {
+ /*
+ * Set up error string but let us clear it later
+ * if at least one open succeeded.
+ */
if (scgp->errstr)
js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '%s'", devname);
- return (0);
+ "Cannot open '/dev/scd*'");
+ } else {
+ sg_clearnblock(f); /* Be very proper about this */
+ if (sg_setup(scgp, f, busno, tgt, tlun, -1)) {
+ globfree(&globbuf);
+ return (++nopen);
+ }
+ if (busno < 0 && tgt < 0 && tlun < 0)
+ nopen++;
}
- } else {
- sg_clearnblock(f); /* Be very proper about this */
- if (sg_setup(scgp, f, busno, tgt, tlun, -1))
- return (++nopen);
- if (busno < 0 && tgt < 0 && tlun < 0)
- nopen++;
}
}
if (nopen > 0 && scgp->errstr)
scgp->errstr[0] = '\0';
- if (nopen == 0) for (i = 0; i <= 25; i++) {
- js_snprintf(devname, sizeof (devname), "/dev/sg%c", i+'a');
- /* O_NONBLOCK is dangerous */
- f = open(devname, O_RDWR | O_NONBLOCK);
- if (f < 0) {
- /*
- * Set up error string but let us clear it later
- * if at least one open succeeded.
- */
- if (scgp->errstr)
- js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '/dev/sg*'");
- if (errno != ENOENT && errno != ENXIO && errno != ENODEV) {
- if (scgp->errstr)
- js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '%s'", devname);
- return (0);
- }
- } else {
- sg_clearnblock(f); /* Be very proper about this */
- if (sg_setup(scgp, f, busno, tgt, tlun, -1))
- return (++nopen);
- if (busno < 0 && tgt < 0 && tlun < 0)
- nopen++;
- }
- }
- if (nopen > 0 && scgp->errstr)
- scgp->errstr[0] = '\0';
openbydev:
if (device != NULL && *device != '\0') {
--- scsilib/libscg/scsi-linux-ata.c.scan 2004-06-12 12:48:12.000000000 +0200
+++ scsilib/libscg/scsi-linux-ata.c 2004-09-22 12:57:24.330983984 +0200
@@ -267,7 +267,7 @@
starget,
slun;
- f = open(device, O_RDONLY | O_NONBLOCK);
+ f = open(device, O_RDWR | O_NONBLOCK);
if (f < 0) {
if (scgp->errstr)
@@ -283,6 +283,9 @@
return (nopen);
}
+#include <glob.h>
+
+
LOCAL int
scan_internal(scgp, nopen)
SCSI *scgp;
@@ -293,118 +296,62 @@
int schilly_bus,
target,
lun;
- char device[128];
+ char *device;
+ glob_t globbuf;
+
/*
* try always with devfs
* unfortunatelly the solution with test of existing
* of '/dev/.devfsd' don't work, because it root.root 700
* and i don't like run suid root
*/
- BOOL DEVFS = TRUE;
+ BOOL DEVFS = FALSE;
- if (DEVFS) {
- for (i = 0; ; i++) {
- sprintf(device, "/dev/cdroms/cdrom%i", i);
- if ((f = open(device, O_RDONLY | O_NONBLOCK)) < 0) {
- if (errno != ENOENT && errno != ENXIO && errno != ENODEV && errno != EACCES) {
- if (scgp->debug > 4) {
- js_fprintf((FILE *) scgp->errfile,
- "try open(%s) return %i, errno %i, cancel\n", device, f, errno);
- }
- return (-2);
- } else if (errno == ENOENT || errno == ENODEV) {
- if (scgp->debug > 4) {
- js_fprintf((FILE *) scgp->errfile,
- "try open(%s) return %i, errno %i\n", device, f, errno);
- }
- if (0 == i) {
- DEVFS = FALSE;
- if (scgp->debug > 4) {
- js_fprintf((FILE *) scgp->errfile,
- "DEVFS not detected, continuing with old dev\n");
- }
- }
- break;
- }
+ glob("/dev/cdroms/cdrom*",
+ GLOB_NOSORT,
+ NULL, &globbuf);
+ glob("/dev/hd[a-z]",
+ GLOB_NOSORT|GLOB_APPEND,
+ NULL, &globbuf);
+ /*glob("/dev/scd*",
+ GLOB_NOSORT|GLOB_APPEND,
+ NULL, &globbuf);*/
+
+ for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
+ device = globbuf.gl_pathv[i];
+ if ((f = open(device, O_RDWR | O_NONBLOCK)) < 0) {
+ if (errno != ENOENT && errno != ENXIO && errno != ENODEV && errno != EACCES) {
if (scgp->debug > 4) {
- if (errno == EACCES) {
- js_fprintf((FILE *) scgp->errfile,
- "errno (EACCESS), you don't have the needed rights for %s\n",
- device);
- }
js_fprintf((FILE *) scgp->errfile,
- "try open(%s) return %i, errno %i, trying next cdrom\n",
- device, f, errno);
+ "try open(%s) return %i, errno %i, cancel\n", device, f, errno);
}
- } else {
- if (scgp->debug > 4) {
+ globfree(&globbuf);
+ return (-2);
+ }
+ if (scgp->debug > 4) {
+ if (errno == EACCES) {
js_fprintf((FILE *) scgp->errfile,
- "try open(%s) return %i errno %i calling sg_mapdev(...)\n",
- device, f, errno);
- }
- if (sg_amapdev(scgp, f, device, &schilly_bus, &target, &lun)) {
- (++(*nopen));
- } else {
- close(f);
+ "errno (EACCESS), you don't have the needed rights for %s\n",
+ device);
}
+ js_fprintf((FILE *) scgp->errfile,
+ "try open(%s) return %i, errno %i, trying next cdrom\n",
+ device, f, errno);
}
- }
- }
- if (!DEVFS) {
- /* for /dev/sr0 - /dev/sr? */
- for (i = 0; ; i++) {
- sprintf(device, "/dev/sr%i", i);
- if ((f = open(device, O_RDONLY | O_NONBLOCK)) < 0) {
- if (errno != ENOENT && errno != ENXIO && errno != ENODEV && errno != EACCES) {
- if (scgp->debug > 4) {
- js_fprintf((FILE *) scgp->errfile,
- "try open(%s) return %i, errno %i, cancel\n",
- device, f, errno);
- }
- return (-2);
- } else if (errno == ENOENT || errno == ENODEV) {
- break;
- }
- } else {
- if (sg_amapdev(scgp, f, device, &schilly_bus, &target, &lun)) {
- (++(*nopen));
- } else {
- close(f);
- }
+ } else {
+ if (scgp->debug > 4) {
+ js_fprintf((FILE *) scgp->errfile,
+ "try open(%s) return %i errno %i calling sg_mapdev(...)\n",
+ device, f, errno);
}
- }
-
- /* for /dev/hda - /dev/hdz */
- for (i = 'a'; i <= 'z'; i++) {
- sprintf(device, "/dev/hd%c", i);
- if ((f = open(device, O_RDONLY | O_NONBLOCK)) < 0) {
- if (errno != ENOENT && errno != ENXIO && errno != EACCES) {
- if (scgp->debug > 4) {
- js_fprintf((FILE *) scgp->errfile,
- "try open(%s) return %i, errno %i, cancel\n",
- device, f, errno);
- }
- return (-2);
- } else if (errno == ENOENT || errno == ENODEV) {
- break;
- }
+ if (sg_amapdev(scgp, f, device, &schilly_bus, &target, &lun)) {
+ (++(*nopen));
} else {
- /* ugly hack, make better, when you can. Alex */
- if (0 > ioctl(f, CDROM_DRIVE_STATUS, CDSL_CURRENT)) {
- if (scgp->debug > 4) {
- js_fprintf((FILE *) scgp->errfile,
- "%s is not a cdrom, skipping\n",
- device);
- }
- close(f);
- } else if (sg_amapdev(scgp, f, device, &schilly_bus, &target, &lun)) {
- (++(*nopen));
- } else {
- close(f);
- }
+ close(f);
}
}
}
+ globfree(&globbuf);
return (0);
}
--- scsilib/libscg/scsi-linux-pg.c.scan 2004-01-15 01:54:36.000000000 +0100
+++ scsilib/libscg/scsi-linux-pg.c 2004-09-22 12:59:04.107815600 +0200
@@ -130,6 +130,8 @@
return (0);
}
+#include <glob.h>
+
LOCAL int
scgo_open(scgp, device)
SCSI *scgp;
@@ -146,6 +148,8 @@
#endif
register int nopen = 0;
char devname[32];
+ glob_t globbuf;
+ int i;
if (busno >= MAX_SCG || tgt >= MAX_TGT || tlun >= MAX_LUN) {
errno = EINVAL;
@@ -217,10 +221,14 @@
scglocal(scgp)->scgfiles[busno][tgt][tlun] = f;
return (1);
} else {
+ const char *dev;
tlun = 0;
- for (tgt = 0; tgt < MAX_TGT; tgt++) {
- js_snprintf(devname, sizeof (devname), "/dev/pg%d", tgt);
- f = open(devname, O_RDWR | O_NONBLOCK);
+ glob("/dev/pg[0-9]", GLOB_NOSORT, NULL, &globbuf);
+ glob("/dev/pg[0-9][0-9]", GLOB_NOSORT|GLOB_APPEND, NULL, &globbuf);
+ for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
+ dev = globbuf.gl_pathv[i];
+ tgt = atoi(&dev[7]);
+ f = open(dev, O_RDWR | O_NONBLOCK);
if (f < 0) {
/*
* Set up error string but let us clear it later
@@ -232,7 +240,8 @@
if (errno != ENOENT && errno != ENXIO && errno != ENODEV) {
if (scgp->errstr)
js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
- "Cannot open '%s'", devname);
+ "Cannot open '%s'", dev);
+ globfree(&globbuf);
return (0);
}
} else {
@@ -240,6 +249,8 @@
nopen++;
}
}
+ globfree(&globbuf);
+
}
if (nopen > 0 && scgp->errstr)
scgp->errstr[0] = '\0';
--- scsilib/include/btorder.h.endianness 2004-01-20 13:53:42.000000000 +0100
+++ scsilib/include/btorder.h 2004-01-20 13:55:24.000000000 +0100
@@ -100,6 +100,7 @@
# endif
# if defined(__i386__) || defined(__i386) || defined(i386) || \
+ defined(__ia64__) || defined(__ia64) || defined(ia64) || \
defined(__alpha__) || defined(__alpha) || defined(alpha) || \
defined(__arm__) || defined(__arm) || defined(arm)
# define _BIT_FIELDS_LTOH
--- cdrtools-2.01/libscg/scsi-linux-sg.c.silly 2004-05-20 15:42:12.000000000 +0200
+++ cdrtools-2.01/libscg/scsi-linux-sg.c 2004-09-08 11:37:47.670038792 +0200
@@ -315,6 +315,10 @@
if (device != NULL && *device != '\0') {
#ifdef USE_ATA
if (strncmp(device, "ATAPI", 5) == 0) {
+ if (scgp->overbose) {
+ js_fprintf((FILE *)scgp->errfile,
+ "Use of ATA is preferred over ATAPI.\n");
+ }
scgp->ops = &ata_ops;
return (SCGO_OPEN(scgp, device));
}
@@ -336,18 +340,6 @@
*/
use_ata = TRUE;
device = NULL;
- if (scgp->overbose) {
- /*
- * I strongly encourage people who believe that
- * they need to patch this message away to read
- * the messages in the Solaris USCSI libscg
- * layer instead of wetting their tissues while
- * being unwilling to look besides their
- * own belly button.
- */
- js_fprintf((FILE *)scgp->errfile,
- "Warning: Using badly designed ATAPI via /dev/hd* interface.\n");
- }
}
}
@@ -497,20 +489,7 @@
if (b < 0 || b > 25)
b = -1;
}
- if (scgp->overbose) {
- /*
- * Before you patch this away, are you sure that you
- * know what you are going to to?
- *
- * Note that this is a warning that helps users from
- * cdda2wav, mkisofs and other programs (that
- * distinguish SCSI addresses from file names) from
- * getting unexpected results.
- */
- js_fprintf((FILE *)scgp->errfile,
- "Warning: Open by 'devname' is unintentional and not supported.\n");
- }
- /* O_NONBLOCK is dangerous */
+ /* O_NONBLOCK is dangerous */
f = open(device, O_RDWR | O_NONBLOCK);
/* if (f < 0 && errno == ENOENT)*/
/* goto openpg;*/
diff -u -r -3 cdrtools-2.01/include/utypes.h cdrtools-2.01.ossdvd/include/utypes.h
--- cdrtools-2.01/include/utypes.h 2003-06-15 23:41:23.000000000 +0200
+++ cdrtools-2.01.ossdvd/include/utypes.h 2004-08-27 07:13:09.076574488 +0200
@@ -75,6 +75,25 @@
typedef unsigned char Uchar;
/*
+ * Added these cause Linux distro's using kernel 2.6.x seems
+ * to want them.
+ */
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+#if defined(__GNUC__) /* this is defined gcc-3.x */
+typedef unsigned long long u64;
+#endif
+
+/*
+ * Dodge the __attribute_const__ out of sneaky kernel includes.
+ * cdrtools is a userland program, so no kernel attribute's
+ */
+#ifndef __attribute_const__
+# define __attribute_const__ /* unimplemented */
+#endif
+
+/*
* This is a definition for a compiler dependant 64 bit type.
* It currently is silently a long if the compiler does not
* support it. Check if this is the right way.
--- cdrtools/include/mconfig.h.xc 2004-07-11 00:46:53.000000000 +0200
+++ cdrtools/include/mconfig.h 2006-06-02 17:21:55.000000000 +0200
@@ -49,6 +49,70 @@
extern "C" {
#endif
+
+#define HAVE_BROKEN_SRC_LINUX_EXT2_FS_H 1 /* whether /usr/src/linux/include/linux/ext2_fs.h is broken */
+#undef DEV_MINOR_BITS /* # if bits needed to hold minor device number */
+/*
+ * Byteorder/Bitorder
+ */
+#define HAVE_C_BIGENDIAN /* Flag that WORDS_BIGENDIAN test was done */
+#if defined(__BIG_ENDIAN__)
+#define WORDS_BIGENDIAN 1 /* If using network byte order */
+#endif
+#define HAVE_C_BITFIELDS /* Flag that BITFIELDS_HTOL test was done */
+#if defined(__BIG_ENDIAN__)
+#define BITFIELDS_HTOL 1 /* If high bits come first in structures */
+#endif
+
+/*
+ * Types/Keywords
+ */
+
+#if defined(__x86_64__) || defined(__ia64__) || defined(__powerpc64__) || defined(__s390x__)
+#define SIZEOF_LONG_INT 8
+#define SIZEOF_CHAR_P 8
+#define SIZEOF_UNSIGNED_LONG_INT 8
+#define SIZEOF_UNSIGNED_CHAR_P 8
+#elif defined(__i386__) || defined(__powerpc__) || defined(__s390__)
+#define SIZEOF_LONG_INT 4
+#define SIZEOF_CHAR_P 4
+#define SIZEOF_UNSIGNED_LONG_INT 4
+#define SIZEOF_UNSIGNED_CHAR_P 4
+#else
+#error Architecture not defined here!
+#endif
+
+#define SIZEOF_CHAR 1
+#define SIZEOF_SHORT_INT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_UNSIGNED_CHAR 1
+#define SIZEOF_UNSIGNED_SHORT_INT 2
+#define SIZEOF_UNSIGNED_INT 4
+#define SIZEOF_UNSIGNED_LONG_LONG 8
+
+#if defined(__LONG_LONG_MAX__)
+#define HAVE_LONGLONG 1 /* Compiler defines long long type */
+#endif
+
+#if defined(__CHAR_UNSIGNED__)
+#define CHAR_IS_UNSIGNED 1 /* Compiler defines char to be unsigned */
+#endif
+
+#define VA_LIST_IS_ARRAY 1 /* va_list is an array */
+#define _FILE_OFFSET_BITS 64 /* # of bits in off_t if settable */
+#define _LARGEFILE_SOURCE 1 /* To make ftello() visible (HP-UX 10.20). */
+
+/*
+ * Strings that help to maintain OS/platform id's in C-programs
+ */
+#define HOST_ALIAS "pc-linux-gnu" /* Output from config.guess (orig) */
+#define HOST_SUB "pc-linux-gnu" /* Output from config.sub (modified) */
+#define HOST_CPU "cpu" /* CPU part from HOST_SUB */
+#define HOST_VENDOR "pc" /* VENDOR part from HOST_SUB */
+#define HOST_OS "linux-gnu" /* CPU part from HOST_SUB */
+
+
/*
* The NetBSD people want to bother us.
* They removed the definition for 'unix' and are bleating for every test
--- cdrtools/conf/xconfig.h.in.xc 2006-02-07 17:23:13.000000000 +0100
+++ cdrtools/conf/xconfig.h.in 2006-06-02 17:22:06.000000000 +0200
@@ -408,38 +406,11 @@
#undef HAVE_ST_FLAGS /* if struct stat contains st_flags */
#undef STAT_MACROS_BROKEN /* if the macros S_ISDIR, S_ISREG .. don't work */
-#undef DEV_MINOR_BITS /* # if bits needed to hold minor device number */
#undef DEV_MINOR_NONCONTIG /* if bits in minor device number are noncontiguous */
#undef HAVE_SOCKADDR_STORAGE /* if socket.h defines struct sockaddr_storage */
-/*
- * Byteorder/Bitorder
- */
-#define HAVE_C_BIGENDIAN /* Flag that WORDS_BIGENDIAN test was done */
-#undef WORDS_BIGENDIAN /* If using network byte order */
-#define HAVE_C_BITFIELDS /* Flag that BITFIELDS_HTOL test was done */
-#undef BITFIELDS_HTOL /* If high bits come first in structures */
-
-/*
- * Types/Keywords
- */
-#undef SIZEOF_CHAR
-#undef SIZEOF_SHORT_INT
-#undef SIZEOF_INT
-#undef SIZEOF_LONG_INT
-#undef SIZEOF_LONG_LONG
-#undef SIZEOF_CHAR_P
-#undef SIZEOF_UNSIGNED_CHAR
-#undef SIZEOF_UNSIGNED_SHORT_INT
-#undef SIZEOF_UNSIGNED_INT
-#undef SIZEOF_UNSIGNED_LONG_INT
-#undef SIZEOF_UNSIGNED_LONG_LONG
-#undef SIZEOF_UNSIGNED_CHAR_P
-
-#undef HAVE_LONGLONG /* Compiler defines long long type */
-#undef CHAR_IS_UNSIGNED /* Compiler defines char to be unsigned */
#undef const /* Define to empty if const doesn't work */
#undef uid_t /* To be used if uid_t is not present */
@@ -479,7 +450,6 @@
/*#undef HAVE_SIZE_T*/
/*#undef NO_SIZE_T*/
-#undef VA_LIST_IS_ARRAY /* va_list is an array */
#undef GETGROUPS_T
#define GID_T GETGROUPS_T
@@ -498,8 +468,6 @@
#ifdef HAVE_LARGEFILES /* If we have working largefiles at all */
/* This is not defined with glibc-2.1.3 */
-#undef _FILE_OFFSET_BITS /* # of bits in off_t if settable */
-#undef _LARGEFILE_SOURCE /* To make ftello() visible (HP-UX 10.20). */
#undef _LARGE_FILES /* Large file defined on AIX-style hosts. */
#undef _XOPEN_SOURCE /* To make ftello() visible (glibc 2.1.3). */
/* XXX We don't use this because glibc2.1.3*/
@@ -583,15 +551,6 @@
#undef NO_USER_MALLOC /* If we cannot define our own malloc() */
#undef HAVE_DYN_ARRAYS /* If the compiler allows dynamic sized arrays */
-/*
- * Strings that help to maintain OS/platform id's in C-programs
- */
-#undef HOST_ALIAS /* Output from config.guess (orig) */
-#undef HOST_SUB /* Output from config.sub (modified) */
-#undef HOST_CPU /* CPU part from HOST_SUB */
-#undef HOST_VENDOR /* VENDOR part from HOST_SUB */
-#undef HOST_OS /* CPU part from HOST_SUB */
-
/*
* Begin restricted code for quality assurance.
--- cdrtools-2.01/libscg/oexcl.c.excl 2004-09-22 12:03:23.426676328 +0200
+++ cdrtools-2.01/libscg/oexcl.c 2004-09-22 12:03:23.426676328 +0200
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int openexcl(const char *device, int mode)
+{
+ int f, i;
+
+ f = open(device, mode | O_EXCL);
+
+ if (f < 0) {
+ f = open(device, mode);
+
+ if (f >= 0) {
+ close(f);
+ f = -1;
+ for (i = 0; (i < 10) && (f == -1); i++) {