c - Reading a mapped file and storing it in a buffer -



c - Reading a mapped file and storing it in a buffer -

can kindly explain how can implemented mread function, using read() scheme call. method needs read contents found in mmapped file , read them buffer. have access both mmapped file , buffer means of pointers. (i.e. void *addr , void *buff).

your help v.much appreciated.

try far:

int fd; if ((fd = open("file.hole",o_rdwr, "rb")) < 0) { perror("create .hole file error"); exit(exit_failure); } if (write(fd, addr, count)!= count) { perror("cannot write address"); exit(exit_failure); } buff = (char*)malloc(count * sizeof(char *)); if (read(fd, buff, count)) { perror("cannot read file descriptor buffer"); exit(exit_failure); }

sorry, might not finish solution, don't have sufficient reputation add together comments.

if need read info mmaped file (assumed have called mmap() on file), don't need read() scheme call; need re-create content addr buff.

if need read() scheme phone call re-create info file buffer, don't need mmap(); should open() on file fd , read() info fd buffer.

c linux mmap

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -