From owner-freebsd-hackers Thu Apr 17 02:31:06 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id CAA22013 for hackers-outgoing; Thu, 17 Apr 1997 02:31:06 -0700 (PDT) Received: from bunyip.cc.uq.edu.au (daemon@bunyip.cc.uq.edu.au [130.102.2.1]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA22006 for ; Thu, 17 Apr 1997 02:31:01 -0700 (PDT) Received: (from daemon@localhost) by bunyip.cc.uq.edu.au (8.8.5/8.8.5) id TAA24082 for freebsd-hackers@freebsd.org; Thu, 17 Apr 1997 19:30:57 +1000 Received: from troll.devetir.qld.gov.au by ogre.dtir.qld.gov.au (8.7.5/DEVETIR-E0.3a) with ESMTP id TAA02494 for ; Thu, 17 Apr 1997 19:19:07 +1000 (EST) Received: from localhost (syssgm@localhost) by troll.devetir.qld.gov.au (8.8.5/8.8.5) with SMTP id TAA10663; Thu, 17 Apr 1997 19:19:03 +1000 (EST) Message-Id: <199704170919.TAA10663@troll.devetir.qld.gov.au> X-Authentication-Warning: troll.devetir.qld.gov.au: syssgm@localhost didn't use HELO protocol To: freebsd-hackers@freebsd.org cc: syssgm@dtir.qld.gov.au Subject: Switching one hack for another in ufs/ufs/dir.h Date: Thu, 17 Apr 1997 19:19:03 +1000 From: Stephen McKay Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I've been looking at the hack in ufs/ufs/dir.h for supporting old (pre 4.4) directory entries. It came about because a short was split into two bytes, one of which was, conveniently, always zero in existing file systems. Yes, this is actually relevant to the real world as I have some old external disk packs that I just carried over unchanged from BSD/OS 1.0 to FreeBSD and I was interested in the mechanism that allowed it to work. Wouldn't it be better to put the hack in the definition of struct direct rather than in the DIRSIZ macro? I think what we have currently violates the principle of least surprise. Instead of the current hack, I'd use something like: struct direct { u_int32_t d_ino; /* inode number of entry */ u_int16_t d_reclen; /* length of this record */ #if (BYTE_ORDER == LITTLE_ENDIAN) u_int8_t d_namlen; /* length of string in d_name */ u_int8_t d_type; /* file type, see below */ #else u_int8_t d_type; /* file type, see below */ u_int8_t d_namlen; /* length of string in d_name */ #endif char d_name[MAXNAMLEN + 1];/* name with length <= MAXNAMLEN */ }; #define DIRSIZ(oldfmt, dp) DIRECTSIZ((dp)->d_namlen) Ok, now that I've really got your blood pumping with enthusiasm, I can sit back and wait for your opinions. :-) Stephen.