From nobody Sun Nov 2 17:23:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527975250265586.1106550344498; Sat, 2 Jun 2018 14:34:10 -0700 (PDT) Received: from localhost ([::1]:32847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPEA5-0001h9-H6 for importer@patchew.org; Sat, 02 Jun 2018 17:34:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPE71-0007xr-Kl for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:31:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPE70-0005pQ-M6 for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:59 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:40148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPE70-0005pG-Hb for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:58 -0400 Received: by mail-qt0-x244.google.com with SMTP id q6-v6so2611766qtn.7 for ; Sat, 02 Jun 2018 14:30:58 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id k2-v6sm21366628qkl.95.2018.06.02.14.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 02 Jun 2018 14:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=2lVGDeuS5rQOtCR6f/x1d+TXu6O90X6nTjdRqW5XFC4=; b=ZBI0+K8Ve/L6JA0gLL8FCFNOlppdJGYYPZY/3GDziC+gBHdXRzOBDKmi2VCkUBG/bK 7nSfnT/uKfyM4Yr+6BF2f/TIu077YVq/khkTyn18HglHgPcXz/zBFSO+Rnqgv7oeJybm 3iOC2VP3NOem3ZjW21yNoMOP3fwFT2Wo84dDJqdwRZWI8yrzx3eWyn906F3SmhJRHtcz Sl200PI5TFBWSBIHKa1QBOtQmc+245NL61ontdsnVEo/mvtjgKL+HPeMutC/cjGydO1Q 796pmvRkEtylqgyc37SwLBKbqbpeEs0Z7Irm//8JGZVDorSbJFlviaLA5to5sRnuBKqz uejQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=2lVGDeuS5rQOtCR6f/x1d+TXu6O90X6nTjdRqW5XFC4=; b=cMXTf8rPnzw2L+WyehUNxJKJzC7E/fI36XexqS3Wyp/TJHZbHSjTak1osJwTdCV50e cwnNirJUvHkJi9oIL3OK7RvHRAYkoZCHNv/iIzrAaUWJ8ulFXVfMtDSxwQO29Py2MS8+ nWkmHsedOapIHM/eMtAs2Xm3SGYUCCEchvs6Pm/pdM3rPKrjJc3KaD/xubZU3iCZwrwe rAGceUOa8ezjb0XI/DNPIq6Zw7/1rZQnNpV2cIF0CDScD1iFg5j3uBKOlcZHSg0yhwlb NSWrOcdx2/PW1+FnytqFx7L7ZVXFTfO/lDmCJ/cvS9l+CNrlDzLBwL/y4WxS5rAKdG2b 97Dg== X-Gm-Message-State: APt69E3diylkgJh8oetBt7R94JRhr/jRPDFVRrhvEunXYhQaBXo3eS2P csaMrkD54fXblVlodTuWJSvFMKQz/LI= X-Google-Smtp-Source: ADUXVKL0afCFzfzqrfUUcO33QO/5mFACy09Aj6akb0Q9Byhb4yULu7SLCjuQR8m8rOqsxdfpo6U1+g== X-Received: by 2002:ac8:2d6c:: with SMTP id o41-v6mr15723923qta.107.1527975057449; Sat, 02 Jun 2018 14:30:57 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 2 Jun 2018 17:29:39 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH v3 5/5] 9p: xattr: Properly translate xattrcreate flags X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As with unlinkat, these flags come from the client and need to be translated to their host values. The protocol values happen to match linux, but that need not be true in general. Signed-off-by: Keno Fischer --- Changes since v2: New patch hw/9pfs/9p.c | 17 +++++++++++++++-- hw/9pfs/9p.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index c842ec5..eef289e 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3327,7 +3327,7 @@ out_nofid: =20 static void coroutine_fn v9fs_xattrcreate(void *opaque) { - int flags; + int flags, rflags =3D 0; int32_t fid; uint64_t size; ssize_t err =3D 0; @@ -3344,6 +3344,19 @@ static void coroutine_fn v9fs_xattrcreate(void *opaq= ue) } trace_v9fs_xattrcreate(pdu->tag, pdu->id, fid, name.data, size, flags); =20 + if (flags & ~(P9_XATTR_CREATE | P9_XATTR_REPLACE)) { + err =3D -EINVAL; + goto out_nofid; + } + + if (flags & P9_XATTR_CREATE) { + rflags |=3D XATTR_CREATE; + } + + if (flags & P9_XATTR_REPLACE) { + rflags |=3D XATTR_REPLACE; + } + if (size > XATTR_SIZE_MAX) { err =3D -E2BIG; goto out_nofid; @@ -3365,7 +3378,7 @@ static void coroutine_fn v9fs_xattrcreate(void *opaqu= e) xattr_fidp->fs.xattr.copied_len =3D 0; xattr_fidp->fs.xattr.xattrwalk_fid =3D false; xattr_fidp->fs.xattr.len =3D size; - xattr_fidp->fs.xattr.flags =3D flags; + xattr_fidp->fs.xattr.flags =3D rflags; v9fs_string_init(&xattr_fidp->fs.xattr.name); v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name); xattr_fidp->fs.xattr.value =3D g_malloc0(size); diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index bad8ee7..6081b0d 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -169,6 +169,10 @@ typedef struct V9fsConf char *fsdev_id; } V9fsConf; =20 +/* 9p2000.L xattr flags (matches Linux values) */ +#define P9_XATTR_CREATE 1 +#define P9_XATTR_REPLACE 2 + typedef struct V9fsXattr { uint64_t copied_len; --=20 2.8.1