From owner-freebsd-current@FreeBSD.ORG Thu Jan 17 19:45:18 2008 Return-Path: Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0553A16A418 for ; Thu, 17 Jan 2008 19:45:18 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (VARK.MIT.EDU [18.95.3.179]) by mx1.freebsd.org (Postfix) with ESMTP id DBA3D13C447 for ; Thu, 17 Jan 2008 19:45:17 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (localhost [127.0.0.1]) by VARK.MIT.EDU (8.14.2/8.14.1) with ESMTP id m0HJiv4s084982; Thu, 17 Jan 2008 14:44:57 -0500 (EST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.MIT.EDU (8.14.2/8.14.1/Submit) id m0HJivrR084981; Thu, 17 Jan 2008 14:44:57 -0500 (EST) (envelope-from das@FreeBSD.ORG) Date: Thu, 17 Jan 2008 14:44:57 -0500 From: David Schultz To: Adam Message-ID: <20080117194457.GA84887@VARK.MIT.EDU> Mail-Followup-To: Adam , freebsd-current@FreeBSD.ORG References: <485228D5-8D0B-4CD5-9FB7-B0D551B172DA@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <485228D5-8D0B-4CD5-9FB7-B0D551B172DA@gmail.com> Cc: freebsd-current@FreeBSD.ORG Subject: Re: Reading and Writing to Block from di_spare X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2008 19:45:18 -0000 On Thu, Jan 17, 2008, Adam wrote: > Hi, I am working on a project for where I want to take the standard > UFS/FFS file system that BSD ships with and add several blocks of > information to the dinode. The simplest way of doing it seemed to be > to allocate blocks to di_spare. I believe that I have figured out how > to do that: > > ffs_alloc(inode, 0 , 0, (int)(inode->i_fs->fs_bsize), td->td_ucred, > &addr); > dinode->di_spare[1]=(int64_t)addr; > > I'm having problems taking that block address and reading/writing to > it. As far as I can tell most of the buffer read routines (getblk, > bread) seem to be geared toward reading and writing direct and > indirect blocks in an inode. > > How do I read and write a block that is neither a direct nor an > indirect block? Maybe I'm misunderstanding your question, but I don't see how you could expect FreeBSD to have routines to read and write things that don't exist in FreeBSD. :) See extattr(2). It may be possible that the "extra information" you want to store with files can be stored in user space using the relatively standard extended attributes API.