Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/linux/common linux_sys_fstatat64: Add support for...



details:   https://anonhg.NetBSD.org/src/rev/db1aeed268e1
branches:  trunk
changeset: 1023663:db1aeed268e1
user:      rin <rin%NetBSD.org@localhost>
date:      Tue Sep 21 09:24:15 2021 +0000

description:
linux_sys_fstatat64: Add support for AT_EMPTY_PATH flag.

This is required for rtld shipped with glibc 2.33.

Now, userland of Fedora 34 is working fine on NetBSD/amd64.

diffstat:

 sys/compat/linux/common/linux_file64.c |  38 +++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 3 deletions(-)

diffs (66 lines):

diff -r 4db30c65efa4 -r db1aeed268e1 sys/compat/linux/common/linux_file64.c
--- a/sys/compat/linux/common/linux_file64.c    Mon Sep 20 23:22:36 2021 +0000
+++ b/sys/compat/linux/common/linux_file64.c    Tue Sep 21 09:24:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_file64.c,v 1.62 2019/08/23 07:53:36 maxv Exp $   */
+/*     $NetBSD: linux_file64.c,v 1.63 2021/09/21 09:24:15 rin Exp $    */
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.62 2019/08/23 07:53:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.63 2021/09/21 09:24:15 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -180,7 +180,38 @@
        } */
        struct linux_stat64 tmplst;
        struct stat tmpst;
-       int error, nd_flag;
+       struct vnode *vp;
+       int error, nd_flag, fd;
+       uint8_t c;
+
+       if (SCARG(uap, flag) & LINUX_AT_EMPTY_PATH) {
+               /*
+                * If path is null string:
+                */
+               error = ufetch_8(SCARG(uap, path), &c);
+               if (error != 0)
+                       return error;
+               if (c == '\0') {
+                       fd = SCARG(uap, fd);
+                       if (fd == AT_FDCWD) {
+                               /*
+                                * operate on current directory
+                                */
+                               vp = l->l_proc->p_cwdi->cwdi_cdir;
+                               vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+                               error = vn_stat(vp, &tmpst);
+                               VOP_UNLOCK(vp);
+                       } else {
+                               /*
+                                * operate on fd
+                                */
+                               error = do_sys_fstat(fd, &tmpst);
+                       }
+                       if (error != 0)
+                               return error;
+                       goto done;
+               }
+       }
 
        if (SCARG(uap, flag) & LINUX_AT_SYMLINK_NOFOLLOW)
                nd_flag = NOFOLLOW;
@@ -191,6 +222,7 @@
        if (error != 0)
                return error;
 
+done:
        bsd_to_linux_stat(&tmpst, &tmplst);
 
        return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);



Home | Main Index | Thread Index | Old Index