a677a039be
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> |
||
---|---|---|
.. | ||
dec | ||
emma2rh | ||
fw | ||
ip32 | ||
lasat | ||
mach-au1x00 | ||
mach-bcm47xx | ||
mach-cobalt | ||
mach-db1x00 | ||
mach-dec | ||
mach-emma2rh | ||
mach-excite | ||
mach-generic | ||
mach-ip22 | ||
mach-ip27 | ||
mach-ip28 | ||
mach-ip32 | ||
mach-jazz | ||
mach-lasat | ||
mach-lemote | ||
mach-malta | ||
mach-mipssim | ||
mach-pb1x00 | ||
mach-pnx8550 | ||
mach-rc32434 | ||
mach-rm | ||
mach-sibyte | ||
mach-tx39xx | ||
mach-tx49xx | ||
mach-vr41xx | ||
mach-wrppmc | ||
mach-yosemite | ||
mips-boards | ||
pci | ||
pmc-sierra/msp71xx | ||
sgi | ||
sibyte | ||
sn | ||
txx9 | ||
vr41xx | ||
xtalk | ||
a.out.h | ||
abi.h | ||
addrspace.h | ||
asm.h | ||
asmmacro-32.h | ||
asmmacro-64.h | ||
asmmacro.h | ||
atomic.h | ||
auxvec.h | ||
barrier.h | ||
bcache.h | ||
bitops.h | ||
bootinfo.h | ||
branch.h | ||
break.h | ||
bug.h | ||
bugs.h | ||
byteorder.h | ||
cache.h | ||
cachectl.h | ||
cacheflush.h | ||
cacheops.h | ||
checksum.h | ||
cmp.h | ||
cmpxchg.h | ||
compat-signal.h | ||
compat.h | ||
compiler.h | ||
cpu-features.h | ||
cpu-info.h | ||
cpu.h | ||
cputime.h | ||
current.h | ||
debug.h | ||
delay.h | ||
device.h | ||
div64.h | ||
dma-mapping.h | ||
dma.h | ||
ds1286.h | ||
ds1287.h | ||
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 | ||
futex.h | ||
gcmpregs.h | ||
gdb-stub.h | ||
gic.h | ||
gpio.h | ||
gt64120.h | ||
hardirq.h | ||
hazards.h | ||
highmem.h | ||
hw_irq.h | ||
i8253.h | ||
i8259.h | ||
ide.h | ||
inst.h | ||
io.h | ||
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 | ||
linkage.h | ||
local.h | ||
m48t35.h | ||
m48t37.h | ||
mc146818-time.h | ||
mc146818rtc.h | ||
mips_mt.h | ||
mipsmtregs.h | ||
mipsprom.h | ||
mipsregs.h | ||
mman.h | ||
mmu_context.h | ||
mmu.h | ||
mmzone.h | ||
module.h | ||
msc01_ic.h | ||
msgbuf.h | ||
mutex.h | ||
namei.h | ||
nile4.h | ||
paccess.h | ||
page.h | ||
param.h | ||
parport.h | ||
pci.h | ||
percpu.h | ||
pgalloc.h | ||
pgtable-32.h | ||
pgtable-64.h | ||
pgtable-bits.h | ||
pgtable.h | ||
pmon.h | ||
poll.h | ||
posix_types.h | ||
prefetch.h | ||
processor.h | ||
ptrace.h | ||
r4k-timer.h | ||
r4kcache.h | ||
reboot.h | ||
reg.h | ||
regdef.h | ||
resource.h | ||
rm9k-ocd.h | ||
rtlx.h | ||
scatterlist.h | ||
seccomp.h | ||
sections.h | ||
segment.h | ||
semaphore.h | ||
sembuf.h | ||
serial.h | ||
setup.h | ||
sgialib.h | ||
sgiarcs.h | ||
sgidefs.h | ||
shmbuf.h | ||
shmparam.h | ||
sigcontext.h | ||
siginfo.h | ||
signal.h | ||
sim.h | ||
smp-ops.h | ||
smp.h | ||
smtc_ipi.h | ||
smtc_proc.h | ||
smtc.h | ||
smvp.h | ||
sni.h | ||
socket.h | ||
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 | ||
timex.h | ||
titan_dep.h | ||
tlb.h | ||
tlbdebug.h | ||
tlbflush.h | ||
topology.h | ||
traps.h | ||
txx9irq.h | ||
txx9pio.h | ||
txx9tmr.h | ||
types.h | ||
uaccess.h | ||
ucontext.h | ||
unaligned.h | ||
unistd.h | ||
user.h | ||
vga.h | ||
vpe.h | ||
war.h | ||
wbflush.h | ||
xor.h |