From patchwork Sun Jun 19 18:05:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=GKUN5qB1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR11d0wR4z9sFx for ; Mon, 20 Jun 2022 04:06:28 +1000 (AEST) Received: from localhost ([::1]:50930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zJZ-0000uJ-4X for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:06:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIS-0000sL-Ug for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:16 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]:35693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIR-0001Kf-88 for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:16 -0400 Received: by mail-io1-xd2f.google.com with SMTP id y79so9138565iof.2 for ; Sun, 19 Jun 2022 11:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Az+dT+4hpKTWFpzpvd6dSLcOyh/SnPbqA6UEA7oKevo=; b=GKUN5qB1vMUBpg7QPZQs2Ro2LqRU47/Hhrsq5x1xOInOHFEQULAI7e0q3LQMAbxzHy hTU28sh4U6aW7HiVcP5QiCIbcUagcwJTJsmyo5kXm4o6mJPl9cbw3SA7rk3lZo67XD3u H/voIRkBN4IVxs/SCrTwocQTtNnU5J+rMA2HCdUd7SY6XwM19mBXggCKaljJiA3Wvn8c GkNNiOQ3j8YCAMgXUrkn0BiwqgJHhJ7Bmg+xd4s3/1STJ5dDmy7toj6k97Pv1HL+mUxf gbQqTu1NqrhvcdY58XQYFqoHBwPuxFBf6GyVJRPrlE46CUXqlSWyBgZo1g7MxZxbSHwy /k7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Az+dT+4hpKTWFpzpvd6dSLcOyh/SnPbqA6UEA7oKevo=; b=PEKmUsGgdo5wQagpb5x/YxPT37jNv9A91E7JcCXwrlbN7YCKw3qaww6VjatrZND36T Nj3E+XvvL5a+jqQcu0uj9GDzHLDjZVImQUWnlKK01e0eTOVc5AIUDfbx/VLBIsZF3txU btLqd1LJsUKaAO6InhCxlJXS+vQcvvoloHnxA11PhL10rd351kVNON6RPBHz4wiY1UcJ kOoUNCZ22opSKiypoqtRDbyKDJy7OdLeyb8Na5MV8M9iE5YcB5Q4q65QRmaqjCVANDe9 VWJoA2u3ETtVCIIXzE6ByFFq8NtZdvpMxHmv86KWDaJ46mQjKoypvAffI2qXGUrNVqRp UoPw== X-Gm-Message-State: AJIora+GikvHbqXgTfQeWix7BJxwCHLUXT1LC/m3rgREKu2Bhs+gkD7o wkPx0KV1VtT19jnp1O68D7r96SO0UlGbBw== X-Google-Smtp-Source: AGRyM1tpQQOq+IltcLHFMUX656jSjU6tt/khyTeahVmxCHP6hLeX8/V9bNQdVa5jdqNmPYAnaP6iBg== X-Received: by 2002:a05:6638:24cf:b0:331:7674:8b3a with SMTP id y15-20020a05663824cf00b0033176748b3amr10455343jat.35.1655661913962; Sun, 19 Jun 2022 11:05:13 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:13 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son , Jung-uk Kim , Kyle Evans Subject: [PULL 01/11] bsd-user: Implement open, openat and close Date: Sun, 19 Jun 2022 12:05:21 -0600 Message-Id: <20220619180531.9161-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add the open, openat and close system calls. We need to lock paths, so implmenent that as well. Signed-off-by: Stacey Son Signed-off-by: Jung-uk Kim Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 49 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 16 ++++++++++++ bsd-user/syscall_defs.h | 4 +++ 3 files changed, 69 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index e9e2c85eb67..2bd312f8e18 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -22,11 +22,25 @@ #include "qemu/path.h" +#define LOCK_PATH(p, arg) \ +do { \ + (p) = lock_user_string(arg); \ + if ((p) == NULL) { \ + return -TARGET_EFAULT; \ + } \ +} while (0) + +#define UNLOCK_PATH(p, arg) unlock_user(p, arg, 0) + + 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, int copy); +int safe_open(const char *path, int flags, mode_t mode); +int safe_openat(int fd, const char *path, int flags, mode_t mode); + ssize_t safe_read(int fd, void *buf, size_t nbytes); ssize_t safe_pread(int fd, void *buf, size_t nbytes, off_t offset); ssize_t safe_readv(int fd, const struct iovec *iov, int iovcnt); @@ -190,4 +204,39 @@ static abi_long do_bsd_pwritev(void *cpu_env, abi_long arg1, return ret; } +/* open(2) */ +static abi_long do_bsd_open(abi_long arg1, abi_long arg2, abi_long arg3) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(safe_open(path(p), target_to_host_bitmask(arg2, + fcntl_flags_tbl), arg3)); + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* openat(2) */ +static abi_long do_bsd_openat(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg2); + ret = get_errno(safe_openat(arg1, path(p), + target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4)); + UNLOCK_PATH(p, arg2); + + return ret; +} + +/* close(2) */ +static inline abi_long do_bsd_close(abi_long arg1) +{ + return get_errno(close(arg1)); +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 71aa0d38e03..a824785fee8 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -44,6 +44,10 @@ #include "bsd-proc.h" /* I/O */ +safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); +safe_syscall4(int, openat, int, fd, const char *, path, int, flags, mode_t, + mode); + safe_syscall3(ssize_t, read, int, fd, void *, buf, size_t, nbytes); safe_syscall4(ssize_t, pread, int, fd, void *, buf, size_t, nbytes, off_t, offset); @@ -257,6 +261,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_pwritev(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); break; + case TARGET_FREEBSD_NR_open: /* open(2) */ + ret = do_bsd_open(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_openat: /* openat(2) */ + ret = do_bsd_openat(arg1, arg2, arg3, arg4); + break; + + case TARGET_FREEBSD_NR_close: /* close(2) */ + ret = do_bsd_close(arg1); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index f5797b28e39..b6d113d24a7 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -226,4 +226,8 @@ type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ } +/* So far all target and host bitmasks are the same */ +#define target_to_host_bitmask(x, tbl) (x) +#define host_to_target_bitmask(x, tbl) (x) + #endif /* SYSCALL_DEFS_H */ From patchwork Sun Jun 19 18:05:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=hI9W5kJJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR11b483Bz9s5V for ; Mon, 20 Jun 2022 04:06:27 +1000 (AEST) Received: from localhost ([::1]:50912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zJZ-0000tL-AI for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:06:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIU-0000sf-5B for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:18 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]:37787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIS-0001Kk-Jp for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:17 -0400 Received: by mail-io1-xd30.google.com with SMTP id n11so9137285iod.4 for ; Sun, 19 Jun 2022 11:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hArKZ9FFGMf88kVfdfvsuQyXRHILT3Hqc9FQtOYlbzA=; b=hI9W5kJJ5xh1S+YVQR0bxiP7aTbyU6Mz+MV+WnX+3H7EgKvom8xWMMR75IMtNNcvYJ kng1WBa8gOy4zELTKwINRDUnQv13XNEARYmFgZy9TDbEwr8bPpYHa56LWXnRmYuwE6MW nIg1PHcbigu8YaqKR7jK87j+6KluhfTwX3cSFtq94i5DoIBUpFOU97kVM03bWecTB2mD Se+ay+jG2GzPbLGRIcMNmzxvs0tUjrzHeMg/ofhL/q+Yrw5xfzzQjPcr/LwVJ7QZZldP f8LRHe14TRpUAluXWaeoT1zu4vkDcqSO8AFb7ex08CdjoWQxaViSEntNPq1w4C3aXroW 5/Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hArKZ9FFGMf88kVfdfvsuQyXRHILT3Hqc9FQtOYlbzA=; b=tqbRUOntAyyRLLdLZZZlqiRtJIxQ76pYN7sEvrn+KdeALBncqgDTe2jWGtoU2OkVO5 Sw/xnf6iOsIoubDoyMWjbhwTHWET3eFxv3ft6Lx2Bgfoy2x7JcJR6MhfB3VBmojZ889h w36XW0dyHv4HQS9J0+YFhLU6c0WMgHAWg4LKidlr+WP1CYoQl+cUopbSuJool9Xw7nAE N1zdwUCJrOcf3Mrc2qD2iDIvORKHXLzFNLefkFQrY3iWZrIeyskdsg0FmQSRRCiVhrlj hICO9U5VsnHj1K3FLaVayenJASGJZIuXD8ZdARdqov6nveoHcX7rBEoNRHtJZxDe8zJZ chfg== X-Gm-Message-State: AJIora+j6Wz5VOEZscb8DE4EHMh0fK6wvNNY1EImskbycoUmoppw1gNp s3b9c8gNWFav/KUjRbXyZUNIFNW++iVtNw== X-Google-Smtp-Source: AGRyM1tONS75T6+8Z9d+IZSzF/j/uPn+AkNZXruFLdQW1by3XUII/dcj6nkyMAJ0ZwWvcOkdLd8b+A== X-Received: by 2002:a05:6602:3d2:b0:65d:c151:f29f with SMTP id g18-20020a05660203d200b0065dc151f29fmr10111901iov.28.1655661915248; Sun, 19 Jun 2022 11:05:15 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:14 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son , Jung-uk Kim Subject: [PULL 02/11] bsd-user: Implement fdatasync, fsync and close_from Date: Sun, 19 Jun 2022 12:05:22 -0600 Message-Id: <20220619180531.9161-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Implement fdatasync(2), fsync(2) and close_from(2). Signed-off-by: Stacey Son Signed-off-by: Jung-uk Kim Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 19 +++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 2bd312f8e18..94eb03df62e 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -239,4 +239,23 @@ static inline abi_long do_bsd_close(abi_long arg1) return get_errno(close(arg1)); } +/* fdatasync(2) */ +static abi_long do_bsd_fdatasync(abi_long arg1) +{ + return get_errno(fdatasync(arg1)); +} + +/* fsync(2) */ +static abi_long do_bsd_fsync(abi_long arg1) +{ + return get_errno(fsync(arg1)); +} + +/* closefrom(2) */ +static abi_long do_bsd_closefrom(abi_long arg1) +{ + closefrom(arg1); /* returns void */ + return get_errno(0); +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index a824785fee8..f7d09909925 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -273,6 +273,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_close(arg1); break; + case TARGET_FREEBSD_NR_fdatasync: /* fdatasync(2) */ + ret = do_bsd_fdatasync(arg1); + break; + + case TARGET_FREEBSD_NR_fsync: /* fsync(2) */ + ret = do_bsd_fsync(arg1); + break; + + case TARGET_FREEBSD_NR_freebsd12_closefrom: /* closefrom(2) */ + ret = do_bsd_closefrom(arg1); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=ytdNeYZ8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR1512Pmjz9s5V for ; Mon, 20 Jun 2022 04:09:24 +1000 (AEST) Received: from localhost ([::1]:59410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zMQ-0006kT-MO for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:09:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIV-0000st-1T for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:19 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]:46043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIT-0001L3-M6 for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:18 -0400 Received: by mail-io1-xd30.google.com with SMTP id 19so9110256iou.12 for ; Sun, 19 Jun 2022 11:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uedUQ2KHIZe9tCAw1aTgfSJGduq3Rf0+S18JxCMy0Hg=; b=ytdNeYZ8Qbd15JVJhZYzsuj1nzOAAWTtiKj4L70Ux6UOPmTyjEzBpo748DnCH2JCqg Pcsf24WUxBMblNv4G6R3ZBKD3flKzyZIXAu+gZPaBUpavBH5Wgbgrq4H+1ik3dLrdF8T bsvucryWv+0Tvi4cpvG2F+tL7Bg7XSHqeLeskn3zpLRgnx7LhwjNeHVUHbcvvbcP6AVt VG83tfk/7kuE6fXquUKxJlofJ4Jo9YBnbthOiG2Fmqfr5iRSnogXCpnroLVCEpuAg2Qw J2rII7d/wlotwrsH2bPpul45rvMZKO/l0vA7Deet65mgIfK6qPflVo4YCpn0EOFq1HNn 2Kyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uedUQ2KHIZe9tCAw1aTgfSJGduq3Rf0+S18JxCMy0Hg=; b=U0EQbWPGUw57tgyZt/eX0whA+nGWq9DZ4FfSq8IgQLWBpMlSLon02xxyIE9Nmlgmf7 NTyo+z2ycfeJxkrTR0Ox7xU7n/6N2qJTIhuDDz2A4i9TMnsJuKUSk6Q6t4fu8tOBc9m/ wsqOUVFi4fYThEvk4zYlaP4ZkK7rm5ZTpV+wHSXqhgb9DCB94DrhDOg4qjU90Q31HO+/ wWVo/DwKAMv99PpknnHp2t4NJIFCZbU94wMOmAUYNrcimRuHBfkcDjUk/i2mlrp9wDnS mBJYp8fpo2MRixNza+RJQNYLiVYaysRlVqEmHGGWqD1PCIr++z8wqKxTDRElTuPJ/jZI MFcg== X-Gm-Message-State: AJIora+lFolPtTF6Voo0Jkk1tmdQxW85XKGFJijIuEDAoQNWfn5tkVyT D6Tmz++VHbuZZuNKEVSmdUGZQ2arNurWIg== X-Google-Smtp-Source: AGRyM1uYQq1iHDqLs+V3tzdNxERSnfhVcUBYHKvOYSjBMDD3FlYOtm48qZ7SgX6NTl7V3iGwosRAsw== X-Received: by 2002:a05:6638:238b:b0:332:2816:62f2 with SMTP id q11-20020a056638238b00b00332281662f2mr11283697jat.106.1655661916518; Sun, 19 Jun 2022 11:05:16 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:16 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son Subject: [PULL 03/11] bsd-user: Implement revoke, access, eaccess and faccessat Date: Sun, 19 Jun 2022 12:05:23 -0600 Message-Id: <20220619180531.9161-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 53 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 16 +++++++++++ 2 files changed, 69 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 94eb03df62e..6ff2be24e30 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -258,4 +258,57 @@ static abi_long do_bsd_closefrom(abi_long arg1) return get_errno(0); } +/* revoke(2) */ +static abi_long do_bsd_revoke(abi_long arg1) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(revoke(p)); /* XXX path(p)? */ + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* access(2) */ +static abi_long do_bsd_access(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(access(path(p), arg2)); + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* eaccess(2) */ +static abi_long do_bsd_eaccess(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(eaccess(path(p), arg2)); + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* faccessat(2) */ +static abi_long do_bsd_faccessat(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg2); + ret = get_errno(faccessat(arg1, p, arg3, arg4)); /* 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 f7d09909925..7b7af914e49 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -285,6 +285,22 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_closefrom(arg1); break; + case TARGET_FREEBSD_NR_revoke: /* revoke(2) */ + ret = do_bsd_revoke(arg1); + break; + + case TARGET_FREEBSD_NR_access: /* access(2) */ + ret = do_bsd_access(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_eaccess: /* eaccess(2) */ + ret = do_bsd_eaccess(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_faccessat: /* faccessat(2) */ + ret = do_bsd_faccessat(arg1, arg2, arg3, arg4); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=mw0blYWm; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR11m6k2kz9s5V for ; Mon, 20 Jun 2022 04:06:36 +1000 (AEST) Received: from localhost ([::1]:51004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zJi-0000ya-Pu for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:06:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIW-0000ui-GW for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:21 -0400 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]:36486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIV-0001LD-2O for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:20 -0400 Received: by mail-il1-x133.google.com with SMTP id h5so3946343ili.3 for ; Sun, 19 Jun 2022 11:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9QIqkwwLRQpn8xMyw5K6t843YHf8OffHXasVl+JrrV8=; b=mw0blYWmkjfQOzIBxuoLPTDkWqKNUMfutAJUJiMyh+xTBWLdrQkdZVBvltloQNmxg4 SyqMYnfPgcwA6lukkuUXOYCyu9PwP56Ca3kcYbaDdtnRdt0zk8W1VBcOwC3RvXIKBaMA sUy4OC3t2CvO7nAzKHzGqesAlk5BNBCJ1V6iHJIYyhyShvSD8XurCMuj8uWd7CJxfJvX 8ZMEwE6k5DT+Cb1nKLkkB025fswR7niKHgfuSloFJSywsUMrTI1Gw9IeziUzBuu7Mned yGgWBXCE0m89cSGU1nnyTcp9WCZCmNHtwJjqZDRd/OfEtpTyhATonalwMA086I+z+hIA mUYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9QIqkwwLRQpn8xMyw5K6t843YHf8OffHXasVl+JrrV8=; b=JYRmLQwVud4x3u6P26VU3BuvNj4P/p9Yr+z8kpIXNvuJ0awFKzVU9X5TiWsyGREX0n WO07XzkAQ6a8Mk2xjZ64awHUXiaYcfBjbfk+Pd1Z6AfDai/raCnz/uGaolgv3zCo0gnj T6xp7NyD5RV9GX07rMWfYvw9Hbz+ARGO5QywY44SMe7UzVmcfLH+w7GA8/NT1+9f067A aNP8EALxHtmmu2lhnkl+DYmv2wmnQU2HgmsJ4qxd/g/8UAiQ7tHLhdk/2n/Z9S37ZHBX m7Arz6DVZS0znQ7lu92FYinQZlChB32we4WmBjRQ81F0WKP5PGVO9oNbWmcCTaUgQVmx gAKQ== X-Gm-Message-State: AJIora9cMYr57v2o82/DSCb674teNX/mbOCS6dZ59AE3iI8UQ+Tvgvlv lfNRkbFfg4JlqV1RCKrAz3MhDnXPcFrUTg== X-Google-Smtp-Source: AGRyM1t//G0Ky/dQkssWs3lJ57hmGDZEsBJAGAppGtFNkCnbjPe9dD+Ncho42dL7+3szrXR2diIaCg== X-Received: by 2002:a05:6e02:1ca6:b0:2d8:f599:dbf0 with SMTP id x6-20020a056e021ca600b002d8f599dbf0mr4782077ill.200.1655661917755; Sun, 19 Jun 2022 11:05:17 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:17 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son Subject: [PULL 04/11] bsd-user: Implement chdir and fchdir Date: Sun, 19 Jun 2022 12:05:24 -0600 Message-Id: <20220619180531.9161-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::133; envelope-from=imp@bsdimp.com; helo=mail-il1-x133.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- 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 6ff2be24e30..bc0a0c08d55 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -311,4 +311,23 @@ static abi_long do_bsd_faccessat(abi_long arg1, abi_long arg2, return ret; } +/* chdir(2) */ +static abi_long do_bsd_chdir(abi_long arg1) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(chdir(p)); /* XXX path(p)? */ + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* fchdir(2) */ +static abi_long do_bsd_fchdir(abi_long arg1) +{ + return get_errno(fchdir(arg1)); +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7b7af914e49..8698db358c1 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -301,6 +301,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_faccessat(arg1, arg2, arg3, arg4); break; + case TARGET_FREEBSD_NR_chdir: /* chdir(2) */ + ret = do_bsd_chdir(arg1); + break; + + case TARGET_FREEBSD_NR_fchdir: /* fchdir(2) */ + ret = do_bsd_fchdir(arg1); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=g867M0jE; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR17g2b2hz9s5V for ; Mon, 20 Jun 2022 04:11:41 +1000 (AEST) Received: from localhost ([::1]:37934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zOc-0002tH-Au for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIX-0000vZ-QK for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:22 -0400 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]:46822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIW-0001LO-Ai for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:21 -0400 Received: by mail-il1-x132.google.com with SMTP id y16so6064399ili.13 for ; Sun, 19 Jun 2022 11:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S40P6qQAunc27gypcFnqBEY9H0MtkqO3VN60QRRCW2w=; b=g867M0jEImjZr6XwLkBEvlZRSG2m6jVSxg1oGfxZeFWM2CKlLSoaEiuDOBYFysjpdm 9h5uS+rHtHZ8vascNhIPhBi8Piy6b9i1nQg6h8jcSOKodxxsMFZFarGpNl7bQeGtonsL m9VFMqa+w9PDffNUjkR3kZriOC44bT4fmhoGJJgOF/n2ijHQwA1R4PZMRpdmI9Umo+ug DcU0siU4YsUDE2mwWYOuNNw3RS90stHkuncEvV0vPGDx3dnoxfEk3LVlX9XyUULq9YuB ElpPawwI3fU0XegfYRgJxcqn6BxtMUD3rCvAf6wkkjnpA3/4M+X5wYv1p2g4bKKgaEZM uw7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S40P6qQAunc27gypcFnqBEY9H0MtkqO3VN60QRRCW2w=; b=BMesQrCQk664i0KZe6+qmWrcUT7+oH4ul52tV72xJwIVQXKInJg5rFgf+1h/DHfbZ6 tQw+lHAOWCJGElaQL20xZfeBC4Ql03kQw5FVaXRrDZTq/S0lf32zYpbH2zgPLV8j/h/S b7zyFls+dBvdtE1Pc+WeB/3hTGfSRNy4G7oa8yzOIgvQL2qNR5Cm5KS73qsrmDEyWxpp w6SrJiRbALZDLxFIOOXMJdeJpHFcUavnF61NlzOvh7ihRkEwfno6LyBHIZk9tNVSVMsn C6a3UXQKPnIZOjbe2YLuu37g7Ez/4VS0mrG2mTdZ3SeQ52V2sAUnCiUUmsnqntBxptcY 7gQg== X-Gm-Message-State: AJIora8msvhw8Lqktrn/k89l2Imy9+S2FcxbzkvbrkV1gFvd8H3RLOKC nDOgaTZgT+VOlZ8IMrpPHwHhk/JwYy7mLg== X-Google-Smtp-Source: AGRyM1tPIJp7viw2HNFp9yPdiNdAwiCzlnvwQsECXTqkWuRJsHdObPv52v274gAC9VU7hIetOjHNTA== X-Received: by 2002:a05:6e02:1905:b0:2d3:d327:6c7b with SMTP id w5-20020a056e02190500b002d3d3276c7bmr11509241ilu.101.1655661918895; Sun, 19 Jun 2022 11:05:18 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:18 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son , Jung-uk Kim Subject: [PULL 05/11] bsd-user: Implement rename and renameat Date: Sun, 19 Jun 2022 12:05:25 -0600 Message-Id: <20220619180531.9161-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::132; envelope-from=imp@bsdimp.com; helo=mail-il1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Plus the helper LOCK_PATH2 and UNLOCK_PATH2 macros. Signed-off-by: Stacey Son Signed-off-by: Jung-uk Kim Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 45 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 +++++++ 2 files changed, 53 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index bc0a0c08d55..fd8aba96180 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -32,6 +32,24 @@ do { \ #define UNLOCK_PATH(p, arg) unlock_user(p, arg, 0) +#define LOCK_PATH2(p1, arg1, p2, arg2) \ +do { \ + (p1) = lock_user_string(arg1); \ + if ((p1) == NULL) { \ + return -TARGET_EFAULT; \ + } \ + (p2) = lock_user_string(arg2); \ + if ((p2) == NULL) { \ + unlock_user(p1, arg1, 0); \ + return -TARGET_EFAULT; \ + } \ +} while (0) + +#define UNLOCK_PATH2(p1, arg1, p2, arg2) \ +do { \ + unlock_user(p2, arg2, 0); \ + unlock_user(p1, arg1, 0); \ +} while (0) extern struct iovec *lock_iovec(int type, abi_ulong target_addr, int count, int copy); @@ -330,4 +348,31 @@ static abi_long do_bsd_fchdir(abi_long arg1) return get_errno(fchdir(arg1)); } +/* rename(2) */ +static abi_long do_bsd_rename(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p1, *p2; + + LOCK_PATH2(p1, arg1, p2, arg2); + ret = get_errno(rename(p1, p2)); /* XXX path(p1), path(p2) */ + UNLOCK_PATH2(p1, arg1, p2, arg2); + + return ret; +} + +/* renameat(2) */ +static abi_long do_bsd_renameat(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4) +{ + abi_long ret; + void *p1, *p2; + + LOCK_PATH2(p1, arg2, p2, arg4); + ret = get_errno(renameat(arg1, p1, arg3, p2)); + UNLOCK_PATH2(p1, arg2, p2, arg4); + + return ret; +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 8698db358c1..2d62a546328 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -309,6 +309,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_fchdir(arg1); break; + case TARGET_FREEBSD_NR_rename: /* rename(2) */ + ret = do_bsd_rename(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_renameat: /* renameat(2) */ + ret = do_bsd_renameat(arg1, arg2, arg3, arg4); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=BwT403YB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR1544FBlz9sG2 for ; Mon, 20 Jun 2022 04:09:26 +1000 (AEST) Received: from localhost ([::1]:59578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zMS-0006rG-Jv for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:09:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIY-0000vc-I6 for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:22 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]:35693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIX-0001Kf-5E for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:22 -0400 Received: by mail-io1-xd2f.google.com with SMTP id y79so9138565iof.2 for ; Sun, 19 Jun 2022 11:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4lp3jEo9v2BadFnXv+3JFzH727s9UtBSFIowCjnWXXo=; b=BwT403YBjYVJSA6WGHPiTdAc/NiWpg8+UHQ3NGsPvncztoFKQObaPXQvKdKgSUkkOC 44NDQ1Yfv7HbU2h5I4yA4gZgf4SfUFklGBdUiNDrLjS/nQsoc1Hdb9xW1R2gryyA6v8S t1MsRu4txALx/kAnKocWTOxV1xs1avm0ZeCmz1j11Yy7/ssHBDKfMVhmAoEULi/fOb5u qIXl4Ep6FChcye++nvzIj8j2IamS+zKe7kgw1SDb2gikAmOsrl2f92Ei3hKYDn9F8bKL A86clHn/XyicUqx+kCThVr2JzOgwFZtLkOlGKp2FCCGwLi3h76yyfu+jtbNfKn9gM5ob E7cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4lp3jEo9v2BadFnXv+3JFzH727s9UtBSFIowCjnWXXo=; b=Y/WARtvSurecHuOXgGFCcAzloPUPm9wd3DGggACEaL2ozMhHdrsGoG1D/knf5v1evA IpCtTrcmJ6LbNJqw7bYrYwVQmchieTIaLMhR8aDL1cUQT2pVR3LcvqGse8qmpUTSdIKw CJtZdIkekdfbjrUcHU8b0U+yE4OjHKWUZgMCZeyUw1tWO5GNTK+ihaPl2ec4sOfC9nvm Y14TpGifKKFYUxOr8WiY5m4iLqgRtjE0ZiPInLcQA4+xli/C9XPXWoRKk0pSyWl93nZG pqUvVi9KVt5K74laIHLCWKFQlIStCqoC8jFZJUJ0ugKQCcJYt3fakYY7lAHfp278m6Zi 4N3w== X-Gm-Message-State: AJIora9jorWCf3BqM96RCKv7LR7RQmBJSQZA95na7vVaV0j1/kwelicv S8bvUnTAEZpfF3QqpYJ5xbmfYJruA4zsvQ== X-Google-Smtp-Source: AGRyM1txXX3XMqqP8ytvDCZ1WWuNfzblEFuty26sCOKf+8c8yJyu57p6/ODcgJRM6Rgs6cQTT5MP3A== X-Received: by 2002:a05:6638:25c8:b0:332:1f0e:3e50 with SMTP id u8-20020a05663825c800b003321f0e3e50mr10890509jat.5.1655661920157; Sun, 19 Jun 2022 11:05:20 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:19 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son , Jung-uk Kim Subject: [PULL 06/11] bsd-user: Implement link, linkat, unlink and unlinkat Date: Sun, 19 Jun 2022 12:05:26 -0600 Message-Id: <20220619180531.9161-7-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Jung-uk Kim Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 54 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 16 +++++++++++ 2 files changed, 70 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index fd8aba96180..93e142d46e7 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -375,4 +375,58 @@ static abi_long do_bsd_renameat(abi_long arg1, abi_long arg2, return ret; } +/* link(2) */ +static abi_long do_bsd_link(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p1, *p2; + + LOCK_PATH2(p1, arg1, p2, arg2); + ret = get_errno(link(p1, p2)); /* XXX path(p1), path(p2) */ + UNLOCK_PATH2(p1, arg1, p2, arg2); + + return ret; +} + +/* linkat(2) */ +static abi_long do_bsd_linkat(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + abi_long ret; + void *p1, *p2; + + LOCK_PATH2(p1, arg2, p2, arg4); + ret = get_errno(linkat(arg1, p1, arg3, p2, arg5)); + UNLOCK_PATH2(p1, arg2, p2, arg4); + + return ret; +} + +/* unlink(2) */ +static abi_long do_bsd_unlink(abi_long arg1) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(unlink(p)); /* XXX path(p) */ + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* unlinkat(2) */ +static abi_long do_bsd_unlinkat(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg2); + ret = get_errno(unlinkat(arg1, p, arg3)); /* 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 2d62a546328..c847e4d20c6 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -317,6 +317,22 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_renameat(arg1, arg2, arg3, arg4); break; + case TARGET_FREEBSD_NR_link: /* link(2) */ + ret = do_bsd_link(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_linkat: /* linkat(2) */ + ret = do_bsd_linkat(arg1, arg2, arg3, arg4, arg5); + break; + + case TARGET_FREEBSD_NR_unlink: /* unlink(2) */ + ret = do_bsd_unlink(arg1); + break; + + case TARGET_FREEBSD_NR_unlinkat: /* unlinkat(2) */ + ret = do_bsd_unlinkat(arg1, arg2, arg3); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=ZcAVHpa+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR19P0wZPz9s5V for ; Mon, 20 Jun 2022 04:13:13 +1000 (AEST) Received: from localhost ([::1]:42152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zQ6-0005ow-W5 for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:13:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIZ-0000wO-Qc for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:25 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]:37787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIY-0001Kk-9O for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:23 -0400 Received: by mail-io1-xd30.google.com with SMTP id n11so9137285iod.4 for ; Sun, 19 Jun 2022 11:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DDt4lR7a0j8LSpHDvGx01/LeHWwn1L1uADG9APhxRcg=; b=ZcAVHpa+dNpQqJXNn+jxFMHLm1E7hVhTpSvqlMsFbsJdfoEPmjWRYG/XhWJEgtA7Rp +0YYUJ1JNH6+WfHJ4UJgcIOSONKMsc5FDm+uTETCAGUtNVs5e5tif+m7FA0kcVPLhxqo Ye0vvlGW48q4dXzIrUb7/H6iaqH+ALkZ0UsxSIFL5JgLndynbLEqyCTZWY2Mvc2c7ZJq Du237PUgNIs2MpgLOngAwFewQ8r8DXtg97cn4CnHafiSPIY+Jeg0+VhhJORJiiX/xrLG rhICJoBFDzRalubLZ3KHXV/ZnLXCuCmWfWD3VpLqrNI15DfblQ7CY6/optqrdgtsCsFG LnLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DDt4lR7a0j8LSpHDvGx01/LeHWwn1L1uADG9APhxRcg=; b=kwSlQJSN4o4BDDbROLWHI28O03z+76xi1/UvOA0KZpBVBgO0DVuNesP//SQh8xb4At xSVYhSFP+aPhypLUC60GwO9NLwJaZM+qIfmRxYLYuMsphIRcvXZf4jIDzEHK0W6DybEl knBptSOg2519xw6P0Br+wtrOJeXcjF/IHw1+nbwaPRjhAfi1D+sDPqOSaJ86y9oXvN7I Dw9x6typ+2jCVVueixKvbMu+7cRzykm6aRPysf+5MlUh4gnxgrW8hhOvvRnQJs40VyLp qpAopygTMoXyyUWc9vIo9LRUFpXhXs6ICXUtefV8jp4iDHxFFvbYoywIKEzzfwvR6sDA 7cyQ== X-Gm-Message-State: AJIora9HUPfXsghGx4dgq8CjG2aK7HCrOyQM8sTLCDFQwmw642nKsePo /tv7YNV6VKbLHgl4MNA0sYtRbRH7vDM3kQ== X-Google-Smtp-Source: AGRyM1te2kLF6ovll+VV/PDdZxfQ1wIhpwjAPSQF/Mn51Gy4FRiiQAKzMen085nWgs5XPHIcnYvU7Q== X-Received: by 2002:a02:9f14:0:b0:331:9195:dd3e with SMTP id z20-20020a029f14000000b003319195dd3emr11154127jal.0.1655661921426; Sun, 19 Jun 2022 11:05:21 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:21 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son Subject: [PULL 07/11] bsd-user: Implement mkdir and mkdirat Date: Sun, 19 Jun 2022 12:05:27 -0600 Message-Id: <20220619180531.9161-8-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- 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 93e142d46e7..a4c6dd52a20 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -429,4 +429,31 @@ static abi_long do_bsd_unlinkat(abi_long arg1, abi_long arg2, return ret; } +/* mkdir(2) */ +static abi_long do_bsd_mkdir(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(mkdir(p, arg2)); /* XXX path(p) */ + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* mkdirat(2) */ +static abi_long do_bsd_mkdirat(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg2); + ret = get_errno(mkdirat(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 c847e4d20c6..9381ddb5be1 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -333,6 +333,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_unlinkat(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_mkdir: /* mkdir(2) */ + ret = do_bsd_mkdir(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_mkdirat: /* mkdirat(2) */ + ret = do_bsd_mkdirat(arg1, arg2, arg3); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=Q2OYbWer; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR1FL6Tczz9s5V for ; Mon, 20 Jun 2022 04:16:38 +1000 (AEST) Received: from localhost ([::1]:46972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zTQ-0000e3-Gx for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:16:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIb-0000wS-20 for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:25 -0400 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]:39849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIZ-0001Kb-JI for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:24 -0400 Received: by mail-il1-x135.google.com with SMTP id m16so4569876ilf.6 for ; Sun, 19 Jun 2022 11:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BxjVu0p+Y0YRX0GMQzrHMgnKskB8sTbcjXqEo7rVcdk=; b=Q2OYbWer9yXlTElfK3DXznp+/GUPJLZP+Eo6nsJT3ojLaQTbJ36x5iQ/WKs9eazF70 dHOW4HbH5xkequyvtFTsjhZAbf8bcsFcbD1Ow31XdbIWXo9I5HUx9ricnBbPOetBnKKG 8LciAPgjjNDvZ3IZaH6uEwp/XFEtqN4Q4tnZvq4X7m0801RrvcuT0FaEHdctwtFhmLrv +SSvd0oXrIU07Hzhjb/IY51PKIoZwIb1qPAGc2MHUotup0sOS1LTwELzeSQ/NF4sf/Bd GeTCC/CY/FMI68hZvi3HkJ1t73UqD+eyPexcXVpUBkNcB8wHzmRI+EIUP0QqoW1YsvZd uYrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BxjVu0p+Y0YRX0GMQzrHMgnKskB8sTbcjXqEo7rVcdk=; b=EWS7FXp5CS70e9zySy+Nb+n9pBW94oZqxIjJrxfK9znv5tGYHzvH0SOvxnwLbyVITJ q8FVGIaGfSYPaLi4ajo8HCvfWJ+nJDCp73B0x9GF64F6Rky/Bd3a4bsmP5eB9BbZnWjd 3ld1BsCs1lh54xOJoa9FqNFU1amhfz3M2Tg26Lc3TgKQaRba83+7I0em12dL4t6lupnU LMgT0gQ9rd9FXy+VNSVEH5jFrndFWewn1Q7sg0TPWWiuaVOjSE652clOcHGO8NDLSu57 z1tSNUn2NHTZ/B6eqChQNpsyZORA7AQp3+9jskVvOUzg78s6D7Y+3X7SMajs0QlkX750 LXPg== X-Gm-Message-State: AJIora9ACBODyCHdpTaSCSLV/UNUKl8MpQal7rWzcr6YsqMfYgHYc4Ks NNLS/3/nakf3l1j6GW4EzWUBWHANgl+8nQ== X-Google-Smtp-Source: AGRyM1t7XWxQiwKobxlUZPtRQHEOz4DKbuXxp8uC6taq/lCxyVVI/y81ULYY1NSzpJ11eGnPd8C6dw== X-Received: by 2002:a05:6e02:1a4d:b0:2d3:d2d2:1f47 with SMTP id u13-20020a056e021a4d00b002d3d2d21f47mr11429067ilv.234.1655661922612; Sun, 19 Jun 2022 11:05:22 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:22 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son , Jung-uk Kim Subject: [PULL 08/11] bsd-user: Implement rmdir and undocumented __getcwd Date: Sun, 19 Jun 2022 12:05:28 -0600 Message-Id: <20220619180531.9161-9-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::135; envelope-from=imp@bsdimp.com; helo=mail-il1-x135.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Implemenet rmdir and __getcwd. __getcwd is the undocumented back end to getcwd(3). Signed-off-by: Stacey Son Signed-off-by: Jung-uk Kim Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 29 +++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 37 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index a4c6dd52a20..8ec53145894 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -456,4 +456,33 @@ static abi_long do_bsd_mkdirat(abi_long arg1, abi_long arg2, return ret; } +/* rmdir(2) */ +static abi_long do_bsd_rmdir(abi_long arg1) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + ret = get_errno(rmdir(p)); /* XXX path(p)? */ + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* undocumented __getcwd(char *buf, size_t len) system call */ +static abi_long do_bsd___getcwd(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p; + + p = lock_user(VERIFY_WRITE, arg1, arg2, 0); + if (p == NULL) { + return -TARGET_EFAULT; + } + ret = safe_syscall(SYS___getcwd, p, arg2); + unlock_user(p, arg1, ret == 0 ? strlen(p) + 1 : 0); + + return get_errno(ret); +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 9381ddb5be1..e28a566d6c3 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -341,6 +341,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_mkdirat(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_rmdir: /* rmdir(2) (XXX no rmdirat()?) */ + ret = do_bsd_rmdir(arg1); + break; + + case TARGET_FREEBSD_NR___getcwd: /* undocumented __getcwd() */ + ret = do_bsd___getcwd(arg1, arg2); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=V6BnCgFC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR17g2r5sz9sFx for ; Mon, 20 Jun 2022 04:11:41 +1000 (AEST) Received: from localhost ([::1]:38014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zOd-0002wj-Qw for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIc-0000yZ-7V for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:26 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]:43745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIa-0001M1-Oc for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:25 -0400 Received: by mail-io1-xd36.google.com with SMTP id d123so9110901iof.10 for ; Sun, 19 Jun 2022 11:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=slM5mo+lyEYK7BDCjCyKBMpfdnmv0SN6/iCP+sM1rKE=; b=V6BnCgFCrQDM/FGPPHVtN+YkvrRve5wzOL0DtfkTx9I7LZkRfskkGCZNWFoWXGk7jo Tl3wTWOnWCZaZAV2nNPQUGlT37VBhgvHuwIhxQaKy3gkm/sa5mgwfbzOFJ7Z/ywdF74f +ubz9pBoJMNo/ihEqnp4wZevHbc6sU5JK9WoQ0RO9eCIhAMiVZbnPVSkNtG4HS9Tzkm4 uJv6JdlWRvzMplZ2Url0XRpv2I+QkenzdMJebQCebhV7+hAaNq3tHd2tA3dEI1ByeZMN PZcxFA4KW+vKCy/DWPxPvOIu3ZuzXAMyOStGBZyY489iVPQSWb0BpXybiJEPFW4Ik09j T/AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=slM5mo+lyEYK7BDCjCyKBMpfdnmv0SN6/iCP+sM1rKE=; b=Y3j/HldnCSLlWg02RwdQb9M4eZfcGYA5djHuEEbcstqA+g1Yjn75IuCnWG2MGcz4fT h04sV6nv9LyQ4Zr9w5+YDQXh7u60tpraFOzIvRXl6kLCySeVllGiOSso9O4FFMTGa0Vc sKzifiQWSbo0hS9oCvBU/TzDk31zrUJDREETR5015WqcK3grLaSsCWmClB96W/9dS4/L MhjPkOcWD+KEKQx0uTaJ0+9Ci3iyEy6UXraGz/wCz5gy4ZSfyrrele9BWsToKycw+c+/ pvGaZZLbEaFsKKa7roIZR/lEeEj7ab1YRkA/0s7BkwQjAwBoCf3sxmw5PstG6aBLPkAN GWdQ== X-Gm-Message-State: AJIora8G/Lxn/mQbzqUzeqpEptjHa4YiSgHpuH2X4yF+W1WoIPDM/6KB lQ2B0zOA9SSCJhuu9JgIsQCbJ53gHL2puQ== X-Google-Smtp-Source: AGRyM1uryGx/xSYgkauVUzDSfx3hJO5CqBlXyw7Bt/TcoBo65YoiR2G7UxfA8FOLlljbVhHaHOcm8w== X-Received: by 2002:a6b:3ec4:0:b0:669:b9e6:cd97 with SMTP id l187-20020a6b3ec4000000b00669b9e6cd97mr10116142ioa.128.1655661923494; Sun, 19 Jun 2022 11:05:23 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:23 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son Subject: [PULL 09/11] bsd-user: Implement dup and dup2 Date: Sun, 19 Jun 2022 12:05:29 -0600 Message-Id: <20220619180531.9161-10-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 12 ++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 8ec53145894..021541ad2e0 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -485,4 +485,16 @@ static abi_long do_bsd___getcwd(abi_long arg1, abi_long arg2) return get_errno(ret); } +/* dup(2) */ +static abi_long do_bsd_dup(abi_long arg1) +{ + return get_errno(dup(arg1)); +} + +/* dup2(2) */ +static abi_long do_bsd_dup2(abi_long arg1, abi_long arg2) +{ + return get_errno(dup2(arg1, arg2)); +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index e28a566d6c3..d9ebb9d50d6 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -349,6 +349,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd___getcwd(arg1, arg2); break; + case TARGET_FREEBSD_NR_dup: /* dup(2) */ + ret = do_bsd_dup(arg1); + break; + + case TARGET_FREEBSD_NR_dup2: /* dup2(2) */ + ret = do_bsd_dup2(arg1, arg2); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=uGANliHe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR1516n72z9sFx for ; Mon, 20 Jun 2022 04:09:25 +1000 (AEST) Received: from localhost ([::1]:59478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zMR-0006nL-Gc for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:09:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zId-0000yp-Dy for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:28 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]:43733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIb-0001MA-Te for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:27 -0400 Received: by mail-io1-xd29.google.com with SMTP id d123so9110925iof.10 for ; Sun, 19 Jun 2022 11:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wJEGbDyUIR4TgYHaYi6XpxnqSx1t+dwpAGBFG5Z8F5Q=; b=uGANliHeeeD0gDASlc0Fy9lkIUNfh/4rWMcurAXnGGX38fOM9LAjJIcqJQOJWeumGV jkEhMKTPiFOiV+A0K51V8ZYLs9tXKvZBemnUdcWifXgrljF0ksGuJWSt2YHY87fJvzDQ KB3tCCgeTQzZzhOwa1WPE6Z5/WeHxsQtTU6gBzrKcKfgAmRqtdLb4qxvO4a9SsU+4s00 QAfJaQbu/THB3yrrhAc2xojEYV73K3fIulH7iCzfUzwxi9BhTVOFE3WpGYaHiKN3TZs3 S2k/Nirwiwu6qQeSZZ4xxV/Kv7zmkx36gbx+wC8DVSEygYeX1k2SYa1pcldXD/g5KdrH QN5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wJEGbDyUIR4TgYHaYi6XpxnqSx1t+dwpAGBFG5Z8F5Q=; b=jxVHe0rGEtJkg/doOHf25rowhrs9/1zXKeHonPQy+t9QlbUM5JRfPTRanD7Nksg3hJ arn60VHlTOoa93qwY1LXeSHc/PwL0tONCKOQqrJkTR9V3DYhilOwk5htumJiV99Xrrvc vOiHICOP/WBsyFOf37APAoaTgSC9l9ng5s2XO0ujvhgw/V5Q5R/zsG6m1DabIFIvkz9k vKf/MfbSrUF1bYXthysYSbsnjkmxw5HeUeoaAN0rjoXzqkHYBz/ztPdKqu/ONdPc7cSh dYR98CGRlHakBGumtd6olpEBsJpJ29JsTj4giOhGh+fFin+JpUzkB8IYt1ezS0fMdATP 51lA== X-Gm-Message-State: AJIora+xCAK32dr6Oh2ASuwrnPrk8MX4afg8ynDkLC0/s8s+HoUjmqNw /ioL4VE9OfrhGDQeHCpK8I2+TfJqapwNzw== X-Google-Smtp-Source: AGRyM1vqkHHFZ2ZEgvJzhZn8CORccoFIuuNu1ZWYWu+HV2R4aCV2IpIZZSn5jvYiweFH9+TdYegQ4A== X-Received: by 2002:a02:9564:0:b0:331:dc7a:1cb8 with SMTP id y91-20020a029564000000b00331dc7a1cb8mr11309874jah.215.1655661924584; Sun, 19 Jun 2022 11:05:24 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:24 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son Subject: [PULL 10/11] bsd-user: Implement trunctate and ftruncate Date: Sun, 19 Jun 2022 12:05:30 -0600 Message-Id: <20220619180531.9161-11-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 29 +++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 37 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 021541ad2e0..fda36894605 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -497,4 +497,33 @@ static abi_long do_bsd_dup2(abi_long arg1, abi_long arg2) return get_errno(dup2(arg1, arg2)); } +/* truncate(2) */ +static abi_long do_bsd_truncate(void *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4) +{ + abi_long ret; + void *p; + + LOCK_PATH(p, arg1); + if (regpairs_aligned(cpu_env) != 0) { + arg2 = arg3; + arg3 = arg4; + } + ret = get_errno(truncate(p, target_arg64(arg2, arg3))); + UNLOCK_PATH(p, arg1); + + return ret; +} + +/* ftruncate(2) */ +static abi_long do_bsd_ftruncate(void *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4) +{ + if (regpairs_aligned(cpu_env) != 0) { + arg2 = arg3; + arg3 = arg4; + } + return get_errno(ftruncate(arg1, target_arg64(arg2, arg3))); +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index d9ebb9d50d6..3c8f6cad0e8 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -357,6 +357,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_dup2(arg1, arg2); break; + case TARGET_FREEBSD_NR_truncate: /* truncate(2) */ + ret = do_bsd_truncate(cpu_env, arg1, arg2, arg3, arg4); + break; + + case TARGET_FREEBSD_NR_ftruncate: /* ftruncate(2) */ + ret = do_bsd_ftruncate(cpu_env, arg1, arg2, arg3, arg4); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS; From patchwork Sun Jun 19 18:05:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1645185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=aw68Pl7P; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LR19Y2qmxz9s5V for ; Mon, 20 Jun 2022 04:13:21 +1000 (AEST) Received: from localhost ([::1]:42258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2zQD-0005t6-QO for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2022 14:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2zIe-0000yv-7k for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:28 -0400 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]:46822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2zIc-0001LO-Jp for qemu-devel@nongnu.org; Sun, 19 Jun 2022 14:05:27 -0400 Received: by mail-il1-x132.google.com with SMTP id y16so6064399ili.13 for ; Sun, 19 Jun 2022 11:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gMytXGUn22yDNlAtdSy95841H0sZIx/2Jw4ZsIHWhmc=; b=aw68Pl7PoYK2sDTyJ84xD3EErFfvb8iDv8qL4NqgNpUjOXr4l8GwIpdFdcYtKF2kbc PVh84ZEn3RL7vmsaRLrHztS6Md2VoeaOixQ8Aace8IPg6xy6rq9TqxPcP+CLyzB31Zd4 WfqQmL3iq2Tv9h3KfDCddZrH5Wur6j4iotvTmd4du1R2+kbqU83TPnBlBzdVJcZPNV5h 9UhkQwrLkQQTKujdgxZD/9ABD1T2V/ab3T6Wq8cFZ2ro0JWyu98vEww90PGBnb+/wutV 5eAkfvGrvCmoJio79XAG6s7VWkL3d1psMdbu7pj0+LRbxcFIAOhAmYbbHjOktReoUOyG 0s+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gMytXGUn22yDNlAtdSy95841H0sZIx/2Jw4ZsIHWhmc=; b=USRMK6IsrwXXBIk+ndir+Zpv5dH+mekokpQ2/Xzehk/5nLjBZcNd7G3pm0hcotmkXZ DW0UyjLjQDG7hCvEOCPHce90ljwDYggvbZyF2gIuR3iaWxdlqfUjN0VnORJcJx12VLTD RLkWW7UvzweXCrPz/wrmKjxlSGDliRwCAq8y5UQb57/5kEKa6x30jqJ64zktkV62/30q VVxJOtESWOJBiks5A0uCiyN8TnbFw9ZCeoD3wWH3nTO/HpE3RUddy81N3F3TTd5jbHZd vYimJ5GHPMg/Pj7B7qUtPQds3e9uZIxzXYR03KqHk/plcZDEpyti+ROBm0Jg6fpwYy9+ WwRw== X-Gm-Message-State: AJIora8zaighgIVFy+H33mkdtG4El1GR9er73jwkEPDJNpLqLC76pe5V izurvESkO6WOlClkDu7+cPeKojDoaTl95w== X-Google-Smtp-Source: AGRyM1twUKQsEZJt/6r21fATNyyQchS4eiSKacXiDp1++Tpb73R70p6Z/kWM/fm5J0mlRR0Frp/ZYg== X-Received: by 2002:a92:dc88:0:b0:2d5:118c:a3f6 with SMTP id c8-20020a92dc88000000b002d5118ca3f6mr11289053iln.204.1655661925754; Sun, 19 Jun 2022 11:05:25 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id 63-20020a6b1542000000b00669b8999911sm5556897iov.15.2022.06.19.11.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 11:05:25 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Richard Henderson , Kyle Evans , jrtc27@FreeBSD.org, arrowd@freebsd.org, def@FreeBSD.org, Stacey Son Subject: [PULL 11/11] bsd-user: Implement acct and sync Date: Sun, 19 Jun 2022 12:05:31 -0600 Message-Id: <20220619180531.9161-12-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220619180531.9161-1-imp@bsdimp.com> References: <20220619180531.9161-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::132; envelope-from=imp@bsdimp.com; helo=mail-il1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index fda36894605..b2dca586129 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -526,4 +526,27 @@ static abi_long do_bsd_ftruncate(void *cpu_env, abi_long arg1, return get_errno(ftruncate(arg1, target_arg64(arg2, arg3))); } +/* acct(2) */ +static abi_long do_bsd_acct(abi_long arg1) +{ + abi_long ret; + void *p; + + if (arg1 == 0) { + ret = get_errno(acct(NULL)); + } else { + LOCK_PATH(p, arg1); + ret = get_errno(acct(path(p))); + UNLOCK_PATH(p, arg1); + } + return ret; +} + +/* sync(2) */ +static abi_long do_bsd_sync(void) +{ + sync(); + return 0; +} + #endif /* BSD_FILE_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 3c8f6cad0e8..2623caf8007 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -365,6 +365,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_ftruncate(cpu_env, arg1, arg2, arg3, arg4); break; + case TARGET_FREEBSD_NR_acct: /* acct(2) */ + ret = do_bsd_acct(arg1); + break; + + case TARGET_FREEBSD_NR_sync: /* sync(2) */ + ret = do_bsd_sync(); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret = -TARGET_ENOSYS;