Date: Thu, 17 Apr 1997 19:19:03 +1000 From: Stephen McKay <syssgm@dtir.qld.gov.au> To: freebsd-hackers@freebsd.org Cc: syssgm@dtir.qld.gov.au Subject: Switching one hack for another in ufs/ufs/dir.h Message-ID: <199704170919.TAA10663@troll.devetir.qld.gov.au>
next in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704170919.TAA10663>