Mail Archives: cygwin/1998/06/20/05:15:24
The documentation for lseek states
The lseek function allows the file offset to be set beyond
the end of the existing end-of-file of the file. If data
is later written at this point, subsequent reads of the
data in the gap return bytes of zeros (until data is actu-
ally written into the gap).
but under Windows 95 the cygwin32 package does not behave this
way. The gap is filled with garbage. One package that depends
on the zeroing behavior is db-1.86. Here is a test program:
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
main(int ac, char *av[])
{
int size = atoi(av[1]);
int fd = open("seektest", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
char buffer[size];
int count;
count = lseek(fd, size, SEEK_SET);
printf("Attempt seek to %d, result %d\n", size, count);
count = write(fd, buffer, size);
printf("Wrote %d of %d character(s)\n", count, size);
count = lseek(fd, 0, SEEK_SET);
printf("Attempt seek to %d, result %d\n", size, count);
count = read(fd, buffer, size);
printf("Read %d of %d characters\n", count, size);
}
Run this with the argument 100 and you will get a two hundred byte
file filled with garbage. Under Unix or cygwin32_nt the first hundred
bytes will be zero. Any advice?
--
David Fox http://www.cat.nyu.edu/fox xoF divaD
NYU Media Research Lab fox AT cat DOT nyu DOT edu baL hcraeseR aideM UYN
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -