qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 3/3] linux-user: Add support for statx() sys


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH v10 3/3] linux-user: Add support for statx() syscall
Date: Wed, 19 Jun 2019 14:56:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]