> Wouldn't this work? (no error checking of course XD)
> 
>     off_t lseek(int fd, off_t offset, int whence);
>     ssize_t write(int fd, const void *buf, size_t count);
> 
>     ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
>         lseek(fd, offset, SEEK_SET);
>         return write(fd, buf, count);
>     }
> 

Actually, no.  There's a subtle difference in that the pwrite system call 
combines the seek and write functions into one -atomic- operation.  That means 
that it can't be interrupted (for instance if the current process is suspended 
or in a multi-threaded environment).  This can avoid potential data loss when 
multiple threads/processes are writing to the same file.

_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to