linux/arch/mips
Ulrich Drepper ed8cae8ba0 flag parameters: pipe
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: Ulrich Drepper <drepper@redhat.com>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-24 10:47:28 -07:00
..
au1000 remove include/linux/pm_legacy.h 2008-07-24 10:47:22 -07:00
basler/excite basler-excite: BKL pushdown 2008-06-20 14:05:54 -06:00
bcm47xx [MIPS] BCM47XX: Use new SSB SPROM data structure 2008-02-19 17:01:34 +00:00
boot [MIPS] checkfiles: Fix "need space after that ','" errors. 2007-10-11 23:46:15 +01:00
cobalt [MIPS] Cobalt: Fix I/O port resource range 2008-07-20 14:38:20 +01:00
configs [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00
dec [MIPS] DS1287: Add clockevent driver 2008-04-28 17:14:32 +01:00
emma2rh [MIPS] Remove mips_machtype from EMMA2RH machines 2008-07-15 18:44:39 +01:00
fw [MIPS] Remove mips_machtype from ARC based machines 2008-07-15 18:44:38 +01:00
gt64120/wrppmc [MIPS] remove wrppmc_machine_power_off() 2008-07-15 18:44:36 +01:00
jazz [MIPS] Remove mips_machtype from ARC based machines 2008-07-15 18:44:38 +01:00
kernel flag parameters: pipe 2008-07-24 10:47:28 -07:00
lasat [MIPS] Remove mips_machtype for LASAT machines 2008-07-15 18:44:39 +01:00
lemote/lm2e [MIPS] Fulong: don't reinitialize pci_probe_only to it's default value. 2008-01-29 10:14:59 +00:00
lib iomap: fix 64 bits resources on 32 bits 2008-04-29 08:06:02 -07:00
math-emu [MIPS] Fix missing prototypes in asm/fpu.h 2008-07-20 14:38:17 +01:00
mipssim [MIPS] Remove TLB sanitation code 2008-04-28 17:14:25 +01:00
mm Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus 2008-07-15 15:01:29 -07:00
mti-malta [MIPS] Malta: Cleanup organization of code into directories. 2008-07-15 18:44:34 +01:00
nxp/pnx8550 [MIPS] Alchemy, PNX: Use symbolic constants for DMA masks. 2008-07-15 18:44:29 +01:00
oprofile generic-ipi: more merge fallout 2008-07-15 22:08:52 +02:00
pci [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00
pmc-sierra Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2008-07-16 17:25:46 -07:00
rb532 [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00
sgi-ip22 [MIPS] mips/sgi-ip22/ip28-berr.c: fix the build 2008-07-20 14:38:19 +01:00
sgi-ip27 PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
sgi-ip32 [MIPS] IP32: Use common SGI button driver 2008-07-20 14:38:18 +01:00
sibyte device create: mips: convert device_create to device_create_drvdata 2008-07-21 21:54:43 -07:00
sni [MIPS] Remove obsolete isa_slot_offset 2008-07-15 18:44:29 +01:00
txx9 [MIPS] TXx9: Fix some sparse warnings 2008-07-20 14:38:21 +01:00
vr41xx [MIPS] cmbvr4133: Remove support 2008-07-15 18:44:36 +01:00
Kconfig [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00
Kconfig.debug [MIPS] Allow setting of the cache attribute at run time. 2008-04-28 17:14:25 +01:00
Makefile [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00