[RFC/PATCH 06/10] libbb: add fanotify support on uClibc

Ari Sundholm ari at tuxera.com
Fri Aug 14 12:46:14 UTC 2015


Hi!

On Thu, 2015-08-13 at 15:57 +0200, Bartosz Golaszewski wrote:
> Fanotify syscalls are not supported in uClibc. Add a new include
> file - missing_syscalls.h - implementing the syscalls directly in
> busybox.
> 

Why not use the existing libbb/missing_syscalls.c? I'm sure you have a
reason, but I can't figure it out.

Best regards,
Ari Sundholm
ari at tuxera.com

> Signed-off-by: Bartosz Golaszewski <bartekgola at gmail.com>
> ---
>  include/missing_syscalls.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
>  create mode 100644 include/missing_syscalls.h
> 
> diff --git a/include/missing_syscalls.h b/include/missing_syscalls.h
> new file mode 100644
> index 0000000..080bb28
> --- /dev/null
> +++ b/include/missing_syscalls.h
> @@ -0,0 +1,47 @@
> +/* vi: set sw=4 ts=4: */
> +/*
> + * Declarations for syscalls missing on some platforms.
> + *
> + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
> + */
> +
> +#ifndef __BB_MISSING_SYSCALLS_H
> +#define __BB_MISSING_SYSCALLS_H
> +
> +#include "libbb.h"
> +
> +#include <sys/syscall.h>
> +
> +#if defined(__UCLIBC__) && defined(__linux__)
> +
> +/* fanotify() is missing on uClibc */
> +
> +#include <limits.h> /* for __WORDSIZE */
> +
> +#if __WORDSIZE == 64
> +#define __SYSCALL_LONG_LONG_ARG(arg) (arg)
> +#else
> +/*
> + * On 32-bit systems we need to pass uint64_t arguments as two
> + * uint32_t's, that are going to be sewn together in the kernel.
> + */
> +#define __SYSCALL_LONG_LONG_ARG(arg) \
> +	((union { uint64_t ll; uint32_t l[2]; }){ .ll = arg }).l[0], \
> +	((union { uint64_t ll; uint32_t l[2]; }){ .ll = arg }).l[1]
> +#endif
> +
> +static ALWAYS_INLINE int fanotify_init(unsigned flags, unsigned event_f_flags)
> +{
> +	return syscall(SYS_fanotify_init, flags, event_f_flags);
> +}
> +
> +static ALWAYS_INLINE int fanotify_mark(int fanotify_fd, unsigned flags,
> +				uint64_t mask, int dfd, const char *pathname)
> +{
> +	return syscall(SYS_fanotify_mark, fanotify_fd, flags,
> +		       __SYSCALL_LONG_LONG_ARG(mask), dfd, pathname);
> +}
> +
> +#endif /* __UCLIBC__ && __linux__ */
> +
> +#endif /* __BB_MISSING_SYSCALLS_H */




More information about the busybox mailing list