[CRIU] [PATCH] syscall: fix arguments for preadv()
Andrei Vagin
avagin at virtuozzo.com
Fri Dec 15 21:52:14 MSK 2017
On Fri, Dec 15, 2017 at 10:39:47AM +0000, Dmitry Safonov wrote:
> 2017-12-15 2:30 GMT+00:00 Andrei Vagin <avagin at openvz.org>:
> > It has two arguments "pos_l and "pos_h" instead of one "off". It is used
> > to handle 64-bit offsets on 32-bit kernels.
> >
> > SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec,
> > unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)
> >
> > https://github.com/checkpoint-restore/criu/issues/424
> > Signed-off-by: Andrei Vagin <avagin at openvz.org>
> > ---
> [..]
> > @@ -53,4 +55,22 @@ typedef int kernel_timer_t;
> >
> > #include <compel/plugins/std/asm/syscall-types.h>
> >
> > +
> > +extern long sys_preadv_raw(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h);
> > +
> > +#ifndef BITS_PER_LONG
> > +# error "BITS_PER_LONG isn't defined"
> > +#endif
> > +
> > +#if BITS_PER_LONG == 64
> > +#define LO_HI_LONG(val) (val), 0
> > +# else
> > +#define LO_HI_LONG(val) (long) (val), (((uint64_t) (val)) >> 32)
> > +#endif
> > +
> > +static inline long sys_preadv(int fd, struct iovec *iov, unsigned long nr, off_t off)
> > +{
> > + return sys_preadv_raw(fd, iov, nr, LO_HI_LONG(off));
> > +}
> > +
>
> Wouldn't it a bit more readable just doing it explicitly:
> static inline long sys_preadv(int fd, struct iovec *iov, unsigned long
> nr, off_t off)
> {
> #if BITS_PER_LONG == 64
> return sys_preadv_raw(fd, iov, nr, off, 0);
> # else
> return sys_preadv_raw(fd, iov, nr, (long)off, ((uint64_t)off) >> 32);
> #endif
Yes, I'm agree with you. I fixed the patch and pushed it into criu-dev.
Thanks a lot!
> }
>
> Well, anyway, it's just my preference,
> Reviewed-by: Dmitry Safonov <0x7f454c46 at gmail.com>
>
> --
> Dima
More information about the CRIU
mailing list