Rein Klazes wrote:
BTW, what goes wrong exactly? From the snippet above I understand that either ftruncate() moves the filepointer when it fails or that the sequence: lseek(fd,-1,SEEK_CUR);write(fd,&buf,1) moves the file pointer.
For your perusal, codeweavers also had a reimplementation of this, so I split that out and posted it.