Subject: Re: mkdir with trailing / (patch proposed)
To: Matthew Orgass <>
From: Bill Studenmund <>
List: tech-userlevel
Date: 04/30/2002 17:21:29
On Tue, 30 Apr 2002, Matthew Orgass wrote:

> On Tue, 30 Apr 2002, Bill Studenmund wrote:
> > I'm not saying you didn't see crashes, I'm saying I don't see where they
> > came from. Directory lookup (VOP_LOOKUP()) seems fine, and readdir
> > (VOP_READDIR()) seems fine for ufs. What failed?
>   DIRSIZ expects the trailing '\0'.  It doesn't look like there is any
> memory corruption, but there is fs corruption.  A DIAGNOSTIC kernel panics
> with "bad dir" on accessing the directory created with a trailing slash,
> failing the last check of ufs_dirbadentry.  fsck also complains.  It may
> be that a kernel without DIAGNOSTIC would be fine until the disk needed to
> be fscked for other reasons.

Hmmm.... Looking at the code and its past versions, it looks like we're
looking at a bit o' history. The very first version of this file didn't
need that \0; we've used a length-specific compare since the begining.

DIRSIZ doesn't seem to rely on there beeing a trailing \0, though it saves
space for it. I think a kernel created w/o DIAGNOSTIC would be fine.

We probably should add the nul, since the sample code for readdir uses
strcmp(), not strncmp().

Take care,