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

fykcee1 at gmail.com fykcee1 at gmail.com
Tue Apr 19 18:15:44 PDT 2011


2011/4/20 Lennart Poettering <lennart at poettering.net>
>
> 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?
It works fine on my asus laptop with a 32bit CPU Pentium-M.

We pass two 32bit arguments instead of one 64bit argument. syscall()
doesn't know the prototype, I guess it will only fetch 9 native-width
arguments(1 syscall number + 8 parameters) from the stack. Aurelien,
am I right?

>
> Also, I'd very much prefer if this could be done with compile time
> checks instead of "if". i.e.
>
> #ifdef __mips__
Actually it's not only related to mips, but also to all arch that
force 64-aligned for 64bit argument (Aurelien said this can also be
reproduced on powerpc and arm). So what I want is:
#if PTR_BYTES == 4
....

I tried to find some macro like PTR_BYTES or PTR_SIZE, but failed. Is
such macro available?

BTW, I guess It's suggested caller should split 64bit arguments for syscall().



--
Regards,
- cee1


More information about the systemd-devel mailing list