mmap text file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am trying to achieve faster file writes using mmap.

so I am trying the follwowing:

/* open file */


while (loop) {
        /* get the current file size of output file */
        filesize = lseek(outfd, 0, SEEK_END);

        /* Increase file size */
        ftruncate(outfd, (off_t)filesize + (off_t)buf.size);
        
            /* mmap destination file */
            if((dest = mmap(0, buf.size, PROT_WRITE, MAP_SHARED, outfd, filesize)) == (void *) -1) {
                printf( "Error mapping ouput file: %s: %d, %d\n", argv[1], i, filesize);
                perror("MMAP Failed\n");
                goto error;
            }

    memcpy(dest, src, size);
    munmap(dest);
}

I am able to only mmap it once next time it fails to mmap, any pointers why it fails ?

Regards,
--Sagar
 		 	   		  
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies





[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux