From: Laurent Vivier <laurent@vivier.eu>
To: Aleksandar Rikalo <arikalo@wavecomp.com>,
Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "lvivier@redhat.com" <lvivier@redhat.com>,
Aleksandar Markovic <amarkovic@wavecomp.com>
Subject: Re: [Qemu-devel] [PATCH v10 3/3] linux-user: Add support for statx() syscall
Date: Wed, 19 Jun 2019 14:56:44 +0200 [thread overview]
Message-ID: <f2e44145-622d-ccff-1b4d-57d603abe80f@vivier.eu> (raw)
In-Reply-To: <DM5PR22MB1658725207C159300EEC786AD2E50@DM5PR22MB1658.namprd22.prod.outlook.com>
Le 19/06/2019 à 14:12, Aleksandar Rikalo a écrit :
> Hi Laurent,
...
>> BTW, do we really need to emulate the syscall if it is not available?
>>
>> I think the user-space application calling statx() should be ready to
>> receive ENOSYS and define some kinds of fallback (like you do below). So
>> it should not be done by QEMU.
>
> nanoMIPS linux port doesn't support any of "stats" but the statx, so there
> is no fallback in nanoMIPS user-space applications.
>
> I think, we can expect similar situation for any new linux port.
OK, I understand, so I agree, we need the emulation part.
>> Why do we divide the case in two parts, fstatat() should work here too.
>
> fstat() uses file descriptor, but here we have string which represents
> file name with absolute path.
>
> All system calls from 'stat' group whose name starts with letter f require
> file descriptor as an argument. Whereas remaining system calls require
> file name / path as string. In that sense, statx() is a hybrid between
> the two, hence the solution I propose.
but fstatat() works like statx(), it accepts file descriptor and path.
So what I proposed is to replace:
+ } else {
+ if (dirfd == AT_FDCWD) {
+ /*
+ * By pathname relative to the current working directory
+ */
+ ret = get_errno(stat(path(p), &st));
+ unlock_user(p, arg2, 0);
+ } else {
+ /*
+ * By pathname relative to the directory referred to by
+ * the file descriptor 'dirfd'
+ */
+ ret = get_errno(fstatat(dirfd, path(p), &st, flags));
+ unlock_user(p, arg2, 0);
+ }
+ }
by something like;
+ } else {
+ ret = get_errno(fstatat(dirfd, path(p), &st, flags));
+ }
as fstatat() also accepts AT_FDCWD.
Moreover in kernel vfs_fstatat() calls vfs_statx():
static inline int vfs_fstatat(int dfd, const char __user *filename,
struct kstat *stat, int flags)
{
return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
stat, STATX_BASIC_STATS);
}
so maybe all the cases can be emulated by fstatat()?
Or did I miss something?
Thanks,
Laurent
next prev parent reply other threads:[~2019-06-19 12:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 10:35 [Qemu-devel] [PATCH v10 0/3] linux-user: A set of miscellaneous patches Aleksandar Markovic
2019-06-07 10:35 ` [Qemu-devel] [PATCH v10 1/3] linux-user: Add support for setsockopt() options IPV6_<ADD|DROP>_MEMBERSHIP Aleksandar Markovic
2019-06-12 16:47 ` Laurent Vivier
2019-06-07 10:35 ` [Qemu-devel] [PATCH v10 2/3] linux-user: Add support for setsockopt() option SOL_ALG Aleksandar Markovic
2019-06-13 10:05 ` Laurent Vivier
2019-06-07 10:35 ` [Qemu-devel] [PATCH v10 3/3] linux-user: Add support for statx() syscall Aleksandar Markovic
2019-06-13 10:46 ` Laurent Vivier
2019-06-19 12:12 ` Aleksandar Rikalo
2019-06-19 12:56 ` Laurent Vivier [this message]
2019-06-18 22:06 ` Jim Wilson
2019-06-18 23:13 ` Aleksandar Markovic
2019-06-19 0:23 ` Jim Wilson
2019-06-11 9:30 ` [Qemu-devel] [PATCH v10 0/3] linux-user: A set of miscellaneous patches Aleksandar Markovic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2e44145-622d-ccff-1b4d-57d603abe80f@vivier.eu \
--to=laurent@vivier.eu \
--cc=aleksandar.markovic@rt-rk.com \
--cc=amarkovic@wavecomp.com \
--cc=arikalo@wavecomp.com \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).