[systemd-devel] [PATCH] Fix broken syscall(__NR_fanotify_mark... on 32bit mips.

Lennart Poettering lennart at poettering.net
Tue Apr 19 16:28:18 PDT 2011


On Thu, 14.04.11 17:34, fykcee1 at gmail.com (fykcee1 at gmail.com) wrote:

> diff --git a/src/missing.h b/src/missing.h
> index 35e209f..b367831 100644
> --- a/src/missing.h
> +++ b/src/missing.h
> @@ -125,7 +125,12 @@ static inline int fanotify_init(unsigned int flags, unsigned int event_f_flags)
>  
>  static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t mask,
>                                  int dfd, const char *pathname) {
> -        return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
> +        if (sizeof(void *) == 4)
> +                return syscall(__NR_fanotify_mark, fanotify_fd, flags,
> +                               *((uint32_t *) &mask), *((uint32_t *) &mask + 1),
> +                               dfd, pathname);
> +        else /* 64bit */
> +                return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
>  }
>  
>  #ifndef BTRFS_IOCTL_MAGIC

Hmm, wouldn't this break x86-32? 

Also, I'd very much prefer if this could be done with compile time
checks instead of "if". i.e.

#ifdef __mips__
...
#else
...
#endif

Finally, we try to avoid casts like this in order to avoid C99 aliasing
issues. Please use a union for this instead!

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list