android_kernel_xiaomi_sm8350/arch/sparc64/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
..
asm-offsets.c
audit.c sparc64: Kill CONFIG_SPARC32_COMPAT 2008-04-26 21:41:19 -07:00
auxio.c
central.c sparc64/kernel/: make code static 2008-07-17 21:38:08 -07:00
cherrs.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
chmc.c
compat_audit.c
cpu.c [SPARC64]: Fix sparse warnings in arch/sparc64/kernel/{cpu,setup}.c 2008-03-25 21:51:40 -07:00
ds.c sparc64/kernel/: make code static 2008-07-17 21:38:08 -07:00
dtlb_miss.S
dtlb_prot.S sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
ebus.c sparc64: fix up bus_id changes in sparc core code 2008-07-21 21:55:03 -07:00
entry.h [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00
etrap.S sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
fpu_traps.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
ftrace.c ftrace: store mcount address in rec->ip 2008-06-23 22:10:56 +02:00
getsetcc.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
head.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
helpers.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
hvapi.c sparc64: Add missing hypervisor service group numbers. 2008-07-18 00:43:52 -07:00
hvcalls.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
hvtramp.S [SPARC64]: Fix cpu trampoline et al. mismatch warnings. 2008-02-20 22:22:16 -08:00
idprom.c sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
init_task.c [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
iommu_common.h PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
iommu.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
irq.c sparc64: Fix wedged irq regression. 2008-04-26 21:41:15 -07:00
itlb_miss.S
ivec.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
kgdb.c sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
kprobes.c [SPARC64]: Fix sparse warnings wrt. __show_regs(). 2008-02-19 20:48:58 -08:00
ktlb.S
ldc.c
Makefile sparc64: add ftrace support. 2008-05-23 22:36:13 +02:00
mdesc.c [SPARC64]: Initialize MDESC earlier and use lmb_alloc() 2008-04-23 23:32:12 -07:00
misctrap.S sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
module.c
of_device.c sparc64: fix up bus_id changes in sparc core code 2008-07-21 21:55:03 -07:00
pci_common.c sparc64: Stop creating dummy root PCI host controller devices. 2008-05-02 05:22:50 -07:00
pci_fire.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_impl.h sparc64: Stop creating dummy root PCI host controller devices. 2008-05-02 05:22:50 -07:00
pci_msi.c sparc64/kernel/: make code static 2008-07-17 21:38:08 -07:00
pci_psycho.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_sabre.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_schizo.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_sun4v_asm.S
pci_sun4v.c sparc64/kernel/: make code static 2008-07-17 21:38:08 -07:00
pci_sun4v.h
pci.c sparc64: fix up bus_id changes in sparc core code 2008-07-21 21:55:03 -07:00
power.c [SPARC64]: Fix sparse warnings wrt. machine_alt_power_off(). 2008-02-19 20:39:18 -08:00
process.c remove CONFIG_KMOD from sparc64 2008-07-22 19:24:30 +10:00
prom.c [SPARC64]: Use lmb_alloc() for PROM device tree. 2008-04-23 23:32:11 -07:00
ptrace.c sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
rtrap.S sparc64: Prevent stack backtrace false positives on trap frames. 2008-05-21 21:50:01 -07:00
sbus.c sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
setup.c sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
signal32.c sparc64: Use a TS_RESTORE_SIGMASK 2008-05-12 22:45:15 -07:00
signal.c sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
smp.c sparc64: Convert to generic helpers for IPI function calls. 2008-07-17 23:44:50 -07:00
sparc64_ksyms.c sparc64: Convert to generic helpers for IPI function calls. 2008-07-17 23:44:50 -07:00
spiterrs.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
sstate.c
stacktrace.c stacktrace: fix build failure on sparc64 2008-07-08 14:24:58 +02:00
starfire.c sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
sun4v_ivec.S
sun4v_tlb_miss.S [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00
sys32.S sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
sys_sparc32.c sparc: Merge asm-sparc{,64}/mman.h 2008-07-17 21:41:51 -07:00
sys_sparc.c flag parameters: pipe 2008-07-24 10:47:28 -07:00
syscalls.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
sysfs.c sysdev: Pass the attribute to the low level sysdev show/store function 2008-07-21 21:55:02 -07:00
systbls.h [SPARC]: Remove SunOS and Solaris binary support. 2008-04-21 15:10:15 -07:00
systbls.S sparc64: use compat_sys_utimes instead of home-grown local copy. 2008-05-05 12:32:39 -07:00
time.c sparc64-rtc: BKL pushdown 2008-07-02 15:06:25 -06:00
trampoline.S sparc64: remove CVS keywords 2008-05-20 00:33:43 -07:00
traps.c remove CONFIG_KMOD from sparc64 2008-07-22 19:24:30 +10:00
tsb.S [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00
ttable.S sparc64: Convert to generic helpers for IPI function calls. 2008-07-17 23:44:50 -07:00
una_asm.S
unaligned.c sparc: Use new '%pS' infrastructure to print symbols. 2008-07-17 22:11:32 -07:00
us2e_cpufreq.c
us3_cpufreq.c
utrap.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
vio.c sparc64: fix up bus_id changes in sparc core code 2008-07-21 21:55:03 -07:00
viohs.c
visemul.c
vmlinux.lds.S
winfixup.S [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00