From nobody Fri Oct 18 08:33:30 2024 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=1707130692; cv=none; d=zohomail.com; s=zohoarc; b=n4b6RnI585OvxklVCSz8YOsGMBQY8m1rlFZGwcAS6XB/E/rsSBcG4IVP5yzixm92gOQ0VtUWScU/VWtOze+fL/Yhgim9xyNr+eVD3lyB749SxtvtrrJaTNpeVP5YXfjHsZgrQ7PVwQJDjdSBT4QXRsAnjh6ob+9eEGWcSjsILiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707130692; 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=pkY/yeFHjo5eL439i+/3VdOn4jDMqN4bEBUDTVhVOHY=; b=a+0q3sV0smcuO+Xr3YBAPa59uYSZ67o0SNRyr+oMLLokfevAEGowDtS/LHvs3ofn5xrqkI7ETV6s+bIQoOgxxHB6gz3I0sb7p5/tnZZOtMlUtcz6sXygizkw1L/7i4durzpKTV8kxNL0vZCH1p1isJE/pNdaVie6kb8kYKk3r00= 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 170713069250174.7200669988132; Mon, 5 Feb 2024 02:58:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.675849.1051503 (Exim 4.92) (envelope-from ) id 1rWwfm-0005mH-46; Mon, 05 Feb 2024 10:57:58 +0000 Received: by outflank-mailman (output) from mailman id 675849.1051503; Mon, 05 Feb 2024 10:57:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rWwfm-0005m8-0U; Mon, 05 Feb 2024 10:57:58 +0000 Received: by outflank-mailman (input) for mailman id 675849; Mon, 05 Feb 2024 10:57:56 +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 1rWwZ4-0000qL-Gw for xen-devel@lists.xenproject.org; Mon, 05 Feb 2024 10:51:02 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73357ec5-c414-11ee-98f5-efadbce2ee36; Mon, 05 Feb 2024 11:51:00 +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-out2.suse.de (Postfix) with ESMTPS id 6190A1F8BB; Mon, 5 Feb 2024 10:51:00 +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 38566132DD; Mon, 5 Feb 2024 10:51:00 +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 2E1cDJS9wGVFNgAAD6G6ig (envelope-from ); Mon, 05 Feb 2024 10:51:00 +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: 73357ec5-c414-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1707130260; 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=pkY/yeFHjo5eL439i+/3VdOn4jDMqN4bEBUDTVhVOHY=; b=ADQmRxO77rZcn29jNH9MAIPkKXIBysVSKul248LPHHNK38xBqqAC0Y/wCs273iIaXJ5PR/ 1ybt1oSdufVIt2+RsQMDVmr152hMaYaf4tPBmrj2Kq8mRCzgUguHI729EedFN9Bcj65tU7 JF3joxZEHPVL4+6Vohcmm55XdCHjrJ0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1707130260; 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=pkY/yeFHjo5eL439i+/3VdOn4jDMqN4bEBUDTVhVOHY=; b=ADQmRxO77rZcn29jNH9MAIPkKXIBysVSKul248LPHHNK38xBqqAC0Y/wCs273iIaXJ5PR/ 1ybt1oSdufVIt2+RsQMDVmr152hMaYaf4tPBmrj2Kq8mRCzgUguHI729EedFN9Bcj65tU7 JF3joxZEHPVL4+6Vohcmm55XdCHjrJ0= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v4 10/32] tools/xen-9pfsd: add 9pfs clunk request support Date: Mon, 5 Feb 2024 11:49:39 +0100 Message-Id: <20240205105001.24171-11-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240205105001.24171-1-jgross@suse.com> References: <20240205105001.24171-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -0.30 X-Spamd-Result: default: False [-0.30 / 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)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; 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]; 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(-0.00)[12.82%] X-Spam-Flag: NO X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1707130693255100002 Content-Type: text/plain; charset="utf-8" Add the clunk request of the 9pfs protocol. Signed-off-by: Juergen Gross Acked-by: Anthony PERARD Reviewed-by: Jason Andryuk --- V3: - use unlinkat() (Jason Andryuk) --- tools/xen-9pfsd/io.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/xen-9pfsd/io.c b/tools/xen-9pfsd/io.c index 2e2275e8ab..74efd21c10 100644 --- a/tools/xen-9pfsd/io.c +++ b/tools/xen-9pfsd/io.c @@ -32,6 +32,7 @@ #define P9_CMD_ERROR 107 #define P9_CMD_WALK 110 #define P9_CMD_OPEN 112 +#define P9_CMD_CLUNK 120 =20 /* P9 protocol open flags. */ #define P9_OREAD 0 /* read */ @@ -962,6 +963,44 @@ static void p9_open(struct ring *ring, struct p9_heade= r *hdr) p9_error(ring, hdr->tag, errno); } =20 +static void p9_clunk(struct ring *ring, struct p9_header *hdr) +{ + device *device =3D ring->device; + uint32_t fid; + struct p9_fid *fidp; + 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 ( fidp->opened ) + { + fidp->opened =3D false; + free_fid(device, fidp); + close(fidp->fd); + if ( fidp->mode & P9_OREMOVE ) + unlinkat(device->root_fd, fidp->path, + fidp->isdir ? AT_REMOVEDIR : 0); + } + + /* 2 calls of free_fid(): one for our reference, and one to free it. */ + free_fid(device, fidp); + free_fid(device, fidp); + + fill_buffer(ring, hdr->cmd + 1, hdr->tag, ""); +} + void *io_thread(void *arg) { struct ring *ring =3D arg; @@ -1033,6 +1072,10 @@ void *io_thread(void *arg) p9_open(ring, &hdr); break; =20 + case P9_CMD_CLUNK: + p9_clunk(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