android_kernel_xiaomi_sm8350/include/asm-mips
Ulrich Drepper a677a039be flag parameters: socket and socketpair
This patch adds support for flag values which are ORed to the type passwd
to socket and socketpair.  The additional code is minimal.  The flag
values in this implementation can and must match the O_* flags.  This
avoids overhead in the conversion.

The internal functions sock_alloc_fd and sock_map_fd get a new parameters
and all callers are changed.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>

#define PORT 57392

/* For Linux these must be the same.  */
#define SOCK_CLOEXEC O_CLOEXEC

int
main (void)
{
  int fd;
  fd = socket (PF_INET, SOCK_STREAM, 0);
  if (fd == -1)
    {
      puts ("socket(0) failed");
      return 1;
    }
  int coe = fcntl (fd, F_GETFD);
  if (coe == -1)
    {
      puts ("fcntl failed");
      return 1;
    }
  if (coe & FD_CLOEXEC)
    {
      puts ("socket(0) set close-on-exec flag");
      return 1;
    }
  close (fd);

  fd = socket (PF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
  if (fd == -1)
    {
      puts ("socket(SOCK_CLOEXEC) failed");
      return 1;
    }
  coe = fcntl (fd, F_GETFD);
  if (coe == -1)
    {
      puts ("fcntl failed");
      return 1;
    }
  if ((coe & FD_CLOEXEC) == 0)
    {
      puts ("socket(SOCK_CLOEXEC) does not set close-on-exec flag");
      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)
    {
      coe = fcntl (fds[i], F_GETFD);
      if (coe == -1)
        {
          puts ("fcntl failed");
          return 1;
        }
      if (coe & FD_CLOEXEC)
        {
          printf ("socketpair(0) set close-on-exec flag for fds[%d]\n", i);
          return 1;
        }
      close (fds[i]);
    }

  if (socketpair (PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds) == -1)
    {
      puts ("socketpair(SOCK_CLOEXEC) failed");
      return 1;
    }
  for (int i = 0; i < 2; ++i)
    {
      coe = fcntl (fds[i], F_GETFD);
      if (coe == -1)
        {
          puts ("fcntl failed");
          return 1;
        }
      if ((coe & FD_CLOEXEC) == 0)
        {
          printf ("socketpair(SOCK_CLOEXEC) does not set close-on-exec flag for fds[%d]\n", i);
          return 1;
        }
      close (fds[i]);
    }

  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: "David S. Miller" <davem@davemloft.net>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-24 10:47:27 -07:00
..
dec [MIPS] DECstation: Document more MB ASIC register bits 2008-07-15 18:44:30 +01:00
emma2rh
fw
ip32
lasat [MIPS] Remove mips_machtype for LASAT machines 2008-07-15 18:44:39 +01:00
mach-au1x00 au1xmmc: remove db1200 board code, rewrite probe. 2008-07-15 14:14:43 +02:00
mach-bcm47xx
mach-cobalt
mach-db1x00 [MIPS] Alchemy: remove unused MMC macros from db1x00 header. 2008-07-15 18:44:30 +01:00
mach-dec
mach-emma2rh
mach-excite
mach-generic [MIPS] make fallback gpio.h gpiolib-friendly 2008-04-28 17:14:31 +01:00
mach-ip22
mach-ip27 [MIPS] IP27: Fix build bug due to missing include 2008-04-28 17:14:32 +01:00
mach-ip28
mach-ip32
mach-jazz
mach-lasat [MIPS] Lasat: fix LASAT_CASCADE_IRQ 2008-03-12 14:14:42 +00:00
mach-lemote
mach-malta [MIPS] Malta: Cleanup organization of code into directories. 2008-07-15 18:44:34 +01:00
mach-mipssim
mach-pb1x00 [MIPS] Pb1200/DBAu1200 code style cleanup 2008-05-12 16:46:55 +01:00
mach-pnx8550
mach-rc32434 [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00
mach-rm
mach-sibyte
mach-tx39xx [MIPS] TXx9: rename asm-mips/mach-jmr3927 to asm-mips/mach-tx39xx 2008-07-15 18:44:38 +01:00
mach-tx49xx
mach-vr41xx [MIPS] cmbvr4133: Remove support 2008-07-15 18:44:36 +01:00
mach-wrppmc
mach-yosemite
mips-boards [MIPS] Remove unused maltasmp.h. 2008-07-20 14:38:22 +01:00
pci
pmc-sierra/msp71xx
sgi
sibyte
sn
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
xtalk
a.out.h aout: move STACK_TOP[_MAX] to asm/processor.h 2008-02-08 09:22:29 -08:00
abi.h
addrspace.h
asm.h
asmmacro-32.h
asmmacro-64.h
asmmacro.h
atomic.h [MIPS] Fix bug in atomic_sub_if_positive. 2008-07-04 08:22:15 +01:00
auxvec.h
barrier.h [MIPS] IP28: switch to "normal" mode after PROM no longer needed 2008-07-15 18:44:32 +01:00
bcache.h
bitops.h [MIPS] Tinker with constraints in <asm/atomic.h> to fix build error. 2008-07-20 14:38:18 +01:00
bootinfo.h [MIPS] Routerboard 532: Support for base system 2008-07-20 14:38:18 +01:00
branch.h
break.h
bug.h
bugs.h
byteorder.h
cache.h
cachectl.h
cacheflush.h [MIPS] Handle aliases in vmalloc correctly. 2008-04-07 22:31:04 +01:00
cacheops.h
checksum.h
cmp.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
cmpxchg.h Add cmpxchg64 and cmpxchg64_local to mips 2008-02-07 08:42:30 -08:00
compat-signal.h
compat.h
compiler.h [MIPS] Add empty argument parenthesis to GCC_IMM_ASM 2008-05-12 16:46:52 +01:00
cpu-features.h
cpu-info.h [MIPS] vpe_id is required for VSMP and SMTC builds 2008-06-16 15:14:48 +01:00
cpu.h [MIPS] modify the MIPS CPU classfication 2008-07-15 18:44:28 +01:00
cputime.h
current.h
debug.h
delay.h
device.h
div64.h rename div64_64 to div64_u64 2008-05-01 08:03:58 -07:00
dma-mapping.h
dma.h
ds1286.h
ds1287.h [MIPS] DS1287: Add clockevent driver 2008-04-28 17:14:32 +01:00
dsp.h
edac.h
elf.h
emergency-restart.h
errno.h
fb.h
fcntl.h
fixmap.h
floppy.h
fpregdef.h
fpu_emulator.h
fpu.h [MIPS] Fix missing prototypes in asm/fpu.h 2008-07-20 14:38:17 +01:00
futex.h asm-*/futex.h should include linux/uaccess.h 2008-04-30 08:29:52 -07:00
gcmpregs.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
gdb-stub.h
gic.h [MIPS] Malta: Fix build errors for 64-bit kernels 2008-06-16 15:14:48 +01:00
gpio.h
gt64120.h
hardirq.h
hazards.h
highmem.h [MIPS] Fix yosemite build error 2008-03-12 14:14:42 +00:00
hw_irq.h
i8253.h
i8259.h
ide.h
inst.h
io.h [MIPS] Remove obsolete isa_slot_offset 2008-07-15 18:44:29 +01:00
ioctl.h
ioctls.h
ipcbuf.h
irq_cpu.h
irq_gt641xx.h
irq_regs.h
irq.h
irqflags.h
isadep.h
jazz.h
jazzdma.h
Kbuild
kdebug.h
kexec.h
kmap_types.h
kspd.h
kvm.h kvm: provide kvm.h for all architecture: fixes headers_install 2008-04-02 15:28:18 -07:00
linkage.h
local.h
m48t35.h
m48t37.h
mc146818-time.h
mc146818rtc.h
mips_mt.h
mipsmtregs.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
mipsprom.h
mipsregs.h [MIPS] Add accessors for random register. 2008-06-05 18:13:15 +01:00
mman.h
mmu_context.h
mmu.h
mmzone.h
module.h
msc01_ic.h
msgbuf.h
mutex.h
namei.h [MIPS] IRIX: Goodbye and thanks for all the fish 2008-07-15 18:44:30 +01:00
nile4.h
paccess.h
page.h PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
param.h
parport.h
pci.h [MIPS] PCI: Make the pcibios_max_latency variable static 2008-07-20 14:38:17 +01:00
percpu.h
pgalloc.h CONFIG_HIGHPTE vs. sub-page page tables. 2008-02-08 09:22:42 -08:00
pgtable-32.h [MIPS] All MIPS32 processors support64-bit physical addresses. 2008-04-28 17:14:25 +01:00
pgtable-64.h
pgtable-bits.h [MIPS] Fix build for PNX platforms. 2008-06-16 15:14:47 +01:00
pgtable.h [MIPS] Add missing braces to pte_mkyoung 2008-06-05 18:13:14 +01:00
pmon.h
poll.h
posix_types.h asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
prefetch.h
processor.h PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
ptrace.h
r4k-timer.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
r4kcache.h
reboot.h
reg.h
regdef.h
resource.h
rm9k-ocd.h
rtlx.h [MIPS] Fix typo in header guard 2008-06-05 18:13:16 +01:00
scatterlist.h
seccomp.h
sections.h
segment.h
semaphore.h Generic semaphore implementation 2008-04-17 10:42:34 -04:00
sembuf.h
serial.h
setup.h [MIPS] don't leak setup_early_printk() in userspace header 2008-07-20 14:38:19 +01:00
sgialib.h
sgiarcs.h
sgidefs.h
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h [MIPS] IRIX: Goodbye and thanks for all the fish 2008-07-15 18:44:30 +01:00
sim.h
smp-ops.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
smp.h mips: convert to generic helpers for IPI function calls 2008-06-26 11:22:57 +02:00
smtc_ipi.h
smtc_proc.h
smtc.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
smvp.h [MIPS] Add support for MIPS CMP platform. 2008-04-28 17:14:26 +01:00
sni.h [MIPS] RM: fix EISA=n compilation 2008-02-19 17:01:34 +00:00
socket.h flag parameters: socket and socketpair 2008-07-24 10:47:27 -07:00
sockios.h
sparsemem.h
spinlock_types.h
spinlock.h
stackframe.h
stacktrace.h
stat.h
statfs.h
string.h
suspend.h
sysmips.h
system.h
termbits.h
termios.h
thread_info.h
time.h [MIPS] Clocksource: Only install r4k counter as clocksource if present. 2008-03-12 14:14:42 +00:00
timex.h
titan_dep.h
tlb.h
tlbdebug.h
tlbflush.h
topology.h
traps.h [MIPS] Remove board_watchpoint_handler 2008-07-15 18:44:29 +01:00
txx9irq.h
txx9pio.h [MIPS] generic txx9 gpio support 2008-04-28 17:14:31 +01:00
txx9tmr.h
types.h fix asm-mips/types.h syntax error 2008-05-04 14:45:55 -07:00
uaccess.h
ucontext.h
unaligned.h kernel: Move arches to use common unaligned access 2008-04-29 08:06:27 -07:00
unistd.h [MIPS] Wire up the timerfd_*() o32 system calls 2008-02-19 17:01:31 +00:00
user.h
vga.h
vpe.h
war.h
wbflush.h
xor.h