Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 97.53 KB | None | 0 0
  1. commit b5127d9b1a517ab767af426b29bf28d5fb2892da
  2. Author: Linus Torvalds <torvalds@linuxfoundation.org>
  3. Date:   Fri Nov 23 15:12:52 2007 -0500
  4.  
  5.     Import 2.1.23pre1
  6.  
  7. diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
  8. index 6c8f5a2..c08bab0 100644
  9. --- a/arch/alpha/kernel/entry.S
  10. +++ b/arch/alpha/kernel/entry.S
  11. @@ -718,7 +718,7 @@ sys_call_table:
  12.     .quad do_entSys, sys_ptrace, do_entSys, do_entSys, do_entSys
  13.     .quad do_entSys, do_entSys, do_entSys, sys_access, do_entSys
  14.     .quad do_entSys, sys_sync, sys_kill, do_entSys, sys_setpgid
  15. -   .quad do_entSys, sys_dup, sys_pipe, do_entSys, do_entSys
  16. +   .quad do_entSys, sys_dup, sys_pipe, osf_set_program_attributes, do_entSys
  17.     .quad sys_open, do_entSys, sys_getxgid, osf_sigprocmask, do_entSys
  18.  /*50*/ .quad do_entSys, sys_acct, sys_sigpending, do_entSys, sys_ioctl
  19.     .quad do_entSys, do_entSys, sys_symlink, sys_readlink, sys_execve
  20. @@ -729,7 +729,7 @@ sys_call_table:
  21.     /* map BSD's setpgrp to sys_setpgid for binary compatibility: */
  22.     .quad sys_setgroups, do_entSys, sys_setpgid, sys_setitimer, do_entSys
  23.     .quad do_entSys, sys_getitimer, sys_gethostname, sys_sethostname, sys_getdtablesize
  24. -   .quad sys_dup2, sys_newfstat, sys_fcntl, sys_select, do_entSys
  25. +   .quad sys_dup2, sys_newfstat, sys_fcntl, sys_select, sys_poll
  26.     .quad sys_fsync, sys_setpriority, sys_socket, sys_connect, sys_accept
  27.  /*100*/    .quad osf_getpriority, sys_send, sys_recv, sys_sigreturn, sys_bind
  28.     .quad sys_setsockopt, sys_listen, do_entSys, do_entSys, do_entSys
  29. @@ -759,7 +759,7 @@ sys_call_table:
  30.     .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
  31.     .quad do_entSys, do_entSys, do_entSys, sys_getpgid, sys_getsid
  32.     .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
  33. -   .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_proplist_syscall
  34. +   .quad do_entSys, osf_sysinfo, do_entSys, do_entSys, osf_proplist_syscall
  35.     .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
  36.  /*250*/    .quad do_entSys, osf_usleep_thread, do_entSys, do_entSys, sys_sysfs
  37.     .quad do_entSys, osf_getsysinfo, osf_setsysinfo, do_entSys, do_entSys
  38. diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
  39. index 003775d..5dc11cb 100644
  40. --- a/arch/alpha/kernel/osf_sys.c
  41. +++ b/arch/alpha/kernel/osf_sys.c
  42. @@ -43,6 +43,23 @@ extern void put_unnamed_dev(kdev_t);
  43.  
  44.  extern asmlinkage int sys_umount(char *);
  45.  extern asmlinkage int sys_swapon(const char *specialfile, int swap_flags);
  46. +extern asmlinkage unsigned long sys_brk(unsigned long);
  47. +
  48. +/*
  49. + * This is pure guess-work..
  50. + */
  51. +asmlinkage int osf_set_program_attributes(
  52. +   unsigned long text_start, unsigned long text_len,
  53. +   unsigned long bss_start, unsigned long bss_len)
  54. +{
  55. +   struct mm_struct *mm = current->mm;
  56. +
  57. +   mm->end_code = bss_start + bss_len;
  58. +   mm->brk = bss_start + bss_len;
  59. +   printk("set_program_attributes(%lx %lx %lx %lx)\n",
  60. +       text_start, text_len, bss_start, bss_len);
  61. +   return 0;
  62. +}
  63.  
  64.  /*
  65.   * OSF/1 directory handling functions...
  66. @@ -699,6 +716,37 @@ asmlinkage unsigned long alpha_create_module(char *module_name, unsigned long si
  67.     return retval;
  68.  }
  69.  
  70. +asmlinkage long osf_sysinfo(int command, char *buf, long count)
  71. +{
  72. +   static char * sysinfo_table[] = {
  73. +       system_utsname.sysname,
  74. +       system_utsname.nodename,
  75. +       system_utsname.release,
  76. +       system_utsname.version,
  77. +       system_utsname.machine,
  78. +       "alpha",    /* instruction set architecture */
  79. +       "dummy",    /* hardware serial number */
  80. +       "dummy",    /* hardware manufacturer */
  81. +       "dummy",    /* secure RPC domain */
  82. +   };
  83. +   unsigned long offset;
  84. +   char *res;
  85. +   long len;
  86. +
  87. +   offset = command-1;
  88. +   if (offset >= sizeof(sysinfo_table)/sizeof(char *)) {
  89. +       /* Digital unix has a few unpublished interfaces here */
  90. +       printk("sysinfo(%d)", command);
  91. +       return -EINVAL;
  92. +   }
  93. +   res = sysinfo_table[offset];
  94. +   len = strlen(res)+1;
  95. +   if (len > count)
  96. +       len = count;
  97. +   if (copy_to_user(buf, res, len))
  98. +       return -EFAULT;
  99. +   return 0;
  100. +}
  101.  
  102.  asmlinkage unsigned long osf_getsysinfo(unsigned long op, void *buffer, unsigned long nbytes,
  103.                     int *start, void *arg)
  104. diff --git a/arch/alpha/mm/extable.c b/arch/alpha/mm/extable.c
  105. index 9b82329..12a1f480 100644
  106. --- a/arch/alpha/mm/extable.c
  107. +++ b/arch/alpha/mm/extable.c
  108. @@ -34,6 +34,8 @@ search_one_table(const struct exception_table_entry *first,
  109.          return 0;
  110.  }
  111.  
  112. +register unsigned long gp __asm__("$29");
  113. +
  114.  unsigned
  115.  search_exception_table(unsigned long addr)
  116.  {
  117. @@ -41,7 +43,6 @@ search_exception_table(unsigned long addr)
  118.  
  119.  #ifndef CONFIG_MODULE
  120.     /* There is only the kernel to search.  */
  121. -   register unsigned long gp __asm__("$29");
  122.     ret = search_one_table(__start___ex_table, __stop___ex_table - 1,
  123.                    addr - gp);
  124.     if (ret) return ret;
  125. diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
  126. index 94f77e6..9e72942 100644
  127. --- a/arch/i386/kernel/entry.S
  128. +++ b/arch/i386/kernel/entry.S
  129. @@ -630,6 +630,7 @@ ENTRY(sys_call_table)
  130.     .long SYMBOL_NAME(sys_getresuid)    /* 165 */
  131.     .long SYMBOL_NAME(sys_vm86)
  132.     .long SYMBOL_NAME(sys_query_module)
  133. -   .rept NR_syscalls-167
  134. +   .long SYMBOL_NAME(sys_poll)
  135. +   .rept NR_syscalls-168
  136.         .long SYMBOL_NAME(sys_ni_syscall)
  137.     .endr
  138. diff --git a/drivers/block/ide-floppy.c b/drivers/block/ide-floppy.c
  139. index ae0c366..5809264 100644
  140. --- a/drivers/block/ide-floppy.c
  141. +++ b/drivers/block/ide-floppy.c
  142. @@ -1,7 +1,7 @@
  143.  /*
  144. - * linux/drivers/block/ide-floppy.c    Version 0.3 - ALPHA Dec   2, 1996
  145. + * linux/drivers/block/ide-floppy.c    Version 0.4 - ALPHA Jan  26, 1997
  146.   *
  147. - * Copyright (C) 1996 Gadi Oxman <gadio@netvision.net.il>
  148. + * Copyright (C) 1996, 1997 Gadi Oxman <gadio@netvision.net.il>
  149.   */
  150.  
  151.  /*
  152. @@ -16,6 +16,7 @@
  153.   * Ver 0.1   Oct 17 96   Initial test version, mostly based on ide-tape.c.
  154.   * Ver 0.2   Oct 31 96   Minor changes.
  155.   * Ver 0.3   Dec  2 96   Fixed error recovery bug.
  156. + * Ver 0.4   Jan 26 97   Add support for the HDIO_GETGEO ioctl.
  157.   */
  158.  
  159.  #include <linux/config.h>
  160. @@ -1048,6 +1049,9 @@ static int idefloppy_get_flexible_disk_page (ide_drive_t *drive)
  161.             drive->name, capacity / 1024, page->cyls, page->heads, page->sectors,
  162.             page->transfer_rate / 8, page->sector_size, page->rpm);
  163.         floppy->flexible_disk_page = *page;
  164. +       drive->bios_cyl = page->cyls;
  165. +       drive->bios_head = page->heads;
  166. +       drive->bios_sect = page->sectors;
  167.         if (capacity != floppy->blocks * floppy->block_size)
  168.             printk (KERN_NOTICE "%s: The drive reports both %d and %d bytes as its capacity\n",
  169.                 drive->name, capacity, floppy->blocks * floppy->block_size);
  170. diff --git a/drivers/block/ide-probe.c b/drivers/block/ide-probe.c
  171. index e2380e5..76e10c0 100644
  172. --- a/drivers/block/ide-probe.c
  173. +++ b/drivers/block/ide-probe.c
  174. @@ -1,5 +1,5 @@
  175.  /*
  176. - *  linux/drivers/block/ide-probe.c    Version 1.0  Oct  31, 1996
  177. + *  linux/drivers/block/ide-probe.c    Version 1.01  Jan  26, 1997
  178.   *
  179.   *  Copyright (C) 1994-1996  Linus Torvalds & authors (see below)
  180.   */
  181. @@ -36,7 +36,8 @@
  182.   *  code is still sprinkled about.  Think of it as a major evolution, with
  183.   *  inspiration from lots of linux users, esp.  hamish@zot.apana.org.au
  184.   *
  185. - * Version 1.0     move drive probing code from ide.c to ide-probe.c
  186. + * Version 1.00        move drive probing code from ide.c to ide-probe.c
  187. + * Version 1.01        fix compilation problem for m68k
  188.   */
  189.  
  190.  #undef REALLY_SLOW_IO      /* most systems can safely undef this */
  191. @@ -494,9 +495,7 @@ static void save_match (ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
  192.  static int init_irq (ide_hwif_t *hwif)
  193.  {
  194.     unsigned long flags;
  195. -#if MAX_HWIFS > 1
  196.     unsigned int index;
  197. -#endif /* MAX_HWIFS > 1 */
  198.     ide_hwgroup_t *hwgroup;
  199.     ide_hwif_t *match = NULL;
  200.  
  201. diff --git a/drivers/block/ide.c b/drivers/block/ide.c
  202. index a7f688f..9906534 100644
  203. --- a/drivers/block/ide.c
  204. +++ b/drivers/block/ide.c
  205. @@ -1,7 +1,7 @@
  206.  /*
  207. - *  linux/drivers/block/ide.c  Version 6.00  Dec   4, 1996
  208. + *  linux/drivers/block/ide.c  Version 6.01  Jan  26, 1997
  209.   *
  210. - *  Copyright (C) 1994-1996  Linus Torvalds & authors (see below)
  211. + *  Copyright (C) 1994-1997  Linus Torvalds & authors (see below)
  212.   */
  213.  #define _IDE_C     /* needed by <linux/blk.h> */
  214.  
  215. @@ -276,6 +276,8 @@
  216.   *         fix bug in ide_error()
  217.   *         fix bug in the first ide_get_lock() call for Atari
  218.   *         don't flush leftover data for ATAPI devices
  219. + * Version 6.01        clear hwgroup->active while the hwgroup sleeps
  220. + *         support HDIO_GETGEO for floppies
  221.   *
  222.   *  Some additional driver compile-time options are in ide.h
  223.   *
  224. @@ -1240,10 +1242,9 @@ static inline void ide_leave_hwgroup (ide_hwgroup_t *hwgroup)
  225.             sleep = jiffies + WAIT_MIN_SLEEP;
  226.         hwgroup->timer.expires = sleep;
  227.         add_timer(&hwgroup->timer);
  228. -   } else {    /* Ugly, but how can we sleep for the lock otherwise? perhaps from tq_scheduler? */
  229. +   } else  /* Ugly, but how can we sleep for the lock otherwise? perhaps from tq_scheduler? */
  230.         ide_release_lock(&ide_lock);
  231. -       hwgroup->active = 0;
  232. -   }
  233. +   hwgroup->active = 0;
  234.  }
  235.  
  236.  /*
  237. @@ -1876,7 +1877,7 @@ static int ide_ioctl (struct inode *inode, struct file *file,
  238.         case HDIO_GETGEO:
  239.         {
  240.             struct hd_geometry *loc = (struct hd_geometry *) arg;
  241. -           if (!loc || drive->media != ide_disk) return -EINVAL;
  242. +           if (!loc || (drive->media != ide_disk && drive->media != ide_floppy)) return -EINVAL;
  243.             if (put_user(drive->bios_head, (byte *) &loc->heads)) return -EFAULT;
  244.             if (put_user(drive->bios_sect, (byte *) &loc->sectors)) return -EFAULT;
  245.             if (put_user(drive->bios_cyl, (unsigned short *) &loc->cylinders)) return -EFAULT;
  246. diff --git a/drivers/char/amigamouse.c b/drivers/char/amigamouse.c
  247. index 558564c..d6227d9 100644
  248. --- a/drivers/char/amigamouse.c
  249. +++ b/drivers/char/amigamouse.c
  250. @@ -11,13 +11,13 @@
  251.   *
  252.   * Heavily modified by David Giller
  253.   *   changed from queue- to counter- driven
  254. - *   hacked out a (probably incorrect) mouse_select
  255. + *   hacked out a (probably incorrect) mouse_poll
  256.   *
  257.   * Modified again by Nathan Laredo to interface with
  258.   *   0.96c-pl1 IRQ handling changes (13JUL92)
  259. - *   didn't bother touching select code.
  260. + *   didn't bother touching poll code.
  261.   *
  262. - * Modified the select() code blindly to conform to the VFS
  263. + * Modified the poll() code blindly to conform to the VFS
  264.   *   requirements. 92.07.14 - Linus. Somebody should test it out.
  265.   *
  266.   * Modified by Johan Myreen to make room for other mice (9AUG92)
  267. @@ -42,6 +42,7 @@
  268.  #include <linux/errno.h>
  269.  #include <linux/miscdevice.h>
  270.  #include <linux/random.h>
  271. +#include <linux/poll.h>
  272.  
  273.  #include <asm/setup.h>
  274.  #include <asm/system.h>
  275. @@ -277,16 +278,14 @@ static long read_mouse(struct inode * inode, struct file * file,
  276.  }
  277.  
  278.  /*
  279. - * select for mouse input
  280. + * poll for mouse input
  281.   */
  282.  
  283. -static int mouse_select(struct inode *inode, struct file *file, int sel_type, select_table * wait)
  284. +static unsigned int mouse_poll(struct file *file, poll_table * wait)
  285.  {
  286. -   if (sel_type == SEL_IN) {
  287. -           if (mouse.ready)
  288. -           return 1;
  289. -       select_wait(&mouse.wait, wait);
  290. -       }
  291. +   poll_wait(&mouse.wait, wait);
  292. +   if (mouse.ready)
  293. +       return POLLIN | POLLRDNORM;
  294.     return 0;
  295.  }
  296.  
  297. @@ -295,7 +294,7 @@ struct file_operations amiga_mouse_fops = {
  298.     read_mouse,
  299.     write_mouse,
  300.     NULL,       /* mouse_readdir */
  301. -   mouse_select,   /* mouse_select */
  302. +   mouse_poll,     /* mouse_poll */
  303.     NULL,       /* mouse_ioctl */
  304.     NULL,       /* mouse_mmap */
  305.     open_mouse,
  306. diff --git a/drivers/char/apm_bios.c b/drivers/char/apm_bios.c
  307. index 96962fa..2fac5b2 100644
  308. --- a/drivers/char/apm_bios.c
  309. +++ b/drivers/char/apm_bios.c
  310. @@ -302,8 +302,7 @@ static void do_apm_timer(unsigned long);
  311.  static int do_open(struct inode *, struct file *);
  312.  static void    do_release(struct inode *, struct file *);
  313.  static long    do_read(struct inode *, struct file *, char *, unsigned long);
  314. -static int do_select(struct inode *, struct file *, int,
  315. -             select_table *);
  316. +static unsigned int do_poll(struct file *, poll_table *);
  317.  static int do_ioctl(struct inode *, struct file *, u_int, u_long);
  318.  
  319.  #ifdef CONFIG_PROC_FS
  320. @@ -360,7 +359,7 @@ static struct file_operations apm_bios_fops = {
  321.     do_read,
  322.     NULL,       /* write */
  323.     NULL,       /* readdir */
  324. -   do_select,
  325. +   do_poll,
  326.     do_ioctl,
  327.     NULL,       /* mmap */
  328.     do_open,
  329. @@ -865,19 +864,16 @@ repeat:
  330.     return 0;
  331.  }
  332.  
  333. -static int do_select(struct inode *inode, struct file *fp, int sel_type,
  334. -            select_table * wait)
  335. +static unsigned int do_poll(struct file *fp, poll_table * wait)
  336.  {
  337. -   struct apm_bios_struct *    as;
  338. +   struct apm_bios_struct * as;
  339.  
  340.     as = fp->private_data;
  341.     if (check_apm_bios_struct(as, "select"))
  342.         return 0;
  343. -   if (sel_type != SEL_IN)
  344. -       return 0;
  345. +   poll_wait(&process_list, wait);
  346.     if (!queue_empty(as))
  347. -       return 1;
  348. -   select_wait(&process_list, wait);
  349. +       return POLLIN | POLLRDNORM;
  350.     return 0;
  351.  }
  352.  
  353. diff --git a/drivers/char/mem.c b/drivers/char/mem.c
  354. index 8f223e9..3b347ef 100644
  355. --- a/drivers/char/mem.c
  356. +++ b/drivers/char/mem.c
  357. @@ -372,7 +372,7 @@ static struct file_operations mem_fops = {
  358.     read_mem,
  359.     write_mem,
  360.     NULL,       /* mem_readdir */
  361. -   NULL,       /* mem_select */
  362. +   NULL,       /* mem_poll */
  363.     NULL,       /* mem_ioctl */
  364.     mmap_mem,
  365.     NULL,       /* no special open code */
  366. @@ -385,7 +385,7 @@ static struct file_operations kmem_fops = {
  367.     read_kmem,
  368.     write_kmem,
  369.     NULL,       /* kmem_readdir */
  370. -   NULL,       /* kmem_select */
  371. +   NULL,       /* kmem_poll */
  372.     NULL,       /* kmem_ioctl */
  373.     mmap_kmem,
  374.     NULL,       /* no special open code */
  375. @@ -398,7 +398,7 @@ static struct file_operations null_fops = {
  376.     read_null,
  377.     write_null,
  378.     NULL,       /* null_readdir */
  379. -   NULL,       /* null_select */
  380. +   NULL,       /* null_poll */
  381.     NULL,       /* null_ioctl */
  382.     NULL,       /* null_mmap */
  383.     NULL,       /* no special open code */
  384. @@ -411,7 +411,7 @@ static struct file_operations port_fops = {
  385.     read_port,
  386.     write_port,
  387.     NULL,       /* port_readdir */
  388. -   NULL,       /* port_select */
  389. +   NULL,       /* port_poll */
  390.     NULL,       /* port_ioctl */
  391.     NULL,       /* port_mmap */
  392.     NULL,       /* no special open code */
  393. @@ -424,7 +424,7 @@ static struct file_operations zero_fops = {
  394.     read_zero,
  395.     write_zero,
  396.     NULL,       /* zero_readdir */
  397. -   NULL,       /* zero_select */
  398. +   NULL,       /* zero_poll */
  399.     NULL,       /* zero_ioctl */
  400.     mmap_zero,
  401.     NULL,       /* no special open code */
  402. @@ -436,7 +436,7 @@ static struct file_operations full_fops = {
  403.     read_full,
  404.     write_full,
  405.     NULL,       /* full_readdir */
  406. -   NULL,       /* full_select */
  407. +   NULL,       /* full_poll */
  408.     NULL,       /* full_ioctl */   
  409.     NULL,       /* full_mmap */
  410.     NULL,       /* no special open code */
  411. @@ -483,7 +483,7 @@ static struct file_operations memory_fops = {
  412.     NULL,       /* read */
  413.     NULL,       /* write */
  414.     NULL,       /* readdir */
  415. -   NULL,       /* select */
  416. +   NULL,       /* poll */
  417.     NULL,       /* ioctl */
  418.     NULL,       /* mmap */
  419.     memory_open,    /* just a selector for the real open */
  420. diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
  421. index 6d6a317..a786359 100644
  422. --- a/drivers/char/n_tty.c
  423. +++ b/drivers/char/n_tty.c
  424. @@ -33,6 +33,7 @@
  425.  #include <linux/mm.h>
  426.  #include <linux/string.h>
  427.  #include <linux/malloc.h>
  428. +#include <linux/poll.h>
  429.  
  430.  #include <asm/uaccess.h>
  431.  #include <asm/system.h>
  432. @@ -982,37 +983,29 @@ static int write_chan(struct tty_struct * tty, struct file * file,
  433.     return (b - buf) ? b - buf : retval;
  434.  }
  435.  
  436. -static int normal_select(struct tty_struct * tty, struct inode * inode,
  437. -            struct file * file, int sel_type, select_table *wait)
  438. +static unsigned int normal_poll(struct tty_struct * tty, struct file * file, poll_table *wait)
  439.  {
  440. -   switch (sel_type) {
  441. -       case SEL_IN:
  442. -           if (input_available_p(tty, TIME_CHAR(tty) ? 0 :
  443. -                         MIN_CHAR(tty)))
  444. -               return 1;
  445. -           /* fall through */
  446. -       case SEL_EX:
  447. -           if (tty->packet && tty->link->ctrl_status)
  448. -               return 1;
  449. -           if (tty->flags & (1 << TTY_OTHER_CLOSED))
  450. -               return 1;
  451. -           if (tty_hung_up_p(file))
  452. -               return 1;
  453. -           if (!waitqueue_active(&tty->read_wait)) {
  454. -               if (MIN_CHAR(tty) && !TIME_CHAR(tty))
  455. -                   tty->minimum_to_wake = MIN_CHAR(tty);
  456. -               else
  457. -                   tty->minimum_to_wake = 1;
  458. -           }
  459. -           select_wait(&tty->read_wait, wait);
  460. -           return 0;
  461. -       case SEL_OUT:
  462. -           if (tty->driver.chars_in_buffer(tty) < WAKEUP_CHARS)
  463. -               return 1;
  464. -           select_wait(&tty->write_wait, wait);
  465. -           return 0;
  466. +   unsigned int mask = 0;
  467. +
  468. +   poll_wait(&tty->read_wait, wait);
  469. +   poll_wait(&tty->write_wait, wait);
  470. +   if (input_available_p(tty, TIME_CHAR(tty) ? 0 : MIN_CHAR(tty)))
  471. +       mask |= POLLIN | POLLRDNORM;
  472. +   if (tty->packet && tty->link->ctrl_status)
  473. +       mask |= POLLPRI | POLLIN | POLLRDNORM;
  474. +   if (tty->flags & (1 << TTY_OTHER_CLOSED))
  475. +       mask |= POLLHUP;
  476. +   if (tty_hung_up_p(file))
  477. +       mask |= POLLHUP;
  478. +   if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {
  479. +       if (MIN_CHAR(tty) && !TIME_CHAR(tty))
  480. +           tty->minimum_to_wake = MIN_CHAR(tty);
  481. +       else
  482. +           tty->minimum_to_wake = 1;
  483.     }
  484. -   return 0;
  485. +   if (tty->driver.chars_in_buffer(tty) < WAKEUP_CHARS)
  486. +       mask |= POLLOUT | POLLWRNORM;
  487. +   return mask;
  488.  }
  489.  
  490.  struct tty_ldisc tty_ldisc_N_TTY = {
  491. @@ -1027,7 +1020,7 @@ struct tty_ldisc tty_ldisc_N_TTY = {
  492.     write_chan,     /* write */
  493.     n_tty_ioctl,        /* ioctl */
  494.     n_tty_set_termios,  /* set_termios */
  495. -   normal_select,      /* select */
  496. +   normal_poll,        /* poll */
  497.     n_tty_receive_buf,  /* receive_buf */
  498.     n_tty_receive_room, /* receive_room */
  499.     0           /* write_wakeup */
  500. diff --git a/drivers/char/psaux.c b/drivers/char/psaux.c
  501. index d9f9525..7f7ec75 100644
  502. --- a/drivers/char/psaux.c
  503. +++ b/drivers/char/psaux.c
  504. @@ -45,6 +45,7 @@
  505.  #include <linux/malloc.h>
  506.  #include <linux/miscdevice.h>
  507.  #include <linux/random.h>
  508. +#include <linux/poll.h>
  509.  
  510.  #include <asm/io.h>
  511.  #include <asm/uaccess.h>
  512. @@ -494,13 +495,11 @@ repeat:
  513.  }
  514.  
  515.  
  516. -static int aux_select(struct inode *inode, struct file *file, int sel_type, select_table * wait)
  517. +static unsigned int aux_poll(struct file *file, poll_table * wait)
  518.  {
  519. -   if (sel_type != SEL_IN)
  520. -       return 0;
  521. +   poll_wait(&queue->proc_list, wait);
  522.     if (aux_ready)
  523. -       return 1;
  524. -   select_wait(&queue->proc_list, wait);
  525. +       return POLLIN | POLLRDNORM;
  526.     return 0;
  527.  }
  528.  
  529. @@ -510,7 +509,7 @@ struct file_operations psaux_fops = {
  530.     read_aux,
  531.     write_aux,
  532.     NULL,       /* readdir */
  533. -   aux_select,
  534. +   aux_poll,
  535.     NULL,       /* ioctl */
  536.     NULL,       /* mmap */
  537.     open_aux,
  538. diff --git a/drivers/char/random.c b/drivers/char/random.c
  539. index 64ffdf4..bd04db6 100644
  540. --- a/drivers/char/random.c
  541. +++ b/drivers/char/random.c
  542. @@ -233,6 +233,7 @@
  543.  #include <linux/fcntl.h>
  544.  #include <linux/malloc.h>
  545.  #include <linux/random.h>
  546. +#include <linux/poll.h>
  547.  
  548.  #include <asm/uaccess.h>
  549.  #include <asm/irq.h>
  550. @@ -332,8 +333,7 @@ static long random_read(struct inode * inode, struct file * file,
  551.                char * buf, unsigned long nbytes);
  552.  static long random_read_unlimited(struct inode * inode, struct file * file,
  553.                  char * buf, unsigned long nbytes);
  554. -static int random_select(struct inode *inode, struct file *file,
  555. -            int sel_type, select_table * wait);
  556. +static unsigned int random_poll(struct file *file, poll_table * wait);
  557.  static long random_write(struct inode * inode, struct file * file,
  558.             const char * buffer, unsigned long count);
  559.  static int random_ioctl(struct inode * inode, struct file * file,
  560. @@ -1086,23 +1086,18 @@ random_read_unlimited(struct inode * inode, struct file * file,
  561.     return extract_entropy(&random_state, buf, nbytes, 1);
  562.  }
  563.  
  564. -static int
  565. -random_select(struct inode *inode, struct file *file,
  566. -             int sel_type, select_table * wait)
  567. +static unsigned int
  568. +random_poll(struct file *file, poll_table * wait)
  569.  {
  570. -   switch (sel_type) {
  571. -   case SEL_IN:
  572. -       if (random_state.entropy_count >= 8)
  573. -           return 1;
  574. -       select_wait(&random_wait, wait);
  575. -       break;
  576. -   case SEL_OUT:
  577. -       if (random_state.entropy_count < WAIT_OUTPUT_BITS)
  578. -           return 1;
  579. -       select_wait(&random_wait, wait);
  580. -       break;
  581. -   }
  582. -   return 0;
  583. +   unsigned int mask;
  584. +
  585. +   poll_wait(&random_wait, wait);
  586. +   mask = 0;
  587. +   if (random_state.entropy_count >= 8)
  588. +       mask |= POLLIN | POLLRDNORM;
  589. +   if (random_state.entropy_count < WAIT_OUTPUT_BITS)
  590. +       mask |= POLLOUT | POLLWRNORM;
  591. +   return mask;
  592.  }
  593.  
  594.  static long
  595. @@ -1270,7 +1265,7 @@ struct file_operations random_fops = {
  596.     random_read,
  597.     random_write,
  598.     NULL,       /* random_readdir */
  599. -   random_select,  /* random_select */
  600. +   random_poll,    /* random_poll */
  601.     random_ioctl,
  602.     NULL,       /* random_mmap */
  603.     NULL,       /* no special open code */
  604. @@ -1282,7 +1277,7 @@ struct file_operations urandom_fops = {
  605.     random_read_unlimited,
  606.     random_write,
  607.     NULL,       /* urandom_readdir */
  608. -   NULL,       /* urandom_select */
  609. +   NULL,       /* urandom_poll */
  610.     random_ioctl,
  611.     NULL,       /* urandom_mmap */
  612.     NULL,       /* no special open code */
  613. diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
  614. index baf0816..483178b 100644
  615. --- a/drivers/char/rtc.c
  616. +++ b/drivers/char/rtc.c
  617. @@ -75,8 +75,7 @@ static long rtc_read(struct inode *inode, struct file *file,
  618.  static int rtc_ioctl(struct inode *inode, struct file *file,
  619.             unsigned int cmd, unsigned long arg);
  620.  
  621. -static int rtc_select(struct inode *inode, struct file *file,
  622. -           int sel_type, select_table *wait);
  623. +static unsigned int rtc_poll(struct file *file, poll_table *wait);
  624.  
  625.  void get_rtc_time (struct rtc_time *rtc_tm);
  626.  void get_rtc_alm_time (struct rtc_time *alm_tm);
  627. @@ -492,14 +491,11 @@ static void rtc_release(struct inode *inode, struct file *file)
  628.     rtc_status &= ~RTC_IS_OPEN;
  629.  }
  630.  
  631. -static int rtc_select(struct inode *inode, struct file *file,
  632. -           int sel_type, select_table *wait)
  633. +static unsigned int rtc_poll(struct file *file, poll_table *wait)
  634.  {
  635. -   if (sel_type == SEL_IN) {
  636. -       if (rtc_irq_data != 0)
  637. -           return 1;
  638. -       select_wait(&rtc_wait, wait);
  639. -   }
  640. +   poll_wait(&rtc_wait, wait);
  641. +   if (rtc_irq_data != 0)
  642. +       return POLLIN | POLLRDNORM;
  643.     return 0;
  644.  }
  645.  
  646. @@ -512,7 +508,7 @@ static struct file_operations rtc_fops = {
  647.     rtc_read,
  648.     NULL,       /* No write */
  649.     NULL,       /* No readdir */
  650. -   rtc_select,
  651. +   rtc_poll,
  652.     rtc_ioctl,
  653.     NULL,       /* No mmap */
  654.     rtc_open,
  655. diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
  656. index ca2fdd8..59d2c27 100644
  657. --- a/drivers/char/tty_io.c
  658. +++ b/drivers/char/tty_io.c
  659. @@ -62,6 +62,7 @@
  660.  #include <linux/mm.h>
  661.  #include <linux/string.h>
  662.  #include <linux/malloc.h>
  663. +#include <linux/poll.h>
  664.  
  665.  #include <asm/uaccess.h>
  666.  #include <asm/system.h>
  667. @@ -110,7 +111,7 @@ static void initialize_tty_struct(struct tty_struct *tty);
  668.  
  669.  static long tty_read(struct inode *, struct file *, char *, unsigned long);
  670.  static long tty_write(struct inode *, struct file *, const char *, unsigned long);
  671. -static int tty_select(struct inode *, struct file *, int, select_table *);
  672. +static unsigned int tty_poll(struct file *, poll_table *);
  673.  static int tty_open(struct inode *, struct file *);
  674.  static void tty_release(struct inode *, struct file *);
  675.  static int tty_ioctl(struct inode * inode, struct file * file,
  676. @@ -322,10 +323,9 @@ static long hung_up_tty_write(struct inode * inode,
  677.     return -EIO;
  678.  }
  679.  
  680. -static int hung_up_tty_select(struct inode * inode, struct file * filp,
  681. -   int sel_type, select_table * wait)
  682. +static unsigned int hung_up_tty_poll(struct file * filp, poll_table * wait)
  683.  {
  684. -   return 1;
  685. +   return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM;
  686.  }
  687.  
  688.  static int hung_up_tty_ioctl(struct inode * inode, struct file * file,
  689. @@ -345,7 +345,7 @@ static struct file_operations tty_fops = {
  690.     tty_read,
  691.     tty_write,
  692.     NULL,       /* tty_readdir */
  693. -   tty_select,
  694. +   tty_poll,
  695.     tty_ioctl,
  696.     NULL,       /* tty_mmap */
  697.     tty_open,
  698. @@ -359,7 +359,7 @@ static struct file_operations hung_up_tty_fops = {
  699.     hung_up_tty_read,
  700.     hung_up_tty_write,
  701.     NULL,       /* hung_up_tty_readdir */
  702. -   hung_up_tty_select,
  703. +   hung_up_tty_poll,
  704.     hung_up_tty_ioctl,
  705.     NULL,       /* hung_up_tty_mmap */
  706.     NULL,       /* hung_up_tty_open */
  707. @@ -1287,16 +1287,16 @@ static void tty_release(struct inode * inode, struct file * filp)
  708.     release_dev(filp);
  709.  }
  710.  
  711. -static int tty_select(struct inode * inode, struct file * filp, int sel_type, select_table * wait)
  712. +static unsigned int tty_poll(struct file * filp, poll_table * wait)
  713.  {
  714.     struct tty_struct * tty;
  715.  
  716.     tty = (struct tty_struct *)filp->private_data;
  717. -   if (tty_paranoia_check(tty, inode->i_rdev, "tty_select"))
  718. +   if (tty_paranoia_check(tty, filp->f_inode->i_rdev, "tty_poll"))
  719.         return 0;
  720.  
  721. -   if (tty->ldisc.select)
  722. -       return (tty->ldisc.select)(tty, inode, filp, sel_type, wait);
  723. +   if (tty->ldisc.poll)
  724. +       return (tty->ldisc.poll)(tty, filp, wait);
  725.     return 0;
  726.  }
  727.  
  728. diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
  729. index b218da3..705afe0 100644
  730. --- a/drivers/char/vc_screen.c
  731. +++ b/drivers/char/vc_screen.c
  732. @@ -243,7 +243,7 @@ static struct file_operations vcs_fops = {
  733.     vcs_read,   /* read */
  734.     vcs_write,  /* write */
  735.     NULL,       /* readdir */
  736. -   NULL,       /* select */
  737. +   NULL,       /* poll */
  738.     NULL,       /* ioctl */
  739.     NULL,       /* mmap */
  740.     vcs_open,   /* open */
  741. diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
  742. index b053aaf..6c6ffd3 100644
  743. --- a/drivers/pci/pci.c
  744. +++ b/drivers/pci/pci.c
  745. @@ -93,6 +93,7 @@ struct pci_dev_info dev_info[] = {
  746.     DEVICE( MATROX,     MATROX_MGA_IMP, "MGA Impression"),
  747.     DEVICE( CT,     CT_65545,   "65545"),
  748.     DEVICE( CT,     CT_65548,   "65548"),
  749. +   DEVICE( CT,     CT_65550,   "65550"),
  750.     DEVICE( MIRO,       MIRO_36050, "ZR36050"),
  751.     DEVICE( FD,     FD_36C70,   "TMC-18C30"),
  752.     DEVICE( SI,     SI_6201,    "6201"),
  753. diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
  754. index 658a2da..3772453 100644
  755. --- a/drivers/scsi/Makefile
  756. +++ b/drivers/scsi/Makefile
  757. @@ -392,7 +392,7 @@ aic7xxx_seq.h:  aic7xxx_asm aic7xxx.seq
  758.     ./aic7xxx_asm -o $@ aic7xxx.seq
  759.  
  760.  seagate.o: seagate.c
  761. -   $(CC) $(CFLAGS) -DARBITRATE -DSLOW_HANDSHAKE -DFAST32 -c seagate.c
  762. +   $(CC) $(CFLAGS) -DARBITRATE -DSLOW_HANDSHAKE -DFAST32 -DPARITY -c seagate.c
  763.  
  764.  # For debugging, use the -g flag
  765.  53c7,8xx.o : 53c7,8xx.c
  766. diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
  767. index ca1d1a7..a8fa2cc 100644
  768. --- a/drivers/scsi/ide-scsi.c
  769. +++ b/drivers/scsi/ide-scsi.c
  770. @@ -1,7 +1,7 @@
  771.  /*
  772. - * linux/drivers/scsi/ide-scsi.c   Version 0.1 - ALPHA Dec   3, 1996
  773. + * linux/drivers/scsi/ide-scsi.c   Version 0.2 - ALPHA Jan  26, 1997
  774.   *
  775. - * Copyright (C) 1996 Gadi Oxman <gadio@netvision.net.il>
  776. + * Copyright (C) 1996, 1997 Gadi Oxman <gadio@netvision.net.il>
  777.   */
  778.  
  779.  /*
  780. @@ -11,6 +11,11 @@
  781.   * native IDE ATAPI drivers.
  782.   *
  783.   * Ver 0.1   Dec  3 96   Initial version.
  784. + * Ver 0.2   Jan 26 97   Fixed bug in cleanup_module() and added emulation
  785. + *                        of MODE_SENSE_6/MODE_SELECT_6 for cdroms. Thanks
  786. + *                        to Janos Farkas for pointing this out.
  787. + *                       Avoid using bitfields in structures for m68k.
  788. + *                       Added Scather/Gather and DMA support.
  789.   */
  790.  
  791.  #include <linux/module.h>
  792. @@ -44,49 +49,40 @@ typedef struct idescsi_pc_s {
  793.     struct request *rq;         /* The corresponding request */
  794.     byte *buffer;               /* Data buffer */
  795.     byte *current_position;         /* Pointer into the above buffer */
  796. +   struct scatterlist *sg;         /* Scather gather table */
  797. +   int b_count;                /* Bytes transferred from current entry */
  798.     Scsi_Cmnd *scsi_cmd;            /* SCSI command */
  799.     void (*done)(Scsi_Cmnd *);      /* Scsi completion routine */
  800. +   unsigned int flags;         /* Status/Action flags */
  801.  } idescsi_pc_t;
  802.  
  803. +/*
  804. + * Packet command status bits.
  805. + */
  806. +#define PC_DMA_IN_PROGRESS     0   /* 1 while DMA in progress */
  807. +#define PC_WRITING         1   /* Data direction */
  808. +
  809.  typedef struct {
  810.     ide_drive_t *drive;
  811.     idescsi_pc_t *pc;           /* Current packet command */
  812.     unsigned int flags;         /* Status/Action flags */
  813.  } idescsi_scsi_t;
  814.  
  815. +/*
  816. + * Per ATAPI device status bits.
  817. + */
  818.  #define IDESCSI_DRQ_INTERRUPT      0   /* DRQ interrupt device */
  819. +
  820. +/*
  821. + * ide-scsi requests.
  822. + */
  823.  #define IDESCSI_PC_RQ          90
  824.  
  825. -typedef union {
  826. -   unsigned all            :8;
  827. -   struct {
  828. -       unsigned check      :1; /* Error occurred */
  829. -       unsigned idx        :1; /* Reserved */
  830. -       unsigned corr       :1; /* Correctable error occurred */
  831. -       unsigned drq        :1; /* Data is request by the device */
  832. -       unsigned dsc        :1; /* Media access command finished */
  833. -       unsigned reserved5  :1; /* Reserved */
  834. -       unsigned drdy       :1; /* Ignored for ATAPI commands (ready to accept ATA command) */
  835. -       unsigned bsy        :1; /* The device has access to the command block */
  836. -   } b;
  837. -} idescsi_status_reg_t;
  838. -
  839. -typedef union {
  840. -   unsigned all            :16;
  841. -   struct {
  842. -       unsigned low        :8; /* LSB */
  843. -       unsigned high       :8; /* MSB */
  844. -   } b;
  845. -} idescsi_bcount_reg_t;
  846. -
  847. -typedef union {
  848. -   unsigned all            :8;
  849. -   struct {
  850. -       unsigned cod        :1; /* Information transferred is command (1) or data (0) */
  851. -       unsigned io     :1; /* The device requests us to read (1) or write (0) */
  852. -       unsigned reserved   :6; /* Reserved */
  853. -   } b;
  854. -} idescsi_ireason_reg_t;
  855. +/*
  856. + * Bits of the interrupt reason register.
  857. + */
  858. +#define IDESCSI_IREASON_COD    0x1     /* Information transferred is command */
  859. +#define IDESCSI_IREASON_IO 0x2     /* The device requests us to read */
  860.  
  861.  static void idescsi_discard_data (ide_drive_t *drive, unsigned int bcount)
  862.  {
  863. @@ -94,6 +90,107 @@ static void idescsi_discard_data (ide_drive_t *drive, unsigned int bcount)
  864.         IN_BYTE (IDE_DATA_REG);
  865.  }
  866.  
  867. +static void idescsi_output_zeros (ide_drive_t *drive, unsigned int bcount)
  868. +{
  869. +   while (bcount--)
  870. +       OUT_BYTE (0, IDE_DATA_REG);
  871. +}
  872. +
  873. +/*
  874. + * PIO data transfer routines using the scather gather table.
  875. + */
  876. +static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
  877. +{
  878. +   int count;
  879. +
  880. +   while (bcount) {
  881. +       if (pc->sg - (struct scatterlist *) pc->scsi_cmd->request_buffer > pc->scsi_cmd->use_sg) {
  882. +           printk (KERN_ERR "ide-scsi: scather gather table too small, discarding data\n");
  883. +           idescsi_discard_data (drive, bcount);
  884. +           return;
  885. +       }
  886. +       count = IDE_MIN (pc->sg->length - pc->b_count, bcount);
  887. +       atapi_input_bytes (drive, pc->sg->address + pc->b_count, count);
  888. +       bcount -= count; pc->b_count += count;
  889. +       if (pc->b_count == pc->sg->length) {
  890. +           pc->sg++;
  891. +           pc->b_count = 0;
  892. +       }
  893. +   }
  894. +}
  895. +
  896. +static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
  897. +{
  898. +   int count;
  899. +
  900. +   while (bcount) {
  901. +       if (pc->sg - (struct scatterlist *) pc->scsi_cmd->request_buffer > pc->scsi_cmd->use_sg) {
  902. +           printk (KERN_ERR "ide-scsi: scather gather table too small, padding with zeros\n");
  903. +           idescsi_output_zeros (drive, bcount);
  904. +           return;
  905. +       }
  906. +       count = IDE_MIN (pc->sg->length - pc->b_count, bcount);
  907. +       atapi_output_bytes (drive, pc->sg->address + pc->b_count, count);
  908. +       bcount -= count; pc->b_count += count;
  909. +       if (pc->b_count == pc->sg->length) {
  910. +           pc->sg++;
  911. +           pc->b_count = 0;
  912. +       }
  913. +   }
  914. +}
  915. +
  916. +/*
  917. + * Most of the SCSI commands are supported directly by ATAPI devices.
  918. + * idescsi_transform_pc handles the few exceptions.
  919. + */
  920. +static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
  921. +{
  922. +   u8 *c = pc->c, *buf = pc->buffer, *sc = pc->scsi_cmd->cmnd;
  923. +   int i;
  924. +
  925. +   if (drive->media == ide_cdrom) {
  926. +       if (c[0] == READ_6) {
  927. +           c[8] = c[4];        c[5] = c[3];        c[4] = c[2];
  928. +           c[3] = c[1] & 0x1f; c[2] = 0;       c[1] &= 0xe0;
  929. +           c[0] = READ_10;
  930. +       }
  931. +       if (c[0] == MODE_SENSE || (c[0] == MODE_SELECT && buf[3] == 8)) {
  932. +           pc->request_transfer -= 4;
  933. +           memset (c, 0, 12);
  934. +           c[0] = sc[0] | 0x40;    c[2] = sc[2];       c[8] = sc[4] - 4;
  935. +           if (c[0] == MODE_SENSE_10) return;
  936. +           for (i = 0; i <= 7; i++) buf[i] = 0;
  937. +           for (i = 8; i < pc->buffer_size - 4; i++) buf[i] = buf[i + 4];
  938. +       }
  939. +   }
  940. +}
  941. +
  942. +static inline void idescsi_transform_pc2 (ide_drive_t *drive, idescsi_pc_t *pc)
  943. +{
  944. +   u8 *buf = pc->buffer;
  945. +   int i;
  946. +
  947. +   if (drive->media == ide_cdrom) {
  948. +       if (pc->c[0] == MODE_SENSE_10 && pc->scsi_cmd->cmnd[0] == MODE_SENSE) {
  949. +           buf[0] = buf[1];    buf[1] = buf[2];
  950. +           buf[2] = 0;     buf[3] = 8;
  951. +           for (i = pc->buffer_size - 1; i >= 12; i--) buf[i] = buf[i - 4];
  952. +           for (i = 11; i >= 4; i--) buf[i] = 0;
  953. +       }
  954. +   }
  955. +}
  956. +
  957. +static inline void idescsi_free_bh (struct buffer_head *bh)
  958. +{
  959. +   struct buffer_head *bhp;
  960. +
  961. +   while (bh) {
  962. +       bhp = bh;
  963. +       bh = bh->b_reqnext;
  964. +       kfree (bhp);
  965. +   }
  966. +}
  967. +
  968.  static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
  969.  {
  970.     ide_drive_t *drive = hwgroup->drive;
  971. @@ -121,18 +218,22 @@ static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
  972.         printk ("ide-scsi: %s: success for %lu\n", drive->name, pc->scsi_cmd->serial_number);
  973.  #endif /* IDESCSI_DEBUG_LOG */
  974.         pc->scsi_cmd->result = DID_OK << 16;
  975. +       idescsi_transform_pc2 (drive, pc);
  976.     }
  977.     pc->done(pc->scsi_cmd);
  978. +   idescsi_free_bh (rq->bh);
  979.     kfree(pc); kfree(rq);
  980.     scsi->pc = NULL;
  981.  }
  982.  
  983. +/*
  984. + * Our interrupt handler.
  985. + */
  986.  static void idescsi_pc_intr (ide_drive_t *drive)
  987.  {
  988.     idescsi_scsi_t *scsi = drive->driver_data;
  989. -   idescsi_status_reg_t status;
  990. -   idescsi_bcount_reg_t bcount;
  991. -   idescsi_ireason_reg_t ireason;
  992. +   byte status, ireason;
  993. +   int bcount;
  994.     idescsi_pc_t *pc=scsi->pc;
  995.     struct request *rq = pc->rq;
  996.     unsigned int temp;
  997. @@ -141,33 +242,40 @@ static void idescsi_pc_intr (ide_drive_t *drive)
  998.     printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n");
  999.  #endif /* IDESCSI_DEBUG_LOG */
  1000.  
  1001. -   status.all = GET_STAT();                    /* Clear the interrupt */
  1002. +   if (clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
  1003. +#if IDESCSI_DEBUG_LOG
  1004. +       printk ("ide-scsi: %s: DMA complete\n", drive->name);
  1005. +#endif /* IDESCSI_DEBUG_LOG */
  1006. +       pc->actually_transferred=pc->request_transfer;
  1007. +       (void) (HWIF(drive)->dmaproc(ide_dma_abort, drive));
  1008. +   }
  1009. +
  1010. +   status = GET_STAT();                        /* Clear the interrupt */
  1011.  
  1012. -   if (!status.b.drq) {                        /* No more interrupts */
  1013. +   if ((status & DRQ_STAT) == 0) {                 /* No more interrupts */
  1014.  #if IDESCSI_DEBUG_LOG
  1015.         printk (KERN_INFO "Packet command completed, %d bytes transferred\n", pc->actually_transferred);
  1016.  #endif /* IDESCSI_DEBUG_LOG */
  1017.         ide_sti();
  1018. -       if (status.b.check)
  1019. +       if (status & ERR_STAT)
  1020.             rq->errors++;
  1021.         idescsi_end_request (1, HWGROUP(drive));
  1022.         return;
  1023.     }
  1024. -   bcount.b.high=IN_BYTE (IDE_BCOUNTH_REG);
  1025. -           bcount.b.low=IN_BYTE (IDE_BCOUNTL_REG);
  1026. -   ireason.all=IN_BYTE (IDE_IREASON_REG);
  1027. +   bcount = IN_BYTE (IDE_BCOUNTH_REG) << 8 | IN_BYTE (IDE_BCOUNTL_REG);
  1028. +   ireason = IN_BYTE (IDE_IREASON_REG);
  1029.  
  1030. -   if (ireason.b.cod) {
  1031. +   if (ireason & IDESCSI_IREASON_COD) {
  1032.         printk (KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
  1033.         ide_do_reset (drive);
  1034.         return;
  1035.     }
  1036. -   if (ireason.b.io) {
  1037. -       temp = pc->actually_transferred + bcount.all;
  1038. +   if (ireason & IDESCSI_IREASON_IO) {
  1039. +       temp = pc->actually_transferred + bcount;
  1040.         if ( temp > pc->request_transfer) {
  1041.             if (temp > pc->buffer_size) {
  1042.                 printk (KERN_ERR "ide-scsi: The scsi wants to send us more data than expected - discarding data\n");
  1043. -               idescsi_discard_data (drive,bcount.all);
  1044. +               idescsi_discard_data (drive,bcount);
  1045.                 ide_set_handler (drive,&idescsi_pc_intr,WAIT_CMD);
  1046.                 return;
  1047.             }
  1048. @@ -176,12 +284,19 @@ static void idescsi_pc_intr (ide_drive_t *drive)
  1049.  #endif /* IDESCSI_DEBUG_LOG */
  1050.         }
  1051.     }
  1052. -   if (ireason.b.io)
  1053. -       atapi_input_bytes (drive,pc->current_position,bcount.all);  /* Read the current buffer */
  1054. -   else
  1055. -       atapi_output_bytes (drive,pc->current_position,bcount.all); /* Write the current buffer */
  1056. -   pc->actually_transferred+=bcount.all;               /* Update the current position */
  1057. -   pc->current_position+=bcount.all;
  1058. +   if (ireason & IDESCSI_IREASON_IO) {
  1059. +       if (pc->sg)
  1060. +           idescsi_input_buffers (drive, pc, bcount);
  1061. +       else
  1062. +           atapi_input_bytes (drive,pc->current_position,bcount);
  1063. +   } else {
  1064. +       if (pc->sg)
  1065. +           idescsi_output_buffers (drive, pc, bcount);
  1066. +       else
  1067. +           atapi_output_bytes (drive,pc->current_position,bcount);
  1068. +   }
  1069. +   pc->actually_transferred+=bcount;               /* Update the current position */
  1070. +   pc->current_position+=bcount;
  1071.  
  1072.     ide_set_handler (drive,&idescsi_pc_intr,WAIT_CMD);      /* And set the interrupt handler again */
  1073.  }
  1074. @@ -189,14 +304,14 @@ static void idescsi_pc_intr (ide_drive_t *drive)
  1075.  static void idescsi_transfer_pc (ide_drive_t *drive)
  1076.  {
  1077.     idescsi_scsi_t *scsi = drive->driver_data;
  1078. -   idescsi_ireason_reg_t ireason;
  1079. +   byte ireason;
  1080.  
  1081.     if (ide_wait_stat (drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) {
  1082.         printk (KERN_ERR "ide-scsi: Strange, packet command initiated yet DRQ isn't asserted\n");
  1083.         return;
  1084.     }
  1085. -   ireason.all=IN_BYTE (IDE_IREASON_REG);
  1086. -   if (!ireason.b.cod || ireason.b.io) {
  1087. +   ireason = IN_BYTE (IDE_IREASON_REG);
  1088. +   if ((ireason & (IDESCSI_IREASON_IO | IDESCSI_IREASON_COD)) != IDESCSI_IREASON_COD) {
  1089.         printk (KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while issuing a packet command\n");
  1090.         ide_do_reset (drive);
  1091.         return;
  1092. @@ -211,19 +326,28 @@ static void idescsi_transfer_pc (ide_drive_t *drive)
  1093.  static void idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
  1094.  {
  1095.     idescsi_scsi_t *scsi = drive->driver_data;
  1096. -   idescsi_bcount_reg_t bcount;
  1097. +   int bcount;
  1098. +   struct request *rq = pc->rq;
  1099. +   int dma_ok = 0;
  1100.  
  1101.     scsi->pc=pc;                            /* Set the current packet command */
  1102.     pc->actually_transferred=0;                 /* We haven't transferred any data yet */
  1103.     pc->current_position=pc->buffer;
  1104. -   bcount.all = IDE_MIN (pc->request_transfer, 63 * 1024);     /* Request to transfer the entire buffer at once */
  1105. +   bcount = IDE_MIN (pc->request_transfer, 63 * 1024);     /* Request to transfer the entire buffer at once */
  1106. +
  1107. +   if (drive->using_dma && rq->bh)
  1108. +       dma_ok=!HWIF(drive)->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
  1109.  
  1110.     OUT_BYTE (drive->ctl,IDE_CONTROL_REG);
  1111. -   OUT_BYTE (0,IDE_FEATURE_REG);
  1112. -   OUT_BYTE (bcount.b.high,IDE_BCOUNTH_REG);
  1113. -   OUT_BYTE (bcount.b.low,IDE_BCOUNTL_REG);
  1114. +   OUT_BYTE (dma_ok,IDE_FEATURE_REG);
  1115. +   OUT_BYTE (bcount >> 8,IDE_BCOUNTH_REG);
  1116. +   OUT_BYTE (bcount & 0xff,IDE_BCOUNTL_REG);
  1117.     OUT_BYTE (drive->select.all,IDE_SELECT_REG);
  1118.  
  1119. +   if (dma_ok) {
  1120. +       set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
  1121. +       (void) (HWIF(drive)->dmaproc(ide_dma_begin, drive));
  1122. +   }
  1123.     if (test_bit (IDESCSI_DRQ_INTERRUPT, &scsi->flags)) {
  1124.         ide_set_handler (drive, &idescsi_transfer_pc, WAIT_CMD);
  1125.         OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG);      /* Issue the packet command */
  1126. @@ -304,7 +428,7 @@ static ide_module_t idescsi_module = {
  1127.  static ide_driver_t idescsi_driver = {
  1128.     ide_scsi,       /* media */
  1129.     0,          /* busy */
  1130. -   0,          /* supports_dma */
  1131. +   1,          /* supports_dma */
  1132.     0,          /* supports_dsc_overlap */
  1133.     idescsi_cleanup,    /* cleanup */
  1134.     idescsi_do_request, /* do_request */
  1135. @@ -389,23 +513,74 @@ const char *idescsi_info (struct Scsi_Host *host)
  1136.     return "SCSI host adapter emulation for IDE ATAPI devices";
  1137.  }
  1138.  
  1139. -/*
  1140. - * Most of the SCSI commands are supported directly by ATAPI devices.
  1141. - * idescsi_transform_pc handles the few exceptions.
  1142. - */
  1143. -static inline void idescsi_transform_pc (ide_drive_t *drive, idescsi_pc_t *pc)
  1144. +static inline struct buffer_head *idescsi_kmalloc_bh (int count)
  1145.  {
  1146. -   if (drive->media == ide_cdrom) {
  1147. -       if (pc->c[0] == READ_6) {
  1148. -           pc->c[8] = pc->c[4];
  1149. -           pc->c[5] = pc->c[3];
  1150. -           pc->c[4] = pc->c[2];
  1151. -           pc->c[3] = pc->c[1] & 0x1f;
  1152. -           pc->c[2] = 0;
  1153. -           pc->c[1] &= 0xe0;
  1154. -           pc->c[0] = READ_10;
  1155. +   struct buffer_head *bh, *bhp, *first_bh;
  1156. +
  1157. +   if ((first_bh = bhp = bh = kmalloc (sizeof(struct buffer_head), GFP_ATOMIC)) == NULL)
  1158. +       goto abort;
  1159. +   memset (bh, 0, sizeof (struct buffer_head));
  1160. +   bh->b_reqnext = NULL;
  1161. +   while (--count) {
  1162. +       if ((bh = kmalloc (sizeof(struct buffer_head), GFP_ATOMIC)) == NULL)
  1163. +           goto abort;
  1164. +       memset (bh, 0, sizeof (struct buffer_head));
  1165. +       bhp->b_reqnext = bh;
  1166. +       bhp = bh;
  1167. +       bh->b_reqnext = NULL;
  1168. +   }
  1169. +   return first_bh;
  1170. +abort:
  1171. +   idescsi_free_bh (first_bh);
  1172. +   return NULL;
  1173. +}
  1174. +
  1175. +static inline int idescsi_set_direction (idescsi_pc_t *pc)
  1176. +{
  1177. +   switch (pc->c[0]) {
  1178. +       case READ_6: case READ_10: case READ_12:
  1179. +           clear_bit (PC_WRITING, &pc->flags);
  1180. +           return 0;
  1181. +       case WRITE_6: case WRITE_10: case WRITE_12:
  1182. +           set_bit (PC_WRITING, &pc->flags);
  1183. +           return 0;
  1184. +       default:
  1185. +           return 1;
  1186. +   }
  1187. +}
  1188. +
  1189. +static inline struct buffer_head *idescsi_dma_bh (ide_drive_t *drive, idescsi_pc_t *pc)
  1190. +{
  1191. +   struct buffer_head *bh = NULL, *first_bh = NULL;
  1192. +   int segments = pc->scsi_cmd->use_sg;
  1193. +   struct scatterlist *sg = pc->scsi_cmd->request_buffer;
  1194. +
  1195. +   if (!drive->using_dma || pc->request_transfer % 1024)
  1196. +       return NULL;
  1197. +   if (idescsi_set_direction(pc))
  1198. +       return NULL;
  1199. +   if (segments) {
  1200. +       if ((first_bh = bh = idescsi_kmalloc_bh (segments)) == NULL)
  1201. +           return NULL;
  1202. +#if IDESCSI_DEBUG_LOG
  1203. +       printk ("ide-scsi: %s: building DMA table, %d segments, %dkB total\n", drive->name, segments, pc->request_transfer >> 10);
  1204. +#endif /* IDESCSI_DEBUG_LOG */
  1205. +       while (segments--) {
  1206. +           bh->b_data = sg->address;
  1207. +           bh->b_size = sg->length;
  1208. +           bh = bh->b_reqnext;
  1209. +           sg++;
  1210.         }
  1211. +   } else {
  1212. +       if ((first_bh = bh = idescsi_kmalloc_bh (1)) == NULL)
  1213. +           return NULL;
  1214. +#if IDESCSI_DEBUG_LOG
  1215. +       printk ("ide-scsi: %s: building DMA table for a single buffer (%dkB)\n", drive->name, pc->request_transfer >> 10);
  1216. +#endif /* IDESCSI_DEBUG_LOG */
  1217. +       bh->b_data = pc->scsi_cmd->request_buffer;
  1218. +       bh->b_size = pc->request_transfer;
  1219.     }
  1220. +   return first_bh;
  1221.  }
  1222.  
  1223.  int idescsi_queue (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
  1224. @@ -430,16 +605,25 @@ int idescsi_queue (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
  1225.     }
  1226.  
  1227.     memset (pc->c, 0, 12);
  1228. +   pc->flags = 0;
  1229.     pc->rq = rq;
  1230.     memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
  1231. -   pc->buffer = cmd->request_buffer;
  1232. +   if (cmd->use_sg) {
  1233. +       pc->buffer = NULL;
  1234. +       pc->sg = cmd->request_buffer;
  1235. +   } else {
  1236. +       pc->buffer = cmd->request_buffer;
  1237. +       pc->sg = NULL;
  1238. +   }
  1239. +   pc->b_count = 0;
  1240.     pc->request_transfer = pc->buffer_size = cmd->request_bufflen;
  1241.     pc->scsi_cmd = cmd;
  1242.     pc->done = done;
  1243. -   idescsi_transform_pc (drive, pc);
  1244. +   idescsi_transform_pc1 (drive, pc);
  1245.  
  1246.     ide_init_drive_cmd (rq);
  1247.     rq->buffer = (char *) pc;
  1248. +   rq->bh = idescsi_dma_bh (drive, pc);
  1249.     rq->cmd = IDESCSI_PC_RQ;
  1250.     (void) ide_do_drive_cmd (drive, rq, ide_end);
  1251.     return 0;
  1252. @@ -481,7 +665,7 @@ void cleanup_module (void)
  1253.     scsi_unregister_module (MODULE_SCSI_HA, &idescsi_template);
  1254.     for (i = 0; media[i] != 255; i++) {
  1255.         failed = 0;
  1256. -       while ((drive = ide_scan_devices (media[i], &idescsi_driver, failed++)) != NULL)
  1257. +       while ((drive = ide_scan_devices (media[i], &idescsi_driver, failed)) != NULL)
  1258.             if (idescsi_cleanup (drive)) {
  1259.                 printk ("%s: cleanup_module() called while still busy\n", drive->name);
  1260.                 failed++;
  1261. diff --git a/drivers/scsi/ide-scsi.h b/drivers/scsi/ide-scsi.h
  1262. index cc687fe..94edaa1 100644
  1263. --- a/drivers/scsi/ide-scsi.h
  1264. +++ b/drivers/scsi/ide-scsi.h
  1265. @@ -1,7 +1,7 @@
  1266.  /*
  1267.   * linux/drivers/scsi/ide-scsi.h
  1268.   *
  1269. - * Copyright (C) 1996 Gadi Oxman <gadio@netvision.net.il>
  1270. + * Copyright (C) 1996, 1997 Gadi Oxman <gadio@netvision.net.il>
  1271.   */
  1272.  
  1273.  #ifndef IDESCSI_H
  1274. @@ -31,7 +31,7 @@ extern int idescsi_reset (Scsi_Cmnd *cmd, unsigned int resetflags);
  1275.     NULL,           /* bios_param   */          \
  1276.     10,         /* can_queue    */          \
  1277.     -1,         /* this_id  */          \
  1278. -   SG_NONE,        /* sg_tablesize */          \
  1279. +   256,            /* sg_tablesize */          \
  1280.     5,          /* cmd_per_lun  */          \
  1281.     0,          /* present  */          \
  1282.     0,          /* isa_dma  */          \
  1283. diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
  1284. index 6ff5209..d084923 100644
  1285. --- a/drivers/scsi/seagate.c
  1286. +++ b/drivers/scsi/seagate.c
  1287. @@ -43,20 +43,41 @@
  1288.   * will configure the driver for a TMC-8xx style controller using IRQ 15
  1289.   * with a base address of 0xC8000.
  1290.   *
  1291. - * -DFAST or -DFAST32 will use blind transfers where possible
  1292. - *
  1293. - * -DARBITRATE will cause the host adapter to arbitrate for the
  1294. + * -DARBITRATE
  1295. + *      Will cause the host adapter to arbitrate for the
  1296.   *      bus for better SCSI-II compatibility, rather than just
  1297.   *      waiting for BUS FREE and then doing its thing.  Should
  1298.   *      let us do one command per Lun when I integrate my
  1299.   *      reorganization changes into the distribution sources.
  1300.   *
  1301. - * -DSLOW_HANDSHAKE will allow compatibility with broken devices that don't
  1302. + * -DDEBUG
  1303. + *      Will activate debug code.
  1304. + *
  1305. + * -DFAST or -DFAST32
  1306. + *      Will use blind transfers where possible
  1307. + *
  1308. + * -DPARITY  
  1309. + *      This will enable parity.
  1310. + *
  1311. + * -DSEAGATE_USE_ASM
  1312. + *      Will use older seagate assembly code. should be (very small amount)
  1313. + *      Faster.
  1314. + *
  1315. + * -DSLOW_HANDSHAKE
  1316. + *      Will allow compatibility with broken devices that don't
  1317.   *      handshake fast enough (ie, some CD ROM's) for the Seagate
  1318.   *      code.
  1319.   *
  1320. - * -DSLOW_RATE=x, x some number will let you specify a default
  1321. + * -DSLOW_RATE=x
  1322. + *      x is some number, It will let you specify a default
  1323.   *      transfer rate if handshaking isn't working correctly.
  1324. + *
  1325. + * The following to options are patches from the SCSI.HOWTO
  1326. + *
  1327. + * -DSWAPSTAT  This will swap the definitions for STAT_MSG and STAT_CD.
  1328. + *
  1329. + * -DSWAPCNTDATA  This will swap the order that seagate.c messes with
  1330. + *                the CONTROL an DATA registers.
  1331.   */
  1332.  
  1333.  #include <linux/module.h>
  1334. @@ -396,8 +417,8 @@ int seagate_st0x_detect (Scsi_Host_Template * tpnt)
  1335.  #ifdef ARBITRATE
  1336.              " ARBITRATE"
  1337.  #endif
  1338. -#ifdef SLOW_HANDSHAKE
  1339. -            " SLOW_HANDSHAKE"
  1340. +#ifdef DEBUG
  1341. +            " DEBUG"
  1342.  #endif
  1343.  #ifdef FAST
  1344.  #ifdef FAST32
  1345. @@ -409,6 +430,21 @@ int seagate_st0x_detect (Scsi_Host_Template * tpnt)
  1346.  #ifdef LINKED
  1347.              " LINKED"
  1348.  #endif
  1349. +#ifdef PARITY
  1350. +            " PARITY"
  1351. +#endif
  1352. +#ifdef SEAGATE_USE_ASM
  1353. +            " SEAGATE_USE_ASM"
  1354. +#endif
  1355. +#ifdef SLOW_HANDSHAKE
  1356. +            " SLOW_HANDSHAKE"
  1357. +#endif
  1358. +#ifdef SWAPSTAT
  1359. +            " SWAPSTAT"
  1360. +#endif
  1361. +#ifdef SWAPCNTDATA
  1362. +            " SWAPCNTDATA"
  1363. +#endif
  1364.              "\n", tpnt->name);
  1365.      return 1;
  1366.    }
  1367. @@ -926,12 +962,21 @@ static int internal_command (unsigned char target, unsigned char lun,
  1368.   *    try this with a SCSI protocol or logic analyzer to see what is
  1369.   *    going on.
  1370.   */
  1371. +#ifdef SWAPCNTDATA
  1372. +   cli();
  1373. +      WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | CMD_SEL |
  1374. +                     (reselect ? CMD_ATTN : 0));
  1375. +      WRITE_DATA ((unsigned char) ((1 << target) |
  1376. +                               (controller_type == SEAGATE ? 0x80 : 0x40)));
  1377. +   sti();
  1378. +#else
  1379.        cli ();
  1380.        WRITE_DATA ((unsigned char) ((1 << target) |
  1381.                                 (controller_type == SEAGATE ? 0x80 : 0x40)));
  1382.        WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | CMD_SEL |
  1383.                       (reselect ? CMD_ATTN : 0));
  1384.        sti ();
  1385. +#endif
  1386.        while (!((status_read = STATUS) & STAT_BSY) && (jiffies < clock)
  1387.               && !st0x_aborted)
  1388.  #if 0 && (DEBUG & PHASE_SELECTION)
  1389. diff --git a/drivers/scsi/seagate.h b/drivers/scsi/seagate.h
  1390. index da18dbe..e56b174 100644
  1391. --- a/drivers/scsi/seagate.h
  1392. +++ b/drivers/scsi/seagate.h
  1393. @@ -37,14 +37,6 @@ int seagate_st0x_biosparam(Disk *, kdev_t, int*);
  1394.              1, 7, SG_ALL, 1, 0, 0, DISABLE_CLUSTERING}
  1395.  #endif
  1396.  
  1397. -
  1398. -/*
  1399. -   defining PARITY causes parity data to be checked
  1400. -*/
  1401. -
  1402. -#define PARITY
  1403. -
  1404. -
  1405.  /*
  1406.     Thanks to Brian Antoine for the example code in his Messy-Loss ST-01
  1407.         driver, and Mitsugu Suzuki for information on the ST-01
  1408. @@ -67,11 +59,16 @@ int seagate_st0x_biosparam(Disk *, kdev_t, int*);
  1409.  /*
  1410.     STATUS
  1411.  */
  1412. +#ifdef SWAPSTAT
  1413. +   #define STAT_MSG        0x08
  1414. +   #define STAT_CD         0x02
  1415. +#else
  1416. +   #define STAT_MSG        0x02
  1417. +   #define STAT_CD         0x08
  1418. +#endif
  1419.  
  1420.  #define STAT_BSY       0x01
  1421. -#define STAT_MSG       0x02
  1422.  #define STAT_IO            0x04
  1423. -#define STAT_CD            0x08
  1424.  #define STAT_REQ       0x10
  1425.  #define STAT_SEL       0x20
  1426.  #define STAT_PARITY        0x40
  1427. diff --git a/fs/devices.c b/fs/devices.c
  1428. index c9af466..c604a55 100644
  1429. --- a/fs/devices.c
  1430. +++ b/fs/devices.c
  1431. @@ -253,7 +253,7 @@ struct file_operations def_blk_fops = {
  1432.     NULL,       /* read */
  1433.     NULL,       /* write */
  1434.     NULL,       /* readdir */
  1435. -   NULL,       /* select */
  1436. +   NULL,       /* poll */
  1437.     NULL,       /* ioctl */
  1438.     NULL,       /* mmap */
  1439.     blkdev_open,    /* open */
  1440. @@ -306,7 +306,7 @@ struct file_operations def_chr_fops = {
  1441.     NULL,       /* read */
  1442.     NULL,       /* write */
  1443.     NULL,       /* readdir */
  1444. -   NULL,       /* select */
  1445. +   NULL,       /* poll */
  1446.     NULL,       /* ioctl */
  1447.     NULL,       /* mmap */
  1448.     chrdev_open,    /* open */
  1449. diff --git a/fs/ext2/symlink.c b/fs/ext2/symlink.c
  1450. index ef4dd52..31f8276 100644
  1451. --- a/fs/ext2/symlink.c
  1452. +++ b/fs/ext2/symlink.c
  1453. @@ -122,12 +122,11 @@ static int ext2_readlink (struct inode * inode, char * buffer, int buflen)
  1454.     }
  1455.     else
  1456.         link = (char *) inode->u.ext2_i.i_data;
  1457. -  
  1458. -   /* XXX I hope link is always '\0'-terminated. */    
  1459. -   i = strlen(link);
  1460. -   if (i >= buflen)
  1461. -       i = buflen-1;
  1462. -   if (copy_to_user(buffer, link, i+1))
  1463. +
  1464. +   i = 0;
  1465. +   while (i < buflen && link[i])
  1466. +       i++;
  1467. +   if (copy_to_user(buffer, link, i))
  1468.         i = -EFAULT;
  1469.     if (DO_UPDATE_ATIME(inode)) {
  1470.         inode->i_atime = CURRENT_TIME;
  1471. diff --git a/fs/nfs/rpcsock.c b/fs/nfs/rpcsock.c
  1472. index d341504..3d6d5c0 100644
  1473. --- a/fs/nfs/rpcsock.c
  1474. +++ b/fs/nfs/rpcsock.c
  1475. @@ -40,6 +40,7 @@
  1476.  #include <linux/net.h>
  1477.  #include <linux/mm.h>
  1478.  #include <linux/rpcsock.h>
  1479. +#include <linux/poll.h>
  1480.  
  1481.  #include <linux/udp.h>
  1482.  #include <net/sock.h>
  1483. @@ -159,21 +160,20 @@ rpc_recvmsg(struct rpc_sock *rsock, struct iovec *iov,
  1484.  
  1485.  /*
  1486.   * This code is slightly complicated. Since the networking code does not
  1487. - * honor the current->timeout value, we have to select on the socket.
  1488. + * honor the current->timeout value, we have to poll on the socket.
  1489.   */
  1490.  static inline int
  1491.  rpc_select(struct rpc_sock *rsock)
  1492.  {
  1493. -   struct select_table_entry entry;
  1494. +   struct poll_table_entry entry;
  1495.     struct file *file = rsock->file;
  1496. -   select_table    wait_table;
  1497. +   poll_table  wait_table;
  1498.  
  1499. -   dprintk("RPC: selecting on socket...\n");
  1500. +   dprintk("RPC: polling socket...\n");
  1501.     wait_table.nr = 0;
  1502.     wait_table.entry = &entry;
  1503.     current->state = TASK_INTERRUPTIBLE;
  1504. -   if (!file->f_op->select(file->f_inode, file, SEL_IN, &wait_table)
  1505. -    && !file->f_op->select(file->f_inode, file, SEL_IN, NULL)) {
  1506. +   if (!(file->f_op->poll(file, &wait_table) & POLLIN)) {
  1507.         schedule();
  1508.         remove_wait_queue(entry.wait_address, &entry.wait);
  1509.         current->state = TASK_RUNNING;
  1510. diff --git a/fs/pipe.c b/fs/pipe.c
  1511. index d43e604..0196e07 100644
  1512. --- a/fs/pipe.c
  1513. +++ b/fs/pipe.c
  1514. @@ -12,6 +12,7 @@
  1515.  #include <linux/termios.h>
  1516.  #include <linux/mm.h>
  1517.  
  1518. +#include <asm/poll.h>
  1519.  #include <asm/uaccess.h>
  1520.  
  1521.  /*
  1522. @@ -159,57 +160,43 @@ static int pipe_ioctl(struct inode *pino, struct file * filp,
  1523.     }
  1524.  }
  1525.  
  1526. -static int pipe_select(struct inode * inode, struct file * filp, int sel_type, select_table * wait)
  1527. +static unsigned int pipe_poll(struct file * filp, poll_table * wait)
  1528.  {
  1529. -   switch (sel_type) {
  1530. -       case SEL_IN:
  1531. -           if (!PIPE_EMPTY(*inode) || !PIPE_WRITERS(*inode))
  1532. -               return 1;
  1533. -           select_wait(&PIPE_WAIT(*inode), wait);
  1534. -           return 0;
  1535. -       case SEL_OUT:
  1536. -           if (PIPE_EMPTY(*inode) || !PIPE_READERS(*inode))
  1537. -               return 1;
  1538. -           select_wait(&PIPE_WAIT(*inode), wait);
  1539. -           return 0;
  1540. -       case SEL_EX:
  1541. -           if (!PIPE_READERS(*inode) || !PIPE_WRITERS(*inode))
  1542. -               return 1;
  1543. -           select_wait(&inode->i_wait,wait);
  1544. -           return 0;
  1545. -   }
  1546. -   return 0;
  1547. +   unsigned int mask;
  1548. +   struct inode * inode = filp->f_inode;
  1549. +
  1550. +   poll_wait(&PIPE_WAIT(*inode), wait);
  1551. +   mask = POLLIN | POLLRDNORM;
  1552. +   if (PIPE_EMPTY(*inode))
  1553. +       mask = POLLOUT | POLLWRNORM;
  1554. +   if (!PIPE_WRITERS(*inode))
  1555. +       mask |= POLLHUP;
  1556. +   if (!PIPE_READERS(*inode))
  1557. +       mask |= POLLERR;
  1558. +   return mask;
  1559.  }
  1560.  
  1561.  #ifdef FIFO_SUNOS_BRAINDAMAGE
  1562.  /*
  1563.   * Arggh. Why does SunOS have to have different select() behaviour
  1564. - * for pipes and fifos? Hate-Hate-Hate. See difference in SEL_IN..
  1565. + * for pipes and fifos? Hate-Hate-Hate. SunOS lacks POLLHUP..
  1566.   */
  1567. -static int fifo_select(struct inode * inode, struct file * filp, int sel_type, select_table * wait)
  1568. +static unsigned int fifo_poll(struct file * filp, poll_table * wait)
  1569.  {
  1570. -   switch (sel_type) {
  1571. -       case SEL_IN:
  1572. -           if (!PIPE_EMPTY(*inode))
  1573. -               return 1;
  1574. -           select_wait(&PIPE_WAIT(*inode), wait);
  1575. -           return 0;
  1576. -       case SEL_OUT:
  1577. -           if (!PIPE_FULL(*inode) || !PIPE_READERS(*inode))
  1578. -               return 1;
  1579. -           select_wait(&PIPE_WAIT(*inode), wait);
  1580. -           return 0;
  1581. -       case SEL_EX:
  1582. -           if (!PIPE_READERS(*inode) || !PIPE_WRITERS(*inode))
  1583. -               return 1;
  1584. -           select_wait(&inode->i_wait,wait);
  1585. -           return 0;
  1586. -   }
  1587. -   return 0;
  1588. +   unsigned int mask;
  1589. +   struct inode * inode = filp->f_inode;
  1590. +
  1591. +   poll_wait(&PIPE_WAIT(*inode), wait);
  1592. +   mask = POLLIN | POLLRDNORM;
  1593. +   if (PIPE_EMPTY(*inode))
  1594. +       mask = POLLOUT | POLLWRNORM;
  1595. +   if (!PIPE_READERS(*inode))
  1596. +       mask |= POLLERR;
  1597. +   return mask;
  1598.  }
  1599.  #else
  1600.  
  1601. -#define fifo_select pipe_select
  1602. +#define fifo_poll pipe_poll
  1603.  
  1604.  #endif /* FIFO_SUNOS_BRAINDAMAGE */
  1605.  
  1606. @@ -227,31 +214,18 @@ static long connect_read(struct inode * inode, struct file * filp,
  1607.     return pipe_read(inode,filp,buf,count);
  1608.  }
  1609.  
  1610. -static int connect_select(struct inode * inode, struct file * filp, int sel_type, select_table * wait)
  1611. +static unsigned int connect_poll(struct file * filp, poll_table * wait)
  1612.  {
  1613. -   switch (sel_type) {
  1614. -       case SEL_IN:
  1615. -           if (!PIPE_EMPTY(*inode)) {
  1616. -               filp->f_op = &read_fifo_fops;
  1617. -               return 1;
  1618. -           }
  1619. -           if (PIPE_WRITERS(*inode)) {
  1620. -               filp->f_op = &read_fifo_fops;
  1621. -           }
  1622. -           select_wait(&PIPE_WAIT(*inode), wait);
  1623. -           return 0;
  1624. -       case SEL_OUT:
  1625. -           if (!PIPE_FULL(*inode))
  1626. -               return 1;
  1627. -           select_wait(&PIPE_WAIT(*inode), wait);
  1628. -           return 0;
  1629. -       case SEL_EX:
  1630. -           if (!PIPE_READERS(*inode) || !PIPE_WRITERS(*inode))
  1631. -               return 1;
  1632. -           select_wait(&inode->i_wait,wait);
  1633. -           return 0;
  1634. +   struct inode * inode = filp->f_inode;
  1635. +
  1636. +   poll_wait(&PIPE_WAIT(*inode), wait);
  1637. +   if (!PIPE_EMPTY(*inode)) {
  1638. +       filp->f_op = &read_fifo_fops;
  1639. +       return POLLIN | POLLRDNORM;
  1640.     }
  1641. -   return 0;
  1642. +   if (PIPE_WRITERS(*inode))
  1643. +       filp->f_op = &read_fifo_fops;
  1644. +   return POLLOUT | POLLWRNORM;
  1645.  }
  1646.  
  1647.  static void pipe_read_release(struct inode * inode, struct file * filp)
  1648. @@ -305,7 +279,7 @@ struct file_operations connecting_fifo_fops = {
  1649.     connect_read,
  1650.     bad_pipe_w,
  1651.     NULL,       /* no readdir */
  1652. -   connect_select,
  1653. +   connect_poll,
  1654.     pipe_ioctl,
  1655.     NULL,       /* no mmap on pipes.. surprise */
  1656.     pipe_read_open,
  1657. @@ -318,7 +292,7 @@ struct file_operations read_fifo_fops = {
  1658.     pipe_read,
  1659.     bad_pipe_w,
  1660.     NULL,       /* no readdir */
  1661. -   fifo_select,
  1662. +   fifo_poll,
  1663.     pipe_ioctl,
  1664.     NULL,       /* no mmap on pipes.. surprise */
  1665.     pipe_read_open,
  1666. @@ -331,7 +305,7 @@ struct file_operations write_fifo_fops = {
  1667.     bad_pipe_r,
  1668.     pipe_write,
  1669.     NULL,       /* no readdir */
  1670. -   fifo_select,
  1671. +   fifo_poll,
  1672.     pipe_ioctl,
  1673.     NULL,       /* mmap */
  1674.     pipe_write_open,
  1675. @@ -344,7 +318,7 @@ struct file_operations rdwr_fifo_fops = {
  1676.     pipe_read,
  1677.     pipe_write,
  1678.     NULL,       /* no readdir */
  1679. -   fifo_select,
  1680. +   fifo_poll,
  1681.     pipe_ioctl,
  1682.     NULL,       /* mmap */
  1683.     pipe_rdwr_open,
  1684. @@ -357,7 +331,7 @@ struct file_operations read_pipe_fops = {
  1685.     pipe_read,
  1686.     bad_pipe_w,
  1687.     NULL,       /* no readdir */
  1688. -   pipe_select,
  1689. +   pipe_poll,
  1690.     pipe_ioctl,
  1691.     NULL,       /* no mmap on pipes.. surprise */
  1692.     pipe_read_open,
  1693. @@ -370,7 +344,7 @@ struct file_operations write_pipe_fops = {
  1694.     bad_pipe_r,
  1695.     pipe_write,
  1696.     NULL,       /* no readdir */
  1697. -   pipe_select,
  1698. +   pipe_poll,
  1699.     pipe_ioctl,
  1700.     NULL,       /* mmap */
  1701.     pipe_write_open,
  1702. @@ -383,7 +357,7 @@ struct file_operations rdwr_pipe_fops = {
  1703.     pipe_read,
  1704.     pipe_write,
  1705.     NULL,       /* no readdir */
  1706. -   pipe_select,
  1707. +   pipe_poll,
  1708.     pipe_ioctl,
  1709.     NULL,       /* mmap */
  1710.     pipe_rdwr_open,
  1711. diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c
  1712. index add1121..2696769 100644
  1713. --- a/fs/proc/kmsg.c
  1714. +++ b/fs/proc/kmsg.c
  1715. @@ -9,6 +9,7 @@
  1716.  #include <linux/errno.h>
  1717.  #include <linux/sched.h>
  1718.  #include <linux/kernel.h>
  1719. +#include <linux/poll.h>
  1720.  
  1721.  #include <asm/uaccess.h>
  1722.  #include <asm/io.h>
  1723. @@ -34,13 +35,11 @@ static long kmsg_read(struct inode * inode, struct file * file,
  1724.     return sys_syslog(2,buf,count);
  1725.  }
  1726.  
  1727. -static int kmsg_select(struct inode *inode, struct file *file, int sel_type, select_table * wait)
  1728. +static unsigned int kmsg_poll(struct file *file, poll_table * wait)
  1729.  {
  1730. -   if (sel_type != SEL_IN)
  1731. -       return 0;
  1732. +   poll_wait(&log_wait, wait);
  1733.     if (log_size)
  1734. -       return 1;
  1735. -   select_wait(&log_wait, wait);
  1736. +       return POLLIN | POLLRDNORM;
  1737.     return 0;
  1738.  }
  1739.  
  1740. @@ -50,7 +49,7 @@ static struct file_operations proc_kmsg_operations = {
  1741.     kmsg_read,
  1742.     NULL,       /* kmsg_write */
  1743.     NULL,       /* kmsg_readdir */
  1744. -   kmsg_select,    /* kmsg_select */
  1745. +   kmsg_poll,  /* kmsg_poll */
  1746.     NULL,       /* kmsg_ioctl */
  1747.     NULL,       /* mmap */
  1748.     kmsg_open,
  1749. diff --git a/fs/select.c b/fs/select.c
  1750. index 3d87796..1528072 100644
  1751. --- a/fs/select.c
  1752. +++ b/fs/select.c
  1753. @@ -1,5 +1,5 @@
  1754.  /*
  1755. - * This file contains the procedures for the handling of select
  1756. + * This file contains the procedures for the handling of select and poll
  1757.   *
  1758.   * Created for Linux based loosely upon Mathius Lattner's minix
  1759.   * patches by Peter MacDonald. Heavily edited by Linus.
  1760. @@ -21,11 +21,14 @@
  1761.  #include <linux/errno.h>
  1762.  #include <linux/personality.h>
  1763.  #include <linux/mm.h>
  1764. +#include <linux/malloc.h>
  1765.  
  1766.  #include <asm/uaccess.h>
  1767.  #include <asm/system.h>
  1768. +#include <asm/poll.h>
  1769.  
  1770.  #define ROUND_UP(x,y) (((x)+(y)-1)/(y))
  1771. +#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
  1772.  
  1773.  /*
  1774.   * Ok, Peter made a complicated, but straightforward multiple_wait() function.
  1775. @@ -34,20 +37,20 @@
  1776.   * understand what I'm doing here, then you understand how the linux
  1777.   * sleep/wakeup mechanism works.
  1778.   *
  1779. - * Two very simple procedures, select_wait() and free_wait() make all the work.
  1780. - * select_wait() is an inline-function defined in <linux/sched.h>, as all select
  1781. - * functions have to call it to add an entry to the select table.
  1782. + * Two very simple procedures, poll_wait() and free_wait() make all the work.
  1783. + * poll_wait() is an inline-function defined in <linux/sched.h>, as all select/poll
  1784. + * functions have to call it to add an entry to the poll table.
  1785.   */
  1786.  
  1787.  /*
  1788. - * I rewrote this again to make the select_table size variable, take some
  1789. + * I rewrote this again to make the poll_table size variable, take some
  1790.   * more shortcuts, improve responsiveness, and remove another race that
  1791.   * Linus noticed.  -- jrs
  1792.   */
  1793.  
  1794. -static void free_wait(select_table * p)
  1795. +static void free_wait(poll_table * p)
  1796.  {
  1797. -   struct select_table_entry * entry = p->entry + p->nr;
  1798. +   struct poll_table_entry * entry = p->entry + p->nr;
  1799.  
  1800.     while (p->nr > 0) {
  1801.         p->nr--;
  1802. @@ -57,34 +60,6 @@ static void free_wait(select_table * p)
  1803.  }
  1804.  
  1805.  /*
  1806. - * The check function checks the ready status of a file using the vfs layer.
  1807. - *
  1808. - * If the file was not ready we were added to its wait queue.  But in
  1809. - * case it became ready just after the check and just before it called
  1810. - * select_wait, we call it again, knowing we are already on its
  1811. - * wait queue this time.  The second call is not necessary if the
  1812. - * select_table is NULL indicating an earlier file check was ready
  1813. - * and we aren't going to sleep on the select_table.  -- jrs
  1814. - */
  1815. -
  1816. -static inline int __check(
  1817. -   int (*select) (struct inode *, struct file *, int, select_table *),
  1818. -   struct inode *inode,
  1819. -   struct file *file,
  1820. -   int flag,
  1821. -   select_table * wait)
  1822. -{
  1823. -   return select(inode, file, flag, wait) ||
  1824. -       (wait && select(inode, file, flag, NULL));
  1825. -}
  1826. -
  1827. -#define check(flag,wait,file) \
  1828. -(((file)->f_op && (file)->f_op->select) ? \
  1829. - __check((file)->f_op->select,(file)->f_inode,file,flag,wait) \
  1830. - : \
  1831. - (flag != SEL_EX))
  1832. -
  1833. -/*
  1834.   * Due to kernel stack usage, we use a _limited_ fd_set type here, and once
  1835.   * we really start supporting >256 file descriptors we'll probably have to
  1836.   * allocate the kernel fd_set copies dynamically.. (The kernel select routines
  1837. @@ -154,11 +129,15 @@ get_max:
  1838.  #define ISSET(i,m) (((i)&*(m)) != 0)
  1839.  #define SET(i,m)   (*(m) |= (i))
  1840.  
  1841. +#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR)
  1842. +#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR)
  1843. +#define POLLEX_SET (POLLPRI)
  1844. +
  1845.  static int do_select(int n, fd_set_buffer *fds)
  1846.  {
  1847.     int retval;
  1848. -   select_table wait_table, *wait;
  1849. -   struct select_table_entry *entry;
  1850. +   poll_table wait_table, *wait;
  1851. +   struct poll_table_entry *entry;
  1852.     int i;
  1853.  
  1854.     retval = max_select_fd(n, fds);
  1855. @@ -166,7 +145,8 @@ static int do_select(int n, fd_set_buffer *fds)
  1856.         goto out;
  1857.     n = retval;
  1858.     retval = -ENOMEM;
  1859. -   if(!(entry = (struct select_table_entry*) __get_free_page(GFP_KERNEL)))
  1860. +   entry = (struct poll_table_entry *) __get_free_page(GFP_KERNEL);
  1861. +   if (!entry)
  1862.         goto out;
  1863.     retval = 0;
  1864.     wait_table.nr = 0;
  1865. @@ -178,24 +158,30 @@ static int do_select(int n, fd_set_buffer *fds)
  1866.         for (i = 0 ; i < n ; i++,fd++) {
  1867.             unsigned long bit = BIT(i);
  1868.             unsigned long *in = MEM(i,fds->in);
  1869. -           struct file * file = *fd;
  1870.  
  1871. -           if (!file)
  1872. -               continue;
  1873. -           if (ISSET(bit,__IN(in)) && check(SEL_IN,wait,file)) {
  1874. -               SET(bit, __RES_IN(in));
  1875. -               retval++;
  1876. -               wait = NULL;
  1877. -           }
  1878. -           if (ISSET(bit,__OUT(in)) && check(SEL_OUT,wait,file)) {
  1879. -               SET(bit, __RES_OUT(in));
  1880. -               retval++;
  1881. -               wait = NULL;
  1882. -           }
  1883. -           if (ISSET(bit,__EX(in)) && check(SEL_EX,wait,file)) {
  1884. -               SET(bit, __RES_EX(in));
  1885. -               retval++;
  1886. -               wait = NULL;
  1887. +           if (bit & BITS(in)) {
  1888. +               struct file * file = *fd;
  1889. +               unsigned int mask = POLLNVAL;
  1890. +               if (file) {
  1891. +                   mask = DEFAULT_POLLMASK;
  1892. +                   if (file->f_op && file->f_op->poll)
  1893. +                       mask = file->f_op->poll(file, wait);
  1894. +               }
  1895. +               if ((mask & POLLIN_SET) && ISSET(bit, __IN(in))) {
  1896. +                   SET(bit, __RES_IN(in));
  1897. +                   retval++;
  1898. +                   wait = NULL;
  1899. +               }
  1900. +               if ((mask & POLLOUT_SET) && ISSET(bit, __OUT(in))) {
  1901. +                   SET(bit, __RES_OUT(in));
  1902. +                   retval++;
  1903. +                   wait = NULL;
  1904. +               }
  1905. +               if ((mask & POLLEX_SET) && ISSET(bit, __EX(in))) {
  1906. +                   SET(bit, __RES_EX(in));
  1907. +                   retval++;
  1908. +                   wait = NULL;
  1909. +               }
  1910.             }
  1911.         }
  1912.         wait = NULL;
  1913. @@ -344,3 +330,95 @@ asmlinkage int sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct
  1914.  out:
  1915.     return error;
  1916.  }
  1917. +
  1918. +static int do_poll(unsigned int nfds, struct pollfd *fds, poll_table *wait)
  1919. +{
  1920. +   int count;
  1921. +   struct file ** fd = current->files->fd;
  1922. +
  1923. +   count = 0;
  1924. +   for (;;) {
  1925. +       unsigned int j;
  1926. +       struct pollfd * fdpnt;
  1927. +
  1928. +       current->state = TASK_INTERRUPTIBLE;
  1929. +       for (fdpnt = fds, j = 0; j < nfds; j++, fdpnt++) {
  1930. +           unsigned int i;
  1931. +           unsigned int mask;
  1932. +           struct file * file;
  1933. +
  1934. +           mask = POLLNVAL;
  1935. +           i = fdpnt->fd;
  1936. +           if (i < NR_OPEN && (file = fd[i]) != NULL) {
  1937. +               mask = DEFAULT_POLLMASK;
  1938. +               if (file->f_op && file->f_op->poll)
  1939. +                   mask = file->f_op->poll(file, wait);
  1940. +               mask &= fdpnt->events | POLLERR | POLLHUP;
  1941. +           }
  1942. +           if (mask) {
  1943. +               wait = NULL;
  1944. +               count++;
  1945. +           }
  1946. +           fdpnt->revents = mask;
  1947. +       }
  1948. +
  1949. +       wait = NULL;
  1950. +       if (count || !current->timeout || (current->signal & ~current->blocked))
  1951. +           break;
  1952. +       schedule();
  1953. +   }
  1954. +   current->state = TASK_RUNNING;
  1955. +   return count;
  1956. +}
  1957. +
  1958. +asmlinkage int sys_poll(struct pollfd * ufds, unsigned int nfds, int timeout)
  1959. +{
  1960. +        int i, count, fdcount;
  1961. +   struct pollfd * fds, *fds1;
  1962. +   poll_table wait_table;
  1963. +   struct poll_table_entry *entry;
  1964. +
  1965. +   if (nfds > NR_OPEN)
  1966. +       return -EINVAL;
  1967. +
  1968. +   entry = (struct poll_table_entry *) __get_free_page(GFP_KERNEL);
  1969. +   if (!entry)
  1970. +       return -ENOMEM;
  1971. +   fds = (struct pollfd *) kmalloc(nfds*sizeof(struct pollfd), GFP_KERNEL);
  1972. +   if (!fds) {
  1973. +       free_page((unsigned long) entry);
  1974. +       return -ENOMEM;
  1975. +   }
  1976. +
  1977. +   if (copy_from_user(fds, ufds, nfds*sizeof(struct pollfd))) {
  1978. +       free_page((unsigned long)entry);
  1979. +       kfree(fds);
  1980. +       return -EFAULT;
  1981. +   }
  1982. +
  1983. +   if (timeout < 0)
  1984. +       timeout = 0x7fffffff;
  1985. +   else if (timeout)
  1986. +       timeout = ((unsigned long)timeout*HZ+999)/1000+jiffies+1;
  1987. +   current->timeout = timeout;
  1988. +
  1989. +   count = 0;
  1990. +   wait_table.nr = 0;
  1991. +   wait_table.entry = entry;
  1992. +
  1993. +   fdcount = do_poll(nfds, fds, &wait_table);
  1994. +   current->timeout = 0;
  1995. +
  1996. +   free_wait(&wait_table);
  1997. +   free_page((unsigned long) entry);
  1998. +
  1999. +   /* OK, now copy the revents fields back to user space. */
  2000. +   fds1 = fds;
  2001. +   for(i=0; i < (int)nfds; i++, ufds++, fds++) {
  2002. +       __put_user(fds->revents, &ufds->revents);
  2003. +   }
  2004. +   kfree(fds1);
  2005. +   if (!fdcount && (current->signal & ~current->blocked))
  2006. +       fdcount = -EINTR;
  2007. +   return fdcount;
  2008. +}
  2009. diff --git a/include/asm-alpha/poll.h b/include/asm-alpha/poll.h
  2010. new file mode 100644
  2011. index 0000000..53bf7a3
  2012. --- /dev/null
  2013. +++ b/include/asm-alpha/poll.h
  2014. @@ -0,0 +1,22 @@
  2015. +#ifndef __ALPHA_POLL_H
  2016. +#define __ALPHA_POLL_H
  2017. +
  2018. +#define POLLIN     1
  2019. +#define POLLPRI        2
  2020. +#define POLLOUT        4
  2021. +#define POLLERR        8
  2022. +#define POLLHUP        16
  2023. +#define POLLNVAL   32
  2024. +#define POLLRDNORM 64
  2025. +#define POLLRDBAND 128
  2026. +#define POLLWRNORM 256
  2027. +#define POLLWRBAND 512
  2028. +#define POLLMSG        1024
  2029. +
  2030. +struct pollfd {
  2031. +   int fd;
  2032. +   short events;
  2033. +   short revents;
  2034. +};
  2035. +
  2036. +#endif
  2037. diff --git a/include/asm-alpha/unistd.h b/include/asm-alpha/unistd.h
  2038. index 3a33d8b..f8aea1e 100644
  2039. --- a/include/asm-alpha/unistd.h
  2040. +++ b/include/asm-alpha/unistd.h
  2041. @@ -1,54 +1,92 @@
  2042.  #ifndef _ALPHA_UNISTD_H
  2043.  #define _ALPHA_UNISTD_H
  2044.  
  2045. +#define __NR_osf_syscall     0 /* not implemented */
  2046.  #define __NR_exit        1
  2047.  #define __NR_fork        2
  2048.  #define __NR_read        3
  2049.  #define __NR_write       4
  2050. +#define __NR_osf_old_open    5 /* not implemented */
  2051.  #define __NR_close       6
  2052.  #define __NR_wait4       7
  2053. +#define __NR_osf_old_creat   8 /* not implemented */
  2054.  #define __NR_link        9
  2055.  #define __NR_unlink         10
  2056. +#define __NR_osf_execve         11 /* not implemented */
  2057.  #define __NR_chdir      12
  2058.  #define __NR_fchdir         13
  2059.  #define __NR_mknod      14
  2060.  #define __NR_chmod      15
  2061.  #define __NR_chown      16
  2062.  #define __NR_brk        17
  2063. +#define __NR_osf_getfsstat  18 /* not implemented */
  2064.  #define __NR_lseek      19
  2065.  #define __NR_getxpid        20
  2066. +#define __NR_osf_mount      21
  2067. +#define __NR_osf_umount         22
  2068.  #define __NR_setuid         23
  2069.  #define __NR_getxuid        24
  2070. +#define __NR_exec_with_loader   25 /* not implemented */
  2071.  #define __NR_ptrace         26
  2072. +#define __NR_osf_nrecvmsg   27 /* not implemented */
  2073. +#define __NR_osf_nsendmsg   28 /* not implemented */
  2074. +#define __NR_osf_nrecvfrom  29 /* not implemented */
  2075. +#define __NR_osf_naccept    30 /* not implemented */
  2076. +#define __NR_osf_ngetpeername   31 /* not implemented */
  2077. +#define __NR_osf_ngetsockname   32 /* not implemented */
  2078.  #define __NR_access         33
  2079. +#define __NR_osf_chflags    34 /* not implemented */
  2080. +#define __NR_osf_fchflags   35 /* not implemented */
  2081.  #define __NR_sync       36
  2082.  #define __NR_kill       37
  2083. +#define __NR_osf_old_stat   38 /* not implemented */
  2084.  #define __NR_setpgid        39
  2085. +#define __NR_osf_old_lstat  40 /* not implemented */
  2086.  #define __NR_dup        41
  2087.  #define __NR_pipe       42
  2088. +#define __NR_osf_set_program_attributes    43
  2089. +#define __NR_osf_profil         44 /* not implemented */
  2090.  #define __NR_open       45
  2091. +#define __NR_osf_old_sigaction  46 /* not implemented */
  2092.  #define __NR_getxgid        47
  2093. +#define __NR_osf_sigprocmask    48
  2094. +#define __NR_osf_getlogin   49 /* not implemented */
  2095. +#define __NR_osf_setlogin   50 /* not implemented */
  2096.  #define __NR_acct       51
  2097.  #define __NR_sigpending         52
  2098. +
  2099.  #define __NR_ioctl      54
  2100. +#define __NR_osf_reboot         55 /* not implemented */
  2101. +#define __NR_osf_revoke         56 /* not implemented */
  2102.  #define __NR_symlink        57
  2103.  #define __NR_readlink       58
  2104.  #define __NR_execve         59
  2105.  #define __NR_umask      60
  2106.  #define __NR_chroot         61
  2107. +#define __NR_osf_old_fstat  62 /* not implemented */
  2108.  #define __NR_getpgrp        63
  2109.  #define __NR_getpagesize    64
  2110. +#define __NR_osf_mremap         65 /* not implemented */
  2111. +#define __NR_osf_vfork      66
  2112.  #define __NR_stat       67
  2113.  #define __NR_lstat      68
  2114. +#define __NR_osf_sbrk       69 /* not implemented */
  2115. +#define __NR_osf_sstk       70 /* not implemented */
  2116.  #define __NR_mmap       71 /* OSF/1 mmap is superset of Linux */
  2117. +#define __NR_osf_old_vadvise    72 /* not implemented */
  2118.  #define __NR_munmap         73
  2119.  #define __NR_mprotect       74
  2120.  #define __NR_madvise        75
  2121.  #define __NR_vhangup        76
  2122. +#define __NR_osf_kmodcall   77 /* not implemented */
  2123. +#define __NR_osf_mincore    78 /* not implemented */
  2124.  #define __NR_getgroups      79
  2125.  #define __NR_setgroups      80
  2126. +#define __NR_osf_old_getpgrp    81 /* not implemented */
  2127.  #define __NR_setpgrp        82 /* BSD alias for setpgid */
  2128.  #define __NR_setitimer      83
  2129. +#define __NR_osf_old_wait   84 /* not implemented */
  2130. +#define __NR_osf_table      85 /* not implemented */
  2131.  #define __NR_getitimer      86
  2132.  #define __NR_gethostname    87
  2133.  #define __NR_sethostname    88
  2134. @@ -57,6 +95,7 @@
  2135.  #define __NR_fstat      91
  2136.  #define __NR_fcntl      92
  2137.  #define __NR_select         93
  2138. +#define __NR_poll       94
  2139.  #define __NR_fsync      95
  2140.  #define __NR_setpriority    96
  2141.  #define __NR_socket         97
  2142. @@ -69,12 +108,19 @@
  2143.  #define __NR_bind      104
  2144.  #define __NR_setsockopt        105
  2145.  #define __NR_listen        106
  2146. +#define __NR_osf_plock     107 /* not implemented */
  2147. +#define __NR_osf_old_sigvec    108 /* not implemented */
  2148. +#define __NR_osf_old_sigblock  109 /* not implemented */
  2149. +#define __NR_osf_old_sigsetmask    110 /* not implemented */
  2150.  #define __NR_sigsuspend        111
  2151. +#define __NR_osf_sigstack  112 /* not implemented */
  2152.  #define __NR_recvmsg       113
  2153.  #define __NR_sendmsg       114
  2154. +#define __NR_osf_old_vtrace    115 /* not implemented */
  2155.  #define __NR_gettimeofday  116
  2156.  #define __NR_getrusage     117
  2157.  #define __NR_getsockopt        118
  2158. +
  2159.  #define __NR_readv     120
  2160.  #define __NR_writev        121
  2161.  #define __NR_settimeofday  122
  2162. @@ -94,14 +140,44 @@
  2163.  #define __NR_mkdir     136
  2164.  #define __NR_rmdir     137
  2165.  #define __NR_utimes        138
  2166. +#define __NR_osf_old_sigreturn 139 /* not implemented */
  2167. +#define __NR_osf_adjtime   140 /* not implemented */
  2168.  #define __NR_getpeername   141
  2169. +#define __NR_osf_gethostid 142 /* not implemented */
  2170. +#define __NR_osf_sethostid 143 /* not implemented */
  2171.  #define __NR_getrlimit     144
  2172.  #define __NR_setrlimit     145
  2173. +#define __NR_osf_old_killpg    146 /* not implemented */
  2174.  #define __NR_setsid        147
  2175.  #define __NR_quotactl      148
  2176. +#define __NR_osf_oldquota  149 /* not implemented */
  2177.  #define __NR_getsockname   150
  2178. +
  2179. +#define __NR_osf_pid_block 153 /* not implemented */
  2180. +#define __NR_osf_pid_unblock   154 /* not implemented */
  2181. +
  2182.  #define __NR_sigaction     156
  2183. +#define __NR_osf_sigwaitprim   157 /* not implemented */
  2184. +#define __NR_osf_nfssvc        158 /* not implemented */
  2185. +#define __NR_osf_getdirentries 159
  2186. +#define __NR_osf_statfs        160
  2187. +#define __NR_osf_fstatfs   161
  2188. +
  2189. +#define __NR_osf_asynch_daemon 163 /* not implemented */
  2190. +#define __NR_osf_getfh     164 /* not implemented */  
  2191. +#define __NR_osf_getdomainname 165
  2192.  #define __NR_setdomainname 166
  2193. +
  2194. +#define __NR_osf_exportfs  169 /* not implemented */
  2195. +
  2196. +#define __NR_osf_alt_plock 181 /* not implemented */
  2197. +
  2198. +#define __NR_osf_getmnt        184 /* not implemented */
  2199. +
  2200. +#define __NR_osf_alt_sigpending    187 /* not implemented */
  2201. +#define __NR_osf_alt_setsid    188 /* not implemented */
  2202. +
  2203. +#define __NR_osf_swapon        199
  2204.  #define __NR_msgctl        200
  2205.  #define __NR_msgget        201
  2206.  #define __NR_msgrcv        202
  2207. @@ -109,16 +185,54 @@
  2208.  #define __NR_semctl        204
  2209.  #define __NR_semget        205
  2210.  #define __NR_semop     206
  2211. +#define __NR_osf_utsname   207
  2212. +#define __NR_osf_lchown        208 /* not implemented */
  2213. +#define __NR_osf_shmat     209
  2214.  #define __NR_shmctl        210
  2215.  #define __NR_shmdt     211
  2216.  #define __NR_shmget        212
  2217. -
  2218. +#define __NR_osf_mvalid        213 /* not implemented */
  2219. +#define __NR_osf_getaddressconf    214 /* not implemented */
  2220. +#define __NR_osf_msleep        215 /* not implemented */
  2221. +#define __NR_osf_mwakeup   216 /* not implemented */
  2222.  #define __NR_msync     217
  2223. +#define __NR_osf_signal        218 /* not implemented */
  2224. +#define __NR_osf_utc_gettime   219 /* not implemented */
  2225. +#define __NR_osf_utc_adjtime   220 /* not implemented */
  2226. +
  2227. +#define __NR_osf_security  222 /* not implemented */
  2228. +#define __NR_osf_kloadcall 223 /* not implemented */
  2229.  
  2230.  #define __NR_getpgid       233
  2231.  #define __NR_getsid        234
  2232. -
  2233. +#define __NR_osf_sigaltstack   235 /* not implemented */
  2234. +#define __NR_osf_waitid        236 /* not implemented */
  2235. +#define __NR_osf_priocntlset   237 /* not implemented */
  2236. +#define __NR_osf_sigsendset    238 /* not implemented */
  2237. +#define __NR_osf_set_speculative   239 /* not implemented */
  2238. +#define __NR_osf_msfs_syscall  240 /* not implemented */
  2239. +#define __NR_osf_sysinfo   241
  2240. +#define __NR_osf_uadmin        242 /* not implemented */
  2241. +#define __NR_osf_fuser     243 /* not implemented */
  2242. +#define __NR_osf_proplist_syscall    244
  2243. +#define __NR_osf_ntp_adjtime   245 /* not implemented */
  2244. +#define __NR_osf_ntp_gettime   246 /* not implemented */
  2245. +#define __NR_osf_pathconf  247 /* not implemented */
  2246. +#define __NR_osf_fpathconf 248 /* not implemented */
  2247. +
  2248. +#define __NR_osf_uswitch   250 /* not implemented */
  2249. +#define __NR_osf_usleep_thread 251
  2250. +#define __NR_osf_audcntl   252 /* not implemented */
  2251. +#define __NR_osf_audgen        253 /* not implemented */
  2252.  #define __NR_sysfs     254
  2253. +#define __NR_osf_subsys_info   255 /* not implemented */
  2254. +#define __NR_osf_getsysinfo    256
  2255. +#define __NR_osf_setsysinfo    257
  2256. +#define __NR_osf_afs_syscall   258 /* not implemented */
  2257. +#define __NR_osf_swapctl   259 /* not implemented */
  2258. +#define __NR_osf_memcntl   260 /* not implemented */
  2259. +#define __NR_osf_fdatasync 261 /* not implemented */
  2260. +
  2261.  
  2262.  /*
  2263.   * Linux-specific system calls begin at 300
  2264. diff --git a/include/asm-i386/poll.h b/include/asm-i386/poll.h
  2265. new file mode 100644
  2266. index 0000000..e5feda7
  2267. --- /dev/null
  2268. +++ b/include/asm-i386/poll.h
  2269. @@ -0,0 +1,25 @@
  2270. +#ifndef __i386_POLL_H
  2271. +#define __i386_POLL_H
  2272. +
  2273. +/* These are specified by iBCS2 */
  2274. +#define POLLIN     0x0001
  2275. +#define POLLPRI        0x0002
  2276. +#define POLLOUT        0x0004
  2277. +#define POLLERR        0x0008
  2278. +#define POLLHUP        0x0010
  2279. +#define POLLNVAL   0x0020
  2280. +
  2281. +/* The rest seem to be more-or-less nonstandard. Check them! */
  2282. +#define POLLRDNORM 0x0040
  2283. +#define POLLRDBAND 0x0080
  2284. +#define POLLWRNORM 0x0100
  2285. +#define POLLWRBAND 0x0200
  2286. +#define POLLMSG        0x0400
  2287. +
  2288. +struct pollfd {
  2289. +   int fd;
  2290. +   short events;
  2291. +   short revents;
  2292. +};
  2293. +
  2294. +#endif
  2295. diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
  2296. index 4241771..b6cc817 100644
  2297. --- a/include/asm-i386/unistd.h
  2298. +++ b/include/asm-i386/unistd.h
  2299. @@ -173,6 +173,7 @@
  2300.  #define __NR_getresuid     165
  2301.  #define __NR_vm86      166
  2302.  #define __NR_query_module  167
  2303. +#define __NR_poll      168
  2304.  
  2305.  /* user-visible error numbers are in the range -1 - -122: see <asm-i386/errno.h> */
  2306.  
  2307. diff --git a/include/asm-sparc/poll.h b/include/asm-sparc/poll.h
  2308. new file mode 100644
  2309. index 0000000..4a7cbe6
  2310. --- /dev/null
  2311. +++ b/include/asm-sparc/poll.h
  2312. @@ -0,0 +1,21 @@
  2313. +#ifndef __SPARC_POLL_H
  2314. +#define __SPARC_POLL_H
  2315. +
  2316. +#define POLLIN       1
  2317. +#define POLLPRI          2
  2318. +#define POLLOUT          4
  2319. +#define POLLERR          8
  2320. +#define POLLHUP         16
  2321. +#define POLLNVAL    32
  2322. +#define POLLRDNORM  64
  2323. +#define POLLWRNORM POLLOUT
  2324. +#define POLLRDBAND 128
  2325. +#define POLLWRBAND 256
  2326. +
  2327. +struct pollfd {
  2328. +   int fd;
  2329. +   short events;
  2330. +   short revents;
  2331. +};
  2332. +
  2333. +#endif
  2334. diff --git a/include/linux/fs.h b/include/linux/fs.h
  2335. index 201bcac..b887ce1 100644
  2336. --- a/include/linux/fs.h
  2337. +++ b/include/linux/fs.h
  2338. @@ -463,7 +463,7 @@ struct file_operations {
  2339.     long (*read) (struct inode *, struct file *, char *, unsigned long);
  2340.     long (*write) (struct inode *, struct file *, const char *, unsigned long);
  2341.     int (*readdir) (struct inode *, struct file *, void *, filldir_t);
  2342. -   int (*select) (struct inode *, struct file *, int, select_table *);
  2343. +   unsigned int (*poll) (struct file *, poll_table *);
  2344.     int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
  2345.     int (*mmap) (struct inode *, struct file *, struct vm_area_struct *);
  2346.     int (*open) (struct inode *, struct file *);
  2347. diff --git a/include/linux/net.h b/include/linux/net.h
  2348. index df2f584..260dc8a 100644
  2349. --- a/include/linux/net.h
  2350. +++ b/include/linux/net.h
  2351. @@ -93,8 +93,7 @@ struct proto_ops {
  2352.              int flags);
  2353.    int  (*getname)  (struct socket *sock, struct sockaddr *uaddr,
  2354.              int *usockaddr_len, int peer);
  2355. -  int  (*select)   (struct socket *sock, int sel_type,
  2356. -            select_table *wait);
  2357. +  unsigned int (*poll) (struct socket *sock, poll_table *wait);
  2358.    int  (*ioctl)    (struct socket *sock, unsigned int cmd,
  2359.              unsigned long arg);
  2360.    int  (*listen)   (struct socket *sock, int len);
  2361. diff --git a/include/linux/pci.h b/include/linux/pci.h
  2362. index b92191a..37aeb1f 100644
  2363. --- a/include/linux/pci.h
  2364. +++ b/include/linux/pci.h
  2365. @@ -304,6 +304,7 @@
  2366.  #define PCI_VENDOR_ID_CT       0x102c
  2367.  #define PCI_DEVICE_ID_CT_65545     0x00d8
  2368.  #define PCI_DEVICE_ID_CT_65548     0x00dc
  2369. +#define PCI_DEVICE_ID_CT_65550     0x00e0
  2370.  
  2371.  #define PCI_VENDOR_ID_MIRO     0x1031
  2372.  #define PCI_DEVICE_ID_MIRO_36050   0x5601
  2373. diff --git a/include/linux/poll.h b/include/linux/poll.h
  2374. new file mode 100644
  2375. index 0000000..2001fed
  2376. --- /dev/null
  2377. +++ b/include/linux/poll.h
  2378. @@ -0,0 +1 @@
  2379. +#include <asm/poll.h>
  2380. diff --git a/include/linux/sched.h b/include/linux/sched.h
  2381. index 28d3237..4fe6eec 100644
  2382. --- a/include/linux/sched.h
  2383. +++ b/include/linux/sched.h
  2384. @@ -445,13 +445,13 @@ extern inline void remove_wait_queue(struct wait_queue ** p, struct wait_queue *
  2385.     restore_flags(flags);
  2386.  }
  2387.  
  2388. -extern inline void select_wait(struct wait_queue ** wait_address, select_table * p)
  2389. +extern inline void poll_wait(struct wait_queue ** wait_address, poll_table * p)
  2390.  {
  2391. -   struct select_table_entry * entry;
  2392. +   struct poll_table_entry * entry;
  2393.  
  2394.     if (!p || !wait_address)
  2395.         return;
  2396. -   if (p->nr >= __MAX_SELECT_TABLE_ENTRIES)
  2397. +   if (p->nr >= __MAX_POLL_TABLE_ENTRIES)
  2398.         return;
  2399.     entry = p->entry + p->nr;
  2400.     entry->wait_address = wait_address;
  2401. diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
  2402. index 0998a97..cd9a1fe 100644
  2403. --- a/include/linux/skbuff.h
  2404. +++ b/include/linux/skbuff.h
  2405. @@ -545,7 +545,7 @@ extern __inline__ void skb_orphan(struct sk_buff *skb)
  2406.  
  2407.  extern struct sk_buff *        skb_realloc_headroom(struct sk_buff *skb, int newheadroom);
  2408.  extern struct sk_buff *        skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
  2409. -extern int         datagram_select(struct socket *sock, int sel_type, select_table *wait);
  2410. +extern unsigned int        datagram_poll(struct socket *sock, poll_table *wait);
  2411.  extern int         skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
  2412.  extern int         skb_copy_datagram_iovec(struct sk_buff *from, int offset, struct iovec *to,int size);
  2413.  extern void            skb_free_datagram(struct sock * sk, struct sk_buff *skb);
  2414. diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
  2415. index 05a3326..8d69c54 100644
  2416. --- a/include/linux/tty_ldisc.h
  2417. +++ b/include/linux/tty_ldisc.h
  2418. @@ -119,9 +119,7 @@ struct tty_ldisc {
  2419.     int (*ioctl)(struct tty_struct * tty, struct file * file,
  2420.              unsigned int cmd, unsigned long arg);
  2421.     void    (*set_termios)(struct tty_struct *tty, struct termios * old);
  2422. -   int (*select)(struct tty_struct * tty, struct inode * inode,
  2423. -             struct file * file, int sel_type,
  2424. -             struct select_table_struct *wait);
  2425. +   unsigned int (*poll)(struct tty_struct *, struct file *, poll_table *);
  2426.    
  2427.     /*
  2428.      * The following routines are called from below.
  2429. diff --git a/include/linux/wait.h b/include/linux/wait.h
  2430. index be24fa2..0a0d11f 100644
  2431. --- a/include/linux/wait.h
  2432. +++ b/include/linux/wait.h
  2433. @@ -28,17 +28,17 @@ static inline int waitqueue_active(struct wait_queue **q)
  2434.     return head && head != WAIT_QUEUE_HEAD(q);
  2435.  }
  2436.  
  2437. -struct select_table_entry {
  2438. +struct poll_table_entry {
  2439.     struct wait_queue wait;
  2440.     struct wait_queue ** wait_address;
  2441.  };
  2442.  
  2443. -typedef struct select_table_struct {
  2444. +typedef struct poll_table_struct {
  2445.     unsigned int nr;
  2446. -   struct select_table_entry * entry;
  2447. -} select_table;
  2448. +   struct poll_table_entry * entry;
  2449. +} poll_table;
  2450.  
  2451. -#define __MAX_SELECT_TABLE_ENTRIES (PAGE_SIZE / sizeof (struct select_table_entry))
  2452. +#define __MAX_POLL_TABLE_ENTRIES (PAGE_SIZE / sizeof (struct poll_table_entry))
  2453.  
  2454.  #endif /* __KERNEL__ */
  2455.  
  2456. diff --git a/include/net/inet_common.h b/include/net/inet_common.h
  2457. index bf9adea..7cdef71 100644
  2458. --- a/include/net/inet_common.h
  2459. +++ b/include/net/inet_common.h
  2460. @@ -31,8 +31,7 @@ extern int            inet_sendmsg(struct socket *sock,
  2461.                          struct msghdr *msg,
  2462.                          int size, struct scm_cookie *scm);
  2463.  extern int         inet_shutdown(struct socket *sock, int how);
  2464. -extern int         inet_select(struct socket *sock, int sel_type,
  2465. -                       select_table *wait);
  2466. +extern unsigned int        inet_poll(struct socket *sock, poll_table *wait);
  2467.  extern int         inet_setsockopt(struct socket *sock, int level,
  2468.                         int optname, char *optval,
  2469.                         int optlen);
  2470. diff --git a/include/net/sock.h b/include/net/sock.h
  2471. index 15104ef..0ab3bea 100644
  2472. --- a/include/net/sock.h
  2473. +++ b/include/net/sock.h
  2474. @@ -531,8 +531,7 @@ struct proto
  2475.     void            (*write_wakeup)(struct sock *sk);
  2476.     void            (*read_wakeup)(struct sock *sk);
  2477.  
  2478. -   int         (*select)(struct socket *sock, int which,
  2479. -                     select_table *wait);
  2480. +   unsigned int        (*poll)(struct socket *sock, poll_table *wait);
  2481.  
  2482.     int         (*ioctl)(struct sock *sk, int cmd,
  2483.                      unsigned long arg);
  2484. diff --git a/include/net/tcp.h b/include/net/tcp.h
  2485. index ab8d0c3..3bb395e 100644
  2486. --- a/include/net/tcp.h
  2487. +++ b/include/net/tcp.h
  2488. @@ -265,8 +265,7 @@ extern int          tcp_rcv_established(struct sock *sk,
  2489.  extern void            tcp_close(struct sock *sk,
  2490.                       unsigned long timeout);
  2491.  extern struct sock *       tcp_accept(struct sock *sk, int flags);
  2492. -extern int         tcp_select(struct socket *sock, int sel_type,
  2493. -                      select_table *wait);
  2494. +extern unsigned int        tcp_poll(struct socket *sock, poll_table *wait);
  2495.  extern int         tcp_getsockopt(struct sock *sk, int level,
  2496.                            int optname, char *optval,
  2497.                            int *optlen);
  2498. diff --git a/kernel/sysctl.c b/kernel/sysctl.c
  2499. index 51c0944..ce4f82d 100644
  2500. --- a/kernel/sysctl.c
  2501. +++ b/kernel/sysctl.c
  2502. @@ -59,7 +59,7 @@ struct file_operations proc_sys_file_operations =
  2503.     proc_readsys,   /* read    */
  2504.     proc_writesys,  /* write   */
  2505.     NULL,       /* readdir */
  2506. -   NULL,       /* select  */
  2507. +   NULL,       /* poll    */
  2508.     NULL,       /* ioctl   */
  2509.     NULL,       /* mmap    */
  2510.     NULL,       /* no special open code    */
  2511. diff --git a/net/core/datagram.c b/net/core/datagram.c
  2512. index 35af151..64308bb 100644
  2513. --- a/net/core/datagram.c
  2514. +++ b/net/core/datagram.c
  2515. @@ -3,17 +3,17 @@
  2516.   *
  2517.   * Generic datagram handling routines. These are generic for all protocols. Possibly a generic IP version on top
  2518.   * of these would make sense. Not tonight however 8-).
  2519. - * This is used because UDP, RAW, PACKET, DDP, IPX, AX.25 and NetROM layer all have identical select code and mostly
  2520. - * identical recvmsg() code. So we share it here. The select was shared before but buried in udp.c so I moved it.
  2521. + * This is used because UDP, RAW, PACKET, DDP, IPX, AX.25 and NetROM layer all have identical poll code and mostly
  2522. + * identical recvmsg() code. So we share it here. The poll was shared before but buried in udp.c so I moved it.
  2523.   *
  2524. - * Authors:    Alan Cox <alan@cymru.net>. (datagram_select() from old udp.c code)
  2525. + * Authors:    Alan Cox <alan@cymru.net>. (datagram_poll() from old udp.c code)
  2526.   *
  2527.   * Fixes:
  2528.   *     Alan Cox    :   NULL return from skb_peek_copy() understood
  2529.   *     Alan Cox    :   Rewrote skb_read_datagram to avoid the skb_peek_copy stuff.
  2530.   *     Alan Cox    :   Added support for SOCK_SEQPACKET. IPX can no longer use the SO_TYPE hack but
  2531.   *                 AX.25 now works right, and SPX is feasible.
  2532. - *     Alan Cox    :   Fixed write select of non IP protocol crash.
  2533. + *     Alan Cox    :   Fixed write poll of non IP protocol crash.
  2534.   *     Florian  La Roche:  Changed for my new skbuff handling.
  2535.   *     Darryl Miles    :   Fixed non-blocking SOCK_SEQPACKET.
  2536.   *     Linus Torvalds  :   BSD semantic fixes.
  2537. @@ -34,6 +34,8 @@
  2538.  #include <linux/sched.h>
  2539.  #include <linux/inet.h>
  2540.  #include <linux/netdevice.h>
  2541. +#include <linux/poll.h>
  2542. +
  2543.  #include <net/ip.h>
  2544.  #include <net/protocol.h>
  2545.  #include <net/route.h>
  2546. @@ -188,57 +190,48 @@ int skb_copy_datagram_iovec(struct sk_buff *skb, int offset, struct iovec *to,
  2547.  }
  2548.  
  2549.  /*
  2550. - * Datagram select: Again totally generic. This also handles
  2551. + * Datagram poll: Again totally generic. This also handles
  2552.   * sequenced packet sockets providing the socket receive queue
  2553.   * is only ever holding data ready to receive.
  2554.   */
  2555.  
  2556. -int datagram_select(struct socket *sock, int sel_type, select_table *wait)
  2557. +unsigned int datagram_poll(struct socket *sock, poll_table *wait)
  2558.  {
  2559.     struct sock *sk = sock->sk;
  2560. +   unsigned int mask;
  2561. +
  2562. +   poll_wait(sk->sleep, wait);
  2563. +   mask = 0;
  2564.  
  2565. +   /* exceptional events? */
  2566.     if (sk->err)
  2567. -       return 1;
  2568. -   switch(sel_type)
  2569. -   {
  2570. -       case SEL_IN:
  2571. -           if (sk->shutdown & RCV_SHUTDOWN)
  2572. -               return 1;
  2573. -           if (connection_based(sk) && sk->state==TCP_CLOSE)
  2574. -           {
  2575. -               /* Connection closed: Wake up */
  2576. -               return 1;
  2577. -           }
  2578. -           if (!skb_queue_empty(&sk->receive_queue))
  2579. -           {   /* This appears to be consistent
  2580. -                  with other stacks */
  2581. -               return 1;
  2582. -           }
  2583. -           break;
  2584. -
  2585. -       case SEL_OUT:
  2586. -           if (sk->shutdown & SEND_SHUTDOWN)
  2587. -               return 1;
  2588. -           if (connection_based(sk) && sk->state==TCP_SYN_SENT)
  2589. -           {
  2590. -               /* Connection still in progress */
  2591. -               break;
  2592. -           }
  2593. -           if (sk->prot && sock_wspace(sk) >= MIN_WRITE_SPACE)
  2594. -           {
  2595. -               return 1;
  2596. -           }
  2597. -           if (sk->prot==NULL && sk->sndbuf-sk->wmem_alloc >= MIN_WRITE_SPACE)
  2598. -           {
  2599. -               return 1;
  2600. -           }
  2601. -           break;
  2602. -
  2603. -       case SEL_EX:
  2604. -           break;
  2605. +       mask |= POLLERR;
  2606. +   if (sk->shutdown & RCV_SHUTDOWN)
  2607. +       mask |= POLLHUP;
  2608. +
  2609. +   /* readable? */
  2610. +   if (!skb_queue_empty(&sk->receive_queue))
  2611. +       mask |= POLLIN | POLLRDNORM;
  2612. +
  2613. +   /* Connection-based need to check for termination and startup */
  2614. +   if (connection_based(sk)) {
  2615. +       if (sk->state==TCP_CLOSE)
  2616. +           mask |= POLLHUP;
  2617. +       /* connection hasn't started yet? */
  2618. +       if (sk->state == TCP_SYN_SENT)
  2619. +           return mask;
  2620. +   }
  2621. +
  2622. +   /* writable? */
  2623. +   if (!(sk->shutdown & SEND_SHUTDOWN)) {
  2624. +       if (sk->prot) {
  2625. +           if (sock_wspace(sk) >= MIN_WRITE_SPACE)
  2626. +               mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
  2627. +       } else {
  2628. +           if (sk->sndbuf-sk->wmem_alloc >= MIN_WRITE_SPACE)
  2629. +               mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
  2630. +       }
  2631.     }
  2632.  
  2633. -   /* select failed.. */
  2634. -   select_wait(sk->sleep, wait);
  2635. -   return 0;
  2636. +   return mask;
  2637.  }
  2638. diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
  2639. index ff390e6..1c67348 100644
  2640. --- a/net/ipv4/af_inet.c
  2641. +++ b/net/ipv4/af_inet.c
  2642. @@ -1188,13 +1188,13 @@ int inet_shutdown(struct socket *sock, int how)
  2643.  }
  2644.  
  2645.  
  2646. -int inet_select(struct socket *sock, int sel_type, select_table *wait)
  2647. +unsigned int inet_poll(struct socket *sock, poll_table *wait)
  2648.  {
  2649.     struct sock *sk = sock->sk;
  2650.  
  2651. -   if (sk->prot->select == NULL)
  2652. +   if (sk->prot->poll == NULL)
  2653.         return(0);
  2654. -   return sk->prot->select(sock, sel_type, wait);
  2655. +   return sk->prot->poll(sock, wait);
  2656.  }
  2657.  
  2658.  /*
  2659. @@ -1589,7 +1589,7 @@ struct proto_ops inet_stream_ops = {
  2660.     NULL,
  2661.     inet_accept,
  2662.     inet_getname,
  2663. -   inet_select,
  2664. +   inet_poll,
  2665.     inet_ioctl,
  2666.     inet_listen,
  2667.     inet_shutdown,
  2668. @@ -1610,7 +1610,7 @@ struct proto_ops inet_dgram_ops = {
  2669.     NULL,
  2670.     NULL,
  2671.     inet_getname,
  2672. -   datagram_select,
  2673. +   datagram_poll,
  2674.     inet_ioctl,
  2675.     NULL,
  2676.     inet_shutdown,
  2677. diff --git a/net/ipv4/ip_fw.c b/net/ipv4/ip_fw.c
  2678. index d643ef9..1d4df36 100644
  2679. --- a/net/ipv4/ip_fw.c
  2680. +++ b/net/ipv4/ip_fw.c
  2681. @@ -209,9 +209,9 @@ extern inline int port_match(unsigned short *portptr,int nports,unsigned short p
  2682.  int ip_fw_chk(struct iphdr *ip, struct device *rif, __u16 *redirport, struct ip_fw *chain, int policy, int mode)
  2683.  {
  2684.     struct ip_fw *f;
  2685. -   struct tcphdr       *tcp=(struct tcphdr *)((unsigned long *)ip+ip->ihl);
  2686. -   struct udphdr       *udp=(struct udphdr *)((unsigned long *)ip+ip->ihl);
  2687. -   struct icmphdr      *icmp=(struct icmphdr *)((unsigned long *)ip+ip->ihl);
  2688. +   struct tcphdr       *tcp=(struct tcphdr *)((__u32 *)ip+ip->ihl);
  2689. +   struct udphdr       *udp=(struct udphdr *)((__u32 *)ip+ip->ihl);
  2690. +   struct icmphdr      *icmp=(struct icmphdr *)((__u32 *)ip+ip->ihl);
  2691.     __u32           src, dst;
  2692.     __u16           src_port=0xFFFF, dst_port=0xFFFF, icmp_type=0xFF;
  2693.     unsigned short      f_prt=0, prt;
  2694. diff --git a/net/ipv4/packet.c b/net/ipv4/packet.c
  2695. index 8187b20..365a294 100644
  2696. --- a/net/ipv4/packet.c
  2697. +++ b/net/ipv4/packet.c
  2698. @@ -497,7 +497,7 @@ struct proto packet_prot =
  2699.     NULL,
  2700.     NULL,
  2701.     NULL,
  2702. -   datagram_select,
  2703. +   datagram_poll,
  2704.     NULL,           /* No ioctl */
  2705.     packet_init,
  2706.     NULL,
  2707. diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
  2708. index 69a2bd4..279778f 100644
  2709. --- a/net/ipv4/raw.c
  2710. +++ b/net/ipv4/raw.c
  2711. @@ -412,7 +412,7 @@ struct proto raw_prot = {
  2712.     NULL,
  2713.     NULL,
  2714.     NULL,
  2715. -   datagram_select,
  2716. +   datagram_poll,
  2717.  #ifdef CONFIG_IP_MROUTE   
  2718.     ipmr_ioctl,
  2719.  #else
  2720. diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
  2721. index bfb3259..4e16792 100644
  2722. --- a/net/ipv4/tcp.c
  2723. +++ b/net/ipv4/tcp.c
  2724. @@ -30,7 +30,7 @@
  2725.   *                 socket was looked up backwards. Nobody
  2726.   *                 tested any icmp error code obviously.
  2727.   *     Alan Cox    :   tcp_err() now handled properly. It
  2728. - *                 wakes people on errors. select
  2729. + *                 wakes people on errors. poll
  2730.   *                 behaves and the icmp error race
  2731.   *                 has gone by moving it into sock.c
  2732.   *     Alan Cox    :   tcp_send_reset() fixed to work for
  2733. @@ -102,12 +102,12 @@
  2734.   *     Alan Cox    :   BSD accept semantics.
  2735.   *     Alan Cox    :   Reset on closedown bug.
  2736.   * Peter De Schrijver  :   ENOTCONN check missing in tcp_sendto().
  2737. - *     Michael Pall    :   Handle select() after URG properly in
  2738. + *     Michael Pall    :   Handle poll() after URG properly in
  2739.   *                 all cases.
  2740.   *     Michael Pall    :   Undo the last fix in tcp_read_urg()
  2741.   *                 (multi URG PUSH broke rlogin).
  2742.   *     Michael Pall    :   Fix the multi URG PUSH problem in
  2743. - *                 tcp_readable(), select() after URG
  2744. + *                 tcp_readable(), poll() after URG
  2745.   *                 works now.
  2746.   *     Michael Pall    :   recv(...,MSG_OOB) never blocks in the
  2747.   *                 BSD api.
  2748. @@ -128,7 +128,7 @@
  2749.   *     Alan Cox    :   Reset tracing code.
  2750.   *     Alan Cox    :   Spurious resets on shutdown.
  2751.   *     Alan Cox    :   Giant 15 minute/60 second timer error
  2752. - *     Alan Cox    :   Small whoops in selecting before an
  2753. + *     Alan Cox    :   Small whoops in polling before an
  2754.   *                 accept.
  2755.   *     Alan Cox    :   Kept the state trace facility since
  2756.   *                 it's handy for debugging.
  2757. @@ -162,7 +162,7 @@
  2758.   *                 generates them.
  2759.   *     Alan Cox    :   Cache last socket.
  2760.   *     Alan Cox    :   Per route irtt.
  2761. - *     Matt Day    :   Select() match BSD precisely on error
  2762. + *     Matt Day    :   poll()->select() match BSD precisely on error
  2763.   *     Alan Cox    :   New buffers
  2764.   *     Marc Tamsky :   Various sk->prot->retransmits and
  2765.   *                 sk->retransmits misupdating fixed.
  2766. @@ -419,6 +419,7 @@
  2767.  
  2768.  #include <linux/types.h>
  2769.  #include <linux/fcntl.h>
  2770. +#include <linux/poll.h>
  2771.  
  2772.  #include <net/icmp.h>
  2773.  #include <net/tcp.h>
  2774. @@ -573,9 +574,9 @@ static int tcp_readable(struct sock *sk)
  2775.          * though there was normal data available. If we subtract
  2776.          * the urg data right here, we even get it to work for more
  2777.          * than one URG PUSH skb without normal data.
  2778. -        * This means that select() finally works now with urg data
  2779. +        * This means that poll() finally works now with urg data
  2780.          * in the queue.  Note that rlogin was never affected
  2781. -        * because it doesn't use select(); it uses two processes
  2782. +        * because it doesn't use poll(); it uses two processes
  2783.          * and a blocking read().  And the queue scan in tcp_read()
  2784.          * was correct.  Mike <pall@rz.uni-karlsruhe.de>
  2785.          */
  2786. @@ -597,81 +598,60 @@ static int tcp_readable(struct sock *sk)
  2787.  }
  2788.  
  2789.  /*
  2790. - * LISTEN is a special case for select..
  2791. + * LISTEN is a special case for poll..
  2792.   */
  2793. -static int tcp_listen_select(struct sock *sk, int sel_type, select_table *wait)
  2794. +static unsigned int tcp_listen_poll(struct sock *sk, poll_table *wait)
  2795.  {
  2796. -   if (sel_type == SEL_IN) {
  2797. -       struct open_request *req;
  2798. +   struct open_request *req;
  2799.  
  2800. -       lock_sock(sk);
  2801. -       req = tcp_find_established(&sk->tp_pinfo.af_tcp);
  2802. -       release_sock(sk);
  2803. -       if (req)
  2804. -           return 1;
  2805. -       select_wait(sk->sleep,wait);
  2806. -       return 0;
  2807. -   }
  2808. +   lock_sock(sk);
  2809. +   req = tcp_find_established(&sk->tp_pinfo.af_tcp);
  2810. +   release_sock(sk);
  2811. +   if (req)
  2812. +       return POLLIN | POLLRDNORM;
  2813.     return 0;
  2814.  }
  2815.  
  2816.  /*
  2817.   * Wait for a TCP event.
  2818.   *
  2819. - * Note that we don't need to lock the socket, as the upper select layers
  2820. + * Note that we don't need to lock the socket, as the upper poll layers
  2821.   * take care of normal races (between the test and the event) and we don't
  2822.   * go look at any of the socket buffers directly.
  2823.   */
  2824. -int tcp_select(struct socket *sock, int sel_type, select_table *wait)
  2825. +unsigned int tcp_poll(struct socket *sock, poll_table *wait)
  2826.  {
  2827. +   unsigned int mask;
  2828.     struct sock *sk = sock->sk;
  2829.     struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
  2830.  
  2831. +   poll_wait(sk->sleep, wait);
  2832.     if (sk->state == TCP_LISTEN)
  2833. -       return tcp_listen_select(sk, sel_type, wait);
  2834. +       return tcp_listen_poll(sk, wait);
  2835.  
  2836. -   switch(sel_type) {
  2837. -   case SEL_IN:
  2838. -       if (sk->err)
  2839. -           return 1;
  2840. -       if (sk->state == TCP_SYN_SENT || sk->state == TCP_SYN_RECV)
  2841. -           break;
  2842. +   mask = 0;
  2843. +   if (sk->err)
  2844. +       mask = POLLERR;
  2845. +   /* connected ? */
  2846. +   if (sk->state != TCP_SYN_SENT && sk->state != TCP_SYN_RECV) {
  2847.  
  2848.         if (sk->shutdown & RCV_SHUTDOWN)
  2849. -           return 1;
  2850. +           mask |= POLLHUP;
  2851.            
  2852. -       if (tp->rcv_nxt == sk->copied_seq)
  2853. -           break;
  2854. -
  2855. -       if (sk->urg_seq != sk->copied_seq ||
  2856. -           tp->rcv_nxt != sk->copied_seq+1 ||
  2857. -           sk->urginline || !sk->urg_data)
  2858. -           return 1;
  2859. -       break;
  2860. -
  2861. -   case SEL_OUT:
  2862. -       if (sk->err)
  2863. -           return 1;
  2864. -       if (sk->shutdown & SEND_SHUTDOWN)
  2865. -           return 0;
  2866. -       if (sk->state == TCP_SYN_SENT || sk->state == TCP_SYN_RECV)
  2867. -           break;
  2868. -       /*
  2869. -        * This is now right thanks to a small fix
  2870. -        * by Matt Dillon.
  2871. -        */
  2872. +       if ((tp->rcv_nxt != sk->copied_seq) &&
  2873. +           (sk->urg_seq != sk->copied_seq ||
  2874. +            tp->rcv_nxt != sk->copied_seq+1 ||
  2875. +            sk->urginline || !sk->urg_data))
  2876. +           mask |= POLLIN | POLLRDNORM;
  2877.  
  2878. -       if (sock_wspace(sk) < sk->mtu+128+sk->prot->max_header)
  2879. -           break;
  2880. -       return 1;
  2881. +       if (!(sk->shutdown & SEND_SHUTDOWN) &&
  2882. +            (sock_wspace(sk) >= sk->mtu+128+sk->prot->max_header))
  2883. +           mask |= POLLOUT | POLLWRNORM;
  2884.  
  2885. -   case SEL_EX:
  2886.         if (sk->urg_data)
  2887. -           return 1;
  2888. -       break;
  2889. +           mask |= POLLPRI;
  2890.     }
  2891. -   select_wait(sk->sleep, wait);
  2892. -   return 0;
  2893. +   return mask;
  2894.  }
  2895.  
  2896.  int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
  2897. diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
  2898. index 9e5a87e..d63f3d5 100644
  2899. --- a/net/ipv4/tcp_ipv4.c
  2900. +++ b/net/ipv4/tcp_ipv4.c
  2901. @@ -1212,7 +1212,7 @@ struct proto tcp_prot = {
  2902.     NULL,
  2903.     tcp_write_wakeup,
  2904.     tcp_read_wakeup,
  2905. -   tcp_select,
  2906. +   tcp_poll,
  2907.     tcp_ioctl,
  2908.     tcp_v4_init_sock,
  2909.     tcp_v4_destroy_sock,
  2910. diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
  2911. index 705c9df..cc124d3 100644
  2912. --- a/net/ipv4/udp.c
  2913. +++ b/net/ipv4/udp.c
  2914. @@ -851,7 +851,7 @@ struct proto udp_prot = {
  2915.     NULL,
  2916.     NULL,
  2917.     NULL,
  2918. -   datagram_select,
  2919. +   datagram_poll,
  2920.     udp_ioctl,
  2921.     NULL,
  2922.     NULL,
  2923. diff --git a/net/netlink.c b/net/netlink.c
  2924. index 32421a4..daf35f3b 100644
  2925. --- a/net/netlink.c
  2926. +++ b/net/netlink.c
  2927. @@ -26,6 +26,7 @@
  2928.  
  2929.  #include <net/netlink.h>
  2930.  
  2931. +#include <asm/poll.h>
  2932.  #include <asm/io.h>
  2933.  #include <asm/uaccess.h>
  2934.  #include <asm/system.h>
  2935. @@ -63,19 +64,16 @@ int netlink_donothing(int minor, struct sk_buff *skb)
  2936.     return -EINVAL;
  2937.  }
  2938.  
  2939. -static int netlink_select(struct inode *inode, struct file *file, int sel_type, select_table * wait)
  2940. +static unsigned int netlink_poll(struct file *file, poll_table * wait)
  2941.  {
  2942. -   unsigned int minor = MINOR(inode->i_rdev);
  2943. -   switch (sel_type) {
  2944. -   case SEL_IN:
  2945. -       if (skb_peek(&skb_queue_rd[minor])!=NULL)
  2946. -           return 1;
  2947. -       select_wait(&read_space_wait[minor], wait);
  2948. -       break;
  2949. -   case SEL_OUT:
  2950. -       return 1;
  2951. -   }
  2952. -   return 0;
  2953. +   unsigned int mask;
  2954. +   unsigned int minor = MINOR(file->f_inode->i_rdev);
  2955. +
  2956. +   poll_wait(&read_space_wait[minor], wait);
  2957. +   mask = POLLOUT | POLLWRNORM;
  2958. +   if (skb_peek(&skb_queue_rd[minor]))
  2959. +       mask |= POLLIN | POLLRDNORM;
  2960. +   return mask;
  2961.  }
  2962.  
  2963.  /*
  2964. @@ -183,7 +181,7 @@ static struct file_operations netlink_fops = {
  2965.     netlink_read,
  2966.     netlink_write,
  2967.     NULL,       /* netlink_readdir */
  2968. -   netlink_select,
  2969. +   netlink_poll,
  2970.     netlink_ioctl,
  2971.     NULL,       /* netlink_mmap */
  2972.     netlink_open,
  2973. diff --git a/net/netsyms.c b/net/netsyms.c
  2974. index 09bd3a9..822ff0e 100644
  2975. --- a/net/netsyms.c
  2976. +++ b/net/netsyms.c
  2977. @@ -99,7 +99,7 @@ EXPORT_SYMBOL(skb_free_datagram);
  2978.  EXPORT_SYMBOL(skb_copy_datagram);
  2979.  EXPORT_SYMBOL(skb_copy_datagram_iovec);
  2980.  EXPORT_SYMBOL(skb_realloc_headroom);
  2981. -EXPORT_SYMBOL(datagram_select);
  2982. +EXPORT_SYMBOL(datagram_poll);
  2983.  
  2984.  /* Needed by smbfs.o */
  2985.  EXPORT_SYMBOL(__scm_destroy);
  2986. @@ -144,7 +144,7 @@ EXPORT_SYMBOL(inet_release);
  2987.  EXPORT_SYMBOL(inet_stream_connect);
  2988.  EXPORT_SYMBOL(inet_dgram_connect);
  2989.  EXPORT_SYMBOL(inet_accept);
  2990. -EXPORT_SYMBOL(inet_select);
  2991. +EXPORT_SYMBOL(inet_poll);
  2992.  EXPORT_SYMBOL(inet_listen);
  2993.  EXPORT_SYMBOL(inet_shutdown);
  2994.  EXPORT_SYMBOL(inet_setsockopt);
  2995. @@ -174,7 +174,7 @@ EXPORT_SYMBOL(tcp_close);
  2996.  EXPORT_SYMBOL(tcp_accept);
  2997.  EXPORT_SYMBOL(tcp_write_wakeup);
  2998.  EXPORT_SYMBOL(tcp_read_wakeup);
  2999. -EXPORT_SYMBOL(tcp_select);
  3000. +EXPORT_SYMBOL(tcp_poll);
  3001.  EXPORT_SYMBOL(tcp_ioctl);
  3002.  EXPORT_SYMBOL(tcp_shutdown);
  3003.  EXPORT_SYMBOL(tcp_setsockopt);
  3004. diff --git a/net/socket.c b/net/socket.c
  3005. index bb2ca90..42b202b 100644
  3006. --- a/net/socket.c
  3007. +++ b/net/socket.c
  3008. @@ -101,7 +101,7 @@ static long sock_write(struct inode *inode, struct file *file,
  3009.                const char *buf, unsigned long size);
  3010.  
  3011.  static void sock_close(struct inode *inode, struct file *file);
  3012. -static int sock_select(struct inode *inode, struct file *file, int which, select_table *seltable);
  3013. +static unsigned int sock_poll(struct file *file, poll_table *wait);
  3014.  static int sock_ioctl(struct inode *inode, struct file *file,
  3015.               unsigned int cmd, unsigned long arg);
  3016.  static int sock_fasync(struct inode *inode, struct file *filp, int on);
  3017. @@ -117,7 +117,7 @@ static struct file_operations socket_file_ops = {
  3018.     sock_read,
  3019.     sock_write,
  3020.     NULL,           /* readdir */
  3021. -   sock_select,
  3022. +   sock_poll,
  3023.     sock_ioctl,
  3024.     NULL,           /* mmap */
  3025.     NULL,           /* no special open code... */
  3026. @@ -444,19 +444,19 @@ int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
  3027.  }
  3028.  
  3029.  
  3030. -static int sock_select(struct inode *inode, struct file *file, int sel_type, select_table * wait)
  3031. +static unsigned int sock_poll(struct file *file, poll_table * wait)
  3032.  {
  3033.     struct socket *sock;
  3034.  
  3035. -   sock = socki_lookup(inode);
  3036. +   sock = socki_lookup(file->f_inode);
  3037.  
  3038.     /*
  3039. -    *  We can't return errors to select, so it's either yes or no.
  3040. +    *  We can't return errors to poll, so it's either yes or no.
  3041.      */
  3042.  
  3043. -   if (sock->ops->select)
  3044. -       return sock->ops->select(sock, sel_type, wait);
  3045. -   return(0);
  3046. +   if (sock->ops->poll)
  3047. +       return sock->ops->poll(sock, wait);
  3048. +   return 0;
  3049.  }
  3050.  
  3051.  
  3052. @@ -1249,7 +1249,7 @@ int sock_fcntl(struct file *filp, unsigned int cmd, unsigned long arg)
  3053.  /*
  3054.   * System call vectors. Since I (RIB) want to rewrite sockets as streams,
  3055.   * we have this level of indirection. Not a lot of overhead, since more of
  3056. - * the work is done via read/write/select directly.
  3057. + * the work is done via read/write/poll directly.
  3058.   *
  3059.   * I'm now expanding this up to a higher level to separate the assorted
  3060.   * kernel/user space manipulations and global assumptions from the protocol
  3061. diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
  3062. index 9490c29..c3bd7ff 100644
  3063. --- a/net/unix/af_unix.c
  3064. +++ b/net/unix/af_unix.c
  3065. @@ -1429,7 +1429,7 @@ struct proto_ops unix_stream_ops = {
  3066.     unix_socketpair,
  3067.     unix_accept,
  3068.     unix_getname,
  3069. -   datagram_select,
  3070. +   datagram_poll,
  3071.     unix_ioctl,
  3072.     unix_listen,
  3073.     unix_shutdown,
  3074. @@ -1450,7 +1450,7 @@ struct proto_ops unix_dgram_ops = {
  3075.     unix_socketpair,
  3076.     NULL,
  3077.     unix_getname,
  3078. -   datagram_select,
  3079. +   datagram_poll,
  3080.     unix_ioctl,
  3081.     NULL,
  3082.     unix_shutdown,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement