Date: Mon, 2 Oct 2006 21:31:44 -0600 (MDT) From: Scott Long <scottl@samsco.org> To: Shane Adams <adamsch1@yahoo.com> Cc: freebsd-fs@freebsd.org Subject: Re: curiosity between bread and UFS_BALLOC on struct buf Message-ID: <20061002212040.V38801@pooker.samsco.org> In-Reply-To: <20061003011243.19533.qmail@web31812.mail.mud.yahoo.com> References: <20061003011243.19533.qmail@web31812.mail.mud.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2 Oct 2006, Shane Adams wrote: > Hey all, > I've been puzzling with a bit of code. I'm creating a file from within > a kernel module, that works fine, but I've got a question if perhaps I'm > missing something: > > I use UFS_BALLOC to allocate some space. That function has a struct buf > thats returned. What I would expect is that I could manipulate the > bp->b_data field then do a bwrite and have my changes saved. Doesnt > workthat way. Only way I can get it to work is > > 1 UFS_BALLOC( ... ) > > 2 bwrite( .. ) > > 3 bread( ... ) > > 4 /* Make changes to what I read */ > > 5 bwrite() > > Seems like I could get rid of, 2 and 3. I'm not sure why I have to > bwrite the buffer returned from UFS_BALLOC. I dug around and there are > a few examples of where ffs/ufs manipulate the buffer returned from > UFS_BALLOC so I am guessing I'm missing a flag or something. > > Hope the question is clear enough! You shouldn't be groping around in UFS internals like this. Using VOP_WRITE will probably serve you much better. Look at something like kern_ktrace.c to see how file writing in the kernel is done. Scott
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061002212040.V38801>