mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
flag parameters: signalfd
This patch adds the new signalfd4 syscall. It extends the old signalfd
syscall by one parameter which is meant to hold a flag value. In this
patch the only flag support is SFD_CLOEXEC which causes the close-on-exec
flag for the returned file descriptor to be set.
A new name SFD_CLOEXEC is introduced which in this implementation must
have the same value as O_CLOEXEC.
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 <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
#ifndef __NR_signalfd4
# ifdef __x86_64__
# define __NR_signalfd4 289
# elif defined __i386__
# define __NR_signalfd4 327
# else
# error "need __NR_signalfd4"
# endif
#endif
#define SFD_CLOEXEC O_CLOEXEC
int
main (void)
{
sigset_t ss;
sigemptyset (&ss);
sigaddset (&ss, SIGUSR1);
int fd = syscall (__NR_signalfd4, -1, &ss, 8, 0);
if (fd == -1)
{
puts ("signalfd4(0) failed");
return 1;
}
int coe = fcntl (fd, F_GETFD);
if (coe == -1)
{
puts ("fcntl failed");
return 1;
}
if (coe & FD_CLOEXEC)
{
puts ("signalfd4(0) set close-on-exec flag");
return 1;
}
close (fd);
fd = syscall (__NR_signalfd4, -1, &ss, 8, SFD_CLOEXEC);
if (fd == -1)
{
puts ("signalfd4(SFD_CLOEXEC) failed");
return 1;
}
coe = fcntl (fd, F_GETFD);
if (coe == -1)
{
puts ("fcntl failed");
return 1;
}
if ((coe & FD_CLOEXEC) == 0)
{
puts ("signalfd4(SFD_CLOEXEC) does not set close-on-exec flag");
return 1;
}
close (fd);
puts ("OK");
return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[[email protected]: add sys_ni stub]
Signed-off-by: Ulrich Drepper <[email protected]>
Acked-by: Davide Libenzi <[email protected]>
Cc: Michael Kerrisk <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
7d9dbca342
commit
9deb27baed
9 changed files with 34 additions and 6 deletions
14
fs/compat.c
14
fs/compat.c
|
|
@ -2131,9 +2131,9 @@ asmlinkage long compat_sys_epoll_pwait(int epfd,
|
|||
|
||||
#ifdef CONFIG_SIGNALFD
|
||||
|
||||
asmlinkage long compat_sys_signalfd(int ufd,
|
||||
const compat_sigset_t __user *sigmask,
|
||||
compat_size_t sigsetsize)
|
||||
asmlinkage long compat_sys_signalfd4(int ufd,
|
||||
const compat_sigset_t __user *sigmask,
|
||||
compat_size_t sigsetsize, int flags)
|
||||
{
|
||||
compat_sigset_t ss32;
|
||||
sigset_t tmp;
|
||||
|
|
@ -2148,9 +2148,15 @@ asmlinkage long compat_sys_signalfd(int ufd,
|
|||
if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
|
||||
return -EFAULT;
|
||||
|
||||
return sys_signalfd(ufd, ksigmask, sizeof(sigset_t));
|
||||
return sys_signalfd4(ufd, ksigmask, sizeof(sigset_t), flags);
|
||||
}
|
||||
|
||||
asmlinkage long compat_sys_signalfd(int ufd,
|
||||
const compat_sigset_t __user *sigmask,
|
||||
compat_size_t sigsetsize)
|
||||
{
|
||||
return compat_sys_signalfd4(ufd, sigmask, sigsetsize, 0);
|
||||
}
|
||||
#endif /* CONFIG_SIGNALFD */
|
||||
|
||||
#ifdef CONFIG_TIMERFD
|
||||
|
|
|
|||
Loading…
Reference in a new issue