how can i sync()

  • Follow


Hi,

Setup:
I have an external device connected through Firewire,    
I am running Redhat 2.4.
I write to it in raw initiated mode (no File System)

Scenario:
I open the device using open() get a file descriptor. (flag set to
O_SYNC)
I write a block in a while loop using write()
I call fsync()|sync()|fdatasync() and check for success response in each loop
I close using close()

Now in this code if I disconnect the firewire cable during the loop I
loose all the data.

is there a way to sync raw writes to the disk.
Please assist

Adnan
0
Reply adnanx (4) 10/6/2004 3:16:50 PM

Adnan Abbas wrote:

> Hi,
> 
> Setup:
> I have an external device connected through Firewire,
> I am running Redhat 2.4.
> I write to it in raw initiated mode (no File System)
> 
> Scenario:
> I open the device using open() get a file descriptor. (flag set to
> O_SYNC)
> I write a block in a while loop using write()
> I call fsync()|sync()|fdatasync() and check for success response in each
> loop I close using close()
> 
> Now in this code if I disconnect the firewire cable during the loop I
> loose all the data.
> 
> is there a way to sync raw writes to the disk.

Use flush() before close(), and if necessary make a system call to "sync".

-- 
Paul Lutus
http://www.arachnoid.com

0
Reply nospam248 (2243) 10/6/2004 4:58:23 PM


Paul Lutus <nospam@nosite.zzz> wrote in message news:<10m891g56e9cbfb@corp.supernews.com>...
> Adnan Abbas wrote:
> 
> > Hi,
> > 
> > Setup:
> > I have an external device connected through Firewire,
> > I am running Redhat 2.4.
> > I write to it in raw initiated mode (no File System)
> > 
> > Scenario:
> > I open the device using open() get a file descriptor. (flag set to
> > O_SYNC)
> > I write a block in a while loop using write()
> > I call fsync()|sync()|fdatasync() and check for success response in each
> > loop I close using close()
> > 
> > Now in this code if I disconnect the firewire cable during the loop I
> > loose all the data.
> > 
> > is there a way to sync raw writes to the disk.
> 
> Use flush() before close(), and if necessary make a system call to "sync".

thank you for the suggestion, I have been using sync() in each loop as
I mentioned in my mail and i just gave a try to flush and flush()
command is not accepted by Red Hat 2.4.

there has to be a way to sync raw writes to an external disk.....
any one!!!
0
Reply adnanx (4) 10/6/2004 11:15:21 PM

Adnan Abbas wrote:

> Paul Lutus <nospam@nosite.zzz> wrote in message
> news:<10m891g56e9cbfb@corp.supernews.com>...
>> Adnan Abbas wrote:
>> 
>> > Hi,
>> > 
>> > Setup:
>> > I have an external device connected through Firewire,
>> > I am running Redhat 2.4.
>> > I write to it in raw initiated mode (no File System)
>> > 
>> > Scenario:
>> > I open the device using open() get a file descriptor. (flag set to
>> > O_SYNC)
>> > I write a block in a while loop using write()
>> > I call fsync()|sync()|fdatasync() and check for success response in
>> > each loop I close using close()
>> > 
>> > Now in this code if I disconnect the firewire cable during the loop I
>> > loose all the data.
>> > 
>> > is there a way to sync raw writes to the disk.
>> 
>> Use flush() before close(), and if necessary make a system call to
>> "sync".
> 
> thank you for the suggestion, I have been using sync() in each loop as
> I mentioned in my mail and i just gave a try to flush and flush()
> command is not accepted by Red Hat 2.4.

What do you mean? You are writing this in C, yes? I surmise this based on
the bits of code you included in your first post. C certainly has flush()
available for its file writing libraries.

If I am wrong, say which language you are writing this in.
 
> there has to be a way to sync raw writes to an external disk.....

$ man sync

-- 
Paul Lutus
http://www.arachnoid.com

0
Reply nospam248 (2243) 10/6/2004 11:58:29 PM

3 Replies
28 Views

(page loaded in 0.099 seconds)

Similiar Articles:













7/27/2012 5:04:32 PM


Reply: