qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stacey Son <sson@FreeBSD.org>
To: qemu-devel@nongnu.org
Cc: Stacey Son <sson@FreeBSD.org>
Subject: [Qemu-devel] [PATCH 16/18] bsd-user: add support for extended attribute and ACL related syscalls
Date: Wed, 16 Oct 2013 09:37:10 -0500	[thread overview]
Message-ID: <1381934232-55158-17-git-send-email-sson@FreeBSD.org> (raw)
In-Reply-To: <1381934232-55158-1-git-send-email-sson@FreeBSD.org>

This change add support for extended attribute and Access Control List
(ACL) related system calls including extattrctl(), extattr_set_file(2),
extattr_delete_file(2), extattr_set_fd(2), extattr_get_fd(2),
extattr_delete_fd(2), extattr_get_link(2), extattr_set_link(2),
extattr_delete_link(2), extattr_list_fd(2), extattr_list_file(2),
extattr_list_link(2), __acl_aclcheck_fd(), __acl_aclcheck_file(),
__acl_aclcheck_link(), __acl_delete_fd(), __acl_delete_file(),
__acl_delete_link(), __acl_get_fd(), __acl_get_file(), __acl_get_link(),
__acl_get_fd(), __acl_set_file(), and __acl_set_link().

Signed-off-by: Stacey Son <sson@FreeBSD.org>
---
 bsd-user/Makefile.objs        |    2 +-
 bsd-user/freebsd/os-extattr.c |  119 ++++++++
 bsd-user/freebsd/os-extattr.h |  644 +++++++++++++++++++++++++++++++++++++++++
 bsd-user/freebsd/qemu-os.h    |    6 +
 bsd-user/netbsd/os-extattr.h  |  247 ++++++++++++++++
 bsd-user/openbsd/os-extattr.h |  247 ++++++++++++++++
 bsd-user/syscall.c            |  104 +++++++
 7 files changed, 1368 insertions(+), 1 deletions(-)
 create mode 100644 bsd-user/freebsd/os-extattr.c
 create mode 100644 bsd-user/freebsd/os-extattr.h
 create mode 100644 bsd-user/netbsd/os-extattr.h
 create mode 100644 bsd-user/openbsd/os-extattr.h

diff --git a/bsd-user/Makefile.objs b/bsd-user/Makefile.objs
index 242e6f4..b9eaf2d 100644
--- a/bsd-user/Makefile.objs
+++ b/bsd-user/Makefile.objs
@@ -1,6 +1,6 @@
 obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \
 	        uaccess.o bsd-ioctl.o bsd-mem.o bsd-proc.o bsd-socket.o \
-			$(HOST_ABI_DIR)/os-proc.o \
+			$(HOST_ABI_DIR)/os-extattr.o $(HOST_ABI_DIR)/os-proc.o \
 			$(HOST_ABI_DIR)/os-socket.o $(HOST_ABI_DIR)/os-stat.o \
 			$(HOST_ABI_DIR)/os-sys.o $(HOST_ABI_DIR)/os-thread.o \
 			$(HOST_ABI_DIR)/os-time.o $(TARGET_ABI_DIR)/target_arch_cpu.o
diff --git a/bsd-user/freebsd/os-extattr.c b/bsd-user/freebsd/os-extattr.c
new file mode 100644
index 0000000..7a10047
--- /dev/null
+++ b/bsd-user/freebsd/os-extattr.c
@@ -0,0 +1,119 @@
+/*
+ *  FreeBSD extend attributes and ACL conversions
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#ifndef _ACL_PRIVATE
+#define _ACL_PRIVATE
+#endif
+#include <sys/acl.h>
+
+#include "qemu.h"
+#include "qemu-os.h"
+
+/*
+ * FreeBSD ACL conversion.
+ */
+abi_long t2h_freebsd_acl(struct acl *host_acl, abi_ulong target_addr)
+{
+    uint32_t i;
+    struct target_freebsd_acl *target_acl;
+
+    if (!lock_user_struct(VERIFY_READ, target_acl, target_addr, 1)) {
+        return -TARGET_EFAULT;
+    }
+    __get_user(host_acl->acl_maxcnt, &target_acl->acl_maxcnt);
+    __get_user(host_acl->acl_cnt, &target_acl->acl_cnt);
+
+    for (i = 0; i < host_acl->acl_maxcnt; i++) {
+        __get_user(host_acl->acl_entry[i].ae_tag,
+            &target_acl->acl_entry[i].ae_tag);
+        __get_user(host_acl->acl_entry[i].ae_id,
+            &target_acl->acl_entry[i].ae_id);
+        __get_user(host_acl->acl_entry[i].ae_perm,
+            &target_acl->acl_entry[i].ae_perm);
+        __get_user(host_acl->acl_entry[i].ae_entry_type,
+            &target_acl->acl_entry[i].ae_entry_type);
+        __get_user(host_acl->acl_entry[i].ae_flags,
+            &target_acl->acl_entry[i].ae_flags);
+    }
+
+    unlock_user_struct(target_acl, target_addr, 0);
+    return 0;
+}
+
+abi_long h2t_freebsd_acl(abi_ulong target_addr, struct acl *host_acl)
+{
+    uint32_t i;
+    struct target_freebsd_acl *target_acl;
+
+    if (!lock_user_struct(VERIFY_WRITE, target_acl, target_addr, 0)) {
+        return -TARGET_EFAULT;
+    }
+
+    __put_user(host_acl->acl_maxcnt, &target_acl->acl_maxcnt);
+    __put_user(host_acl->acl_cnt, &target_acl->acl_cnt);
+
+    for (i = 0; i < host_acl->acl_maxcnt; i++) {
+        __put_user(host_acl->acl_entry[i].ae_tag,
+            &target_acl->acl_entry[i].ae_tag);
+        __put_user(host_acl->acl_entry[i].ae_id,
+            &target_acl->acl_entry[i].ae_id);
+        __put_user(host_acl->acl_entry[i].ae_perm,
+            &target_acl->acl_entry[i].ae_perm);
+        __get_user(host_acl->acl_entry[i].ae_entry_type,
+            &target_acl->acl_entry[i].ae_entry_type);
+        __get_user(host_acl->acl_entry[i].ae_flags,
+            &target_acl->acl_entry[i].ae_flags);
+    }
+
+    unlock_user_struct(target_acl, target_addr, 1);
+    return 0;
+}
+
+abi_long t2h_freebsd_acl_type(acl_type_t *host_type, abi_long target_type)
+{
+    acl_type_t type = tswap32(target_type);
+
+    switch (type) {
+    case TARGET_FREEBSD_ACL_TYPE_ACCESS_OLD:
+        *host_type = ACL_TYPE_ACCESS_OLD;
+        break;
+
+    case TARGET_FREEBSD_ACL_TYPE_DEFAULT_OLD:
+        *host_type = ACL_TYPE_DEFAULT_OLD;
+        break;
+
+    case TARGET_FREEBSD_ACL_TYPE_ACCESS:
+        *host_type = ACL_TYPE_ACCESS;
+        break;
+
+    case TARGET_FREEBSD_ACL_TYPE_DEFAULT:
+        *host_type = ACL_TYPE_ACCESS;
+        break;
+
+    case TARGET_FREEBSD_ACL_TYPE_NFS4:
+        *host_type = ACL_TYPE_NFS4;
+        break;
+
+    default:
+        return -TARGET_EINVAL;
+    }
+    return 0;
+}
+
diff --git a/bsd-user/freebsd/os-extattr.h b/bsd-user/freebsd/os-extattr.h
new file mode 100644
index 0000000..0cae8b0
--- /dev/null
+++ b/bsd-user/freebsd/os-extattr.h
@@ -0,0 +1,644 @@
+/*
+ *  FreeBSD extended attributes and ACL system call support
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/extattr.h>
+#ifndef _ACL_PRIVATE
+#define _ACL_PRIVATE
+#endif
+#include <sys/acl.h>
+
+#include "qemu-os.h"
+
+/* extattrctl() */
+static inline abi_long do_freebsd_extattrctl(abi_ulong arg1, abi_ulong arg2,
+        abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void *p, *a, *f;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    f = lock_user_string(arg3);
+    if (f == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg5);
+    if (a == NULL) {
+        unlock_user(f, arg3, 0);
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattrctl(path(p), arg2, f, arg4, a));
+    unlock_user(a, arg5, 0);
+    unlock_user(f, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_set_file(2) */
+static inline abi_long do_freebsd_extattr_set_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void *p, *a, *d;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    d = lock_user(VERIFY_READ, arg4, arg5, 1);
+    if (d == NULL) {
+        unlock_user(a, arg3, 0);
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattr_set_file(path(p), arg2, a, d, arg5));
+    unlock_user(d, arg4, arg5);
+    unlock_user(a, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_get_file(2) */
+static inline abi_long do_freebsd_extattr_get_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void *p, *a, *d;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    if (arg4 && arg5 > 0) {
+        d = lock_user(VERIFY_WRITE, arg4, arg5, 0);
+        if (d == NULL) {
+            unlock_user(a, arg3, 0);
+            unlock_user(p, arg1, 0);
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(extattr_get_file(path(p), arg2, a, d, arg5));
+        unlock_user(d, arg4, arg5);
+    } else {
+        ret = get_errno(extattr_get_file(path(p), arg2, a, NULL, arg5));
+    }
+    unlock_user(a, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_delete_file(2) */
+static inline abi_long do_freebsd_extattr_delete_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+    abi_long ret;
+    void *p, *a;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattr_delete_file(path(p), arg2, a));
+    unlock_user(a, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_set_fd(2) */
+static inline abi_long do_freebsd_extattr_set_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void *a, *d;
+
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        return -TARGET_EFAULT;
+    }
+    d = lock_user(VERIFY_READ, arg4, arg5, 1);
+    if (d == NULL) {
+        unlock_user(a, arg3, 0);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattr_set_fd(arg1, arg2, a, d, arg5));
+    unlock_user(d, arg4, arg5);
+    unlock_user(a, arg3, 0);
+
+    return ret;
+}
+
+/* extattr_get_fd(2) */
+static inline abi_long do_freebsd_extattr_get_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void *a, *d;
+
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        return -TARGET_EFAULT;
+    }
+
+    if (arg4 && arg5 > 0) {
+        d = lock_user(VERIFY_WRITE, arg4, arg5, 0);
+        if (d == NULL) {
+            unlock_user(a, arg3, 0);
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(extattr_get_fd(arg1, arg2, a, d, arg5));
+        unlock_user(d, arg4, arg5);
+    } else {
+        ret = get_errno(extattr_get_fd(arg1, arg2, a, NULL, arg5));
+    }
+    unlock_user(a, arg3, 0);
+
+    return ret;
+}
+
+/* extattr_delete_fd(2) */
+static inline abi_long do_freebsd_extattr_delete_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+    abi_long ret;
+    void *a;
+
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattr_delete_fd(arg1, arg2, a));
+    unlock_user(a, arg3, 0);
+
+    return ret;
+}
+
+/* extattr_get_link(2) */
+static inline abi_long do_freebsd_extattr_get_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void  *p, *a, *d;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    if (arg4 && arg5 > 0) {
+        d = lock_user(VERIFY_WRITE, arg4, arg5, 0);
+        if (d == NULL) {
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(extattr_get_link(path(p), arg2, a, d, arg5));
+        unlock_user(d, arg4, arg5);
+    } else {
+        ret = get_errno(extattr_get_link(path(p), arg2, a, NULL, arg5));
+    }
+    unlock_user(a, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_set_link(2) */
+static inline abi_long do_freebsd_extattr_set_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+    abi_long ret;
+    void  *p, *a, *d;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    d = lock_user(VERIFY_READ, arg4, arg5, 1);
+    if (d == NULL) {
+        unlock_user(a, arg3, 0);
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattr_set_link(path(p), arg2, a, d, arg5));
+    unlock_user(d, arg4, arg5);
+    unlock_user(a, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_delete_link(2) */
+static inline abi_long do_freebsd_extattr_delete_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+    abi_long ret;
+    void *p, *a;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    a = lock_user_string(arg3);
+    if (a == NULL) {
+        unlock_user(p, arg1, 0);
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(extattr_delete_link(path(p), arg2, a));
+    unlock_user(a, arg3, 0);
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_list_fd(2) */
+static inline abi_long do_freebsd_extattr_list_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3, abi_ulong arg4)
+{
+    abi_long ret;
+    void *d;
+
+    if (arg3 && arg4 > 0) {
+        d = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+        if (d == NULL) {
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(extattr_list_fd(arg1, arg2, d, arg4));
+        unlock_user(d, arg3, arg4);
+    } else {
+        ret = get_errno(extattr_list_fd(arg1, arg2, NULL, arg4));
+    }
+    return ret;
+}
+
+/* extattr_list_file(2) */
+static inline abi_long do_freebsd_extattr_list_file(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4)
+{
+    abi_long ret;
+    void *p, *d;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    if (arg3 && arg4 > 0) {
+        d = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+        if (d == NULL) {
+            unlock_user(p, arg1, 0);
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(extattr_list_file(path(p), arg2, d, arg4));
+        unlock_user(d, arg3, arg4);
+    } else {
+        ret = get_errno(extattr_list_file(path(p), arg2, NULL, arg4));
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* extattr_list_link(2) */
+static inline abi_long do_freebsd_extattr_list_link(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4)
+{
+    abi_long ret;
+    void *p, *d;
+
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    if (arg3 && arg4 > 0) {
+        d = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+        if (d == NULL) {
+            unlock_user(p, arg1, 0);
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(extattr_list_link(path(p), arg2, d, arg4));
+        unlock_user(d, arg3, arg4);
+    } else {
+        ret = get_errno(extattr_list_link(path(p), arg2, NULL, arg4));
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/*
+ *  Access Control Lists
+ */
+
+/* __acl_aclcheck_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_fd(abi_long arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+    abi_long ret;
+    struct acl host_acl;
+    acl_type_t type;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    ret = t2h_freebsd_acl(&host_acl, arg3);
+    if (!is_error(ret)) {
+        ret = get_errno(__acl_aclcheck_fd(arg1, type, &host_acl));
+    }
+
+    return ret;
+}
+
+/* __acl_aclcheck_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+    abi_long ret;
+    void *p;
+    struct acl host_acl;
+    acl_type_t type;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = t2h_freebsd_acl(&host_acl, arg3);
+    if (!is_error(ret)) {
+        ret = get_errno(__acl_aclcheck_file(path(p) , arg2, &host_acl));
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* __acl_aclcheck_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+    abi_long ret;
+    void *p;
+    struct acl host_acl;
+    acl_type_t type;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = t2h_freebsd_acl(&host_acl, arg3);
+    if (!is_error(ret)) {
+        ret = get_errno(__acl_aclcheck_link(path(p), type, &host_acl));
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* int __acl_delete_fd(int filedes, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_fd(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    acl_type_t type;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    return get_errno(__acl_delete_fd(arg1, type));
+}
+
+/* int __acl_delete_file(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_file(abi_ulong arg1,
+        abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+    acl_type_t type;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(__acl_delete_file(path(p), type));
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* int __acl_delete_link(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_link(abi_ulong arg1,
+        abi_long arg2)
+{
+    abi_long ret;
+    void *p;
+    acl_type_t type;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(__acl_delete_link(path(p), type));
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3)
+{
+    abi_long ret;
+    acl_type_t type;
+    struct acl host_acl;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    ret = get_errno(__acl_get_fd(arg1, type, &host_acl));
+    if (!is_error(ret)) {
+        ret = h2t_freebsd_acl(arg3, &host_acl);
+    }
+    return ret;
+}
+
+/* __acl_get_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_file(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+    abi_long ret;
+    void *p;
+    acl_type_t type;
+    struct acl host_acl;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(__acl_get_file(path(p), type, &host_acl));
+    if (!is_error(ret)) {
+        ret = h2t_freebsd_acl(arg3, &host_acl);
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_link(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+    abi_long ret;
+    void *p;
+    acl_type_t type;
+    struct acl host_acl;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(__acl_get_link(path(p), type, &host_acl));
+    if (!is_error(ret)) {
+        ret = h2t_freebsd_acl(arg3, &host_acl);
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3)
+{
+    abi_long ret;
+    acl_type_t type;
+    struct acl host_acl;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    ret = t2h_freebsd_acl(&host_acl, arg3);
+    if (!is_error(ret)) {
+        ret = get_errno(__acl_set_fd(arg1, type, &host_acl));
+    }
+
+    return ret;
+}
+
+/* int __acl_set_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_file(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+    abi_long ret;
+    void *p;
+    acl_type_t type;
+    struct acl host_acl;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = t2h_freebsd_acl(&host_acl, arg3);
+    if (!is_error(ret)) {
+        ret = get_errno(__acl_set_file(path(p), type, &host_acl));
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
+/* int __acl_set_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_link(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+    abi_long ret;
+    void *p;
+    acl_type_t type;
+    struct acl host_acl;
+
+    ret = t2h_freebsd_acl_type(&type, arg2);
+    if (is_error(ret)) {
+        return ret;
+    }
+    p = lock_user_string(arg1);
+    if (p == NULL) {
+        return -TARGET_EFAULT;
+    }
+    ret = t2h_freebsd_acl(&host_acl, arg3);
+    if (!is_error(ret)) {
+        ret = get_errno(__acl_set_link(path(p), type, &host_acl));
+    }
+    unlock_user(p, arg1, 0);
+
+    return ret;
+}
+
diff --git a/bsd-user/freebsd/qemu-os.h b/bsd-user/freebsd/qemu-os.h
index b5510dc..7d79e52 100644
--- a/bsd-user/freebsd/qemu-os.h
+++ b/bsd-user/freebsd/qemu-os.h
@@ -70,4 +70,10 @@ abi_long h2t_freebsd_rtprio(abi_ulong target_addr, struct rtprio *host_rtp);
 abi_long do_freebsd_thr_new(CPUArchState *env, abi_ulong target_param_addr,
         int32_t param_size);
 
+/* os-extattr.c */
+struct acl;
+abi_long t2h_freebsd_acl(struct acl *host_acl, abi_ulong target_addr);
+abi_long h2t_freebsd_acl(abi_ulong target_addr, struct acl *host_acl);
+abi_long t2h_freebsd_acl_type(acl_type_t *host_type, abi_long target_type);
+
 #endif /* !_QEMU_OS_H_ */
diff --git a/bsd-user/netbsd/os-extattr.h b/bsd-user/netbsd/os-extattr.h
new file mode 100644
index 0000000..c2f42ac
--- /dev/null
+++ b/bsd-user/netbsd/os-extattr.h
@@ -0,0 +1,247 @@
+/*
+ *  NetBSD extended attributes and ACL system call support
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* XXX To support FreeBSD targets the following will need to be added. */
+
+/* extattrctl() */
+static inline abi_long do_freebsd_extattrctl(abi_ulong arg1, abi_ulong arg2,
+        abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattrctl()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_set_file(2) */
+static inline abi_long do_freebsd_extattr_set_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_set_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_get_file(2) */
+static inline abi_long do_freebsd_extattr_get_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_get_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_delete_file(2) */
+static inline abi_long do_freebsd_extattr_delete_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_delete_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_set_fd(2) */
+static inline abi_long do_freebsd_extattr_set_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_set_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_get_fd(2) */
+static inline abi_long do_freebsd_extattr_get_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_get_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_delete_fd(2) */
+static inline abi_long do_freebsd_extattr_delete_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_delete_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_get_link(2) */
+static inline abi_long do_freebsd_extattr_get_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_get_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_set_link(2) */
+static inline abi_long do_freebsd_extattr_set_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_set_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_delete_link(2) */
+static inline abi_long do_freebsd_extattr_delete_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_delete_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_list_fd(2) */
+static inline abi_long do_freebsd_extattr_list_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3, abi_ulong arg4)
+{
+
+    qemu_log("qemu: Unsupported syscall exattr_list_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_list_file(2) */
+static inline abi_long do_freebsd_extattr_list_file(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_list_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_list_link(2) */
+static inline abi_long do_freebsd_extattr_list_link(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_list_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/*
+ *  Access Control Lists
+ */
+
+/* __acl_aclcheck_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_fd(abi_long arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_aclcheck_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* __acl_aclcheck_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_aclcheck_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* __acl_aclcheck_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_aclcheck_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_delete_fd(int filedes, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_fd(abi_long arg1, abi_long arg2)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_delete_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_delete_file(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_file(abi_ulong arg1,
+        abi_long arg2)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_delete_fil()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_delete_link(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_link(abi_ulong arg1,
+        abi_long arg2)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_delete_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_get_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* __acl_get_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_file(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_get_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_link(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall _acl_get_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_set_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_set_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_file(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_set_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_set_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_link(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_set_link()\n");
+    return -TARGET_ENOSYS;
+}
+
diff --git a/bsd-user/openbsd/os-extattr.h b/bsd-user/openbsd/os-extattr.h
new file mode 100644
index 0000000..5c23af3
--- /dev/null
+++ b/bsd-user/openbsd/os-extattr.h
@@ -0,0 +1,247 @@
+/*
+ *  OpenBSD extended attributes and ACL system call support
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* XXX To support FreeBSD targets the following will need to be added. */
+
+/* extattrctl() */
+static inline abi_long do_freebsd_extattrctl(abi_ulong arg1, abi_ulong arg2,
+        abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattrctl()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_set_file(2) */
+static inline abi_long do_freebsd_extattr_set_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_set_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_get_file(2) */
+static inline abi_long do_freebsd_extattr_get_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_get_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_delete_file(2) */
+static inline abi_long do_freebsd_extattr_delete_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_delete_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_set_fd(2) */
+static inline abi_long do_freebsd_extattr_set_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_set_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_get_fd(2) */
+static inline abi_long do_freebsd_extattr_get_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_get_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_delete_fd(2) */
+static inline abi_long do_freebsd_extattr_delete_fd(abi_long arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_delete_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_get_link(2) */
+static inline abi_long do_freebsd_extattr_get_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_get_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_set_link(2) */
+static inline abi_long do_freebsd_extattr_set_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4, abi_ulong arg5)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_set_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_delete_link(2) */
+static inline abi_long do_freebsd_extattr_delete_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_delete_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_list_fd(2) */
+static inline abi_long do_freebsd_extattr_list_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3, abi_ulong arg4)
+{
+
+    qemu_log("qemu: Unsupported syscall exattr_list_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_list_file(2) */
+static inline abi_long do_freebsd_extattr_list_file(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_list_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* extattr_list_link(2) */
+static inline abi_long do_freebsd_extattr_list_link(abi_long arg1,
+        abi_long arg2, abi_ulong arg3, abi_ulong arg4)
+{
+
+    qemu_log("qemu: Unsupported syscall extattr_list_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/*
+ *  Access Control Lists
+ */
+
+/* __acl_aclcheck_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_fd(abi_long arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_aclcheck_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* __acl_aclcheck_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_file(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_aclcheck_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* __acl_aclcheck_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_link(abi_ulong arg1,
+        abi_long arg2, abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_aclcheck_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_delete_fd(int filedes, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_fd(abi_long arg1, abi_long arg2)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_delete_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_delete_file(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_file(abi_ulong arg1,
+        abi_long arg2)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_delete_fil()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_delete_link(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_link(abi_ulong arg1,
+        abi_long arg2)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_delete_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_get_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* __acl_get_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_file(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_get_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_link(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall _acl_get_link()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_fd(abi_long arg1, abi_long arg2,
+        abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_set_fd()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_set_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_file(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_set_file()\n");
+    return -TARGET_ENOSYS;
+}
+
+/* int __acl_set_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_link(abi_ulong arg1, abi_long arg2,
+       abi_ulong arg3)
+{
+
+    qemu_log("qemu: Unsupported syscall __acl_set_link()\n");
+    return -TARGET_ENOSYS;
+}
+
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index 6cd7dbd..ab17f3f 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -42,6 +42,7 @@
 #include "bsd-socket.h"
 
 /* *BSD dependent syscall shims */
+#include "os-extattr.h"
 #include "os-time.h"
 #include "os-proc.h"
 #include "os-signal.h"
@@ -1204,6 +1205,109 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
                 arg5, arg6, arg7, arg8, 0);
         break;
 
+        /*
+         * extended attributes system calls
+         */
+    case TARGET_FREEBSD_NR_extattrctl: /* extattrctl() */
+        ret = do_freebsd_extattrctl(arg1, arg2, arg3, arg4, arg5);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_set_file: /* extattr_set_file(2) */
+        ret = do_freebsd_extattr_set_file(arg1, arg2, arg3, arg4, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_get_file: /* extattr_get_file(2) */
+        ret = do_freebsd_extattr_get_file(arg1, arg2, arg3, arg4, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_delete_file: /* extattr_delete_file(2) */
+        ret = do_freebsd_extattr_delete_file(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_set_fd: /* extattr_set_fd(2) */
+        ret = do_freebsd_extattr_set_fd(arg1, arg2, arg3, arg4, arg5);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_get_fd: /* extattr_get_fd(2) */
+        ret = do_freebsd_extattr_get_fd(arg1, arg2, arg3, arg4, arg5);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_delete_fd: /* extattr_delete_fd(2) */
+        ret = do_freebsd_extattr_delete_fd(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_get_link: /* extattr_get_link(2) */
+        ret = do_freebsd_extattr_get_link(arg1, arg2, arg3, arg4, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_set_link: /* extattr_set_link(2) */
+        ret = do_freebsd_extattr_set_link(arg1, arg2, arg3, arg4, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_delete_link: /* extattr_delete_link(2) */
+        ret = do_freebsd_extattr_delete_link(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_list_fd: /* extattr_list_fd(2) */
+        ret = do_freebsd_extattr_list_fd(arg1, arg2, arg3, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_list_file: /* extattr_list_file(2) */
+        ret = do_freebsd_extattr_list_file(arg1, arg2, arg3,  arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_extattr_list_link: /* extattr_list_link(2) */
+        ret = do_freebsd_extattr_list_link(arg1, arg2, arg3, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_aclcheck_fd: /* __acl_aclcheck_fd() */
+        ret = do_freebsd__acl_aclcheck_fd(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_aclcheck_file: /* __acl_aclcheck_file() */
+        ret = do_freebsd__acl_aclcheck_file(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_aclcheck_link: /* __acl_aclcheck_link() */
+        ret = do_freebsd__acl_aclcheck_link(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_delete_fd: /* __acl_delete_fd() */
+        ret = do_freebsd__acl_delete_fd(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_delete_file: /* __acl_delete_file() */
+        ret = do_freebsd__acl_delete_file(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_delete_link: /* __acl_delete_link() */
+        ret = do_freebsd__acl_delete_link(arg1, arg2);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_get_fd: /* __acl_get_fd() */
+        ret =  do_freebsd__acl_get_fd(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_get_file: /* __acl_get_file() */
+        ret = do_freebsd__acl_get_file(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_get_link: /* __acl_get_link() */
+        ret = do_freebsd__acl_get_link(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_set_fd: /* __acl_get_fd() */
+        ret = do_freebsd__acl_set_fd(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_set_file: /* __acl_set_file() */
+        ret = do_freebsd__acl_set_file(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR___acl_set_link: /* __acl_set_link() */
+        ret = do_freebsd__acl_set_link(arg1, arg2, arg3);
+        break;
+
     default:
         ret = get_errno(syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
                     arg8));
-- 
1.7.8

  parent reply	other threads:[~2013-10-16 14:38 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 14:36 [Qemu-devel] [PATCH 00/18] bsd-user: Add system call and mips/arm support Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 01/18] bsd-user: refresh freebsd system call numbers Stacey Son
2013-10-24  1:22   ` Ed Maste
2013-10-16 14:36 ` [Qemu-devel] [PATCH 02/18] bsd-user: add HOST_ABI_DIR for the various *BSD dependent code Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 03/18] bsd-user: move OS/arch dependent code for strace into separate directories Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 04/18] bsd-user: move target arch and host OS dependent code out of main.c Stacey Son
2013-10-16 15:38   ` [Qemu-devel] [PATCH 04/18] bsd-user: move target arch and host OSdependent code out of main.cc Alex Bennée
2013-10-16 15:46     ` Stacey Son
2013-10-16 16:32       ` Peter Maydell
2013-10-17 19:07         ` Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 05/18] bsd-user: move target arch and host OS dependent code out of syscall.c Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 06/18] bsd-user: add support for freebsd time related system calls Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 07/18] bsd-user: add support for freebsd signal " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 08/18] bsd-user: move target arch and host OS dependent code out of elfload.c Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 09/18] bsd-user: add support for freebsd process related system calls Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 10/18] bsd-user: add support for file system " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 11/18] bsd-user: add support for stat, directory, and file control " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 12/18] bsd-user: add support for memory management " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 13/18] bsd-user: add support for socket " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 14/18] bsd-user: add support for thread " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 15/18] bsd-user: add support for the ioctl system call Stacey Son
2013-10-16 14:37 ` Stacey Son [this message]
2014-01-27 20:11   ` [Qemu-devel] [PATCH 16/18] bsd-user: add support for extended attribute and ACL related syscalls Peter Maydell
2013-10-16 14:37 ` [Qemu-devel] [PATCH 17/18] bsd-user: add support for miscellaneous system calls Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 18/18] bsd-user: add arm, mips and mips64 options to configure target-list Stacey Son
2013-10-16 15:22   ` [Qemu-devel] [PATCH 18/18] bsd-user: add arm, mips and mips64 options to configure target-listt Alex Bennée
2013-10-16 16:12     ` Stacey Son
2013-10-16 16:31     ` Peter Maydell
2013-10-16 16:26   ` [Qemu-devel] [PATCH 18/18] bsd-user: add arm, mips and mips64 options to configure target-list Peter Maydell
2013-10-16 15:27 ` [Qemu-devel] [PATCH 00/18] bsd-user: Add system call and mips/armsupport Alex Bennée
2013-10-16 15:40   ` Stacey Son
2013-10-16 16:29 ` [Qemu-devel] [PATCH 00/18] bsd-user: Add system call and mips/arm support Peter Maydell
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 00/19] " Stacey Son
2013-11-26 21:01   ` Ed Maste
2013-11-27 11:29     ` Paolo Bonzini
2013-12-12 19:57       ` Ed Maste
2013-12-12 20:15         ` Stacey Son
2013-12-13 12:44         ` Paolo Bonzini
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 " Stacey Son
2014-01-27 19:15     ` Peter Maydell
2014-01-27 19:27       ` Stacey Son
2014-01-27 20:18         ` Peter Maydell
2014-05-08 14:59           ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 01/19] bsd-user: refresh freebsd system call numbers Stacey Son
2014-01-27 19:30     ` Peter Maydell
2014-02-01 12:11       ` Ed Maste
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 02/19] bsd-user: add HOST_VARIANT_DIR for various *BSD dependent code Stacey Son
2014-01-27 19:31     ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 03/19] bsd-user: move strace OS/arch dependent code to host/arch dirs Stacey Son
2014-01-27 19:46     ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 04/19] bsd-user: move arch/OS dependent code out of main.c Stacey Son
2014-01-27 19:50     ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 05/19] bsd-user: move arch/OS dependent code out of syscall.c Stacey Son
2014-01-27 19:52     ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 06/19] bsd-user: add support for freebsd time related system calls Stacey Son
2014-01-27 19:58     ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 07/19] bsd-user: add support for freebsd signal " Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 08/19] bsd-user: move arch/OS dependent code out of elfload.c Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 09/19] bsd-user: add support for freebsd process related system calls Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 10/19] bsd-user: add support for file system " Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 11/19] bsd-user: add support for stat, dir, and fcntl related syscalls Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 12/19] bsd-user: add support for memory management " Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 13/19] bsd-user: add support for socket related system calls Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 14/19] bsd-user: add support for thread " Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 15/19] bsd-user: add support for the ioctl system call Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 16/19] bsd-user: add support for extattr and ACL related syscalls Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 17/19] bsd-user: add support for miscellaneous system calls Stacey Son
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 18/19] bsd-user: add arm, mips and mips64 options to configure target-list Stacey Son
2014-01-27 20:03     ` Peter Maydell
2013-12-17 11:52   ` [Qemu-devel] [PATCH v3 19/19] bsd-user: fix linking conflicts with FreeBSD libcrypto Stacey Son
2014-01-27 20:07     ` Peter Maydell
2014-01-27 20:15       ` Stacey Son
2014-01-28 10:17       ` Paolo Bonzini
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 01/19] bsd-user: refresh freebsd system call numbers Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 02/19] bsd-user: add HOST_ABI_DIR for the various *BSD dependent code Stacey Son
2013-11-27 11:27   ` Paolo Bonzini
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 03/19] bsd-user: move OS/arch dependent code for strace into separate directories Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 04/19] bsd-user: move target arch and host OS dependent code out of main.c Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 05/19] bsd-user: move target arch and host OS dependent code out of syscall.c Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 06/19] bsd-user: add support for freebsd time related system calls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 07/19] bsd-user: add support for freebsd signal " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 08/19] bsd-user: move target arch and host OS dependent code out of elfload.c Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 09/19] bsd-user: add support for freebsd process related system calls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 10/19] bsd-user: add support for file system " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 11/19] bsd-user: add support for stat, directory, and file control " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 12/19] bsd-user: add support for memory management " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 13/19] bsd-user: add support for socket " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 14/19] bsd-user: add support for thread " Stacey Son
2013-11-27 11:28   ` Paolo Bonzini
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 15/19] bsd-user: add support for the ioctl system call Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 16/19] bsd-user: add support for extended attribute and ACL related syscalls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 17/19] bsd-user: add support for miscellaneous system calls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 18/19] bsd-user: add arm, mips and mips64 options to configure target-list Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 19/19] bsd-user: fix linking conflicts with FreeBSD libcrypto Stacey Son
2013-11-27 11:23   ` Paolo Bonzini

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=1381934232-55158-17-git-send-email-sson@FreeBSD.org \
    --to=sson@freebsd.org \
    --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).