libowfat/mmap/mmap_shared.c

20 lines
409 B
C
Raw Normal View History

2001-05-12 03:34:27 +00:00
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
#include "open.h"
#include "mmap.h"
2001-10-15 14:34:02 +00:00
extern char* mmap_shared(const char* filename,unsigned long* filesize) {
2001-05-12 03:34:27 +00:00
int fd=open_read(filename);
char *map;
if (fd>=0) {
*filesize=lseek(fd,0,SEEK_END);
map=mmap(0,*filesize,PROT_WRITE,MAP_SHARED,fd,0);
if (map==(char*)-1)
map=0;
close(fd);
return map;
}
return 0;
}