[Interest] QFile copy and sync/fsync

Duane duane.hebert at group-upc.com
Wed Jan 2 21:49:42 CET 2013


Qt 4.8 on Linux TinyCore or Fedora.

I have a function to back up some files to a usb stick.  I've had 
complaints from users that the files are sometime not copied.  It looks 
like they're removing the usb stick before the standard sync cycle.  If 
I call sync from my copy routine this works but it hangs the system 
waiting for sync to complete.

If I mount the usb stick with -o sync, this also solves my problem but 
it also hangs the system.

I have tried to use fsync on a per file basis but this doesn't solve my 
problem.  I have a watchdog to maintain so I would need to use 
qApp->processEvents() periodically in busy loops.

Does fsync not force the write to disk?  Is there a way to sync only a 
particular folder?

Thanks.




More information about the Interest mailing list