From owner-freebsd-fs@freebsd.org Wed Aug 23 10:11:41 2017 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30896DE2F98 for ; Wed, 23 Aug 2017 10:11:41 +0000 (UTC) (envelope-from Nikolaus@rath.org) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01AC769DB3 for ; Wed, 23 Aug 2017 10:11:40 +0000 (UTC) (envelope-from Nikolaus@rath.org) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8FA3E21B08 for ; Wed, 23 Aug 2017 06:11:38 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 23 Aug 2017 06:11:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=jEcOKpNm6z9a8pmY79UnsJNWXCrPT17jeWjkqEhtZVw=; b=OQtf7jyR incj9tn8Ng2SdkzIb/HuT8UYBBMz4NK//cQ3Z4o5EXCiaABJw4ReCF7+VsnNyVc8 IQV0ou4z2N9MbpGDIEeNU+WXZWHGLBT5Jem+FsnFxnSTrU2wWzZDuXz3E2mT+zUK WKPk8ZXfGub1re2VMIjPUv9vhj8O9IpSEt+lfaUzZnSdQwH7vI2saKduS7yfub7i EEwnZeCj+3cG4ZFjiN5RuqitG/QvVJyNZFD5ekmCo/gosh+s40OZBU8iN8uR7Rgr sfc0953C8R1LktPEf9Nc4zTiSz6v6pzeygnyokswwFUDktYxLG0JWtP/XOjEC6gT xxKUKFRW40jx8Q== X-ME-Sender: X-Sasl-enc: 88x/h//SfweNYgVSMenFgloqsd0uF9cr2Ho4xRj+1Gey 1503483098 Received: from ebox.rath.org (ebox.rath.org [45.79.69.51]) by mail.messagingengine.com (Postfix) with ESMTPA id 4B9347FA1C for ; Wed, 23 Aug 2017 06:11:38 -0400 (EDT) Received: from vostro.rath.org (vostro [192.168.12.4]) by ebox.rath.org (Postfix) with ESMTPS id 48E92116 for ; Wed, 23 Aug 2017 10:11:37 +0000 (UTC) Received: by vostro.rath.org (Postfix, from userid 1000) id A88091031FE; Wed, 23 Aug 2017 12:11:35 +0200 (CEST) From: Nikolaus Rath To: freebsd-fs@freebsd.org Subject: Re: Can telldir() == 0 value be made special? References: <87bmn7kf3b.fsf@vostro.rath.org> <87lgmbfob2.fsf@vostro.rath.org> Mail-Copies-To: never Mail-Followup-To: freebsd-fs@freebsd.org Date: Wed, 23 Aug 2017 12:11:35 +0200 In-Reply-To: (Conrad Meyer's message of "Tue, 22 Aug 2017 12:05:29 -0700") Message-ID: <87ziaqr3u0.fsf@vostro.rath.org> User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 10:11:41 -0000 On Aug 22 2017, Conrad Meyer wrote: > One could also make it reserve the zero slot for the loc =3D=3D 0 entry, > but not create it dynamically. Just set loccnt=3D1 at initialization > and then special-case dd_loc=3D=3D0. Like this: > > --- a/lib/libc/gen/opendir.c > +++ b/lib/libc/gen/opendir.c > @@ -295,7 +295,7 @@ __opendir_common(int fd, int flags, bool use_current_= pos) > dirp->dd_lock =3D NULL; > dirp->dd_td =3D (struct _telldir *)((char *)dirp + sizeof(DIR)); > LIST_INIT(&dirp->dd_td->td_locq); > - dirp->dd_td->td_loccnt =3D 0; > + dirp->dd_td->td_loccnt =3D 1; > dirp->dd_compat_de =3D NULL; > > /* > --- a/lib/libc/gen/telldir.c > +++ b/lib/libc/gen/telldir.c > @@ -76,7 +76,10 @@ telldir(DIR *dirp) > _pthread_mutex_unlock(&dirp->dd_lock); > return (-1); > } > - lp->loc_index =3D dirp->dd_td->td_loccnt++; > + if (dirp->dd_loc =3D=3D 0) > + lp->loc_index =3D 0; > + else > + lp->loc_index =3D dirp->dd_td->td_loccnt++; > lp->loc_seek =3D dirp->dd_seek; > lp->loc_loc =3D dirp->dd_loc; > if (flp !=3D NULL) > This would improve Linux/fuse compatibility a lot, and seems like a minimal increase in complexity. Is there any way I can help to get it merged? Best, -Nikolaus --=20 GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2= =AB