qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Help needed -- vvfat.c


From: Pintu Kumar
Subject: Re: [Qemu-devel] Help needed -- vvfat.c
Date: Fri, 23 Sep 2011 16:00:49 +0530

On Mon, Sep 19, 2011 at 8:07 PM, Kevin Wolf <address@hidden> wrote:
> Am 15.09.2011 14:49, schrieb Pintu Kumar:
>> Hi,
>>
>> This is regarding qemu block/vvfat.c.
>>
>> Currently vvfat scans all directories and sub-directories in the
>> beginning during init_directories().
>>
>> I want to modify vvfat such that it should scan only the TOP directory
>> content and not the sub-directory content before mounting.
>> And after mounting vvfat I should be able to dynamically get the TOP
>> directory content when I do "ls -l" on that directory.
>> How can I do that?
>>
>> I tried skipping sub-directory in read_directory() as follows.
>>                 else if(S_ISDIR(st.st_mode))
>>                 {
>>                         LOGD("Skipping sub-directory : %s\n", buffer);
>>                         s->current_mapping=NULL;
>>                         continue;
>>                 }
>> After that the sub-directories are visible after mounting and part1 is 
>> working.
>> But after mounting when I do "ls -l" on vvfat mounted path, on any
>> directory, vvfat_read() is not getting called.
>>
>> Somebody who knows about vvfat implementation please let me know where
>> is the problem.
>
> I doubt that this is possible. A guest OS doesn't expect that data on
> the disk changes when it didn't write to it. So for example, it could
> read in the whole FAT and never really look at the on-disk FAT any more.
>
> In practice, probably only parts of the FAT are cached, but that doesn't
> help you. You never know which parts are cached, and anyway, even if you
> knew which parts you may change, restricting changes to these parts of
> the FATs would be tricky... vvfat is already complicated enough without
> doing anything like this.
>
> Kevin
>

--------------------------------------------------------------------------------------------------------------

Dear Mr. Kevin,

Thank you very much for your reply.
So according to your opinion it is not possible to perform dynamic
scanning and mapping of sub-directories after mounting the vvfat.

Actually,
In our case, we have implemented VVFAT as a daemon process on our
linux mobile device.
And developed a block driver (/dev/vvfat) to process the request from deamon.
(My vvfat device is mounted as :)
(/dev/vvfat              515584        32    515552   0% /mnt/vvfatfs)

2314 pts/0    S      0:00 ./vvfatd /opt/targetdir/

The real problem for us is : if the ext4 partition to be mounted as
VVFAT contains very large data (directory hierarchy and files) then it
may take longer time for VVFAT to mount.
So we wanted to perform only TOP directory scanning initially and then
after mounting if the user tries to access any
sub-directory we should be able to map rest of the contents on the fly.


To do partition scanning of only ROOT directory I used the following
logic in read_directory.
while(entry=readdir(dir))
{
        ----
        ----
        if( (parent_mapping_index >= 0) && (!is_dotdot && !is_dot) )
        break;
        -----
        -----
}


That is I am creating only _dot_ and _dotdot_ entries for the sub-directories.
With this logic I am able to skip the content of top directories and
also vvfat_read is invoked when I try to do
"ls -l" (ls -l /mnt/vvfatfs/test1/) on one of the top directory.

With this approach my content of the mounted vvfat were as follows:

ext4 path (Original Host OS)
============================
/opt/testdir/
-------------
  |-file1.txt
  |-test1
     |_ .
     |_ ..
     |- dir1
        |- .
        |- ..
        |- sample1.txt


VVFAT mount path (Guest OS)
============================
/mnt/vvfatfs/
-------------
  |_ file1.txt
  |_ test1
      |- .
      |- ..


Now my second approach is:
After the mount, we I use "ls -l /mnt/vvfatfs/test1", since vvfat_read
is called here, I could able to scan the content
of test1 from original ext4 location and map it to VVFAT partition.
But I am not able to do this.
I used the following in start of vvfat_read to perform this:-
1) Call read_directory again using the current mapping index with few
changes accordingly.
2) Using insert_mappings() to create new mappings for the rest of the contents.
3) Using insert_direntries() instead of insert_mappings().
4) Calling commit_mappings() after new mapping is created.

But none of this is working.

Please let me know the purpose of the following API:
- commit_mappings()
- insert_mappings()
- insert_direntries()
- commit_direntries()


Finally, the contact information for the author of VVFAT.



Thanks, Regards,
Pintu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]