Autoflush USB thumb drive after copy

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Thu Feb 1 17:43:47 UTC 2007


On Thu, Feb 01, 2007 at 12:17:54PM -0500, Byron Sonne wrote:
> Umm... totally defeats the purpose of being USB hotpluggable, doesn't it?

Hotplugable means you can connect and disconnect while powered.  It has
nothing to do with connecting and disconnecting while _IN_USE_.

> If it's gonna behave like that, then ls shouldn't show it as being
> present until it's committed, like my other disks. Either it's on the
> bloody stick or it's not.

Well you could turn of write caching if you don't want performance at
all, and you could run with it mounted with sync if you don't care about
the lifespan of the device, in which case yes it will not return until
it is done writing.

> My OS should not lie to me, and I shouldn't have to wonder where my
> files are. Here's what should happen:

> 1. I copy the file.
> 2. The file is copied.
> 3. If I pull it out while it's copying, then the file gets corrupted.
> 4. Done.

Well you can always do this then:
cp ....
sync

When sync returns, then it is done.  Of course you still have to umount
the filesystem since that is the unix way, unless that is somehow
handled automatically.  Or call umount after the copy.  when umount
returns, it is done writing and unmounted.

I personally love the fact I can mount a usb key of floppy, copy some
stuff to it, edit some files on it, copy more stuff, rename a few
things, all while the actualy writing is taking place.  Why should we go
back to the idiotic dos days where you had to wait for the computer to
do every single step before it would even let you tell it what the next
step was.  You couldn't even type ahead anymore than the keyboard buffer
(which I think was less than 50 characters).

If you want to be sure something is done, use sync.  That is what it is
for.  It tells the system to flsuh everything unwritten to disk and
don't return until done that.

> And wearing out the memory? Dudes... at these costs, that's not an issue
> :) It's cheap and plentiful.

Problem is it doesn't go from working to not working, it goes from
working to working but unreliably and occationally corrupting bits, to
not working at all.

--
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list