Unix Programming - Writing to a USB device

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2006 > Writing to a USB device





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Writing to a USB device
Simon Elliott

2006-09-18, 7:50 pm

I have a Linux box which automounts a USB flash disk. I can test for
the existence of the directory which corresponds to the USB disk and
access files on it.

I now want to take this a step further. If the USB device is present, I
want to open a file on it for logging. If the user pulls the USB device:

a) I want the app to know about it, stop trying to write to it, and go
back to the "checking for USB disk" state.

b) I want as much as possible of the log file to be written, as little
as possible to be lost, and the file system on the USB disk to be not
corrupt. The file system on the USB disk must be fat32.

c) I want the app to do this without blocking for more than say five
milliseconds.

It's an embedded system with no monitor, mouse or keyboard so there's
no way the user can do anything "nicer" than just pull the USB disk out.

I'd like a generic solution if possible but if there's only a Linux
specific way then so be it!

Any thoughts?


--
Simon Elliott http://www.ctsn.co.uk
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com