xfs
[Top] [All Lists]

how to preallocate??

To: linux-xfs@xxxxxxxxxxx
Subject: how to preallocate??
From: Miguel Angel de Vega <mvega@xxxxxx>
Date: Wed, 8 Sep 2004 13:25:29 +0200
Sender: linux-xfs-bounce@xxxxxxxxxxx
User-agent: KMail/1.5
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


<Prev in Thread] Current Thread [Next in Thread>