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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B91C5C433F5 for ; Wed, 20 Apr 2022 08:41:50 +0000 (UTC) Received: from localhost ([::1]:37014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nh5uH-0005Ki-Np for qemu-devel@archiver.kernel.org; Wed, 20 Apr 2022 04:41:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nh5sp-0003h9-Vc for qemu-devel@nongnu.org; Wed, 20 Apr 2022 04:40:23 -0400 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:59513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nh5sk-0006A3-RO for qemu-devel@nongnu.org; Wed, 20 Apr 2022 04:40:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-M8pqHLTWPfmTfBXsuMMz7A-1; Wed, 20 Apr 2022 04:40:07 -0400 X-MC-Unique: M8pqHLTWPfmTfBXsuMMz7A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4403F1014A61; Wed, 20 Apr 2022 08:40:07 +0000 (UTC) Received: from bahia (unknown [10.39.192.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14ACC401E6C; Wed, 20 Apr 2022 08:40:05 +0000 (UTC) Date: Wed, 20 Apr 2022 10:40:05 +0200 From: Greg Kurz To: Akihiko Odaki Subject: Re: [PATCH 1/5] 9pfs: fix qemu_mknodat(S_IFREG) on macOS Message-ID: <20220420104005.742b818b@bahia> In-Reply-To: <280dfc7a-7985-3c01-c1ac-5fe15825c95a@gmail.com> References: <2a515431fdc02b0b2d3613f5d569305a32cfba30.1650370026.git.qemu_oss@crudebyte.com> <280dfc7a-7985-3c01-c1ac-5fe15825c95a@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: softfail client-ip=207.211.30.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Christian Schoenebeck , qemu-devel@nongnu.org, qemu-stable@nongnu.org, Keno Fischer , Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, 20 Apr 2022 11:03:52 +0900 Akihiko Odaki wrote: > On 2022/04/19 20:40, Christian Schoenebeck wrote: > > mknod() on macOS does not support creating regular files, so > > divert to openat_file() if S_IFREG is passed with mode argument. > > > > Furthermore, 'man 2 mknodat' on Linux says: "Zero file type is > > equivalent to type S_IFREG". > > > > Link: https://lore.kernel.org/qemu-devel/17933734.zYzKuhC07K@silver/ > > Signed-off-by: Christian Schoenebeck > > --- > > hw/9pfs/9p-util-darwin.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c > > index bec0253474..53e0625501 100644 > > --- a/hw/9pfs/9p-util-darwin.c > > +++ b/hw/9pfs/9p-util-darwin.c > > @@ -77,6 +77,10 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, > > int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) > > { > > int preserved_errno, err; > > + > > + if (S_ISREG(mode) || !(mode & S_IFMT)) { > > + return openat_file(dirfd, filename, O_CREAT, mode); > > + } > > if (!pthread_fchdir_np) { > > error_report_once("pthread_fchdir_np() not available on this version of macOS"); > > return -ENOTSUP; > > openat_file returns a file descriptor on success while mknodat returns 0 > on success. The inconsistency should be handled. > And most importantly that file descriptor must be closed ! > Regards, > Akihiko Odaki