exfat
exfat copied to clipboard
Using O_SYNC parameter in Python isn't working with exfat drive
I copy a file in Python to removable drives using O_SYNC and it's not working for exfat formatted drives. If I format the same drive to ext4 or fat32 it works and synchronous writes happen. With exfat though it seems to use the file system cache and wait for a sync command to actually write.
Python code:
fsrc = os.open(source, os.O_RDWR)
fdst = os.open(destination, os.O_CREAT | os.O_SYNC | os.O_RDWR)
while True:
buf = os.read(fsrc, 1048576)
if not buf:
break
os.write(fdst, buf)
Looks like there's no way to handle O_SYNC in FUSE.
@relan that's unfortunate. Thanks for the quick reply though.
Maybe this helps someone else but I ended up with my desired behavior by adding:
os.fsync(fdst)
after each os.write call. This effectively writes the data each loop iteration like I want.