Skip to content

Commit

Permalink
fix arm64 compile breakage
Browse files Browse the repository at this point in the history
This removes the hack for signalfd, which uses __NR_signalfd to check
whether a system supports signalfd or not. arm64 uses _NR_signalfd4 so
tgt wrongly assumes that arm64 doesn't support signalfd.

This hack was introduced when some distributions doesn't have a header
file for signalfd. Now all the distributions should have so we can
simply use sys/signalfd.h

Reported-by: Andreas Hasenack <andreas@canonical.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
  • Loading branch information
fujita committed Feb 16, 2024
1 parent df991fa commit 7ea5597
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 41 deletions.
2 changes: 1 addition & 1 deletion usr/bs.c
Expand Up @@ -311,7 +311,7 @@ static int bs_init_signalfd(void)
sigaddset(&mask, SIGUSR2);
sigprocmask(SIG_BLOCK, &mask, NULL);

sig_fd = __signalfd(-1, &mask, 0);
sig_fd = signalfd(-1, &mask, O_NONBLOCK);
if (sig_fd < 0)
return 1;

Expand Down
43 changes: 3 additions & 40 deletions usr/util.h
Expand Up @@ -14,11 +14,12 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <sys/types.h>
#include <sys/signalfd.h>
#include <sys/stat.h>
#include <sys/types.h>

#include "be_byteshift.h"

Expand Down Expand Up @@ -103,44 +104,6 @@ static inline int between(uint32_t seq1, uint32_t seq2, uint32_t seq3)

extern unsigned long pagesize, pageshift;

#if defined(__NR_signalfd) && defined(USE_SIGNALFD)

/*
* workaround for broken linux/signalfd.h including
* usr/include/linux/fcntl.h
*/
#define _LINUX_FCNTL_H

#include <linux/signalfd.h>

static inline int __signalfd(int fd, const sigset_t *mask, int flags)
{
int fd2, ret;

fd2 = syscall(__NR_signalfd, fd, mask, _NSIG / 8);
if (fd2 < 0)
return fd2;

ret = fcntl(fd2, F_GETFL);
if (ret < 0) {
close(fd2);
return -1;
}

ret = fcntl(fd2, F_SETFL, ret | O_NONBLOCK);
if (ret < 0) {
close(fd2);
return -1;
}

return fd2;
}
#else
#define __signalfd(fd, mask, flags) (-1)
struct signalfd_siginfo {
};
#endif

/* convert string to integer, check for validity of the string numeric format
* and the natural boundaries of the integer value type (first get a 64-bit
* value and check that it fits the range of the destination integer).
Expand Down

0 comments on commit 7ea5597

Please sign in to comment.