Re: Mass Storage driver IOMedia Object
Re: Mass Storage driver IOMedia Object
- Subject: Re: Mass Storage driver IOMedia Object
- From: Yogesh P <email@hidden>
- Date: 10 Oct 2005 19:20:41 +0530
Hi Mike,
We actually want to read some data from one partition(media object) say
"Part1" and write the same data on another partition(media object) say
"Part2" within the write call of "Part1".
Say, "Part1" is associated with partition -> /Volume/Org and "Part2" is
associated with partition -> /Volume/New
After loading the driver, when I write on /Volume/Org the write()
routine of my driver gets called for "Part1" and writes some data at
specific byteStart on "Part1".
Now,before writing the new data on "Part1" at specific byteStart,I want
to read the original data from same byteStart for "Part1" and write the
read data on "Part2" within same write() routine of "Part1".
Please suggest some way to achieve this.
Thanks,
Yogesh
On Fri, 2005-10-07 at 22:16, Mike Smith wrote:
> Yogesh,
>
> What you're doing here looks suspiciously like RAID. You are aware that
> MacOS already includes a perfectly good RAID 0/1 engine?
>
> On Oct 7, 2005, at 1:02 AM, Yogesh P wrote:
>
> > Hi Mike,
> >
> > Thanks for your quick reply.
> >
> > As you mention that the write() routine is associated with specific
> > instance of the media,means every media object is associated with
> > particular instance of driver and the write() routine use this
> > specific
> > instance of driver for writting on that specific media object.
> >
> > Suppose, I have two media objects exposed by my driver say "Part1" and
> > "Part2".Now I am in default write() routine of "Part1" and want to
> > write
> > some data on another media object.i.e on "Part2" before I exit from
> > "Part1" write() routine.
> >
> > You will understand the problem by looking at the below code snippet:
> >
> > // write routine for "Part1"
> > void MyDriver::write(IOService *provider, UInt64 byteStart,
> > IOMemoryDescriptor *buffer, IOStorageCompletion completion)
> > {
> > IOMedia* _filteredMedia; // MyDriver Media Object
> > IOMedia* _media; // MyDriver's provider Media
> > Object(IOBlockStorageDriver)
> > char MediaName[100];
> > sprintf(MediaName, "%s",_media->getName());//get the Media
> > Name
> > // Match the Media Names
> > if(strcmp(MediaName, "Part2") == 0)
> > {
> > // write on "Part2"
> > getProvider()->write(this, byteStart, buffer, completion);
> > // This should write the buffer on
> > "Part2"
> > }
> >
> > // write on "Part1"
> > getProvider()->write(this, byteStart,buffer, completion);
> > }
>
> This code isn't going to work at all. If the media name is "Part2"
> you make
> the same write call twice.
>
> Don't use strings in the I/O path either, unless you're really trying
> to make
> it slow.
>
> If you want a one-way replication, that is, anything written to
> "part1" goes
> to "part2" as well but not vice-versa, then in your media object
> class you
> want to have a reference to the 'partner' object.
>
> class MyDriver {
> ...
> class MyDriver *fPartner;
> };
>
> You need to arrange to have this field set at the point you decide that
> "part2" is the shadow for "part1"l.
>
> Then you want to do something like this:
>
> MyDriver::write()
> {
> getProvider()->write(...)
>
> if (fPartner)
> fPartner->write(...)
> }
>
> > What I have found that if i have 2 media's then it goes in
> > write routine
> > twice, first time for "Part1" and then next time for "Part2".But I
> > want
> > that when it comes in write() for "Part1" it should write on
> > "Part2" as
> > well, in the same write()routine before coming out of it.
>
> Are you sure that the write call to the second media is coming from
> your class?
>
> Note that if the system has mounted both of your media (because they
> have
> filesystems on them) cross-writing between the two should be avoided
> at all costs.
>
> Once an IOMedia has a consumer, the consumer owns the exported
> contents and
> you are generally forbidden from changing them.
>
> = Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden