1. 25 7月, 2008 40 次提交
    • I
      autofs4: fix symlink name allocation · ef581a74
      Ian Kent 提交于
      The length of the symlink name has been moved but it needs to be set
      before allocating space for it in the dentry info struct.  This corrects a
      mistake in a recent patch.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ef581a74
    • I
      autofs4: use look aside list for lookups · 25767378
      Ian Kent 提交于
      A while ago a patch to resolve a deadlock during directory creation was
      merged.  This delayed the hashing of lookup dentrys until the ->mkdir()
      (or ->symlink()) operation completed to ensure we always went through
      ->lookup() instead of also having processes go through ->revalidate() so
      our VFS locking remained consistent.
      
      Now we are seeing a couple of side affects of that change in situations
      with heavy mount activity.
      
      Two cases have been identified:
      
      1) When a mount request is triggered, due to the delayed hashing, the
         directory created by user space for the mount point doesn't have the
         DCACHE_AUTOFS_PENDING flag set.  In the case of an autofs multi-mount
         where a tree of mount point directories are created this can lead to
         the path walk continuing rather than the dentry being sent to the wait
         queue to wait for request completion.  This is because, if the pending
         flag isn't set, the criteria for deciding this is a mount in progress
         fails to hold, namely that the dentry is not a mount point and has no
         subdirectories.
      
      2) A mount request dentry is initially created negative and unhashed.
         It remains this way until the ->mkdir() callback completes.  Since it
         is unhashed a fresh dentry is used when the user space mount request
         creates the mount point directory.  This leaves the original dentry
         negative and unhashed.  But revalidate has no way to tell the VFS that
         the dentry has changed, other than to force another ->lookup() by
         returning false, which is at best wastefull and at worst not possible.
         This results in an -ENOENT return from the original path walk when in
         fact the mount succeeded.
      
      To resolve this we need to ensure that the same dentry is used in all
      calls to ->lookup() during the course of a mount request.  This patch
      achieves that by adding the initial dentry to a look aside list and
      removes it at ->mkdir() or ->symlink() completion (or when the dentry is
      released), since these are the only create operations autofs4 supports.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      25767378
    • I
      autofs4: revert - redo lookup in ttfd · caf7da3d
      Ian Kent 提交于
      This patch series enables the use of a single dentry for lookups prior to
      the dentry being hashed and so we no longer need to redo the lookup.  This
      patch reverts the patch of commit
      03379044.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      caf7da3d
    • I
      autofs4: don't make expiring dentry negative · 5f6f4f28
      Ian Kent 提交于
      Correct the error of making a positive dentry negative after it has been
      instantiated.
      
      The code that makes this error attempts to re-use the dentry from a
      concurrent expire and mount to resolve a race and the dentry used for the
      lookup must be negative for mounts to trigger in the required cases.  The
      fact is that the dentry doesn't need to be re-used because all that is
      needed is to preserve the flag that indicates an expire is still
      incomplete at the time of the mount request.
      
      This change uses the the dentry to check the flag and wait for the expire
      to complete then discards it instead of attempting to re-use it.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5f6f4f28
    • M
      eCryptfs: Make all persistent file opens delayed · 391b52f9
      Michael Halcrow 提交于
      There is no good reason to immediately open the lower file, and that can
      cause problems with files that the user does not intend to immediately
      open, such as device nodes.
      
      This patch removes the persistent file open from the interpose step and
      pushes that to the locations where eCryptfs really does need the lower
      persistent file, such as just before reading or writing the metadata
      stored in the lower file header.
      
      Two functions are jumping to out_dput when they should just be jumping to
      out on error paths.  This patch also fixes these.
      Signed-off-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      391b52f9
    • M
      eCryptfs: do not try to open device files on mknod · 72b55fff
      Michael Halcrow 提交于
      When creating device nodes, eCryptfs needs to delay actually opening the lower
      persistent file until an application tries to open.  Device handles may not be
      backed by anything when they first come into existence.
      
      [Valdis.Kletnieks@vt.edu: build fix]
      Signed-off-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Cc: <Valdis.Kletnieks@vt.edu}
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      72b55fff
    • H
      ecryptfs: inode.c mmap.c use unaligned byteorder helpers · 0a688ad7
      Harvey Harrison 提交于
      Fixe sparse warnings:
      fs/ecryptfs/inode.c:368:15: warning: cast to restricted __be64
      fs/ecryptfs/mmap.c:385:12: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/mmap.c:385:12:    expected unsigned long long [unsigned] [assigned] [usertype] file_size
      fs/ecryptfs/mmap.c:385:12:    got restricted __be64 [usertype] <noident>
      fs/ecryptfs/mmap.c:428:12: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/mmap.c:428:12:    expected unsigned long long [unsigned] [assigned] [usertype] file_size
      fs/ecryptfs/mmap.c:428:12:    got restricted __be64 [usertype] <noident>
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Cc: Michael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0a688ad7
    • H
      ecryptfs: crypto.c use unaligned byteorder helpers · 29335c6a
      Harvey Harrison 提交于
      Fixes the following sparse warnings:
      fs/ecryptfs/crypto.c:1036:8: warning: cast to restricted __be32
      fs/ecryptfs/crypto.c:1038:8: warning: cast to restricted __be32
      fs/ecryptfs/crypto.c:1077:10: warning: cast to restricted __be32
      fs/ecryptfs/crypto.c:1103:6: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/crypto.c:1105:6: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/crypto.c:1124:8: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/crypto.c:1241:21: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/crypto.c:1244:30: warning: incorrect type in assignment (different base types)
      fs/ecryptfs/crypto.c:1414:23: warning: cast to restricted __be32
      fs/ecryptfs/crypto.c:1417:32: warning: cast to restricted __be16
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Cc: Michael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      29335c6a
    • M
      ecryptfs: string copy cleanup · 8f236809
      Miklos Szeredi 提交于
      Clean up overcomplicated string copy, which also gets rid of this
      bogus warning:
      
      fs/ecryptfs/main.c: In function 'ecryptfs_parse_options':
      include/asm/arch/string_32.h:75: warning: array subscript is above array bounds
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Cc: Michael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8f236809
    • E
      ecryptfs: propagate key errors up at mount time · 982363c9
      Eric Sandeen 提交于
      Mounting with invalid key signatures should probably fail, if they were
      specifically requested but not available.
      
      Also fix case checks in process_request_key_err() for the right sign of
      the errnos, as spotted by Jan Tluka.
      Signed-off-by: NEric Sandeen <sandeen@redhat.com>
      Reviewed-by: NJan Tluka <jtluka@redhat.com>
      Acked-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      982363c9
    • T
      ecryptfs: discard ecryptfsd registration messages in miscdev · 6c4c17b0
      Tyler Hicks 提交于
      The userspace eCryptfs daemon sends HELO and QUIT messages to the kernel
      for per-user daemon (un)registration.  These messages are required when
      netlink is used as the transport, but (un)registration is handled by
      opening and closing the device file when miscdev is the transport.  These
      messages should be discarded in the miscdev transport so that a daemon
      isn't registered twice.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      Cc: Michael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6c4c17b0
    • M
      eCryptfs: Privileged kthread for lower file opens · 746f1e55
      Michael Halcrow 提交于
      eCryptfs would really like to have read-write access to all files in the
      lower filesystem.  Right now, the persistent lower file may be opened
      read-only if the attempt to open it read-write fails.  One way to keep
      from having to do that is to have a privileged kthread that can open the
      lower persistent file on behalf of the user opening the eCryptfs file;
      this patch implements this functionality.
      
      This patch will properly allow a less-privileged user to open the eCryptfs
      file, followed by a more-privileged user opening the eCryptfs file, with
      the first user only being able to read and the second user being able to
      both read and write.  eCryptfs currently does this wrong; it will wind up
      calling vfs_write() on a file that was opened read-only.  This is fixed in
      this patch.
      Signed-off-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Cc: Dave Kleikamp <shaggy@austin.ibm.com>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Cc: Eric Sandeen <sandeen@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      746f1e55
    • W
      I2O: handle sysfs_create_link() failures · 0293902a
      Wang Chen 提交于
      Compile warning:
      ignoring return value of `sysfs_create_link', declared with attribute warn_unused_result.
      
      If sysfs_create_link failed, take care of the return value and do some
      error handle after the failure.
      
      Since sysfs_remove_link() will check whether a link exists, when removing the
      link in error path, we don't need to care whether a link was created.
      Signed-off-by: NWang Chen <wangchen@cn.fujitsu.com>
      Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0293902a
    • S
      vt: do not update when the console is blanked · f700d6e5
      Stefano Stabellini 提交于
      vt.c DO_UPDATE macro checks if the console is visible but doesn't check if
      the console is blanked.
      
      In fact updating fbcon while the console is blanked is not only
      unnecessary but can even cause screen corruption.
      
      Therefore I am adding a simple check on console_blanked in DO_UPDATE.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
      Cc: "Antonino A. Daplas" <adaplas@pol.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f700d6e5
    • J
      vt: hold console_sem across sysfs operations · e0426e6a
      Jiri Slaby 提交于
      Hold console sem while creating/destroying sysfs files.  Serialisation is
      so far done by BKL held in tty release_dev and chrdev_open, but no other
      locks are held in open path.
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Aristeu Rozanski <aris@ruivo.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e0426e6a
    • J
      spi: au1550_spi: improve pio transfer mode · bbe48ecc
      Jan Nikitenko 提交于
      Improve PIO transfer mode of au1550 spi controller by continuing of spi
      transfer, instead of aborting transfer when transmit underflow interrupt
      occurrs.
      
      Verified by oscilloscope that the spi clock pauses on trasmit underflow,
      so transfer continuation is perfectly valid even though au1550 datasheet
      says that on tx underflow zeroes will be transfered.
      
      Also make some error messages more specific.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NJan Nikitenko <jan.nikitenko@gmail.com>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bbe48ecc
    • M
      spi: au1550_spi: proper platform device · 3a93a159
      Manuel Lauss 提交于
      Remove the Au1550 resource table and instead extract MMIO/IRQ/DMA
      resources from platform resource information like any well-behaved
      platform driver.
      Signed-off-by: NManuel Lauss <mano@roarinelk.homelinux.net>
      Signed-off-by: NJan Nikitenko <jan.nikitenko@gmail.com>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3a93a159
    • A
      spidev: BKL removal · 4ef754b7
      Alan Cox 提交于
      Another step to removing ->ioctl and to removing the BKL
      
      [dbrownell@users.sourceforge.net: take final step; BKL not needed]
      Signed-off-by: NAlan Cox <alan@redhat.com>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4ef754b7
    • G
      spi: make spi_board_info.modalias a char array · 102eb975
      Grant Likely 提交于
      Currently, 'modalias' in the spi_device structure is a 'const char *'.
      The spi_new_device() function fills in the modalias value from a passed in
      spi_board_info data block.  Since it is a pointer copy, the new spi_device
      remains dependent on the spi_board_info structure after the new spi_device
      is registered (no other fields in spi_device directly depend on the
      spi_board_info structure; all of the other data is copied).
      
      This causes a problem when dynamically propulating the list of attached
      SPI devices.  For example, in arch/powerpc, the list of SPI devices can be
      populated from data in the device tree.  With the current code, the device
      tree adapter must kmalloc() a new spi_board_info structure for each new
      SPI device it finds in the device tree, and there is no simple mechanism
      in place for keeping track of these allocations.
      
      This patch changes modalias from a 'const char *' to a fixed char array.
      By copying the modalias string instead of referencing it, the dependency
      on the spi_board_info structure is eliminated and an outside caller does
      not need to maintain a separate spi_board_info allocation for each device.
      
      If searched through the code to the best of my ability for any references
      to modalias which may be affected by this change and haven't found
      anything.  It has been tested with the lite5200b platform in arch/powerpc.
      
      [dbrownell@users.sourceforge.net: cope with linux-next changes: KOBJ_NAME_LEN obliterated, etc]
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      102eb975
    • R
      SPI Kconfig simplifications · 6291fe2a
      Robert P. J. Day 提交于
      Use "if SPI_MASTER" to remove numerous dependencies.
      
      [dbrownell@users.sourceforge.net: remove a couple now-needless EXPERIMENTAL dependencies too]
      Signed-off-by: NRobert P. J. Day <rpjday@crashcourse.ca>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6291fe2a
    • R
      xilinx_spi: test below 0 on unsigned irq in xilinx_spi_probe() · 166a375b
      Roel Kluin 提交于
      xilinx_spi->irq is unsigned, so the test fails
      Signed-off-by: NRoel Kluin <12o3l@tiscali.nl>
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      Cc: Andrei Konovalov <akonovalov@ru.mvista.com>
      Cc: Yuri Frolov <yfrolov@ru.mvista.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      166a375b
    • C
      spi: spi_mpc83xx clockrate fixes · a61f5345
      Chen Gong 提交于
      This updates the SPI clock rate calculations for the spi_mpc83xx driver.
      Some boundary conditions were wrong, and in several cases divide-by-16
      wasn't always needed
      Signed-off-by: NChen Gong <g.chen@freescale.com>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a61f5345
    • A
      708d8cef
    • N
      cpm1: don't send break on TX_STOP, don't interrupt RX/TX when adjusting termios parameters · ae2d4c39
      Nye Liu 提交于
      Before setting STOP_TX, set _brkcr to 0 so the SMC does not send a break
      character.  The driver appears to properly re-initialize _brkcr when the
      SMC is restarted.
      
      Do not interrupt RX/TX when the termios is being adjusted; it results in
      corrupted characters appearing on the line.
      
      Cc: Vitaly Bordug <vbordug@ru.mvista.com>
      Cc: Scott Wood <scottwood@freescale.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Kumar Gala <galak@kernel.crashing.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ae2d4c39
    • M
      serial: DZ11: avoid a hang at console switch-over · e9a8f4d1
      Maciej W. Rozycki 提交于
      Changes to the generic console support code that happened a while ago
      introduced a scenario where the initial console is used in parallel with
      the final console during a brief period when switching between the two is
      in progress.  During that time a message about the switch-over is printed.
      
      With some combinations of chips, firmware and drivers, such as the DEC
      DZ11 clone used with the DECstation, a hang may happen because the
      firmware used for the initial console may not expect the state of the chip
      after it has been initialised by the driver.
      
      This is a workaround for the DZ11 which reuses the power-management
      callback to keep the transmitter of the line associated with the console
      enabled.  It reflects the consensus reached in a discussion a while ago.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: Jiri Slaby <jirislaby@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e9a8f4d1
    • M
      serial: Z85C30: avoid a hang at console switch-over · 37713591
      Maciej W. Rozycki 提交于
      Changes to the generic console support code that happened a while ago
      introduced a scenario where the initial console is used in parallel with
      the final console during a brief period when switching between the two is
      in progress.  During that time a message about the switch-over is printed.
      
      With some combinations of chips, firmware and drivers, such as the Zilog
      Z85C30 SCC used with the DECstation, a hang may happen because the
      firmware used for the initial console may not expect the state of the chip
      after it has been initialised by the driver.  This is not a bug in the
      firmware, as some registers it would have to examine are write-only.
      
      This is a workaround for the Z85C30 which reuses the power-management
      callback to keep the transmitter of the line associated with the console
      enabled.  It reflects the consensus reached in a discussion a while ago.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: Jiri Slaby <jirislaby@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      37713591
    • C
      serial: add support for a no-name 4 ports multiserial card · b76c5a07
      Catalin(ux) M BOIE 提交于
      It is a no-name PCI card.  I found no reference to a producer so I used
      "UNKNOWN_0x1584" as the name.
      
      Full lspci:
      01:07.0 0780: 10b5:9050 (rev 01)
              Subsystem: 10b5:1584
              Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- \
                      ParErr- Stepping- SERR+ FastB2B-
              Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- \
                      DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
              Interrupt: pin A routed to IRQ 10
              Region 1: I/O ports at ec00 [size=128]
              Region 2: I/O ports at e480 [size=32]
              Region 3: I/O ports at e400 [size=8]
              Capabilities: [40] Power Management version 1
                      Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA \
                              PME(D0+,D1-,D2-,D3hot+,D3cold-)
                      Status: D0 PME-Enable- DSel=0 DScale=0 PME-
              Capabilities: [48] #06 [0080]
              Capabilities: [4c] Vital Product Data
      
      After:
      0000:01:07.0: ttyS4 at I/O 0xe480 (irq = 10) is a 16550A
      0000:01:07.0: ttyS5 at I/O 0xe488 (irq = 10) is a 16550A
      0000:01:07.0: ttyS6 at I/O 0xe490 (irq = 10) is a 16550A
      0000:01:07.0: ttyS7 at I/O 0xe498 (irq = 10) is a 16550A
      Signed-off-by: NCatalin(ux) M BOIE <catab@embedromix.ro>
      Acked-by: NAlan Cox <alan@redhat.com>
      Acked-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b76c5a07
    • A
      8250: fix break handling for Intel 82571 · 7500b1f6
      Aristeu Rozanski 提交于
      Intel 82571 has a "Serial Over LAN" feature that doesn't properly
      implements the receiving of break characters.  When a break is received,
      it doesn't set UART_LSR_DR and unless another character is received, the
      break won't be received by the application.
      Signed-off-by: NAristeu Rozanski <arozansk@redhat.com>
      Acked-by: NAlan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7500b1f6
    • A
      serial/8250_gsc.c: add MODULE_LICENSE · 920519c1
      Adrian Bunk 提交于
      This patch adds the missing MODULE_LICENSE("GPL").
      Signed-off-by: NAdrian Bunk <bunk@kernel.org>
      Acked-by: NAlan Cox <alan@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      920519c1
    • U
      flag parameters add-on: remove epoll_create size param · 9fe5ad9c
      Ulrich Drepper 提交于
      Remove the size parameter from the new epoll_create syscall and renames the
      syscall itself.  The updated test program follows.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <time.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_epoll_create2
      # ifdef __x86_64__
      #  define __NR_epoll_create2 291
      # elif defined __i386__
      #  define __NR_epoll_create2 329
      # else
      #  error "need __NR_epoll_create2"
      # endif
      #endif
      
      #define EPOLL_CLOEXEC O_CLOEXEC
      
      int
      main (void)
      {
        int fd = syscall (__NR_epoll_create2, 0);
        if (fd == -1)
          {
            puts ("epoll_create2(0) failed");
            return 1;
          }
        int coe = fcntl (fd, F_GETFD);
        if (coe == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (coe & FD_CLOEXEC)
          {
            puts ("epoll_create2(0) set close-on-exec flag");
            return 1;
          }
        close (fd);
      
        fd = syscall (__NR_epoll_create2, EPOLL_CLOEXEC);
        if (fd == -1)
          {
            puts ("epoll_create2(EPOLL_CLOEXEC) failed");
            return 1;
          }
        coe = fcntl (fd, F_GETFD);
        if (coe == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((coe & FD_CLOEXEC) == 0)
          {
            puts ("epoll_create2(EPOLL_CLOEXEC) set close-on-exec flag");
            return 1;
          }
        close (fd);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9fe5ad9c
    • U
      flag parameters: check magic constants · e38b36f3
      Ulrich Drepper 提交于
      This patch adds test that ensure the boundary conditions for the various
      constants introduced in the previous patches is met.  No code is generated.
      
      [akpm@linux-foundation.org: fix alpha]
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e38b36f3
    • U
      flag parameters: NONBLOCK in inotify_init · 510df2dd
      Ulrich Drepper 提交于
      This patch adds non-blocking support for inotify_init1.  The
      additional changes needed are minimal.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_inotify_init1
      # ifdef __x86_64__
      #  define __NR_inotify_init1 294
      # elif defined __i386__
      #  define __NR_inotify_init1 332
      # else
      #  error "need __NR_inotify_init1"
      # endif
      #endif
      
      #define IN_NONBLOCK O_NONBLOCK
      
      int
      main (void)
      {
        int fd = syscall (__NR_inotify_init1, 0);
        if (fd == -1)
          {
            puts ("inotify_init1(0) failed");
            return 1;
          }
        int fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (fl & O_NONBLOCK)
          {
            puts ("inotify_init1(0) set non-blocking mode");
            return 1;
          }
        close (fd);
      
        fd = syscall (__NR_inotify_init1, IN_NONBLOCK);
        if (fd == -1)
          {
            puts ("inotify_init1(IN_NONBLOCK) failed");
            return 1;
          }
        fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((fl & O_NONBLOCK) == 0)
          {
            puts ("inotify_init1(IN_NONBLOCK) set non-blocking mode");
            return 1;
          }
        close (fd);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      510df2dd
    • U
      flag parameters: NONBLOCK in pipe · be61a86d
      Ulrich Drepper 提交于
      This patch adds O_NONBLOCK support to pipe2.  It is minimally more involved
      than the patches for eventfd et.al but still trivial.  The interfaces of the
      create_write_pipe and create_read_pipe helper functions were changed and the
      one other caller as well.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_pipe2
      # ifdef __x86_64__
      #  define __NR_pipe2 293
      # elif defined __i386__
      #  define __NR_pipe2 331
      # else
      #  error "need __NR_pipe2"
      # endif
      #endif
      
      int
      main (void)
      {
        int fds[2];
        if (syscall (__NR_pipe2, fds, 0) == -1)
          {
            puts ("pipe2(0) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            int fl = fcntl (fds[i], F_GETFL);
            if (fl == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if (fl & O_NONBLOCK)
              {
                printf ("pipe2(0) set non-blocking mode for fds[%d]\n", i);
                return 1;
              }
            close (fds[i]);
          }
      
        if (syscall (__NR_pipe2, fds, O_NONBLOCK) == -1)
          {
            puts ("pipe2(O_NONBLOCK) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            int fl = fcntl (fds[i], F_GETFL);
            if (fl == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if ((fl & O_NONBLOCK) == 0)
              {
                printf ("pipe2(O_NONBLOCK) does not set non-blocking mode for fds[%d]\n", i);
                return 1;
              }
            close (fds[i]);
          }
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      be61a86d
    • U
      flag parameters: NONBLOCK in timerfd_create · 6b1ef0e6
      Ulrich Drepper 提交于
      This patch adds support for the TFD_NONBLOCK flag to timerfd_create.  The
      additional changes needed are minimal.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <time.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_timerfd_create
      # ifdef __x86_64__
      #  define __NR_timerfd_create 283
      # elif defined __i386__
      #  define __NR_timerfd_create 322
      # else
      #  error "need __NR_timerfd_create"
      # endif
      #endif
      
      #define TFD_NONBLOCK O_NONBLOCK
      
      int
      main (void)
      {
        int fd = syscall (__NR_timerfd_create, CLOCK_REALTIME, 0);
        if (fd == -1)
          {
            puts ("timerfd_create(0) failed");
            return 1;
          }
        int fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (fl & O_NONBLOCK)
          {
            puts ("timerfd_create(0) set non-blocking mode");
            return 1;
          }
        close (fd);
      
        fd = syscall (__NR_timerfd_create, CLOCK_REALTIME, TFD_NONBLOCK);
        if (fd == -1)
          {
            puts ("timerfd_create(TFD_NONBLOCK) failed");
            return 1;
          }
        fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((fl & O_NONBLOCK) == 0)
          {
            puts ("timerfd_create(TFD_NONBLOCK) set non-blocking mode");
            return 1;
          }
        close (fd);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6b1ef0e6
    • U
      flag parameters: NONBLOCK in eventfd · e7d476df
      Ulrich Drepper 提交于
      This patch adds support for the EFD_NONBLOCK flag to eventfd2.  The
      additional changes needed are minimal.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_eventfd2
      # ifdef __x86_64__
      #  define __NR_eventfd2 290
      # elif defined __i386__
      #  define __NR_eventfd2 328
      # else
      #  error "need __NR_eventfd2"
      # endif
      #endif
      
      #define EFD_NONBLOCK O_NONBLOCK
      
      int
      main (void)
      {
        int fd = syscall (__NR_eventfd2, 1, 0);
        if (fd == -1)
          {
            puts ("eventfd2(0) failed");
            return 1;
          }
        int fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (fl & O_NONBLOCK)
          {
            puts ("eventfd2(0) sets non-blocking mode");
            return 1;
          }
        close (fd);
      
        fd = syscall (__NR_eventfd2, 1, EFD_NONBLOCK);
        if (fd == -1)
          {
            puts ("eventfd2(EFD_NONBLOCK) failed");
            return 1;
          }
        fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((fl & O_NONBLOCK) == 0)
          {
            puts ("eventfd2(EFD_NONBLOCK) does not set non-blocking mode");
            return 1;
          }
        close (fd);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e7d476df
    • U
      flag parameters: NONBLOCK in signalfd · 5fb5e049
      Ulrich Drepper 提交于
      This patch adds support for the SFD_NONBLOCK flag to signalfd4.  The
      additional changes needed are minimal.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <signal.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_signalfd4
      # ifdef __x86_64__
      #  define __NR_signalfd4 289
      # elif defined __i386__
      #  define __NR_signalfd4 327
      # else
      #  error "need __NR_signalfd4"
      # endif
      #endif
      
      #define SFD_NONBLOCK O_NONBLOCK
      
      int
      main (void)
      {
        sigset_t ss;
        sigemptyset (&ss);
        sigaddset (&ss, SIGUSR1);
        int fd = syscall (__NR_signalfd4, -1, &ss, 8, 0);
        if (fd == -1)
          {
            puts ("signalfd4(0) failed");
            return 1;
          }
        int fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (fl & O_NONBLOCK)
          {
            puts ("signalfd4(0) set non-blocking mode");
            return 1;
          }
        close (fd);
      
        fd = syscall (__NR_signalfd4, -1, &ss, 8, SFD_NONBLOCK);
        if (fd == -1)
          {
            puts ("signalfd4(SFD_NONBLOCK) failed");
            return 1;
          }
        fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((fl & O_NONBLOCK) == 0)
          {
            puts ("signalfd4(SFD_NONBLOCK) does not set non-blocking mode");
            return 1;
          }
        close (fd);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5fb5e049
    • U
      flag parameters: NONBLOCK in socket and socketpair · 77d27200
      Ulrich Drepper 提交于
      This patch introduces support for the SOCK_NONBLOCK flag in socket,
      socketpair, and  paccept.  To do this the internal function sock_attach_fd
      gets an additional parameter which it uses to set the appropriate flag for
      the file descriptor.
      
      Given that in modern, scalable programs almost all socket connections are
      non-blocking and the minimal additional cost for the new functionality
      I see no reason not to add this code.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <pthread.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <netinet/in.h>
      #include <sys/socket.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_paccept
      # ifdef __x86_64__
      #  define __NR_paccept 288
      # elif defined __i386__
      #  define SYS_PACCEPT 18
      #  define USE_SOCKETCALL 1
      # else
      #  error "need __NR_paccept"
      # endif
      #endif
      
      #ifdef USE_SOCKETCALL
      # define paccept(fd, addr, addrlen, mask, flags) \
        ({ long args[6] = { \
             (long) fd, (long) addr, (long) addrlen, (long) mask, 8, (long) flags }; \
           syscall (__NR_socketcall, SYS_PACCEPT, args); })
      #else
      # define paccept(fd, addr, addrlen, mask, flags) \
        syscall (__NR_paccept, fd, addr, addrlen, mask, 8, flags)
      #endif
      
      #define PORT 57392
      
      #define SOCK_NONBLOCK O_NONBLOCK
      
      static pthread_barrier_t b;
      
      static void *
      tf (void *arg)
      {
        pthread_barrier_wait (&b);
        int s = socket (AF_INET, SOCK_STREAM, 0);
        struct sockaddr_in sin;
        sin.sin_family = AF_INET;
        sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
        sin.sin_port = htons (PORT);
        connect (s, (const struct sockaddr *) &sin, sizeof (sin));
        close (s);
        pthread_barrier_wait (&b);
      
        pthread_barrier_wait (&b);
        s = socket (AF_INET, SOCK_STREAM, 0);
        sin.sin_port = htons (PORT);
        connect (s, (const struct sockaddr *) &sin, sizeof (sin));
        close (s);
        pthread_barrier_wait (&b);
      
        return NULL;
      }
      
      int
      main (void)
      {
        int fd;
        fd = socket (PF_INET, SOCK_STREAM, 0);
        if (fd == -1)
          {
            puts ("socket(0) failed");
            return 1;
          }
        int fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (fl & O_NONBLOCK)
          {
            puts ("socket(0) set non-blocking mode");
            return 1;
          }
        close (fd);
      
        fd = socket (PF_INET, SOCK_STREAM|SOCK_NONBLOCK, 0);
        if (fd == -1)
          {
            puts ("socket(SOCK_NONBLOCK) failed");
            return 1;
          }
        fl = fcntl (fd, F_GETFL);
        if (fl == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((fl & O_NONBLOCK) == 0)
          {
            puts ("socket(SOCK_NONBLOCK) does not set non-blocking mode");
            return 1;
          }
        close (fd);
      
        int fds[2];
        if (socketpair (PF_UNIX, SOCK_STREAM, 0, fds) == -1)
          {
            puts ("socketpair(0) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            fl = fcntl (fds[i], F_GETFL);
            if (fl == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if (fl & O_NONBLOCK)
              {
                printf ("socketpair(0) set non-blocking mode for fds[%d]\n", i);
                return 1;
              }
            close (fds[i]);
          }
      
        if (socketpair (PF_UNIX, SOCK_STREAM|SOCK_NONBLOCK, 0, fds) == -1)
          {
            puts ("socketpair(SOCK_NONBLOCK) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            fl = fcntl (fds[i], F_GETFL);
            if (fl == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if ((fl & O_NONBLOCK) == 0)
              {
                printf ("socketpair(SOCK_NONBLOCK) does not set non-blocking mode for fds[%d]\n", i);
                return 1;
              }
            close (fds[i]);
          }
      
        pthread_barrier_init (&b, NULL, 2);
      
        struct sockaddr_in sin;
        pthread_t th;
        if (pthread_create (&th, NULL, tf, NULL) != 0)
          {
            puts ("pthread_create failed");
            return 1;
          }
      
        int s = socket (AF_INET, SOCK_STREAM, 0);
        int reuse = 1;
        setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
        sin.sin_family = AF_INET;
        sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
        sin.sin_port = htons (PORT);
        bind (s, (struct sockaddr *) &sin, sizeof (sin));
        listen (s, SOMAXCONN);
      
        pthread_barrier_wait (&b);
      
        int s2 = paccept (s, NULL, 0, NULL, 0);
        if (s2 < 0)
          {
            puts ("paccept(0) failed");
            return 1;
          }
      
        fl = fcntl (s2, F_GETFL);
        if (fl & O_NONBLOCK)
          {
            puts ("paccept(0) set non-blocking mode");
            return 1;
          }
        close (s2);
        close (s);
      
        pthread_barrier_wait (&b);
      
        s = socket (AF_INET, SOCK_STREAM, 0);
        sin.sin_port = htons (PORT);
        setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
        bind (s, (struct sockaddr *) &sin, sizeof (sin));
        listen (s, SOMAXCONN);
      
        pthread_barrier_wait (&b);
      
        s2 = paccept (s, NULL, 0, NULL, SOCK_NONBLOCK);
        if (s2 < 0)
          {
            puts ("paccept(SOCK_NONBLOCK) failed");
            return 1;
          }
      
        fl = fcntl (s2, F_GETFL);
        if ((fl & O_NONBLOCK) == 0)
          {
            puts ("paccept(SOCK_NONBLOCK) does not set non-blocking mode");
            return 1;
          }
        close (s2);
        close (s);
      
        pthread_barrier_wait (&b);
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      77d27200
    • U
      flag parameters: NONBLOCK in anon_inode_getfd · 99829b83
      Ulrich Drepper 提交于
      Building on the previous change to anon_inode_getfd, this patch introduces
      support for handling of O_NONBLOCK in addition to the already supported
      O_CLOEXEC.  Following patches will take advantage of this support.  As can be
      seen, the additional support for supporting this functionality is minimal.
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      99829b83
    • U
      flag parameters: inotify_init · 4006553b
      Ulrich Drepper 提交于
      This patch introduces the new syscall inotify_init1 (note: the 1 stands for
      the one parameter the syscall takes, as opposed to no parameter before).  The
      values accepted for this parameter are function-specific and defined in the
      inotify.h header.  Here the values must match the O_* flags, though.  In this
      patch CLOEXEC support is introduced.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_inotify_init1
      # ifdef __x86_64__
      #  define __NR_inotify_init1 294
      # elif defined __i386__
      #  define __NR_inotify_init1 332
      # else
      #  error "need __NR_inotify_init1"
      # endif
      #endif
      
      #define IN_CLOEXEC O_CLOEXEC
      
      int
      main (void)
      {
        int fd;
        fd = syscall (__NR_inotify_init1, 0);
        if (fd == -1)
          {
            puts ("inotify_init1(0) failed");
            return 1;
          }
        int coe = fcntl (fd, F_GETFD);
        if (coe == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (coe & FD_CLOEXEC)
          {
            puts ("inotify_init1(0) set close-on-exit");
            return 1;
          }
        close (fd);
      
        fd = syscall (__NR_inotify_init1, IN_CLOEXEC);
        if (fd == -1)
          {
            puts ("inotify_init1(IN_CLOEXEC) failed");
            return 1;
          }
        coe = fcntl (fd, F_GETFD);
        if (coe == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((coe & FD_CLOEXEC) == 0)
          {
            puts ("inotify_init1(O_CLOEXEC) does not set close-on-exit");
            return 1;
          }
        close (fd);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      [akpm@linux-foundation.org: add sys_ni stub]
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4006553b
    • U
      flag parameters: pipe · ed8cae8b
      Ulrich Drepper 提交于
      This patch introduces the new syscall pipe2 which is like pipe but it also
      takes an additional parameter which takes a flag value.  This patch implements
      the handling of O_CLOEXEC for the flag.  I did not add support for the new
      syscall for the architectures which have a special sys_pipe implementation.  I
      think the maintainers of those archs have the chance to go with the unified
      implementation but that's up to them.
      
      The implementation introduces do_pipe_flags.  I did that instead of changing
      all callers of do_pipe because some of the callers are written in assembler.
      I would probably screw up changing the assembly code.  To avoid breaking code
      do_pipe is now a small wrapper around do_pipe_flags.  Once all callers are
      changed over to do_pipe_flags the old do_pipe function can be removed.
      
      The following test must be adjusted for architectures other than x86 and
      x86-64 and in case the syscall numbers changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      
      #ifndef __NR_pipe2
      # ifdef __x86_64__
      #  define __NR_pipe2 293
      # elif defined __i386__
      #  define __NR_pipe2 331
      # else
      #  error "need __NR_pipe2"
      # endif
      #endif
      
      int
      main (void)
      {
        int fd[2];
        if (syscall (__NR_pipe2, fd, 0) != 0)
          {
            puts ("pipe2(0) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            int coe = fcntl (fd[i], F_GETFD);
            if (coe == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if (coe & FD_CLOEXEC)
              {
                printf ("pipe2(0) set close-on-exit for fd[%d]\n", i);
                return 1;
              }
          }
        close (fd[0]);
        close (fd[1]);
      
        if (syscall (__NR_pipe2, fd, O_CLOEXEC) != 0)
          {
            puts ("pipe2(O_CLOEXEC) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            int coe = fcntl (fd[i], F_GETFD);
            if (coe == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if ((coe & FD_CLOEXEC) == 0)
              {
                printf ("pipe2(O_CLOEXEC) does not set close-on-exit for fd[%d]\n", i);
                return 1;
              }
          }
        close (fd[0]);
        close (fd[1]);
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ed8cae8b