]> cvs.zerfleddert.de Git - usb-driver/blob - usb-driver.c
implement support for multiple XPCU cables for ISE 10.1
[usb-driver] / usb-driver.c
1 /* libusb/ppdev connector for XILINX impact
2 *
3 * Copyright (c) 2007 Michael Gernoth <michael@gernoth.net>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #define _GNU_SOURCE 1
25
26 #include <dlfcn.h>
27 #include <stdarg.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <fcntl.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <sys/time.h>
35 #include <stdio.h>
36 #include <signal.h>
37 #include <errno.h>
38 #include <inttypes.h>
39 #include <sys/ioctl.h>
40 #include <sys/utsname.h>
41 #include <bits/wordsize.h>
42 #include "usb-driver.h"
43 #include "config.h"
44 #include "xpcu.h"
45
46 static int (*ioctl_func) (int, int, void *) = NULL;
47 static int *windrvrfds = NULL;
48 static int windrvrfds_count = 0;
49 static unsigned long ppbase = 0;
50 static unsigned long ecpbase = 0;
51 static struct parport_config *pport = NULL;
52 static FILE *modulesfp = NULL;
53 static FILE *baseaddrfp = NULL;
54 static int baseaddrnum = 0;
55 static int modules_read = 0;
56
57 #define NO_WINDRVR 1
58
59 void hexdump(unsigned char *buf, int len) {
60 int i;
61
62 for(i=0; i<len; i++) {
63 fprintf(stderr,"%02x ", buf[i]);
64 if ((i % 16) == 15)
65 fprintf(stderr,"\n");
66 }
67 fprintf(stderr,"\n");
68 }
69
70
71 static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
72 struct header_struct* wdheader = (struct header_struct*)wdioctl;
73 struct version_struct *version;
74 int ret = 0;
75
76 if (wdheader->magic != MAGIC) {
77 fprintf(stderr,"!!!ERROR: magic header does not match!!!\n");
78 return (*ioctl_func) (fd, request, wdioctl);
79 }
80
81 switch(request & ~(0xc0000000)) {
82 case VERSION:
83 version = (struct version_struct*)(wdheader->data);
84 strcpy(version->version, "libusb-driver.so version: " USB_DRIVER_VERSION);
85 version->versionul = 802;
86 DPRINTF("VERSION\n");
87 break;
88
89 case LICENSE:
90 DPRINTF("LICENSE\n");
91 break;
92
93 case CARD_REGISTER_OLD:
94 case CARD_REGISTER:
95 DPRINTF("CARD_REGISTER\n");
96 {
97 struct card_register* cr = (struct card_register*)(wdheader->data);
98
99 DPRINTF("-> Items: %lu, Addr: 0x%lx, bytes: %lu, bar: %lu\n",
100 cr->Card.dwItems,
101 (unsigned long)cr->Card.Item[0].I.IO.dwAddr,
102 cr->Card.Item[0].I.IO.dwBytes,
103 cr->Card.Item[0].I.IO.dwBar);
104
105 DPRINTF("-> Items: %lu, Addr: 0x%lx, bytes: %lu, bar: %lu\n",
106 cr->Card.dwItems,
107 (unsigned long)cr->Card.Item[1].I.IO.dwAddr,
108 cr->Card.Item[1].I.IO.dwBytes,
109 cr->Card.Item[1].I.IO.dwBar);
110 #ifndef NO_WINDRVR
111 ret = (*ioctl_func) (fd, request, wdioctl);
112 #else
113
114 pport = config_get((unsigned long)cr->Card.Item[0].I.IO.dwAddr / 0x10);
115 if (!pport)
116 break;
117
118 ret = pport->open((unsigned long)cr->Card.Item[0].I.IO.dwAddr / 0x10);
119
120 ppbase = (unsigned long)cr->Card.Item[0].I.IO.dwAddr;
121
122 if (cr->Card.dwItems > 1 && cr->Card.Item[1].I.IO.dwAddr)
123 ecpbase = (unsigned long)cr->Card.Item[1].I.IO.dwAddr;
124
125 if (ret >= 0) {
126 cr->hCard = ret;
127 } else {
128 cr->hCard = 0;
129 }
130 #endif
131 DPRINTF("<-hCard: %lu\n", cr->hCard);
132 }
133 break;
134
135 case USB_TRANSFER:
136 DPRINTF("USB_TRANSFER\n");
137 {
138 struct usb_transfer *ut = (struct usb_transfer*)(wdheader->data);
139
140 #ifdef DEBUG
141 DPRINTF("-> unique: 0x%lx, pipe: %lu, read: %lu, options: %lx, size: %lu, timeout: %lx\n",
142 ut->dwUniqueID, ut->dwPipeNum, ut->fRead,
143 ut->dwOptions, ut->dwBufferSize, ut->dwTimeout);
144 if (ut->dwPipeNum == 0) {
145 DPRINTF("-> setup packet: ");
146 hexdump(ut->SetupPacket, 8);
147 }
148
149 if (!ut->fRead && ut->dwBufferSize)
150 {
151 hexdump(ut->pBuffer, ut->dwBufferSize);
152 }
153 #endif
154
155 #ifndef NO_WINDRVR
156 ret = (*ioctl_func) (fd, request, wdioctl);
157 #else
158 ret = xpcu_transfer(ut);
159 #endif
160
161 #ifdef DEBUG
162 DPRINTF("Transferred: %lu (%s)\n",ut->dwBytesTransferred, (ut->fRead?"read":"write"));
163 if (ut->fRead && ut->dwBytesTransferred)
164 {
165 DPRINTF("<- Read: ");
166 hexdump(ut->pBuffer, ut->dwBytesTransferred);
167 }
168 #endif
169 }
170 break;
171
172 case INT_ENABLE_OLD:
173 case INT_ENABLE:
174 DPRINTF("INT_ENABLE\n");
175 {
176 struct interrupt *it = (struct interrupt*)(wdheader->data);
177
178 DPRINTF("-> Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
179 it->hInterrupt, it->dwOptions,
180 it->dwCmds, it->fEnableOk, it->dwCounter,
181 it->dwLost, it->fStopped);
182
183 #ifndef NO_WINDRVR
184 ret = (*ioctl_func) (fd, request, wdioctl);
185 #else
186 ret = xpcu_int_state(it, ENABLE_INTERRUPT);
187 #endif
188
189 DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
190 it->hInterrupt, it->dwOptions,
191 it->dwCmds, it->fEnableOk, it->dwCounter,
192 it->dwLost, it->fStopped);
193 }
194
195 break;
196
197 case INT_DISABLE:
198 DPRINTF("INT_DISABLE\n");
199 {
200 struct interrupt *it = (struct interrupt*)(wdheader->data);
201
202 DPRINTF("-> Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
203 it->hInterrupt, it->dwOptions,
204 it->dwCmds, it->fEnableOk, it->dwCounter,
205 it->dwLost, it->fStopped);
206 #ifndef NO_WINDRVR
207 ret = (*ioctl_func) (fd, request, wdioctl);
208 #else
209 ret = xpcu_int_state(it, DISABLE_INTERRUPT);
210 #endif
211 DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
212 it->hInterrupt, it->dwOptions,
213 it->dwCmds, it->fEnableOk, it->dwCounter,
214 it->dwLost, it->fStopped);
215 }
216 break;
217
218 case USB_SET_INTERFACE:
219 DPRINTF("USB_SET_INTERFACE\n");
220 {
221 struct usb_set_interface *usi = (struct usb_set_interface*)(wdheader->data);
222
223 DPRINTF("-> unique: 0x%lx, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
224 usi->dwUniqueID, usi->dwInterfaceNum,
225 usi->dwAlternateSetting, usi->dwOptions);
226 #ifndef NO_WINDRVR
227 ret = (*ioctl_func) (fd, request, wdioctl);
228 #else
229 ret = xpcu_set_interface(usi);
230 #endif
231 DPRINTF("<- unique: 0x%lx, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
232 usi->dwUniqueID, usi->dwInterfaceNum,
233 usi->dwAlternateSetting, usi->dwOptions);
234 }
235 break;
236
237 case USB_GET_DEVICE_DATA_OLD:
238 case USB_GET_DEVICE_DATA:
239 DPRINTF("USB_GET_DEVICE_DATA\n");
240 {
241 struct usb_get_device_data *ugdd = (struct usb_get_device_data*)(wdheader->data);
242
243 DPRINTF("-> unique: 0x%lx, bytes: %lu, options: %lx\n",
244 ugdd->dwUniqueID, ugdd->dwBytes,
245 ugdd->dwOptions);
246
247 ret = xpcu_deviceinfo(ugdd);
248
249 }
250 break;
251
252 case EVENT_REGISTER_OLD:
253 case EVENT_REGISTER:
254 DPRINTF("EVENT_REGISTER\n");
255 {
256 struct event *e = (struct event*)(wdheader->data);
257 #ifdef DEBUG
258 int i;
259 #endif
260
261 DPRINTF("-> handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
262 e->handle, e->dwAction,
263 e->dwStatus, e->dwEventId, e->dwCardType,
264 e->hKernelPlugIn, e->dwOptions,
265 e->u.Usb.deviceId.dwVendorId,
266 e->u.Usb.deviceId.dwProductId,
267 e->u.Usb.dwUniqueID, e->dwEventVer,
268 e->dwNumMatchTables);
269
270 #ifndef NO_WINDRVR
271 ret = (*ioctl_func) (fd, request, wdioctl);
272 #else
273 ret = xpcu_find(e);
274 #endif
275
276 #ifdef DEBUG
277 DPRINTF("<- handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
278 e->handle, e->dwAction,
279 e->dwStatus, e->dwEventId, e->dwCardType,
280 e->hKernelPlugIn, e->dwOptions,
281 e->u.Usb.deviceId.dwVendorId,
282 e->u.Usb.deviceId.dwProductId,
283 e->u.Usb.dwUniqueID, e->dwEventVer,
284 e->dwNumMatchTables);
285
286 for (i = 0; i < e->dwNumMatchTables; i++)
287 DPRINTF("match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
288 e->matchTables[i].VendorId,
289 e->matchTables[i].ProductId,
290 e->matchTables[i].bDeviceClass,
291 e->matchTables[i].bDeviceSubClass,
292 e->matchTables[i].bInterfaceClass,
293 e->matchTables[i].bInterfaceSubClass,
294 e->matchTables[i].bInterfaceProtocol);
295 #endif
296 }
297 break;
298
299 case TRANSFER_OLD:
300 case TRANSFER:
301 DPRINTF("TRANSFER\n");
302 {
303 WD_TRANSFER *tr = (WD_TRANSFER*)(wdheader->data);
304
305 #ifndef NO_WINDRVR
306 ret = (*ioctl_func) (fd, request, wdioctl);
307 #else
308 ret = pport->transfer(tr, fd, request, ppbase, ecpbase, 1);
309 #endif
310 }
311 break;
312
313 case MULTI_TRANSFER_OLD:
314 case MULTI_TRANSFER:
315 DPRINTF("MULTI_TRANSFER\n");
316 {
317 WD_TRANSFER *tr = (WD_TRANSFER*)(wdheader->data);
318 unsigned long num = wdheader->size/sizeof(WD_TRANSFER);
319 #ifndef NO_WINDRVR
320 ret = (*ioctl_func) (fd, request, wdioctl);
321 #else
322 ret = pport->transfer(tr, fd, request, ppbase, ecpbase, num);
323 #endif
324 }
325 break;
326
327 case EVENT_UNREGISTER:
328 {
329 struct event *e = (struct event*)(wdheader->data);
330
331 DPRINTF("EVENT_UNREGISTER\n");
332 #ifndef NO_WINDRVR
333 ret = (*ioctl_func) (fd, request, wdioctl);
334 #else
335 ret = xpcu_close(e);
336 #endif
337 }
338 break;
339
340 case INT_WAIT:
341 DPRINTF("INT_WAIT\n");
342 {
343 struct interrupt *it = (struct interrupt*)(wdheader->data);
344
345 DPRINTF("-> Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
346 it->hInterrupt, it->dwOptions,
347 it->dwCmds, it->fEnableOk, it->dwCounter,
348 it->dwLost, it->fStopped);
349
350 #ifndef NO_WINDRVR
351 ret = (*ioctl_func) (fd, request, wdioctl);
352 #else
353 ret = xpcu_int_wait(it);
354 #endif
355
356 DPRINTF("<- INT_WAIT_RETURN: Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
357 it->hInterrupt, it->dwOptions, it->dwCmds,
358 it->fEnableOk, it->dwCounter, it->dwLost,
359 it->fStopped);
360 }
361 break;
362
363 case CARD_UNREGISTER:
364 DPRINTF("CARD_UNREGISTER\n");
365 {
366 struct card_register* cr = (struct card_register*)(wdheader->data);
367
368 DPRINTF("-> Addr: 0x%lx, bytes: %lu, bar: %lu\n",
369 (unsigned long)cr->Card.Item[0].I.IO.dwAddr,
370 cr->Card.Item[0].I.IO.dwBytes,
371 cr->Card.Item[0].I.IO.dwBar);
372
373 DPRINTF("-> hCard: %lu\n", cr->hCard);
374
375 #ifndef NO_WINDRVR
376 ret = (*ioctl_func) (fd, request, wdioctl);
377 #else
378 if (pport)
379 pport->close(cr->hCard);
380
381 pport = NULL;
382 #endif
383 }
384 break;
385
386 case EVENT_PULL:
387 DPRINTF("EVENT_PULL\n");
388 {
389 struct event *e = (struct event*)(wdheader->data);
390 #ifdef DEBUG
391 int i;
392
393 DPRINTF("-> handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lx, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
394 e->handle, e->dwAction, e->dwStatus,
395 e->dwEventId, e->dwCardType, e->hKernelPlugIn,
396 e->dwOptions, e->u.Usb.deviceId.dwVendorId,
397 e->u.Usb.deviceId.dwProductId,
398 e->u.Usb.dwUniqueID, e->dwEventVer,
399 e->dwNumMatchTables);
400
401 for (i = 0; i < e->dwNumMatchTables; i++)
402 DPRINTF("-> match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
403 e->matchTables[i].VendorId,
404 e->matchTables[i].ProductId,
405 e->matchTables[i].bDeviceClass,
406 e->matchTables[i].bDeviceSubClass,
407 e->matchTables[i].bInterfaceClass,
408 e->matchTables[i].bInterfaceSubClass,
409 e->matchTables[i].bInterfaceProtocol);
410 #endif
411
412 #ifndef NO_WINDRVR
413 ret = (*ioctl_func) (fd, request, wdioctl);
414 #else
415 ret = xpcu_found(e);
416 #endif
417
418 #ifdef DEBUG
419 DPRINTF("<- handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lx, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
420 e->handle, e->dwAction, e->dwStatus,
421 e->dwEventId, e->dwCardType, e->hKernelPlugIn,
422 e->dwOptions, e->u.Usb.deviceId.dwVendorId,
423 e->u.Usb.deviceId.dwProductId,
424 e->u.Usb.dwUniqueID, e->dwEventVer,
425 e->dwNumMatchTables);
426
427 for (i = 0; i < e->dwNumMatchTables; i++)
428 DPRINTF("<- match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
429 e->matchTables[i].VendorId,
430 e->matchTables[i].ProductId,
431 e->matchTables[i].bDeviceClass,
432 e->matchTables[i].bDeviceSubClass,
433 e->matchTables[i].bInterfaceClass,
434 e->matchTables[i].bInterfaceSubClass,
435 e->matchTables[i].bInterfaceProtocol);
436 #endif
437
438 }
439 break;
440
441 default:
442 fprintf(stderr,"!!!Unsupported IOCTL: %x!!!\n", request);
443 #ifndef NO_WINDRVR
444 ret = (*ioctl_func) (fd, request, wdioctl);
445 #endif
446 break;
447 }
448
449 return ret;
450 }
451
452 int ioctl(int fd, unsigned long int request, ...) {
453 va_list args;
454 void *argp;
455 int i;
456
457 if (!ioctl_func)
458 ioctl_func = (int (*) (int, int, void *)) dlsym (RTLD_NEXT, "ioctl");
459
460 va_start (args, request);
461 argp = va_arg (args, void *);
462 va_end (args);
463
464 for (i = 0; i < windrvrfds_count; i++) {
465 if (fd == windrvrfds[i])
466 return do_wdioctl(fd, request, argp);
467 }
468
469 return (*ioctl_func) (fd, request, argp);
470 }
471
472 int open (const char *pathname, int flags, ...) {
473 static int (*func) (const char *, int, mode_t) = NULL;
474 mode_t mode = 0;
475 va_list args;
476 int fd;
477
478 if (!func)
479 func = (int (*) (const char *, int, mode_t)) dlsym (RTLD_NEXT, "open");
480
481 if (flags & O_CREAT) {
482 va_start(args, flags);
483 mode = va_arg(args, mode_t);
484 va_end(args);
485 }
486
487 if (!strcmp (pathname, "/dev/windrvr6")) {
488 DPRINTF("opening windrvr6 (%d)\n", windrvrfds_count);
489 windrvrfds = realloc(windrvrfds, sizeof(int) * (++windrvrfds_count));
490 if (!windrvrfds)
491 return -ENOMEM;
492
493 #ifdef NO_WINDRVR
494 windrvrfds[windrvrfds_count-1] = fd = (*func) ("/dev/null", flags, mode);
495 #else
496 windrvrfds[windrvrfds_count-1] = fd = (*func) (pathname, flags, mode);
497 #endif
498
499 return fd;
500 }
501
502 return (*func) (pathname, flags, mode);
503 }
504
505 int close(int fd) {
506 static int (*func) (int) = NULL;
507 int i;
508
509 if (!func)
510 func = (int (*) (int)) dlsym(RTLD_NEXT, "close");
511
512 for (i = 0; i < windrvrfds_count; i++) {
513 if (fd == windrvrfds[i] && windrvrfds[i] >= 0) {
514 int remaining = windrvrfds_count - (i + 1);
515 DPRINTF("close windrvr6 (%d)\n", i);
516 if (remaining)
517 memmove(&(windrvrfds[i]), &(windrvrfds[i+1]), remaining * sizeof(int));
518 windrvrfds = realloc(windrvrfds, sizeof(int) * --windrvrfds_count);
519 if (!windrvrfds_count)
520 windrvrfds = NULL;
521 break;
522 }
523 }
524
525 return (*func) (fd);
526 }
527
528 FILE *fopen(const char *path, const char *mode) {
529 FILE *ret;
530 static FILE* (*func) (const char*, const char*) = NULL;
531 char buf[256];
532 int i;
533
534 if (!func)
535 func = (FILE* (*) (const char*, const char*)) dlsym(RTLD_NEXT, "fopen");
536
537 for (i = 0; i < 4; i++) {
538 snprintf(buf, sizeof(buf), "/proc/sys/dev/parport/parport%d/base-addr", i);
539 if (!strcmp(path, buf)) {
540 DPRINTF("open base-addr of parport%d\n", i);
541 if (config_is_real_pport(i)) {
542 ret = (*func) (path, mode);
543 } else {
544 ret = (*func) ("/dev/null", mode);
545 }
546
547 if (ret) {
548 baseaddrfp = ret;
549 baseaddrnum = i;
550 }
551
552 return ret;
553 }
554 }
555
556 ret = (*func) (path, mode);
557
558 if (!strcmp(path, "/proc/modules")) {
559 DPRINTF("opening /proc/modules\n");
560 #ifdef NO_WINDRVR
561 modulesfp = ret;
562 modules_read = 0;
563 #endif
564 }
565
566 return ret;
567 }
568
569 char *fgets(char *s, int size, FILE *stream) {
570 static char* (*func) (char*, int, FILE*) = NULL;
571 const char modules[][256] = {"windrvr6 1 0 - Live 0xdeadbeef\n", "parport_pc 1 0 - Live 0xdeadbeef\n"};
572 char buf[256];
573 char *ret = NULL;
574
575
576 if (!func)
577 func = (char* (*) (char*, int, FILE*)) dlsym(RTLD_NEXT, "fgets");
578
579 if (modulesfp == stream) {
580 if (modules_read < sizeof(modules) / sizeof(modules[0])) {
581 strcpy(s, modules[modules_read]);
582 ret = s;
583 modules_read++;
584 }
585 } else if (baseaddrfp == stream) {
586 snprintf(s, sizeof(buf), "%d\t%d\n",
587 (baseaddrnum) * 0x10,
588 ((baseaddrnum) * 0x10) + 0x400);
589 ret = s;
590 } else {
591 ret = (*func)(s,size,stream);
592 }
593
594 return ret;
595 }
596
597 int fclose(FILE *fp) {
598 static int (*func) (FILE*) = NULL;
599
600 if (!func)
601 func = (int (*) (FILE*)) dlsym(RTLD_NEXT, "fclose");
602
603 if (fp == modulesfp) {
604 modulesfp = NULL;
605 }
606
607 if (fp == baseaddrfp) {
608 baseaddrfp = NULL;
609 }
610
611 return (*func)(fp);
612 }
613
614 int access(const char *pathname, int mode) {
615 static int (*func) (const char*, int);
616
617 if (!func)
618 func = (int (*) (const char*, int)) dlsym(RTLD_NEXT, "access");
619
620 if (pathname && !strcmp(pathname, "/dev/windrvr6")) {
621 return 0;
622 } else {
623 return (*func)(pathname, mode);
624 }
625 }
626
627 #if __WORDSIZE == 32
628 int uname (struct utsname *__name) {
629 static int (*func) (struct utsname*);
630 int ret;
631
632 if (!func)
633 func = (int (*) (struct utsname*)) dlsym(RTLD_NEXT, "uname");
634
635 ret = (*func)(__name);
636
637 if (ret == 0 && (!strcmp(__name->machine, "x86_64"))) {
638 strcpy(__name->machine, "i686");
639 }
640
641 return ret;
642 }
643 #endif
Impressum, Datenschutz