From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Mahoney Subject: Re: Access content of file via inodes Date: Tue, 05 Apr 2005 21:53:16 -0400 Message-ID: <4253410C.20405@suse.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Bryan Henderson , linux-fsdevel@vger.kernel.org Return-path: Received: from locomotive.csh.rit.edu ([129.21.60.149]:14120 "EHLO locomotive.unixthugs.org") by vger.kernel.org with ESMTP id S262075AbVDFBxU (ORCPT ); Tue, 5 Apr 2005 21:53:20 -0400 To: "Kathy KN (HK)" In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Kathy KN (HK) wrote: > On Apr 6, 2005 1:53 AM, Bryan Henderson wrote: >>>How do I access/read the content of the files via using inodes >>>or blocks that belong to the inode, at sys_link and vfs_link layer? >>This is tricky because many interfaces that one would expect to use an >>inode as a file handle use a dentry instead. To read the contents of a >>file via the VFS interface, you need a file pointer (struct file), and the >>file pointer identifies the file by dentry. So you need to create a dummy >>dentry, which you can do with d_alloc_root(), and then create the file >>pointer with dentry_open(), then read the file with vfs_read(). >> >>That's for "via inodes." I don't know what "via blocks" means. > > Bryan, > > Thanks for the description on how to read the contents of a file via > the VFS interface. I got to try to see if I can write it in codes, and make > sure that I can read the file via the vfs_read() routine. What I meant by > via blocks is to gain knowledge of the physical blocks used by the inodes > and retrieve the content from it directly, by accessing b_data. The problem with that approach is that some filesystems may store part of the file outside of a complete block. For example, reiserfs "tails" will respond with -ENOENT on ->bmap. For files smaller than 16k, they are quite common. -Jeff -- Jeff Mahoney SuSE Labs