[wplug-bsd] Patching a driver

Tom Rhodes trhodes at FreeBSD.org
Tue Oct 17 18:09:07 EDT 2006


On Mon, 16 Oct 2006 18:48:19 -0400 (EDT)
Brandon Kuczenski <brandon at 301south.net> wrote:

> I'm working with samba at work and came across the following bug:
> 
> https://bugzilla.samba.org/show_bug.cgi?id=2794
> 
> in a somewhat unpleasant way.  It seems the samba people think that 
> FreeBSD's ntfs driver is broken, and misreports the number of hard links 
> for files on ntfs filesystems.
> 
> It looks like there is a simple one-line hack of a patch, to 
> sys/fs/ntfs/ntfs_vnops.c, which is explained in the comments to the bug:
> 
>   before:
>  	vap->va_nlink = ip->i_nlink;
>   after:
>  	vap->va_nlink = (ip->i_nlink ? ip->i_nlink : 1);
> 
> My question: what is the 'BSD' way to implement this patch and install the 
> patched driver, if possible without rebuilding the kernel?

Two things:

First, I would use:
vap->va_nlink = (ip->i_nlink || ip->i_flag & IN_LOADED ? ip->i_nlink : 1);
in place of the one above, which is an ugly hack.  My version still
doesn't offer POSIX conformance as it fakes the link count in place of
reading the MFT every time, which is a considerable decrease in speed.

Two, you can patch and rebuild a driver without rebuilding the kernel
so long as the source has not changed and said driver is not built
into the kernel itself.  Good luck.

-- 
Tom Rhodes


More information about the wplug-bsd mailing list