From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65405C88E75 for ; Fri, 18 Sep 2026 04:30:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7QAx-0006Eb-Tj; Fri, 18 Sep 2026 00:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x7QAl-0005rh-Ga for qemu-devel@nongnu.org; Fri, 18 Sep 2026 00:26:03 -0400 Received: from mail-oi2-x10.google.com ([2607:f8b0:4864:32::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x7QAi-0004PG-MA for qemu-devel@nongnu.org; Fri, 18 Sep 2026 00:26:03 -0400 Received: by mail-oi2-x10.google.com with SMTP id 46e09a7af769-7f4f0cfb33cso186936a34.0 for ; Thu, 17 Sep 2026 21:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20251104.gappssmtp.com; s=20251104; t=1789705549; x=1790310349; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=txxZEGmgiR65GvH6Ifffpx5njMN/4m8TrPzV4WhVh9U=; b=O32dVuYILdRV1+yX08Lq57A4BGIO6kW8ztw3zYFHxVS5SKjKdcbT1KOwstV+7c1vQr UlrUvz+hAj37Sx5r0lFjoOzi6BQEB99jqB5vGeLZ9geXeZiaksHo4vRsXNDlOenYAWx1 KoTKDqjMDhHxUgwCbLFcwLur/gMHB1Vy3nuaYNJ69WAgoO4ykqKAUsXhILQTT0uOZMg0 4yiFkqf7EyjakgNZ7CJywe/synwPjwBeY+0BR2tRLZelwNSf6mqU+lvP1xBdOResMNpE Gt5ccdsNqkVxrEbunRnlR1jjom8REMu+IQjuBJzn80kOt8fYCr0iQJisE+t1VtxBoBWb 4R5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789705549; x=1790310349; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=txxZEGmgiR65GvH6Ifffpx5njMN/4m8TrPzV4WhVh9U=; b=MrQzEyvt1n/BsS84h2KKweZ3guGPmFi+xR5+rcrdIeLLuNlynl47PyKnPTAQkL5Hry Et8yIRfjYYo290k9oFmCDh0qtYHIAFIPQWPHehU9x/BGFKSHyXbh2aKRgEHcwr6r/CrG B7fzXgGklk9uTHv4ETnwl/atTpG/jVzAPMVEOdOxpGm+lh6DaOY5CcgLS5LiGiAtdUFR 3a+FjDTv3WYZIMUiFPuqyeb6j8G+ZIsIT3K0JSoqfcZ82I8lZJVBa8hYPLXSC2z5OP2A gH5hSokKszdfftx4Tm6ix7TYKar4M3+Ar+N8hNoUPUddALf8j+hPFLL2bqWiKXo/lKpc tkdw== X-Gm-Message-State: AFuF++nEqukYo2+PLqwLFZ8EOEkcI1B1TFuZz+TT+OugJb/uDPz779ph Peue/2/PR3V60Sv9eTRjKX5sAsHPvIBSWVtMqS4kKN8bc0GcKyQqqUAiJH7RocDrSuld/xp+cWE WPjEp9Ck= X-Gm-Gg: AYBFou0lUrq39e3mr2XTLsscLhBGO0NnfHk71QhAQjQphZjWCiSXCK93I/s1zGSZ602 4avi+8EeWwgrTl0fKJJqRUEAs3POd1NaiR5b3oXoDwmn2GDdgI3132B+aU8/kRWWFhwMuFtuMpx Hn8xL+1Yq37897Guid3chb2YZmNZVMzbSRv4QFnmUgxkaAAwwwyv/yONRkUp2dvhHf4Tqr1ySOp I32/inEHaeAfCd5PqZ4nMUHFFrEoSMyAB83ZymRaT7QvpaFmsRkAOjNCqo0t+taFs5+IX5MYlJB B5HI725e0LyPkHWmMmOt9gyEZ0pxqZEfbqrPTCknXAHbwatyOXQcURE2AI1jIypu4X/aQmPPceb HBE9TTvqkRzuvYwZKacFnO8MTEWkTGJ/BkyZdhWtlCdoRdshEupc+2YoLKPL/8nzyEnvFC86Fy6 a77aooHwKHGAg0ayqFZzlc4cHoJ4L4/LqmN5HHKZaJhcWwuh9s8FLK/F49Lg== X-Received: by 2002:a05:6830:44a2:b0:80c:d34f:5f5f with SMTP id 46e09a7af769-80de2de5911mr1614127a34.24.1789705549605; Thu, 17 Sep 2026 21:25:49 -0700 (PDT) Received: from rebo.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-80e51d627b5sm489718a34.20.2026.09.17.21.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 21:25:49 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Kyle Evans , Warner Losh , Stacey Son , Richard Henderson Subject: [PULL 33/41] bsd-user: Add os-extattr.h with file and fd extattr functions Date: Thu, 17 Sep 2026 22:24:14 -0600 Message-ID: <20260918042422.38713-34-imp@bsdimp.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260918042422.38713-1-imp@bsdimp.com> References: <20260918042422.38713-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2607:f8b0:4864:32::10; envelope-from=imp@bsdimp.com; helo=mail-oi2-x10.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add the first part of extended attribute support: extattrctl, extattr_set_file, extattr_get_file, extattr_delete_file, extattr_set_fd, extattr_get_fd, and extattr_delete_fd. Signed-off-by: Stacey Son Assisted-by: Claude Opus 4.6 (1M context) Acked-by: Richard Henderson Signed-off-by: Warner Losh --- bsd-user/freebsd/os-extattr.h | 208 ++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 bsd-user/freebsd/os-extattr.h diff --git a/bsd-user/freebsd/os-extattr.h b/bsd-user/freebsd/os-extattr.h new file mode 100644 index 0000000000..fb3ef27346 --- /dev/null +++ b/bsd-user/freebsd/os-extattr.h @@ -0,0 +1,208 @@ +/* + * FreeBSD extended attributes and ACL system call support + * + * Copyright (c) 2013 Stacey D. Son + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include + +/* 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_long arg1, + abi_long arg2, + abi_long arg3, + abi_long arg4, + abi_long 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_long arg1, + abi_long arg2, + abi_long arg3, + abi_long arg4, + abi_long 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_long arg1, + abi_long arg2, + abi_long 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_long arg3, abi_long arg4, + abi_long 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_long arg3, abi_long arg4, + abi_long 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_long 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; +} + + +#endif /* FREEBSD_OS_EXTATTR_H */ -- 2.55.0