From nobody Mon Feb 9 16:12:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1704359568; cv=none; d=zohomail.com; s=zohoarc; b=le/Ipp5MUZ6ouKT5qgqljC5RuFBwg5EVSg+y+G7S92eaclAEH1g2Yx0OYbMKWMlsMxdG7PDpux+VmsoOQom69L0XIvkLpp3iSPlSAFtePjKrJGj7Nk8hCmfHGnjXpzAk/l/tp8ap3xhX3FZ4FX8Cs+u7/FKoDm0y9efHbyXl7ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704359568; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H8wa9pWvrMOGw1akjDhfhUuR8F7bLlS3/Tu/6p/vKMw=; b=P1dfq78VFMVKnIOedhQqH9YRzkBnQ/kKkBzDfWxiumh9apkVIe8Jc/Bl+7l3iP8e+R8a0SHFxDmKil2z4T/Ny2nM6cmOJrkD/XDn8lOzwiDjNhSSbQSi6AOm9OYEf5rAVTKzsnP8Kec0LEfs6wVDY4lr+0rn/+k7MZK0E+0ATp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1704359568483188.72825576404216; Thu, 4 Jan 2024 01:12:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.661281.1031034 (Exim 4.92) (envelope-from ) id 1rLJm9-0003uM-8S; Thu, 04 Jan 2024 09:12:29 +0000 Received: by outflank-mailman (output) from mailman id 661281.1031034; Thu, 04 Jan 2024 09:12:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rLJm8-0003ra-VT; Thu, 04 Jan 2024 09:12:28 +0000 Received: by outflank-mailman (input) for mailman id 661281; Thu, 04 Jan 2024 09:12:26 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rLJcD-0007Zm-C2 for xen-devel@lists.xenproject.org; Thu, 04 Jan 2024 09:02:13 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f254ffa5-aadf-11ee-9b0f-b553b5be7939; Thu, 04 Jan 2024 10:02:11 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4E93721EE1; Thu, 4 Jan 2024 09:02:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2963E13722; Thu, 4 Jan 2024 09:02:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id QhXeCBN0lmXlWAAAD6G6ig (envelope-from ); Thu, 04 Jan 2024 09:02:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f254ffa5-aadf-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704358931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H8wa9pWvrMOGw1akjDhfhUuR8F7bLlS3/Tu/6p/vKMw=; b=NyPjfCnUel768c1HJYvf92BSkfRaB74bir+jAuLF/c4m3dvbFqyKScxmWz3g/kE7yB1sGP N4JjFGw1jonvOMzB6Ba2oU1hWRDfrNNcsbFzmuT83zhveATgAK2RPy4giTnpkdJOgjhdmC dxmrphTSvM5sH7TVzAzuRuFgNAjPVg4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704358931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H8wa9pWvrMOGw1akjDhfhUuR8F7bLlS3/Tu/6p/vKMw=; b=NyPjfCnUel768c1HJYvf92BSkfRaB74bir+jAuLF/c4m3dvbFqyKScxmWz3g/kE7yB1sGP N4JjFGw1jonvOMzB6Ba2oU1hWRDfrNNcsbFzmuT83zhveATgAK2RPy4giTnpkdJOgjhdmC dxmrphTSvM5sH7TVzAzuRuFgNAjPVg4= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v3 13/33] tools/xenlogd: add 9pfs stat request support Date: Thu, 4 Jan 2024 10:00:35 +0100 Message-Id: <20240104090055.27323-14-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240104090055.27323-1-jgross@suse.com> References: <20240104090055.27323-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: * X-Spam-Score: 1.20 X-Spamd-Result: default: False [1.20 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; NEURAL_SPAM_LONG(3.50)[1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Flag: NO X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1704359569927100006 Content-Type: text/plain; charset="utf-8" Add the stat request of the 9pfs protocol. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- V3: - use fstatat() (Jason Andryuk) --- tools/xen-9pfsd/io.c | 93 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/tools/xen-9pfsd/io.c b/tools/xen-9pfsd/io.c index 9d816dc97e..7d40747b60 100644 --- a/tools/xen-9pfsd/io.c +++ b/tools/xen-9pfsd/io.c @@ -34,6 +34,7 @@ #define P9_CMD_OPEN 112 #define P9_CMD_CREATE 114 #define P9_CMD_CLUNK 120 +#define P9_CMD_STAT 124 =20 /* P9 protocol open flags. */ #define P9_OREAD 0 /* read */ @@ -60,6 +61,25 @@ struct p9_qid { uint64_t path; }; =20 +struct p9_stat { + uint16_t size; + uint16_t type; + uint32_t dev; + struct p9_qid qid; + uint32_t mode; + uint32_t atime; + uint32_t mtime; + uint64_t length; + const char *name; + const char *uid; + const char *gid; + const char *muid; + const char *extension; + uint32_t n_uid; + uint32_t n_gid; + uint32_t n_muid; +}; + /* * Note that the ring names "in" and "out" are from the frontend's * perspective, so the "in" ring will be used for responses to the fronten= d, @@ -1140,6 +1160,75 @@ static void p9_clunk(struct ring *ring, struct p9_he= ader *hdr) fill_buffer(ring, hdr->cmd + 1, hdr->tag, ""); } =20 +static void fill_p9_stat(device *device, struct p9_stat *p9s, struct stat = *st, + const char *name) +{ + memset(p9s, 0, sizeof(*p9s)); + fill_qid(device, NULL, &p9s->qid, st); + p9s->mode =3D st->st_mode & 0777; + if ( S_ISDIR(st->st_mode) ) + p9s->mode |=3D P9_CREATE_PERM_DIR; + p9s->atime =3D st->st_atime; + p9s->mtime =3D st->st_mtime; + p9s->length =3D st->st_size; + p9s->name =3D name; + p9s->uid =3D ""; + p9s->gid =3D ""; + p9s->muid =3D ""; + p9s->extension =3D ""; + p9s->n_uid =3D 0; + p9s->n_gid =3D 0; + p9s->n_muid =3D 0; + + /* + * Size of individual fields without the size field, including 5 2-byte + * string length fields. + */ + p9s->size =3D 71 + strlen(p9s->name); +} + +static void p9_stat(struct ring *ring, struct p9_header *hdr) +{ + device *device =3D ring->device; + uint32_t fid; + struct p9_fid *fidp; + struct p9_stat p9s; + struct stat st; + uint16_t total_length; + int ret; + + ret =3D fill_data(ring, "U", &fid); + if ( ret !=3D 1 ) + { + p9_error(ring, hdr->tag, EINVAL); + return; + } + + fidp =3D get_fid_ref(device, fid); + if ( !fidp ) + { + p9_error(ring, hdr->tag, ENOENT); + return; + } + + if ( fstatat(device->root_fd, relpath_from_path(fidp->path), &st, 0) <= 0 ) + { + p9_error(ring, hdr->tag, errno); + goto out; + } + fill_p9_stat(device, &p9s, &st, strrchr(fidp->path, '/') + 1); + + total_length =3D p9s.size + sizeof(p9s.size); + fill_buffer(ring, hdr->cmd + 1, hdr->tag, "uuuUQUUULSSSSSUUU", + &total_length, &p9s.size, &p9s.type, &p9s.dev, &p9s.qid, + &p9s.mode, &p9s.atime, &p9s.mtime, &p9s.length, p9s.name, + p9s.uid, p9s.gid, p9s.muid, p9s.extension, &p9s.n_uid, + &p9s.n_gid, &p9s.n_muid); + + out: + free_fid(device, fidp); +} + void *io_thread(void *arg) { struct ring *ring =3D arg; @@ -1219,6 +1308,10 @@ void *io_thread(void *arg) p9_clunk(ring, &hdr); break; =20 + case P9_CMD_STAT: + p9_stat(ring, &hdr); + break; + default: syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n", ring->device->domid, ring->device->devid, hdr.cmd); --=20 2.35.3