linux_ioctl.c (69539) | linux_ioctl.c (72543) |
---|---|
1/* 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/* 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/compat/linux/linux_ioctl.c 69539 2000-12-03 01:30:31Z marcel $ | 28 * $FreeBSD: head/sys/compat/linux/linux_ioctl.c 72543 2001-02-16 16:40:43Z jlemon $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/sysproto.h> 34#include <sys/proc.h> 35#include <sys/cdio.h> 36#include <sys/consio.h> --- 68 unchanged lines hidden (view full) --- 105 int error; 106 struct disklabel dl; 107 108 switch (args->cmd & 0xffff) { 109 case LINUX_BLKGETSIZE: 110 error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); 111 if (error) 112 return (error); | 29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/sysproto.h> 34#include <sys/proc.h> 35#include <sys/cdio.h> 36#include <sys/consio.h> --- 68 unchanged lines hidden (view full) --- 105 int error; 106 struct disklabel dl; 107 108 switch (args->cmd & 0xffff) { 109 case LINUX_BLKGETSIZE: 110 error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); 111 if (error) 112 return (error); |
113 return copyout(&(dl.d_secperunit), (caddr_t)args->arg, sizeof(dl.d_secperunit)); | 113 return (copyout(&(dl.d_secperunit), (caddr_t)args->arg, 114 sizeof(dl.d_secperunit))); |
114 break; 115 } 116 return (ENOIOCTL); 117} 118 119/* 120 * termio related ioctls 121 */ --- 77 unchanged lines hidden (view full) --- 199} 200 201static void 202bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios) 203{ 204 int i; 205 206#ifdef DEBUG | 115 break; 116 } 117 return (ENOIOCTL); 118} 119 120/* 121 * termio related ioctls 122 */ --- 77 unchanged lines hidden (view full) --- 200} 201 202static void 203bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios) 204{ 205 int i; 206 207#ifdef DEBUG |
207 printf("LINUX: BSD termios structure (input):\n"); 208 printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", 209 bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, 210 bios->c_ispeed, bios->c_ospeed); 211 printf("c_cc "); 212 for (i=0; i<NCCS; i++) 213 printf("%02x ", bios->c_cc[i]); 214 printf("\n"); | 208 if (ldebug(ioctl)) { 209 printf("LINUX: BSD termios structure (input):\n"); 210 printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", 211 bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, 212 bios->c_ispeed, bios->c_ospeed); 213 printf("c_cc "); 214 for (i=0; i<NCCS; i++) 215 printf("%02x ", bios->c_cc[i]); 216 printf("\n"); 217 } |
215#endif 216 217 lios->c_iflag = 0; 218 if (bios->c_iflag & IGNBRK) 219 lios->c_iflag |= LINUX_IGNBRK; 220 if (bios->c_iflag & BRKINT) 221 lios->c_iflag |= LINUX_BRKINT; 222 if (bios->c_iflag & IGNPAR) --- 95 unchanged lines hidden (view full) --- 318 319 for (i=0; i<LINUX_NCCS; i++) { 320 if (lios->c_cc[i] == _POSIX_VDISABLE) 321 lios->c_cc[i] = LINUX_POSIX_VDISABLE; 322 } 323 lios->c_line = 0; 324 325#ifdef DEBUG | 218#endif 219 220 lios->c_iflag = 0; 221 if (bios->c_iflag & IGNBRK) 222 lios->c_iflag |= LINUX_IGNBRK; 223 if (bios->c_iflag & BRKINT) 224 lios->c_iflag |= LINUX_BRKINT; 225 if (bios->c_iflag & IGNPAR) --- 95 unchanged lines hidden (view full) --- 321 322 for (i=0; i<LINUX_NCCS; i++) { 323 if (lios->c_cc[i] == _POSIX_VDISABLE) 324 lios->c_cc[i] = LINUX_POSIX_VDISABLE; 325 } 326 lios->c_line = 0; 327 328#ifdef DEBUG |
326 printf("LINUX: LINUX termios structure (output):\n"); 327 printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, 328 lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); 329 printf("c_cc "); 330 for (i=0; i<LINUX_NCCS; i++) 331 printf("%02x ", lios->c_cc[i]); 332 printf("\n"); | 329 if (ldebug(ioctl)) { 330 printf("LINUX: LINUX termios structure (output):\n"); 331 printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", 332 lios->c_iflag, lios->c_oflag, lios->c_cflag, 333 lios->c_lflag, (int)lios->c_line); 334 printf("c_cc "); 335 for (i=0; i<LINUX_NCCS; i++) 336 printf("%02x ", lios->c_cc[i]); 337 printf("\n"); 338 } |
333#endif 334} 335 336static void 337linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios) 338{ 339 int i; 340 341#ifdef DEBUG | 339#endif 340} 341 342static void 343linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios) 344{ 345 int i; 346 347#ifdef DEBUG |
342 printf("LINUX: LINUX termios structure (input):\n"); 343 printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, 344 lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); 345 printf("c_cc "); 346 for (i=0; i<LINUX_NCCS; i++) 347 printf("%02x ", lios->c_cc[i]); 348 printf("\n"); | 348 if (ldebug(ioctl)) { 349 printf("LINUX: LINUX termios structure (input):\n"); 350 printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", 351 lios->c_iflag, lios->c_oflag, lios->c_cflag, 352 lios->c_lflag, (int)lios->c_line); 353 printf("c_cc "); 354 for (i=0; i<LINUX_NCCS; i++) 355 printf("%02x ", lios->c_cc[i]); 356 printf("\n"); 357 } |
349#endif 350 351 bios->c_iflag = 0; 352 if (lios->c_iflag & LINUX_IGNBRK) 353 bios->c_iflag |= IGNBRK; 354 if (lios->c_iflag & LINUX_BRKINT) 355 bios->c_iflag |= BRKINT; 356 if (lios->c_iflag & LINUX_IGNPAR) --- 96 unchanged lines hidden (view full) --- 453 if (bios->c_cc[i] == LINUX_POSIX_VDISABLE) 454 bios->c_cc[i] = _POSIX_VDISABLE; 455 } 456 457 bios->c_ispeed = bios->c_ospeed = 458 linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab); 459 460#ifdef DEBUG | 358#endif 359 360 bios->c_iflag = 0; 361 if (lios->c_iflag & LINUX_IGNBRK) 362 bios->c_iflag |= IGNBRK; 363 if (lios->c_iflag & LINUX_BRKINT) 364 bios->c_iflag |= BRKINT; 365 if (lios->c_iflag & LINUX_IGNPAR) --- 96 unchanged lines hidden (view full) --- 462 if (bios->c_cc[i] == LINUX_POSIX_VDISABLE) 463 bios->c_cc[i] = _POSIX_VDISABLE; 464 } 465 466 bios->c_ispeed = bios->c_ospeed = 467 linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab); 468 469#ifdef DEBUG |
461 printf("LINUX: BSD termios structure (output):\n"); 462 printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", 463 bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, 464 bios->c_ispeed, bios->c_ospeed); 465 printf("c_cc "); 466 for (i=0; i<NCCS; i++) 467 printf("%02x ", bios->c_cc[i]); 468 printf("\n"); | 470 if (ldebug(ioctl)) { 471 printf("LINUX: BSD termios structure (output):\n"); 472 printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", 473 bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, 474 bios->c_ispeed, bios->c_ospeed); 475 printf("c_cc "); 476 for (i=0; i<NCCS; i++) 477 printf("%02x ", bios->c_cc[i]); 478 printf("\n"); 479 } |
469#endif 470} 471 472static void 473bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio) 474{ 475 struct linux_termios lios; 476 --- 937 unchanged lines hidden (view full) --- 1414linux_ioctl(struct proc *p, struct linux_ioctl_args *args) 1415{ 1416 struct filedesc *fdp = p->p_fd; 1417 struct file *fp; 1418 struct handler_element *he; 1419 int error, cmd; 1420 1421#ifdef DEBUG | 480#endif 481} 482 483static void 484bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio) 485{ 486 struct linux_termios lios; 487 --- 937 unchanged lines hidden (view full) --- 1425linux_ioctl(struct proc *p, struct linux_ioctl_args *args) 1426{ 1427 struct filedesc *fdp = p->p_fd; 1428 struct file *fp; 1429 struct handler_element *he; 1430 int error, cmd; 1431 1432#ifdef DEBUG |
1422 printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", (long)p->p_pid, 1423 args->fd, args->cmd); | 1433 if (ldebug(ioctl)) 1434 printf(ARGS(ioctl, "%d, %04lx, *"), args->fd, args->cmd); |
1424#endif 1425 1426 if ((unsigned)args->fd >= fdp->fd_nfiles) 1427 return (EBADF); 1428 1429 fp = fdp->fd_ofiles[args->fd]; 1430 if (fp == NULL || (fp->f_flag & (FREAD|FWRITE)) == 0) 1431 return (EBADF); 1432 1433 /* Iterate over the ioctl handlers */ 1434 cmd = args->cmd & 0xffff; 1435 TAILQ_FOREACH(he, &handlers, list) { 1436 if (cmd >= he->low && cmd <= he->high) { 1437 error = (*he->func)(p, args); 1438 if (error != ENOIOCTL) 1439 return (error); 1440 } 1441 } 1442 | 1435#endif 1436 1437 if ((unsigned)args->fd >= fdp->fd_nfiles) 1438 return (EBADF); 1439 1440 fp = fdp->fd_ofiles[args->fd]; 1441 if (fp == NULL || (fp->f_flag & (FREAD|FWRITE)) == 0) 1442 return (EBADF); 1443 1444 /* Iterate over the ioctl handlers */ 1445 cmd = args->cmd & 0xffff; 1446 TAILQ_FOREACH(he, &handlers, list) { 1447 if (cmd >= he->low && cmd <= he->high) { 1448 error = (*he->func)(p, args); 1449 if (error != ENOIOCTL) 1450 return (error); 1451 } 1452 } 1453 |
1443 printf("linux: 'ioctl' fd=%d, cmd=%x ('%c',%d) not implemented\n", | 1454 printf("linux: 'ioctl' fd=%d, cmd=0x%x ('%c',%d) not implemented\n", |
1444 args->fd, (int)(args->cmd & 0xffff), 1445 (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff)); 1446 1447 return (EINVAL); 1448} 1449 1450int 1451linux_ioctl_register_handler(struct linux_ioctl_handler *h) --- 90 unchanged lines hidden --- | 1455 args->fd, (int)(args->cmd & 0xffff), 1456 (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff)); 1457 1458 return (EINVAL); 1459} 1460 1461int 1462linux_ioctl_register_handler(struct linux_ioctl_handler *h) --- 90 unchanged lines hidden --- |