mmap text file
Ssagarr Patil
hugarsagar at outlook.com
Tue Mar 31 07:41:33 EDT 2015
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
More information about the Kernelnewbies
mailing list