Subject: Re: modstat + gehenna-devsw
To: Jaromir Dolecek <jdolecek@netbsd.org>
From: Love <lha@stacken.kth.se>
List: current-users
Date: 09/17/2002 20:48:25
Jaromir Dolecek <jdolecek@netbsd.org> writes:

> I thought gehenna had some patch to modstat, similar to yours.

Where ?
 
> >  	offset = (long)sbuf.offset;
> > -	if (offset < 0)
> > +	if (sbuf.type == LM_DEV) {
> > +		int len = 0;
> > +		
> > +		if (block_major(offset) > 0)
> > +			len = snprintf(offset_string, sizeof(offset_string),
> > +			    "%3d%s", block_major(offset), 
> > +			    char_major(offset) > 0 ? "/" : "");
> > +		if (char_major(offset) > 0 && len < sizeof(offset_string))
> > +			(void) snprintf(offset_string + len, 
> > +			    sizeof(offset_string) - len,
> > +			    "%3d", char_major(offset));
> > +
> > +	} else if (offset < 0)
> 
> The check for type should go into else branch, i.e. should only
> be visited if offset is >= 0. You could then also simplify
> the block_major()/char_major() checks. BTW, are block_major/char_major()
> new macros? Should be uppercase in that case.

But when block_major(offset) == -1, offset will also be negative.

Yes they are, they are part of the userland kernel lkm api apprently, guess
they should be prefixed by lkm too.

Love