From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMHd0-0000LI-UZ for qemu-devel@nongnu.org; Tue, 26 Aug 2014 10:21:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMHcw-000501-6K for qemu-devel@nongnu.org; Tue, 26 Aug 2014 10:21:42 -0400 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:57320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMHcv-0004zX-Lb for qemu-devel@nongnu.org; Tue, 26 Aug 2014 10:21:37 -0400 Received: by mail-wg0-f43.google.com with SMTP id l18so14423505wgh.26 for ; Tue, 26 Aug 2014 07:21:36 -0700 (PDT) Date: Tue, 26 Aug 2014 15:21:30 +0100 From: Paul Burton Message-ID: <20140826142130.GE2333@gmail.com> References: <1402849113-11402-13-git-send-email-paul@archlinuxmips.org> <20140826123041.GA27386@afflict.kos.to> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="f2QGlHpHGjS2mn6Y" Content-Disposition: inline In-Reply-To: <20140826123041.GA27386@afflict.kos.to> Subject: Re: [Qemu-devel] [12/16] linux-user: support {name_to, open_by}_handle_at syscalls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org --f2QGlHpHGjS2mn6Y Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 26, 2014 at 03:30:41PM +0300, Riku Voipio wrote: > Hi Paul, >=20 > On Sun, Jun 15, 2014 at 05:18:29PM +0100, Paul Burton wrote: > > Implement support for the name_to_handle_at and open_by_handle_at > > syscalls, allowing their use by the target program.=20 >=20 > What was your testcase for these syscalls? I usually use LTP for testing > syscalls, but there is no testcase for name_to_handle_at and > open_by_handle_at. Hi Riku, First thanks for taking care of a whole bunch of these patches, and my apologies for not being around or responsive! Meatspace has been keeping me busy, but has calmed down for now so I should be able to find more time to contribute :) Actually my test for these was that a mipsel systemd could boot from init through to a login prompt inside a container on my x86-64 host using QEMU via binfmt_misc. That does however also require a few more patches which I need to clean up before submitting. But you can find them here in the short term if you're interested: https://github.com/Arch-Linux-MIPS/qemu Paul > Riku >=20 > > Signed-off-by: Paul Burton > > --- > > linux-user/strace.c | 30 ++++++++++++++++++++++++++++++ > > linux-user/strace.list | 6 ++++++ > > linux-user/syscall.c | 50 ++++++++++++++++++++++++++++++++++++++++++= ++++++++ > > 3 files changed, 86 insertions(+) > >=20 > > diff --git a/linux-user/strace.c b/linux-user/strace.c > > index ea6c1d2..c20ddf1 100644 > > --- a/linux-user/strace.c > > +++ b/linux-user/strace.c > > @@ -1552,6 +1552,36 @@ print_kill(const struct syscallname *name, > > } > > #endif > > =20 > > +#ifdef TARGET_NR_name_to_handle_at > > +static void > > +print_name_to_handle_at(const struct syscallname *name, > > + abi_long arg0, abi_long arg1, abi_long arg2, > > + abi_long arg3, abi_long arg4, abi_long arg5) > > +{ > > + print_syscall_prologue(name); > > + print_at_dirfd(arg0, 0); > > + print_string(arg1, 0); > > + print_pointer(arg2, 0); > > + print_pointer(arg3, 0); > > + print_raw_param("0x%x", arg4, 1); > > + print_syscall_epilogue(name); > > +} > > +#endif > > + > > +#ifdef TARGET_NR_open_by_handle_at > > +static void > > +print_open_by_handle_at(const struct syscallname *name, > > + abi_long arg0, abi_long arg1, abi_long arg2, > > + abi_long arg3, abi_long arg4, abi_long arg5) > > +{ > > + print_syscall_prologue(name); > > + print_raw_param("%d", arg0, 0); > > + print_pointer(arg2, 0); > > + print_open_flags(arg3, 1); > > + print_syscall_epilogue(name); > > +} > > +#endif > > + > > /* > > * An array of all of the syscalls we know about > > */ > > diff --git a/linux-user/strace.list b/linux-user/strace.list > > index 8de972a..147f579 100644 > > --- a/linux-user/strace.list > > +++ b/linux-user/strace.list > > @@ -582,6 +582,9 @@ > > #ifdef TARGET_NR_munmap > > { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, > > #endif > > +#ifdef TARGET_NR_name_to_handle_at > > +{ TARGET_NR_name_to_handle_at, "name_to_handle_at" , NULL, print_name_= to_handle_at, NULL }, > > +#endif > > #ifdef TARGET_NR_nanosleep > > { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL }, > > #endif > > @@ -624,6 +627,9 @@ > > #ifdef TARGET_NR_openat > > { TARGET_NR_openat, "openat" , NULL, print_openat, NULL }, > > #endif > > +#ifdef TARGET_NR_open_by_handle_at > > +{ TARGET_NR_open_by_handle_at, "open_by_handle_at" , NULL, print_open_= by_handle_at, NULL }, > > +#endif > > #ifdef TARGET_NR_osf_adjtime > > { TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL }, > > #endif > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > > index c7f176a..192ad3a 100644 > > --- a/linux-user/syscall.c > > +++ b/linux-user/syscall.c > > @@ -5349,6 +5349,56 @@ abi_long do_syscall(void *cpu_env, int num, abi_= long arg1, > > unlock_user(p, arg2, 0); > > break; > > #endif > > +#ifdef TARGET_NR_name_to_handle_at > > + case TARGET_NR_name_to_handle_at: > > + { > > + struct file_handle *fh; > > + uint32_t sz; > > + int mount_id; > > + > > + if (!(p =3D lock_user_string(arg2))) > > + goto efault; > > + > > + if (get_user_u32(sz, arg3)) { > > + unlock_user(p, arg2, 0); > > + goto efault; > > + } > > + > > + if (!(fh =3D lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + s= z, 1))) { > > + unlock_user(p, arg2, 0); > > + goto efault; > > + } > > + > > + ret =3D get_errno(name_to_handle_at(arg1, path(p), fh, > > + &mount_id, arg5)); > > + > > + unlock_user(p, arg2, 0); > > + unlock_user(p, arg3, sizeof(*fh) + sz); > > + > > + if (put_user_s32(mount_id, arg4)) > > + goto efault; > > + } > > + break; > > +#endif > > +#ifdef TARGET_NR_open_by_handle_at > > + case TARGET_NR_open_by_handle_at: > > + { > > + struct file_handle *fh; > > + uint32_t sz; > > + > > + if (get_user_u32(sz, arg2)) > > + goto efault; > > + > > + if (!(fh =3D lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + s= z, 1))) > > + goto efault; > > + > > + ret =3D get_errno(open_by_handle_at(arg1, fh, > > + target_to_host_bitmask(arg3, fcntl_flags_tbl))); > > + > > + unlock_user(p, arg2, sizeof(*fh) + sz); > > + } > > + break; > > +#endif > > case TARGET_NR_close: > > ret =3D get_errno(close(arg1)); > > break; --f2QGlHpHGjS2mn6Y Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJT/JfqAAoJENzvn0paErs5JLQP/1bxZ2IL1JaIxMAGMkGODm7V MlnWOgKPr2C0YG/iK7Lr6f9cFLyCUFI9p+Ez/hIli5udOr0yPW/HrOyn/zBVldUw pVnqkrdiRTXGGqRg32JLMxPD4T7EJNJHFXo8rtYbGDJH3FwnKtTkfBKI509DMa9y tmK3uPdkR6hCHePmAd/QiDOc648EN/fJqHyEdXjmPjVoXnVWVUr5FUEhwPn6jZFh LM0RsMW89592Lrka0TrQoHwTXQcQ1BhrExsgqOMoLMJzX30jOJ69qb4R5N/zvKGb IyN4m8K9YTqg6nsqoiL3lKDq/o69SNP/AhLNEL8FR3o/wAzF55ybR0jNKYnaNsr6 A1kYs9pL0z9hX2brPvGK8YydvpwTOfJ1zpxt52vC9OfHxpUjXJrdf7n2Oe+fyWi5 D+lrui6f4+53OIL1dckwFl/CMgc2vTqa5LEC8Dw/8Gy4/ycRtCjEag5EGkPifIif 4Cj1w7J0v22Wu0mKnGCjz/5ILVYRoiN1kAbSPAOIuCKCw5dL8JjKEjmQfDyEmmD1 CHQ/kZ//kW18qEupQ1TTDoUmgwxHkX7Z34Gg0doKaNTZggNGXckDb25t6OcEc2rN VJiBFEZCikuwgReNLqoilLfGi7JFXKN1bfA+iKQsH3rwZdNyVvLFowmajaqsS9aT iTixXiFE2m3izRhaQA3M =Lvb6 -----END PGP SIGNATURE----- --f2QGlHpHGjS2mn6Y--