android_kernel_xiaomi_sm8350/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
acpi-ext.c
acpi-processor.c
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
brl_emu.c
crash_dump.c
crash.c [IA64] simplify notify hooks in mca.c 2008-04-22 08:56:38 -07:00
cyclone.c
efi_stub.S
efi.c [IA64] Kernel parameter for max number of concurrent global TLB purges 2008-04-04 11:06:38 -07:00
entry.h
entry.S [IA64] pvops: paravirtualize entry.S 2008-05-27 15:08:01 -07: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_stub.S
esi.c
fsys.S Pull miscellaneous into release branch 2008-04-17 10:14:51 -07:00
fsyscall_gtod_data.h
gate-data.S
gate.lds.S
gate.S
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_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
irq.c [IA64] fix section mismatch in arch/ia64/kernel/irq.c 2008-04-30 14:08:01 -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
kprobes.c [IA64] kprobes: kprobe-booster for ia64 2008-04-09 10:36:43 -07:00
machine_kexec.c
machvec.c
Makefile [IA64] pvops: paravirtualize NR_IRQS 2008-05-27 15:09:30 -07:00
mca_asm.S
mca_drv_asm.S
mca_drv.c
mca_drv.h
mca.c on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02: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
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
palinfo.c smp_call_function: get rid of the unused nonatomic/retry argument 2008-06-26 11:24:35 +02:00
paravirt_inst.h [IA64] pvops: paravirtualize minstate.h. 2008-05-27 15:02:17 -07:00
paravirt.c [IA64] pvops: add to hooks, pv_time_ops, for steal time accounting. 2008-05-27 15:11:42 -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_default_smpl.c
perfmon_generic.h
perfmon_itanium.h
perfmon_mckinley.h
perfmon_montecito.h
perfmon.c on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02:00
process.c ACPI : Create "idle=nomwait" bootparam 2008-07-16 23:27:05 +02:00
ptrace.c
relocate_kernel.S
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
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
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_decoder.c
unwind_i.h
unwind.c
vmlinux.lds.S [IA64] pvops: preparation: move the constants, LOAD_OFFSET, to a header file. 2008-05-27 14:38:18 -07:00