A somewhat safer fix might be to do the fsync for both bock and char (raw) devices, but only check the return code if it was a block device. Although it's hard for me to believe there are any systems that allow fsync on raw devices.