From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 16 16:31:03 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2281B16A4DA for ; Wed, 16 Aug 2006 16:31:03 +0000 (UTC) (envelope-from anderson@centtech.com) Received: from mh1.centtech.com (moat3.centtech.com [207.200.51.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C18943D4C for ; Wed, 16 Aug 2006 16:30:59 +0000 (GMT) (envelope-from anderson@centtech.com) Received: from [10.177.171.220] (neutrino.centtech.com [10.177.171.220]) by mh1.centtech.com (8.13.1/8.13.1) with ESMTP id k7GGUpQr076345; Wed, 16 Aug 2006 11:30:55 -0500 (CDT) (envelope-from anderson@centtech.com) Message-ID: <44E3484D.8090905@centtech.com> Date: Wed, 16 Aug 2006 11:31:09 -0500 From: Eric Anderson User-Agent: Thunderbird 1.5.0.5 (X11/20060802) MIME-Version: 1.0 To: Tobias Roth References: <44E29055.3080205@centtech.com> <20060816054925.GA11651@droopy.unibe.ch> In-Reply-To: <20060816054925.GA11651@droopy.unibe.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.87.1/1670/Wed Aug 16 08:49:00 2006 on mh1.centtech.com X-Virus-Status: Clean Cc: FreeBSD Hackers Subject: Re: struct dirent question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2006 16:31:03 -0000 On 08/16/06 00:49, Tobias Roth wrote: > On Tue, Aug 15, 2006 at 10:26:13PM -0500, Eric Anderson wrote: >> Does the ifdef in the struct dirent (pasted in below) make any sense? >> Seems like regardless of whether the __BSD_VISIBLE is defined or not, >> the d_name length will always be 255 + 1. >> >> Eric >> >> >> struct dirent { >> __uint32_t d_fileno; /* file number of entry */ >> __uint16_t d_reclen; /* length of this record */ >> __uint8_t d_type; /* file type, see below */ >> __uint8_t d_namlen; /* length of string in d_name */ >> #if __BSD_VISIBLE >> #define MAXNAMLEN 255 >> char d_name[MAXNAMLEN + 1]; /* name must be no longer than >> this */ >> #else >> char d_name[255 + 1]; /* name must be no longer than >> this */ >> #endif >> }; > > The difference is whether MAXNAMLEN is defined or not, the value of d_name > is irrelevant. How far not defining MAXNAMLEN (in the case __BSD_VISIBLE= > false) makes sense, I cannot tell. > > cheers, t. My point was, that either path you take (if BSD_VISIBLE is defined or not), you end up with d_name having a size of 255 + 1, so what's the point the having it at all? Isn't this the same thing (but easier to read): #if __BSD_VISIBLE #define MAXNAMLEN 255 #endif struct dirent { __uint32_t d_fileno; /* file number of entry */ __uint16_t d_reclen; /* length of this record */ __uint8_t d_type; /* file type, see below */ __uint8_t d_namlen; /* length of string in d_name char d_name[255 + 1]; /* name must be no longer than this */ }; -- ------------------------------------------------------------------------ Eric Anderson Sr. Systems Administrator Centaur Technology Anything that works is better than anything that doesn't. ------------------------------------------------------------------------