1512 /*
1513 * System call vectors.
1514 *
1515 * Argument checking cleaned up. Saved 20% in size.
1516 * This function doesn't need to set the kernel lock because
1517 * it is set by the callees.
1518 */
1519
1520 asmlinkage long sys_socketcall(int call, unsigned long *args)
1521 {
1522 unsigned long a[6];
1523 unsigned long a0,a1;
1524 int err;
1525
1526 if(call<1||call>SYS_RECVMSG)
1527 return -EINVAL;
1528
1529 /* copy_from_user should be SMP safe. */
1530 if (copy_from_user(a, args, nargs[call]))
1531 return -EFAULT;
1532
1533 a0=a[0];
1534 a1=a[1];
1535
1536 switch(call)
1537 {
1538 case SYS_SOCKET:
1539 err = sys_socket(a0,a1,a[2]);
1540 break;
1541 case SYS_BIND:
1542 err = sys_bind(a0,(struct sockaddr *)a1, a[2]);
1543 break;
1544 case SYS_CONNECT:
1545 err = sys_connect(a0, (struct sockaddr *)a1, a[2]);
1546 break;
1547 case SYS_LISTEN:
1548 err = sys_listen(a0,a1);
1549 break;
1550 case SYS_ACCEPT:
-CtrXa-cFkD.cP Click to buy NOW! om wwEw G. G.dNoAcHu
846
1551 err = sys_accept(a0,(struct sockaddr *)a1, (int *)a[2]);
1552 break;
1553 case SYS_GETSOCKNAME:
1554 err = sys_getsockname(a0,(struct sockaddr *)a1, (int *)a[2]);
1555 break;
1556 case SYS_GETPEERNAME:
1557 err = sys_getpeername(a0, (struct sockaddr *)a1, (int *)a[2]);
1558 break;
1559 case SYS_SOCKETPAIR:
1560 err = sys_socketpair(a0,a1, a[2], (int *)a[3]);
1561 break;
1562 case SYS_SEND:
1563 err = sys_send(a0, (void *)a1, a[2], a[3]);
1564 break;
1565 case SYS_SENDTO:
1566 err = sys_sendto(a0,(void *)a1, a[2], a[3],
1567 (struct sockaddr *)a[4], a[5]);
1568 break;
1569 case SYS_RECV:
1570 err = sys_recv(a0, (void *)a1, a[2], a[3]);
1571 break;
1572 case SYS_RECVFROM:
1573 err = sys_recvfrom(a0, (void *)a1, a[2], a[3],
1574 (struct sockaddr *)a[4], (int *)a[5]);
1575 break;
1576 case SYS_SHUTDOWN:
1577 err = sys_shutdown(a0,a1);
1578 break;
1579 case SYS_SETSOCKOPT:
1580 err = sys_setsockopt(a0, a1, a[2], (char *)a[3], a[4]);
1581 break;
1582 case SYS_GETSOCKOPT:
1583 err = sys_getsockopt(a0, a1, a[2], (char *)a[3], (int *)a[4]);
1584 break;
1585 case SYS_SENDMSG:
1586 err = sys_sendmsg(a0, (struct msghdr *) a1, a[2]);
1587 break;
1588 case SYS_RECVMSG:
1589 err = sys_recvmsg(a0, (struct msghdr *) a1, a[2]);
1590 break;
1591 default:
1592 err = -EINVAL;
1593 break;
1594 }
1595 return err;
1596 }
sock内核调用
最新推荐文章于 2024-11-09 08:19:06 发布