From owner-freebsd-bugs@FreeBSD.ORG Sun Jan 13 10:10:05 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B1EB16A4CD for ; Sun, 13 Jan 2008 10:10:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 65F0813C467 for ; Sun, 13 Jan 2008 10:10:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0DAA5O3067801 for ; Sun, 13 Jan 2008 10:10:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0DAA4Rj067796; Sun, 13 Jan 2008 10:10:04 GMT (envelope-from gnats) Date: Sun, 13 Jan 2008 10:10:04 GMT Message-Id: <200801131010.m0DAA4Rj067796@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: David Schultz Cc: Subject: Re: misc/113668: scandir(3) uses st_size of directory in unsupported manner X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: David Schultz List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jan 2008 10:10:05 -0000 The following reply was made to PR kern/113668; it has been noted by GNATS. From: David Schultz To: Ed Ravin Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: misc/113668: scandir(3) uses st_size of directory in unsupported manner Date: Sun, 13 Jan 2008 05:03:10 -0500 In the original Unix, directories were just files. FreeBSD has always supported that philosophy; you can still `cat' a directory, and so it makes sense that st_size gives you the size in bytes. It's not scandir's fault that System V made directories more magical, then POSIX came along and had to cope with it, then the ZFS team exploited the underspecification in POSIX for their own nefarious purposes. :) That said, given that FreeBSD now has ZFS, and some of the ZFS utils probably assume the new ZFS rules for st_size, I guess we ought to do something! Note that this is just a performance problem, since scandir will realloc the array as necessary. However, it does the increases in increments of 10 entries, and it should probably realloc multiplicatively so the amortized cost of the reallocs is linear. I'm not sure what to do about the initial estimate, though. If we really want to support every old st_size value filesystem designers come up with, we need to worry about st_size being too large as well, so we basically shouldn't use it at all...