From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kathy KN (HK)" Subject: Re: Access content of file via inodes Date: Wed, 6 Apr 2005 09:27:01 +0800 Message-ID: References: Reply-To: "Kathy KN (HK)" 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 zproxy.gmail.com ([64.233.162.198]:48011 "EHLO zproxy.gmail.com") by vger.kernel.org with ESMTP id S262065AbVDFB1D (ORCPT ); Tue, 5 Apr 2005 21:27:03 -0400 Received: by zproxy.gmail.com with SMTP id 18so6414nzp for ; Tue, 05 Apr 2005 18:27:01 -0700 (PDT) To: Bryan Henderson In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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. Kathy