Excellent! This pretty much does the trick. There is one little probelm though. I need to write that line to another mapped output file after being modified. I've modified the code above with the following:
Code:
int fd2 = open("out", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
char * temp = (char *) malloc(128);
char * dest = mmap(0, s.st_size*2, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd2, 0);
if (dest == MAP_FAILED) {
perror("mmap dest");
exit(1);
} //size*2 just to be safe
.
.
.
while( getline( p, &get ) != 0 ) {
temp = get.bufp;
temp = strcat(temp, " foo bar\n");
memcpy(dest, temp, sizeof(temp));
printf( "temp = %s", temp );
}
.
.
.