On Wed, 6 Apr 2005, Kathy KN (HK) wrote:
> On Apr 6, 2005 1:53 AM, Bryan Henderson <[EMAIL PROTECTED]> 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/
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html