linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Altaparmakov <aia21@cam.ac.uk>
To: "Kathy KN (HK)" <kathy.kn@gmail.com>
Cc: Bryan Henderson <hbryan@us.ibm.com>, linux-fsdevel@vger.kernel.org
Subject: Re: Access content of file via inodes
Date: Wed, 6 Apr 2005 08:54:23 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.60.0504060851270.25589@hermes-1.csi.cam.ac.uk> (raw)
In-Reply-To: <f8ad67b3050405182753206558@mail.gmail.com>

On Wed, 6 Apr 2005, Kathy KN (HK) wrote:
> On Apr 6, 2005 1:53 AM, Bryan Henderson <hbryan@us.ibm.com> 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.
> 
> 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.

You cannot do that safely because some file systems do not store things in 
whole blocks.  For example small files in ntfs are stored as a variable 
length and variable offset record inside the inode record on disk.  And 
compressed/encrypted files on ntfs are stored compressed/encrypted on disk 
and are decompressed/decrypted on access so there are no blocks you could 
usefully read at all.  (This is why ntfs does not implement ->bmap - it 
just makes no sense.)

Oh and another thing is that ->bmap returns 0 for a sparse block, i.e. not 
allocated on disk, it is zero.  But for example ntfs uses 0 as a valid 
block number you can read from/write to so that is not compatible with 
->bmap either.

Best regards,

	Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/

  parent reply	other threads:[~2005-04-06  7:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-05  1:23 Access content of file via inodes Kathy KN
2005-04-05  7:22 ` Christoph Hellwig
2005-04-05 17:53 ` Bryan Henderson
2005-04-06  1:27   ` Kathy KN (HK)
2005-04-06  1:53     ` Jeff Mahoney
2005-04-06 17:57       ` Bryan Henderson
2005-04-06  7:54     ` Anton Altaparmakov [this message]
2005-04-06 11:33     ` Anton Altaparmakov
2005-04-06 13:09       ` Jeffrey Mahoney
2005-04-07  5:25       ` Kathy KN (HK)
2005-04-07  6:47         ` Jeffrey Mahoney
2005-04-07  8:09           ` Anton Altaparmakov
2005-04-05 19:01 ` Jeff Mahoney
2005-04-06  1:32   ` Kathy KN (HK)
2005-04-06  1:50     ` Jeff Mahoney
2005-04-08  6:01   ` Kathy KN (HK)
2005-04-08  8:17     ` Anton Altaparmakov
2005-05-27 19:13       ` Martin Jambor
2005-05-28 15:57         ` Anton Altaparmakov
2005-05-28 21:44           ` Martin Jambor
2005-05-29  7:26             ` Anton Altaparmakov
2005-05-30 21:51               ` Martin Jambor
2005-05-30 22:19                 ` Anton Altaparmakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.60.0504060851270.25589@hermes-1.csi.cam.ac.uk \
    --to=aia21@cam.ac.uk \
    --cc=hbryan@us.ibm.com \
    --cc=kathy.kn@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).