I'm currently on a project what has to handle writing of large number of bytes to a file. I use the low-level C function write(int, const void *, size_t). To handle lots of bytes at once, I split the data into blocks of the block size that's given by the system:
struct stat b_stat; stat("/", &b_stat); blksize_t block_size = b_stat.st_blksize; The project manages important data, so I have to check for every error. My problem is, how I should proceed when I'm in the middle of the writing process and one block throws an error. The previous data is already written to the file and the low-level C functions does not include something like an "undo"-function.
Do you have any idea on how I should proceed in that sample of case?
statthe root directory/but the directory containing the file you are writing to (or the written file itself). They probably will be on different filesystems!