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 15:01:47 -0400 Message-ID: <4252E09B.9020606@suse.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from locomotive.csh.rit.edu ([129.21.60.149]:25121 "EHLO locomotive.unixthugs.org") by vger.kernel.org with ESMTP id S261514AbVDETBx (ORCPT ); Tue, 5 Apr 2005 15:01:53 -0400 To: Kathy KN In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Kathy KN wrote: > Good day all, > > 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? > I used bmap to access the blocks that belongs to the inodes, but > getting access to the buffer_head's b_data doesn't seem to help. Hi Kathy - What you're trying to do is possible, but you need to go about it in a different way. Ignore the buffer cache completely and use the page cache; it's more appropriate for file contents. You have two options: If performance isn't critical, a simple approach would be to use your old_dentry pointer to dentry_open a file and then vfs_read from it to a buffer you allocate. Make sure you use get_fs/set_fs, since vfs_read won't accept a kernel pointer otherwise. If performance is more important or you really do only have access to an inode, you can read from the page cache directly using inode->i_mapping and read_cache_page. This has the advantage that you don't need to copy the data to access it, but the disadvantage that it is more complex and can be tricky to get right. -Jeff -- Jeff Mahoney SuSE Labs