From nobody Sun Feb 8 21:36:58 2026 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 1527816787573426.3678534712582; Thu, 31 May 2018 18:33:07 -0700 (PDT) Received: from localhost ([::1]:46910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYwE-0006eP-Kg for importer@patchew.org; Thu, 31 May 2018 21:33:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr3-00034Q-Pw for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr2-00036J-K6 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:40686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr2-00035u-FV for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:44 -0400 Received: by mail-qk0-x241.google.com with SMTP id r66-v6so18731601qkr.7 for ; Thu, 31 May 2018 18:27:44 -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 o68-v6sm2003842qkc.19.2018.05.31.18.27.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:42 -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=L68nHRkEn0HuX90KY/3eElE7cAN+upBxcoYsXFPKTUQ=; b=xkRjBYTu5v0PGwaE2QZ2ekB2duNJyr233s35RQ4hsABaRAUZ9fh66YZDGGJdULYth7 tts1HM7jL81dXi7T4AgT8iyb5mqOtquqLuIMd1zBTqnPHsqKaggb/NaxZ4J0QVKzqJdK 9SZeg7xbQVL4E7NY+mGKo2zyT/tJkzaTqh+mW2bx5oGcAfqa8HEmTtR6vVGb2pEAbbco o8WRgoiW+d1EScmZ6Joo91mBcAy0/PG7HlvHj6Ip8vUZwYR5C7HTWXofzyuOAtyJ+IBJ 1hhU/H9fPSQHO4/u8PPPaq+EC9x3X4odCFe/GboN0GRgxQEFd4gFiQhvqzskC6Gp/AK+ 3mcg== 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=L68nHRkEn0HuX90KY/3eElE7cAN+upBxcoYsXFPKTUQ=; b=BnVUrqKIxssUa7bLEwuCUrBunfQntQT1KPiMKY4iPfbTHj8QoEEsWJ+qppnQfiAi/T JY3tN6rFV4YrhO3Aik5LHGnVlRi6uEgEfKhhrRsHSKpfYGVUA4Pd5wQFvR5aK/0rNEkg t/Lbv6emgsIhZgPNO7zcWNEI5st0oMr+/gekF05nO2n64e/RbA2V9khTTvyxrS9dmtAE fLjsxoN/jp4wn44yIJGWkF48ZOSRQI6BBZypFsY+VRtB54ZZqDqsBYjtplfWV9fVVQd4 BI19orSdDGD03SHz0zzKLxmdtaU1zlDLWtfsj5OFBRSRXL1SdK0T+Q9lytcyV2b/ey7H q7RQ== X-Gm-Message-State: APt69E1a60TIRWArHhQ0g29QXKAqYH1BirL0pySZuJScmLvPZuj3RU8e ZSKObKnOFBDb93BTzCTne48AyOmYTKY= X-Google-Smtp-Source: ADUXVKK689UuPk64os+cYfW+uOMymUyHtg+AtSmFDpEiYvOh9zThsozeg5v7ozhk2TdR9siOynrraw== X-Received: by 2002:a37:8b07:: with SMTP id n7-v6mr4112161qkd.353.1527816463571; Thu, 31 May 2018 18:27:43 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:06 -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:c09::241 Subject: [Qemu-devel] [PATCH v2 11/20] 9p: darwin: Handle struct dirent differences 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" On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset. Signed-off-by: Keno Fischer --- Changes since v1: * Drop setting d_seekoff in synth_direntry * Factor telldir vs d_off logic into v9fs_dent_telldir * Error path for telldir failure hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index eb68b42..a312f8c 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -221,7 +221,9 @@ static void synth_direntry(V9fsSynthNode *node, { strcpy(entry->d_name, node->name); entry->d_ino =3D node->attr->inode; +#ifndef CONFIG_DARWIN entry->d_off =3D off + 1; +#endif } =20 static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 212f569..9751246 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1738,6 +1738,25 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pd= u, V9fsFidState *fidp, return offset; } =20 +/** + * Get the seek offset of a dirent. If not available from the structure it= self, + * obtain it by calling telldir. + */ +static int v9fs_dent_telldir(V9fsPDU *pdu, V9fsFidState *fidp, + struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + /* + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so use telldir for correctness. + */ + return v9fs_co_telldir(pdu, fidp); +#else + return dent->d_off; +#endif +} + static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, V9fsFidState *fidp, uint32_t max_count) @@ -1801,7 +1820,11 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9= fsPDU *pdu, count +=3D len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos =3D dent->d_off; + saved_dir_pos =3D v9fs_dent_telldir(pdu, fidp, dent); + if (saved_dir_pos < 0) { + err =3D saved_dir_pos; + break; + } } =20 v9fs_readdir_unlock(&fidp->fs.dir); @@ -1915,7 +1938,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, V9fsString name; int len, err =3D 0; int32_t count =3D 0; - off_t saved_dir_pos; + off_t saved_dir_pos, off; struct dirent *dent; =20 /* save the directory position */ @@ -1951,10 +1974,15 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pd= u, V9fsFidState *fidp, /* Fill the other fields with dummy values */ qid.type =3D 0; qid.version =3D 0; + off =3D v9fs_dent_telldir(pdu, fidp, dent); + if (off < 0) { + err =3D off; + break; + } =20 /* 11 =3D 7 + 4 (7 =3D start offset, 4 =3D space for storing count= ) */ len =3D pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); =20 v9fs_readdir_unlock(&fidp->fs.dir); @@ -1966,7 +1994,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, } count +=3D len; v9fs_string_free(&name); - saved_dir_pos =3D dent->d_off; + saved_dir_pos =3D off; } =20 v9fs_readdir_unlock(&fidp->fs.dir); --=20 2.8.1