Hi all!
I'm trying to do a program that preallocate a file and fill it, but when I use
xfs_bmap on the file gives me the same number of holes that if I don't do
preallocation. To preallocate I use de ioctl call with XFS_IOC_RESVSP64 in
this way:
int main(int argc, char **argv)
{
int oflags = O_CREAT|O_TRUNC|O_WRONLY;
int fd=0;
xfs_flock64_t flck;
if(argc < 3)
{
printf("usage: %s [filename] [numbytes]\n", argv[0]);
exit (1);
}
int numImages = atoll(argv[2]);
int aux = 66;
long long int bufferSize = 720 * 576 * 2;
int buffer[bufferSize];
bzero(buffer, bufferSize);
flck.l_whence = SEEK_SET;
flck.l_start = 0LL;
flck.l_len = numImages * bufferSize;
fd = open(argv[1], oflags, 0600);
int res = ioctl(fd, XFS_IOC_RESVSP64, &flck);
for(int i = 0; i < numImages; i++)
write(fd, buffer, bufferSize);
close(fd);
exit( 0 );
}
Is this correctly????
very much thanks,
Miguel Angel de Vega
mvega@xxxxxx
|