Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / sysutils / dvdrecord / patches / patch-ab
blob5f3647e2faf88bd026c156e51167fbb2635f2599
1 $NetBSD: patch-ab,v 1.1 2003/01/31 11:02:29 abs Exp $
3 --- libscg/scsi-bsd.c.orig      Tue Jan 29 17:23:22 2002
4 +++ libscg/scsi-bsd.c
5 @@ -48,7 +48,7 @@ static        char __sccsid[] =
6   *     Choose your name instead of "schily" and make clear that the version
7   *     string is related to a modified source.
8   */
9 -LOCAL  char    _scg_trans_version[] = "scsi-bsd.c-1.40";       /* The version for this transport*/
10 +LOCAL  char    _scg_trans_version[] = "scsi-bsd.c-1.40nb1";    /* The version for this transport*/
12  #define        MAX_SCG         16      /* Max # of SCSI controllers */
13  #define        MAX_TGT         16
14 @@ -108,7 +108,7 @@ scgo_version(scgp, what)
15                  * return "schily" for the SCG_AUTHOR request.
16                  */
17                 case SCG_AUTHOR:
18 -                       return (_scg_auth_schily);
19 +                       return ("frueauf");
20                 case SCG_SCCS_ID:
21                         return (__sccsid);
22                 }
23 @@ -130,6 +130,15 @@ scgo_open(scgp, device)
24         register int    l;
25         register int    nopen = 0;
26         char            devname[64];
27 +#if defined(__NetBSD__)
28 +       struct scsi_addr mysaddr;
29 +#if defined(__i386__) || defined(__amd64__)
30 +       char    slicename[] = "d";      /* i386 is special */
31 +#else
32 +       char    slicename[] = "c";      /* this is what the rest uses */
33 +#endif
34 +       char    *myslicename = slicename;
35 +#endif
37         if (busno >= MAX_SCG || tgt >= MAX_TGT || tlun >= MAX_LUN) {
38                 errno = EINVAL;
39 @@ -156,6 +165,60 @@ scgo_open(scgp, device)
40         if ((device != NULL && *device != '\0') || (busno == -2 && tgt == -2))
41                 goto openbydev;
44 +/*
45 + * I know of no method in NetBSD to probe the scsibus and get the mapping
46 + * busnumber,target,lun --> devicename.
47 + *
48 + * Because of this implement a true bruteforce hack to find
49 + * out what cdroms there are.
50 + *
51 + * Note that this method only finds cd0-cd7. Anything higher
52 + * than this needs additional tweaks.
53 + *
54 + * Feel free to implement this cleanly if you have better knowledge.
55 + * Until then this helps to get -scanbus und thus xcdroast working :-)
56 + *
57 + */
58 +#if defined(__NetBSD__)
59 +       if (busno >= 0 && tgt >= 0 && tlun >= 0) {
60 +               for (l=0; l < MAX_LUN ; l++) {
61 +                       sprintf(devname, "/dev/rcd%d%s", l, myslicename);
62 +                       f = open(devname, O_RDWR);
63 +                       if (f >= 0) {
64 +                               if (ioctl(f, SCIOCIDENTIFY, &mysaddr) < 0) {
65 +                                       close(f);
66 +                                       errno = EINVAL;
67 +                                       return (0);
68 +                               }
69 +                               if (busno == SADDR_BUS(mysaddr) && tgt == SADDR_TARGET(mysaddr) && tlun == SADDR_LUN(mysaddr)) {
70 +                                       scglocal(scgp)->scgfiles[busno][tgt][tlun] = f;
71 +                                       return(1);
72 +                               }
73 +                       } else goto openbydev;
74 +               }
75 +       } else for (l=0; l < MAX_LUN ; l++) {
76 +                       sprintf(devname, "/dev/rcd%d%s", l, myslicename);
77 +                       f = open(devname, O_RDWR);
78 +                       if (f >= 0) {
79 +                               if (ioctl(f, SCIOCIDENTIFY, &mysaddr) < 0) {
80 +                                       close(f);
81 +                                       errno = EINVAL;
82 +                                       return (0);
83 +                               }
84 +                               scg_scsibus(scgp) = busno   = SADDR_BUS(mysaddr);
85 +                               scg_target(scgp)  = tgt     = SADDR_TARGET(mysaddr);
86 +                               if ((tlun >= 0) && (tlun != SADDR_LUN(mysaddr))) {
87 +                                       close(f);
88 +                                       errno = EINVAL;
89 +                                       return (0);
90 +                               }
91 +                               scg_lun(scgp)     = tlun    = SADDR_LUN(mysaddr);
92 +                               if (scg_setup(scgp, f, busno, tgt, tlun))
93 +                                       nopen++;
94 +                       }
95 +               }
96 +#else /* not __NetBSD__ */
97         if (busno >= 0 && tgt >= 0 && tlun >= 0) {
99                 js_snprintf(devname, sizeof(devname),
100 @@ -192,6 +255,7 @@ scgo_open(scgp, device)
101                         }
102                 }
103         }
104 +#endif /* end of not __NetBSD__ */
105         /*
106          * Could not open /dev/su-* or got dev=devname:b,l,l / dev=devname:@,l
107          * We do the apropriate tests and try our best.