linux/arch/ia64/kernel
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
..
cpufreq [IA64] improper printk format in acpi-cpufreq 2008-07-17 11:11:17 -07:00
.gitignore [IA64] Add gate.lds to list of files ignored by Git 2007-11-06 15:39:45 -08:00
Makefile [IA64] pvops: paravirtualize NR_IRQS 2008-05-27 15:09:30 -07:00
acpi-ext.c Pull acpi_os_free into release branch 2006-07-01 17:19:08 -04:00
acpi-processor.c ACPI: Set _PSD ACPI_PDC_SMP_T_SWCOORD 2008-02-02 02:22:43 -05:00
acpi.c [IA64] Avoid overflowing ia64_cpu_to_sapicid in acpi_map_lsapic() 2008-07-17 11:24:42 -07:00
asm-offsets.c ia64: use kbuild.h macros instead of defining macros in asm-offsets.c 2008-04-29 08:06:29 -07:00
audit.c [PATCH] audit signal recipients 2007-05-11 05:38:25 -04:00
brl_emu.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
crash.c [IA64] simplify notify hooks in mca.c 2008-04-22 08:56:38 -07:00
crash_dump.c [IA64] kexec: Minor enhancement to includes in crash.c 2007-02-05 11:31:04 -08:00
cyclone.c cyclone.c: silly use of volatile, __iomem fixes 2007-07-26 11:11:57 -07:00
efi.c [IA64] Kernel parameter for max number of concurrent global TLB purges 2008-04-04 11:06:38 -07:00
efi_stub.S [IA64] make efi_stub.S fit in 80 cols 2006-06-21 14:35:28 -07:00
entry.S [IA64] pvops: paravirtualize entry.S 2008-05-27 15:08:01 -07:00
entry.h Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
err_inject.c sysdev: Pass the attribute to the low level sysdev show/store function 2008-07-21 21:55:02 -07:00
esi.c [IA64] esi-support 2006-06-21 11:19:22 -07:00
esi_stub.S [IA64] esi-support 2006-06-21 11:19:22 -07:00
fsys.S Pull miscellaneous into release branch 2008-04-17 10:14:51 -07:00
fsyscall_gtod_data.h [IA64] generalize attribute of fsyscall_gtod_data 2008-02-04 15:36:36 -08:00
gate-data.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
gate.S [IA64] Stop bit for brl instruction 2007-07-09 13:37:44 -07:00
gate.lds.S [IA64] increase .data.patch offset 2007-12-07 14:28:02 -08:00
head.S [IA64] pvops: add an early setup hook for pv_ops. 2008-05-27 14:39:54 -07:00
ia64_ksyms.c Generic semaphore implementation 2008-04-17 10:42:34 -04:00
init_task.c [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
iosapic.c Pull pvops into release branch 2008-07-17 10:53:37 -07:00
irq.c [IA64] fix section mismatch in arch/ia64/kernel/irq.c 2008-04-30 14:08:01 -07:00
irq_ia64.c [IA64] pvops: add hooks, pv_irq_ops, to paravirtualized irq related operations. 2008-05-27 15:11:10 -07:00
irq_lsapic.c [IA64] spelling fixes: arch/ia64/ 2007-05-11 14:55:43 -07:00
ivt.S [IA64] pv_ops: move some functions in ivt.S to avoid lack of space. 2008-05-28 09:41:58 -07:00
jprobes.S [IA64] enable trap code on slot 1 2006-12-12 12:00:55 -08:00
kprobes.c [IA64] kprobes: kprobe-booster for ia64 2008-04-09 10:36:43 -07:00
machine_kexec.c vmcoreinfo: fix the configuration dependencies 2008-02-07 08:42:25 -08:00
machvec.c [IA64] Ensure that machvec is set up takes place before serial console 2007-07-25 11:12:47 -07:00
mca.c on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02:00
mca_asm.S [IA64] Add API for allocating Dynamic TR resource. 2008-04-03 11:02:58 -07:00
mca_drv.c [IA64] mca style cleanup 2008-02-04 15:42:06 -08:00
mca_drv.h [IA64] mca style cleanup 2008-02-04 15:42:06 -08:00
mca_drv_asm.S [IA64] mca style cleanup 2008-02-04 15:42:06 -08:00
minstate.h [IA64] pvops: paravirtualize minstate.h. 2008-05-27 15:02:17 -07:00
module.c [IA64] adding parameter check to module_free() 2008-07-17 11:22:01 -07:00
msi_ia64.c [IA64] Fix irq migration in multiple vector domain 2008-03-04 14:16:20 -08:00
nr-irqs.c [IA64] pvops: paravirtualize NR_IRQS 2008-05-27 15:09:30 -07:00
numa.c [IA64] Minimize per_cpu reservations. 2008-04-08 13:51:35 -07:00
pal.S [IA64] reformat pal.S to fit in 80 columns, fix typos 2006-10-17 14:54:19 -07:00
palinfo.c smp_call_function: get rid of the unused nonatomic/retry argument 2008-06-26 11:24:35 +02:00
paravirt.c [IA64] pvops: add to hooks, pv_time_ops, for steal time accounting. 2008-05-27 15:11:42 -07:00
paravirt_inst.h [IA64] pvops: paravirtualize minstate.h. 2008-05-27 15:02:17 -07:00
paravirtentry.S [IA64] pvops: paravirtualize entry.S 2008-05-27 15:08:01 -07:00
patch.c [IA64] Workaround for RSE issue 2008-05-27 13:24:39 -07:00
perfmon.c on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02:00
perfmon_default_smpl.c [IA64] remove remaining __FUNCTION__ occurrences 2008-03-06 09:19:27 -08:00
perfmon_generic.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
perfmon_itanium.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
perfmon_mckinley.h [IA64] spelling fixes: arch/ia64/ 2007-05-11 14:55:43 -07:00
perfmon_montecito.h [IA64] sparse cleanups 2006-12-07 10:48:19 -08:00
process.c ACPI : Create "idle=nomwait" bootparam 2008-07-16 23:27:05 +02:00
ptrace.c [IA64] remove duplicate code for register access 2008-03-12 16:28:02 -07:00
relocate_kernel.S [IA64] Removal of percpu TR cleanup in kexec code 2007-05-08 10:00:28 -07:00
sal.c [IA64] Update check_sal_cache_flush to use platform_send_ipi() 2008-06-11 16:40:33 -07:00
salinfo.c ia64: use non-racy method for proc entries creation 2008-04-29 08:06:21 -07:00
setup.c Pull pvops into release branch 2008-07-17 10:53:37 -07:00
sigframe.h [IA64] Add TIF_RESTORE_SIGMASK 2007-05-08 14:51:59 -07:00
signal.c [IA64] TS_RESTORE_SIGMASK 2008-05-01 14:29:44 -07:00
smp.c on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02:00
smpboot.c Pull pvops into release branch 2008-07-17 10:53:37 -07:00
sys_ia64.c flag parameters: pipe 2008-07-24 10:47:28 -07:00
time.c Pull pvops into release branch 2008-07-17 10:53:37 -07:00
topology.c [IA64] fix section mismatch in arch/ia64/kernel/topology.c 2008-04-30 14:08:07 -07:00
traps.c [IA64] honor notify_die() returning NOTIFY_STOP 2008-02-05 08:26:44 -08:00
unaligned.c [IA64] arch/ia64/kernel/: use time_* macros 2008-04-09 10:38:30 -07:00
uncached.c smp_call_function: get rid of the unused nonatomic/retry argument 2008-06-26 11:24:35 +02:00
unwind.c [IA64] remove remaining __FUNCTION__ occurrences 2008-03-06 09:19:27 -08:00
unwind_decoder.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
unwind_i.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vmlinux.lds.S [IA64] pvops: preparation: move the constants, LOAD_OFFSET, to a header file. 2008-05-27 14:38:18 -07:00