I am working on a relational database project that involves tweaking around with the file storage.I need to load a file representing a relation into memory. I thought using mmap() would help but I am not able to interpret the output. This is what I did :
Now, the man pages say that the call to mmap() returns the pointer to the location where the mapping was placed. So, my questions are:Code:int main() { int fp; int sz=100; unsigned char *op; fp=open("file.c"); op = mmap (NULL, sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fp,0); printf ("mmap (out) returned %08lx\n", (long)op); return 0; }
1) is this the pointer to the location in main memory? and how do I use this pointer to perform any update operations.
2)I got a seg fault when I tried to read the value stored in the pointer.
3)Is mmap() the appropriate sys call to use here or is there any other call that does the job that I am looking for?



LinkBack URL
About LinkBacks


