All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] bsd-user: More file-related system calls
@ 2022-06-20 17:42 Warner Losh
  2022-06-20 17:42 ` [PATCH 01/10] bsd-user: Implement mount, umount and nmount Warner Losh
                   ` (9 more replies)
  0 siblings, 10 replies; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans

A second round of mostly BSD-independent filesystem calls: mount, unmount,
nmount, symlink, symlinkat, readlink, readlinkat, chmod, fchmod, lchmod,
fchmodat, freebsd11_mknod, freebsd11_monodat, mknodat, chown, fchown, lchown,
fchownat, chflags, lchflags, fchflags, chroot, flock, mkfifo, mkfifoat,
pathconf, lpathconf, fpathconf, undelete.

These are all non-reentrant system calls, so these wrappers are pretty simple
and no safe_* versions need to be created.

Warner Losh (10):
  bsd-user: Implement mount, umount and nmount
  bsd-user: Implement symlink, symlinkat, readlink and readlinkat
  bsd-user: implement chmod, fchmod, lchmod and fchmodat
  bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat
  bsd-user: Implement chown, fchown, lchown and fchownat
  bsd-user: Implement chflags, lchflags and fchflags
  bsd-user: Implement chroot and flock
  bsd-user: Implement mkfifo and mkfifoat
  bsd-user: Implement pathconf, lpathconf and fpathconf
  bsd-user: Implement undelete

 bsd-user/bsd-file.h           | 403 ++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 120 ++++++++++
 2 files changed, 523 insertions(+)

-- 
2.33.1



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/10] bsd-user: Implement mount, umount and nmount
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 18:19   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat Warner Losh
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son, Jung-uk Kim

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 52 +++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 13 +++++++++
 2 files changed, 65 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index b2dca586129..4545df3a056 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -549,4 +549,56 @@ static abi_long do_bsd_sync(void)
     return 0;
 }
 
+/* mount(2) */
+static abi_long do_bsd_mount(abi_long arg1, abi_long arg2, abi_long arg3,
+        abi_long arg4)
+{
+    abi_long ret;
+    void *p1, *p2;
+
+    LOCK_PATH2(p1, arg1, p2, arg2);
+    /*
+     * XXX arg4 should be locked, but it isn't clear how to do that
+     * since it's it may be not be a NULL-terminated string.
+     */
+    if (arg4 == 0) {
+        ret = get_errno(mount(p1, p2, arg3, NULL)); /* XXX path(p2)? */
+    } else {
+        ret = get_errno(mount(p1, p2, arg3, g2h_untagged(arg4))); /* XXX path(p2)? */
+    }
+    UNLOCK_PATH2(p1, arg1, p2, arg2);
+
+    return ret;
+}
+
+/* unmount(2) */
+static abi_long do_bsd_unmount(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(unmount(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* nmount(2) */
+static abi_long do_bsd_nmount(abi_long arg1, abi_long count,
+        abi_long flags)
+{
+    abi_long ret;
+    struct iovec *vec = lock_iovec(VERIFY_READ, arg1, count, 1);
+
+    if (vec != NULL) {
+        ret = get_errno(nmount(vec, count, flags));
+        unlock_iovec(vec, arg1, count, 0);
+    } else {
+        return -TARGET_EFAULT;
+    }
+
+    return ret;
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 2623caf8007..bd4dfa6ddc7 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -33,6 +33,7 @@
 #include "qemu/path.h"
 #include <sys/syscall.h>
 #include <sys/param.h>
+#include <sys/mount.h>
 #include <sys/sysctl.h>
 #include <utime.h>
 
@@ -373,6 +374,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_sync();
         break;
 
+    case TARGET_FREEBSD_NR_mount: /* mount(2) */
+        ret = do_bsd_mount(arg1, arg2, arg3, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_unmount: /* unmount(2) */
+        ret = do_bsd_unmount(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_nmount: /* nmount(2) */
+        ret = do_bsd_nmount(arg1, arg2, arg3);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
  2022-06-20 17:42 ` [PATCH 01/10] bsd-user: Implement mount, umount and nmount Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 18:28   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 03/10] bsd-user: implement chmod, fchmod, lchmod and fchmodat Warner Losh
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son, Jung-uk Kim

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 75 +++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 16 ++++++++
 2 files changed, 91 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index 4545df3a056..e5133268546 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -601,4 +601,79 @@ static abi_long do_bsd_nmount(abi_long arg1, abi_long count,
     return ret;
 }
 
+/* symlink(2) */
+static abi_long do_bsd_symlink(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p1, *p2;
+
+    LOCK_PATH2(p1, arg1, p2, arg2);
+    ret = get_errno(symlink(p1, p2)); /* XXX path(p1), path(p2) */
+    UNLOCK_PATH2(p1, arg1, p2, arg2);
+
+    return ret;
+}
+
+/* symlinkat(2) */
+static abi_long do_bsd_symlinkat(abi_long arg1, abi_long arg2,
+        abi_long arg3)
+{
+    abi_long ret;
+    void *p1, *p2;
+
+    LOCK_PATH2(p1, arg1, p2, arg3);
+    ret = get_errno(symlinkat(p1, arg2, p2)); /* XXX path(p1), path(p2) */
+    UNLOCK_PATH2(p1, arg1, p2, arg3);
+
+    return ret;
+}
+
+/* readlink(2) */
+static abi_long do_bsd_readlink(CPUArchState *env, abi_long arg1,
+        abi_long arg2, abi_long arg3)
+{
+    abi_long ret;
+    void *p1, *p2;
+
+    LOCK_PATH(p1, arg1);
+    p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
+    if (p2 == NULL) {
+        UNLOCK_PATH(p1, arg1);
+        return -TARGET_EFAULT;
+    }
+#ifdef __FreeBSD__
+    if (strcmp(p1, "/proc/curproc/file") == 0) {
+        CPUState *cpu = env_cpu(env);
+        TaskState *ts = (TaskState *)cpu->opaque;
+        strncpy(p2, ts->bprm->fullpath, arg3);
+        ret = MIN((abi_long)strlen(ts->bprm->fullpath), arg3);
+    } else
+#endif
+    ret = get_errno(readlink(path(p1), p2, arg3));
+    unlock_user(p2, arg2, ret);
+    UNLOCK_PATH(p1, arg1);
+
+    return ret;
+}
+
+/* readlinkat(2) */
+static abi_long do_bsd_readlinkat(abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4)
+{
+    abi_long ret;
+    void *p1, *p2;
+
+    LOCK_PATH(p1, arg2);
+    p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+    if (p2 == NULL) {
+        UNLOCK_PATH(p1, arg2);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(readlinkat(arg1, p1, p2, arg4));
+    unlock_user(p2, arg3, ret);
+    UNLOCK_PATH(p1, arg2);
+
+    return ret;
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index bd4dfa6ddc7..80ec9dd4954 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -386,6 +386,22 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_nmount(arg1, arg2, arg3);
         break;
 
+    case TARGET_FREEBSD_NR_symlink: /* symlink(2) */
+        ret = do_bsd_symlink(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_symlinkat: /* symlinkat(2) */
+        ret = do_bsd_symlinkat(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_readlink: /* readlink(2) */
+        ret = do_bsd_readlink(cpu_env, arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_readlinkat: /* readlinkat(2) */
+        ret = do_bsd_readlinkat(arg1, arg2, arg3, arg4);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/10] bsd-user: implement chmod, fchmod, lchmod and fchmodat
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
  2022-06-20 17:42 ` [PATCH 01/10] bsd-user: Implement mount, umount and nmount Warner Losh
  2022-06-20 17:42 ` [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 18:37   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat Warner Losh
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 46 +++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 16 ++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index e5133268546..0585f6a2a40 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -676,4 +676,50 @@ static abi_long do_bsd_readlinkat(abi_long arg1, abi_long arg2,
     return ret;
 }
 
+/* chmod(2) */
+static abi_long do_bsd_chmod(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(chmod(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* fchmod(2) */
+static abi_long do_bsd_fchmod(abi_long arg1, abi_long arg2)
+{
+    return get_errno(fchmod(arg1, arg2));
+}
+
+/* lchmod(2) */
+static abi_long do_bsd_lchmod(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(lchmod(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* fchmodat(2) */
+static abi_long do_bsd_fchmodat(abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg2);
+    ret = get_errno(fchmodat(arg1, p, arg3, arg4));
+    UNLOCK_PATH(p, arg2);
+
+    return ret;
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 80ec9dd4954..b33d548a4b6 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -402,6 +402,22 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_readlinkat(arg1, arg2, arg3, arg4);
         break;
 
+    case TARGET_FREEBSD_NR_chmod: /* chmod(2) */
+        ret = do_bsd_chmod(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_fchmod: /* fchmod(2) */
+        ret = do_bsd_fchmod(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_lchmod: /* lchmod(2) */
+        ret = do_bsd_lchmod(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_fchmodat: /* fchmodat(2) */
+        ret = do_bsd_fchmodat(arg1, arg2, arg3, arg4);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (2 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 03/10] bsd-user: implement chmod, fchmod, lchmod and fchmodat Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:13   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 05/10] bsd-user: Implement chown, fchown, lchown and fchownat Warner Losh
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son, Michal Meloun

These implement both the old-pre INO64 mknod variations, as well as the
now current INO64 variant. To implement the old stuff, we use some
linker magic to bind to the old versions of these functions.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Michal Meloun <mmel@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 59 +++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 15 +++++++++
 2 files changed, 74 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index 0585f6a2a40..3be832b2a74 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -51,6 +51,16 @@ do {                                        \
     unlock_user(p1, arg1, 0);               \
 } while (0)
 
+#ifndef BSD_HAVE_INO64
+#define freebsd11_mknod         mknod
+#define freebsd11_mknodat       mknodat
+#else
+int freebsd11_mknod(char *path, mode_t mode, uint32_t dev);
+__sym_compat(mknod, freebsd11_mknod, FBSD_1.0);
+int freebsd11_mknodat(int fd, char *path, mode_t mode, uint32_t dev);
+__sym_compat(mknodat, freebsd11_mknodat, FBSD_1.1);
+#endif
+
 extern struct iovec *lock_iovec(int type, abi_ulong target_addr, int count,
         int copy);
 extern void unlock_iovec(struct iovec *vec, abi_ulong target_addr, int count,
@@ -722,4 +732,53 @@ static abi_long do_bsd_fchmodat(abi_long arg1, abi_long arg2,
     return ret;
 }
 
+/* pre-ino64 mknod(2) */
+static abi_long do_bsd_freebsd11_mknod(abi_long arg1, abi_long arg2, abi_long arg3)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(freebsd11_mknod(p, arg2, arg3)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* pre-ino64 mknodat(2) */
+static abi_long do_bsd_freebsd11_mknodat(abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg2);
+    ret = get_errno(freebsd11_mknodat(arg1, p, arg3, arg4));
+    UNLOCK_PATH(p, arg2);
+
+    return ret;
+}
+
+#ifdef BSD_HAVE_INO64
+/* post-ino64 mknodat(2) */
+static abi_long do_bsd_mknodat(void *cpu_env, abi_long arg1,
+        abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
+        abi_long arg6)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg2);
+       /* 32-bit arch's use two 32 registers for 64 bit return value */
+    if (regpairs_aligned(cpu_env) != 0) {
+        ret = get_errno(mknodat(arg1, p, arg3, target_arg64(arg5, arg6)));
+    } else {
+        ret = get_errno(mknodat(arg1, p, arg3, target_arg64(arg4, arg5)));
+    }
+    UNLOCK_PATH(p, arg2);
+
+    return ret;
+}
+#endif
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index b33d548a4b6..fea6a857b78 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -32,6 +32,7 @@
 #include "qemu/cutils.h"
 #include "qemu/path.h"
 #include <sys/syscall.h>
+#include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/mount.h>
 #include <sys/sysctl.h>
@@ -418,6 +419,20 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_fchmodat(arg1, arg2, arg3, arg4);
         break;
 
+    case TARGET_FREEBSD_NR_freebsd11_mknod: /* mknod(2) */
+        ret = do_bsd_freebsd11_mknod(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_freebsd11_mknodat: /* mknodat(2) */
+        ret = do_bsd_freebsd11_mknodat(arg1, arg2, arg3, arg4);
+        break;
+
+#ifdef BSD_HAVE_INO64
+    case TARGET_FREEBSD_NR_mknodat: /* mknodat(2) */
+        ret = do_bsd_mknodat(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);
+        break;
+#endif
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/10] bsd-user: Implement chown, fchown, lchown and fchownat
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (3 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:18   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 06/10] bsd-user: Implement chflags, lchflags and fchflags Warner Losh
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 48 +++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 16 ++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index 3be832b2a74..152579ad541 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -781,4 +781,52 @@ static abi_long do_bsd_mknodat(void *cpu_env, abi_long arg1,
 }
 #endif
 
+/* chown(2) */
+static abi_long do_bsd_chown(abi_long arg1, abi_long arg2, abi_long arg3)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(chown(p, arg2, arg3)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* fchown(2) */
+static abi_long do_bsd_fchown(abi_long arg1, abi_long arg2,
+        abi_long arg3)
+{
+    return get_errno(fchown(arg1, arg2, arg3));
+}
+
+/* lchown(2) */
+static abi_long do_bsd_lchown(abi_long arg1, abi_long arg2,
+        abi_long arg3)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(lchown(p, arg2, arg3)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* fchownat(2) */
+static abi_long do_bsd_fchownat(abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg2);
+    ret = get_errno(fchownat(arg1, p, arg3, arg4, arg5)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg2);
+
+    return ret;
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index fea6a857b78..4d10334ef21 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -433,6 +433,22 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         break;
 #endif
 
+    case TARGET_FREEBSD_NR_chown: /* chown(2) */
+        ret = do_bsd_chown(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_fchown: /* fchown(2) */
+        ret = do_bsd_fchown(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_lchown: /* lchown(2) */
+        ret = do_bsd_lchown(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_fchownat: /* fchownat(2) */
+        ret = do_bsd_fchownat(arg1, arg2, arg3, arg4, arg5);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/10] bsd-user: Implement chflags, lchflags and fchflags
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (4 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 05/10] bsd-user: Implement chown, fchown, lchown and fchownat Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:19   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 07/10] bsd-user: Implement chroot and flock Warner Losh
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 32 ++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 12 ++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index 152579ad541..f5375a39a2c 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -829,4 +829,36 @@ static abi_long do_bsd_fchownat(abi_long arg1, abi_long arg2,
     return ret;
 }
 
+/* chflags(2) */
+static abi_long do_bsd_chflags(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(chflags(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* lchflags(2) */
+static abi_long do_bsd_lchflags(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(lchflags(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* fchflags(2) */
+static abi_long do_bsd_fchflags(abi_long arg1, abi_long arg2)
+{
+    return get_errno(fchflags(arg1, arg2));
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 4d10334ef21..d10635eae05 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -449,6 +449,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_fchownat(arg1, arg2, arg3, arg4, arg5);
         break;
 
+    case TARGET_FREEBSD_NR_chflags: /* chflags(2) */
+        ret = do_bsd_chflags(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_lchflags: /* lchflags(2) */
+        ret = do_bsd_lchflags(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_fchflags: /* fchflags(2) */
+        ret = do_bsd_fchflags(arg1, arg2);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/10] bsd-user: Implement chroot and flock
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (5 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 06/10] bsd-user: Implement chflags, lchflags and fchflags Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:21   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 08/10] bsd-user: Implement mkfifo and mkfifoat Warner Losh
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 19 +++++++++++++++++++
 bsd-user/freebsd/os-syscall.c |  8 ++++++++
 2 files changed, 27 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index f5375a39a2c..f11369655a0 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -861,4 +861,23 @@ static abi_long do_bsd_fchflags(abi_long arg1, abi_long arg2)
     return get_errno(fchflags(arg1, arg2));
 }
 
+/* chroot(2) */
+static abi_long do_bsd_chroot(abi_long arg1)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(chroot(p)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* flock(2) */
+static abi_long do_bsd_flock(abi_long arg1, abi_long arg2)
+{
+    return get_errno(flock(arg1, arg2));
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index d10635eae05..f3fb585b7ec 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -461,6 +461,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_fchflags(arg1, arg2);
         break;
 
+    case TARGET_FREEBSD_NR_chroot: /* chroot(2) */
+        ret = do_bsd_chroot(arg1);
+        break;
+
+    case TARGET_FREEBSD_NR_flock: /* flock(2) */
+        ret = do_bsd_flock(arg1, arg2);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/10] bsd-user: Implement mkfifo and mkfifoat
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (6 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 07/10] bsd-user: Implement chroot and flock Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:21   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 09/10] bsd-user: Implement pathconf, lpathconf and fpathconf Warner Losh
  2022-06-20 17:42 ` [PATCH 10/10] bsd-user: Implement undelete Warner Losh
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 27 +++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c |  8 ++++++++
 2 files changed, 35 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index f11369655a0..0b4b89c8d5c 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -880,4 +880,31 @@ static abi_long do_bsd_flock(abi_long arg1, abi_long arg2)
     return get_errno(flock(arg1, arg2));
 }
 
+/* mkfifo(2) */
+static abi_long do_bsd_mkfifo(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(mkfifo(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* mkfifoat(2) */
+static abi_long do_bsd_mkfifoat(abi_long arg1, abi_long arg2,
+        abi_long arg3)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg2);
+    ret = get_errno(mkfifoat(arg1, p, arg3));
+    UNLOCK_PATH(p, arg2);
+
+    return ret;
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index f3fb585b7ec..ff3893b9197 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -469,6 +469,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_flock(arg1, arg2);
         break;
 
+    case TARGET_FREEBSD_NR_mkfifo: /* mkfifo(2) */
+        ret = do_bsd_mkfifo(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_mkfifoat: /* mkfifoat(2) */
+        ret = do_bsd_mkfifoat(arg1, arg2, arg3);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/10] bsd-user: Implement pathconf, lpathconf and fpathconf
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (7 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 08/10] bsd-user: Implement mkfifo and mkfifoat Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:23   ` Richard Henderson
  2022-06-20 17:42 ` [PATCH 10/10] bsd-user: Implement undelete Warner Losh
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 32 ++++++++++++++++++++++++++++++++
 bsd-user/freebsd/os-syscall.c | 12 ++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index 0b4b89c8d5c..79eb5a73a9b 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -907,4 +907,36 @@ static abi_long do_bsd_mkfifoat(abi_long arg1, abi_long arg2,
     return ret;
 }
 
+/* pathconf(2) */
+static abi_long do_bsd_pathconf(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(pathconf(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* lpathconf(2) */
+static abi_long do_bsd_lpathconf(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(lpathconf(p, arg2)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
+/* fpathconf(2) */
+static abi_long do_bsd_fpathconf(abi_long arg1, abi_long arg2)
+{
+    return get_errno(fpathconf(arg1, arg2));
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index ff3893b9197..ee08b74bdd5 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -477,6 +477,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_mkfifoat(arg1, arg2, arg3);
         break;
 
+    case TARGET_FREEBSD_NR_pathconf: /* pathconf(2) */
+        ret = do_bsd_pathconf(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_lpathconf: /* lpathconf(2) */
+        ret = do_bsd_lpathconf(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR_fpathconf: /* fpathconf(2) */
+        ret = do_bsd_fpathconf(arg1, arg2);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/10] bsd-user: Implement undelete
  2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
                   ` (8 preceding siblings ...)
  2022-06-20 17:42 ` [PATCH 09/10] bsd-user: Implement pathconf, lpathconf and fpathconf Warner Losh
@ 2022-06-20 17:42 ` Warner Losh
  2022-06-20 19:23   ` Richard Henderson
  9 siblings, 1 reply; 23+ messages in thread
From: Warner Losh @ 2022-06-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Kyle Evans, Stacey Son

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-file.h           | 13 +++++++++++++
 bsd-user/freebsd/os-syscall.c |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
index 79eb5a73a9b..94e756ae550 100644
--- a/bsd-user/bsd-file.h
+++ b/bsd-user/bsd-file.h
@@ -939,4 +939,17 @@ static abi_long do_bsd_fpathconf(abi_long arg1, abi_long arg2)
     return get_errno(fpathconf(arg1, arg2));
 }
 
+/* undelete(2) */
+static abi_long do_bsd_undelete(abi_long arg1)
+{
+    abi_long ret;
+    void *p;
+
+    LOCK_PATH(p, arg1);
+    ret = get_errno(undelete(p)); /* XXX path(p)? */
+    UNLOCK_PATH(p, arg1);
+
+    return ret;
+}
+
 #endif /* BSD_FILE_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index ee08b74bdd5..7d791aeb91b 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -489,6 +489,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_fpathconf(arg1, arg2);
         break;
 
+    case TARGET_FREEBSD_NR_undelete: /* undelete(2) */
+        ret = do_bsd_undelete(arg1);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;
-- 
2.33.1



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 01/10] bsd-user: Implement mount, umount and nmount
  2022-06-20 17:42 ` [PATCH 01/10] bsd-user: Implement mount, umount and nmount Warner Losh
@ 2022-06-20 18:19   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 18:19 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son, Jung-uk Kim

On 6/20/22 10:42, Warner Losh wrote:
> +    /*
> +     * XXX arg4 should be locked, but it isn't clear how to do that
> +     * since it's it may be not be a NULL-terminated string.

it's it.

Unless you meant https://www.itsiticecream.com/  ;-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat
  2022-06-20 17:42 ` [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat Warner Losh
@ 2022-06-20 18:28   ` Richard Henderson
  2022-06-20 20:17     ` Warner Losh
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 18:28 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son, Jung-uk Kim

On 6/20/22 10:42, Warner Losh wrote:
> +static abi_long do_bsd_readlink(CPUArchState *env, abi_long arg1,
> +        abi_long arg2, abi_long arg3)
> +{
> +    abi_long ret;
> +    void *p1, *p2;
> +
> +    LOCK_PATH(p1, arg1);
> +    p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
> +    if (p2 == NULL) {
> +        UNLOCK_PATH(p1, arg1);
> +        return -TARGET_EFAULT;
> +    }
> +#ifdef __FreeBSD__
> +    if (strcmp(p1, "/proc/curproc/file") == 0) {
> +        CPUState *cpu = env_cpu(env);
> +        TaskState *ts = (TaskState *)cpu->opaque;
> +        strncpy(p2, ts->bprm->fullpath, arg3);
> +        ret = MIN((abi_long)strlen(ts->bprm->fullpath), arg3);
> +    } else
> +#endif

Unfortunate ifdef.  Do we really need it while the other bsds are presumably still 
non-functional?  I see that HOST_DEFAULT_BSD_TYPE isn't hooked up either...


r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 03/10] bsd-user: implement chmod, fchmod, lchmod and fchmodat
  2022-06-20 17:42 ` [PATCH 03/10] bsd-user: implement chmod, fchmod, lchmod and fchmodat Warner Losh
@ 2022-06-20 18:37   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 18:37 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 46 +++++++++++++++++++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c | 16 ++++++++++++
>   2 files changed, 62 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat
  2022-06-20 17:42 ` [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat Warner Losh
@ 2022-06-20 19:13   ` Richard Henderson
  2022-06-20 20:32     ` Warner Losh
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:13 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son, Michal Meloun

On 6/20/22 10:42, Warner Losh wrote:
> These implement both the old-pre INO64 mknod variations, as well as the
> now current INO64 variant. To implement the old stuff, we use some
> linker magic to bind to the old versions of these functions.
> 
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Michal Meloun <mmel@FreeBSD.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 59 +++++++++++++++++++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c | 15 +++++++++
>   2 files changed, 74 insertions(+)
> 
> diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
> index 0585f6a2a40..3be832b2a74 100644
> --- a/bsd-user/bsd-file.h
> +++ b/bsd-user/bsd-file.h
> @@ -51,6 +51,16 @@ do {                                        \
>       unlock_user(p1, arg1, 0);               \
>   } while (0)
>   
> +#ifndef BSD_HAVE_INO64
> +#define freebsd11_mknod         mknod
> +#define freebsd11_mknodat       mknodat
> +#else
> +int freebsd11_mknod(char *path, mode_t mode, uint32_t dev);
> +__sym_compat(mknod, freebsd11_mknod, FBSD_1.0);
> +int freebsd11_mknodat(int fd, char *path, mode_t mode, uint32_t dev);
> +__sym_compat(mknodat, freebsd11_mknodat, FBSD_1.1);
> +#endif

Where does BSD_HAVE_INO64 come from?  I can't find it defined in freebsd git.

You should probably avoid the linker tricks and use direct syscalls of 
SYS_freebsd11_mknodat etc.


r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 05/10] bsd-user: Implement chown, fchown, lchown and fchownat
  2022-06-20 17:42 ` [PATCH 05/10] bsd-user: Implement chown, fchown, lchown and fchownat Warner Losh
@ 2022-06-20 19:18   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:18 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 48 +++++++++++++++++++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c | 16 ++++++++++++
>   2 files changed, 64 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 06/10] bsd-user: Implement chflags, lchflags and fchflags
  2022-06-20 17:42 ` [PATCH 06/10] bsd-user: Implement chflags, lchflags and fchflags Warner Losh
@ 2022-06-20 19:19   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:19 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 32 ++++++++++++++++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c | 12 ++++++++++++
>   2 files changed, 44 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 07/10] bsd-user: Implement chroot and flock
  2022-06-20 17:42 ` [PATCH 07/10] bsd-user: Implement chroot and flock Warner Losh
@ 2022-06-20 19:21   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:21 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 19 +++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c |  8 ++++++++
>   2 files changed, 27 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 08/10] bsd-user: Implement mkfifo and mkfifoat
  2022-06-20 17:42 ` [PATCH 08/10] bsd-user: Implement mkfifo and mkfifoat Warner Losh
@ 2022-06-20 19:21   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:21 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 27 +++++++++++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c |  8 ++++++++
>   2 files changed, 35 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 09/10] bsd-user: Implement pathconf, lpathconf and fpathconf
  2022-06-20 17:42 ` [PATCH 09/10] bsd-user: Implement pathconf, lpathconf and fpathconf Warner Losh
@ 2022-06-20 19:23   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:23 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 32 ++++++++++++++++++++++++++++++++
>   bsd-user/freebsd/os-syscall.c | 12 ++++++++++++
>   2 files changed, 44 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 10/10] bsd-user: Implement undelete
  2022-06-20 17:42 ` [PATCH 10/10] bsd-user: Implement undelete Warner Losh
@ 2022-06-20 19:23   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-06-20 19:23 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son

On 6/20/22 10:42, Warner Losh wrote:
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/bsd-file.h           | 13 +++++++++++++
>   bsd-user/freebsd/os-syscall.c |  4 ++++
>   2 files changed, 17 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat
  2022-06-20 18:28   ` Richard Henderson
@ 2022-06-20 20:17     ` Warner Losh
  0 siblings, 0 replies; 23+ messages in thread
From: Warner Losh @ 2022-06-20 20:17 UTC (permalink / raw)
  To: Richard Henderson; +Cc: QEMU Developers, Kyle Evans, Stacey Son, Jung-uk Kim

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

On Mon, Jun 20, 2022 at 12:28 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 6/20/22 10:42, Warner Losh wrote:
> > +static abi_long do_bsd_readlink(CPUArchState *env, abi_long arg1,
> > +        abi_long arg2, abi_long arg3)
> > +{
> > +    abi_long ret;
> > +    void *p1, *p2;
> > +
> > +    LOCK_PATH(p1, arg1);
> > +    p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
> > +    if (p2 == NULL) {
> > +        UNLOCK_PATH(p1, arg1);
> > +        return -TARGET_EFAULT;
> > +    }
> > +#ifdef __FreeBSD__
> > +    if (strcmp(p1, "/proc/curproc/file") == 0) {
> > +        CPUState *cpu = env_cpu(env);
> > +        TaskState *ts = (TaskState *)cpu->opaque;
> > +        strncpy(p2, ts->bprm->fullpath, arg3);
> > +        ret = MIN((abi_long)strlen(ts->bprm->fullpath), arg3);
> > +    } else
> > +#endif
>
> Unfortunate ifdef.  Do we really need it while the other bsds are
> presumably still
> non-functional?  I see that HOST_DEFAULT_BSD_TYPE isn't hooked up either...
>

I can remove the ifdef for now and add it to the TODO file as something to
check
when we try to support NetBSD/OpenBSD again.

Warner

[-- Attachment #2: Type: text/html, Size: 1703 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat
  2022-06-20 19:13   ` Richard Henderson
@ 2022-06-20 20:32     ` Warner Losh
  0 siblings, 0 replies; 23+ messages in thread
From: Warner Losh @ 2022-06-20 20:32 UTC (permalink / raw)
  To: Richard Henderson; +Cc: QEMU Developers, Kyle Evans, Stacey Son, Michal Meloun

[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]

On Mon, Jun 20, 2022 at 1:13 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 6/20/22 10:42, Warner Losh wrote:
> > These implement both the old-pre INO64 mknod variations, as well as the
> > now current INO64 variant. To implement the old stuff, we use some
> > linker magic to bind to the old versions of these functions.
> >
> > Signed-off-by: Stacey Son <sson@FreeBSD.org>
> > Signed-off-by: Michal Meloun <mmel@FreeBSD.org>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/bsd-file.h           | 59 +++++++++++++++++++++++++++++++++++
> >   bsd-user/freebsd/os-syscall.c | 15 +++++++++
> >   2 files changed, 74 insertions(+)
> >
> > diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
> > index 0585f6a2a40..3be832b2a74 100644
> > --- a/bsd-user/bsd-file.h
> > +++ b/bsd-user/bsd-file.h
> > @@ -51,6 +51,16 @@ do {                                        \
> >       unlock_user(p1, arg1, 0);               \
> >   } while (0)
> >
> > +#ifndef BSD_HAVE_INO64
> > +#define freebsd11_mknod         mknod
> > +#define freebsd11_mknodat       mknodat
> > +#else
> > +int freebsd11_mknod(char *path, mode_t mode, uint32_t dev);
> > +__sym_compat(mknod, freebsd11_mknod, FBSD_1.0);
> > +int freebsd11_mknodat(int fd, char *path, mode_t mode, uint32_t dev);
> > +__sym_compat(mknodat, freebsd11_mknodat, FBSD_1.1);
> > +#endif
>
> Where does BSD_HAVE_INO64 come from?  I can't find it defined in freebsd
> git.
>

It used to be defined conditionally on FreeBSD 12 vs earlier. Now it's
defined unconditionally
in a file that wasn't part of the upstreaming. I'll rework now that it's
unconditional because
there's no way we could run on a FreeBSD 11 system. Normally we'd just
retire these older
system calls to limit the scope of what we need to maintain, but we have to
have the old FreeBSD-11
era pre-INO64 system calls (here and elsewhere) to support rust since it
doesn't use libc at all.


> You should probably avoid the linker tricks and use direct syscalls of
> SYS_freebsd11_mknodat etc
>

Yea, on pre-ino64 systems, there were no system calls like that. Now that
we have them, I think
you are right that we'd be better off just using the system call directly
rather than needing this hack
to get the old system calls. the old symbols will be around forever, but
it's better to be more direct here.
There's nothing hidden in the libc versions of these symbols.

tl;dr: It's always defined now, so I'll unifdef it.

Warner

[-- Attachment #2: Type: text/html, Size: 3464 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-06-20 20:36 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20 17:42 [PATCH 00/10] bsd-user: More file-related system calls Warner Losh
2022-06-20 17:42 ` [PATCH 01/10] bsd-user: Implement mount, umount and nmount Warner Losh
2022-06-20 18:19   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 02/10] bsd-user: Implement symlink, symlinkat, readlink and readlinkat Warner Losh
2022-06-20 18:28   ` Richard Henderson
2022-06-20 20:17     ` Warner Losh
2022-06-20 17:42 ` [PATCH 03/10] bsd-user: implement chmod, fchmod, lchmod and fchmodat Warner Losh
2022-06-20 18:37   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 04/10] bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodat Warner Losh
2022-06-20 19:13   ` Richard Henderson
2022-06-20 20:32     ` Warner Losh
2022-06-20 17:42 ` [PATCH 05/10] bsd-user: Implement chown, fchown, lchown and fchownat Warner Losh
2022-06-20 19:18   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 06/10] bsd-user: Implement chflags, lchflags and fchflags Warner Losh
2022-06-20 19:19   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 07/10] bsd-user: Implement chroot and flock Warner Losh
2022-06-20 19:21   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 08/10] bsd-user: Implement mkfifo and mkfifoat Warner Losh
2022-06-20 19:21   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 09/10] bsd-user: Implement pathconf, lpathconf and fpathconf Warner Losh
2022-06-20 19:23   ` Richard Henderson
2022-06-20 17:42 ` [PATCH 10/10] bsd-user: Implement undelete Warner Losh
2022-06-20 19:23   ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.