The prototype of mmap() is:
void *
mmap(void *addr, size_t len, int prot, int flags, int fd, off_t
offset);
The second argument len is used to tell mmap() how many bytes I want to
map.
My question is: If len that i give to mmap() is larger than the size of
mapping file, and some data are wrote to these exceeding speces, where
are these data to be wrote to?
In Freebsd, this program section below will be executed without core
dump:
fd=open("mem.tmp", O_RDWR | O_CREAT | O_TRUNC | O_SHLOCK, S_IRWXU);
if(fd<0) {
printf("error at open() (errno: %d).\n", errno);
goto quit;
}
write(fd, empty, 8);
ptr=(char *)mmap((void *)NULL, 9, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, 0);
if(fd==MAP_FAILED) {
printf("error at mmap() (errno: %d).\n", errno);
goto quit;
}
ptr[0]='a';
ptr[1]='b';
ptr[2]='b';
ptr[3]='a';
ptr[4]='b';
ptr[5]='b';
ptr[6]='b';
ptr[7]='b';
ptr[8]='z';
But, where is 'z' to be wrote to? 2 6096
bite me if you can... wrote: The prototype of mmap() is: void * mmap(void *addr, size_t len, int prot, int flags, int fd, off_t
[snip]
This question is off topic here (as mmap() is *not* part of ISO standard
C); it should be asked in...(see response to your next post)
HTH
--ag
--
Artie Gold -- Austin, Texas http://goldsays.blogspot.com
"You can't KISS* unless you MISS**"
[*-Keep it simple, stupid. **-Make it simple, stupid.]
"bite me if you can..." <cc*****@gmail.com> writes: The prototype of mmap() is: void * mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
The second argument len is used to tell mmap() how many bytes I want to map. My question is: If len that i give to mmap() is larger than the size of mapping file, and some data are wrote to these exceeding speces, where are these data to be wrote to?
We don't know. mmap() is not a standard C function. It's defined by
POSIX, so try comp.unix.programmer.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hao Xu |
last post by:
Hi everyone!
I found that if you want to write to the memory got by mmap(), you have
to get the file descriptor for mmap() in O_RDWR mode. If you...
|
by: Hao Xu |
last post by:
Hi everyone!
I found that if you want to write to the memory got by mmap(), you have
to get the file descriptor for mmap() in O_RDWR mode. If you...
|
by: Fabiano Sidler |
last post by:
Hi folks!
I created an mmap object like so:
--- snip ---
from mmap import mmap,MAP_ANONYMOUS,MAP_PRIVATE
fl = file('/dev/zero','rw')
mm =...
|
by: Owen Zhang |
last post by:
I have a file loaded into virtual memory space by mmap. I need to
search some key word inside the memory opened by mmap. What is the
best and...
|
by: Matias Surdi |
last post by:
Suppose I've a process P1, which generates itself a lot of data , for
example 2Mb.
Then, I've a process P2 which must access P1 shared memory and,...
|
by: Unknown Soldier |
last post by:
Hello,
I have a couple queries about mmap() that ppl here might be able to help
with.
1. What's the best way to resize an mmap()d area when...
|
by: Neal Becker |
last post by:
On linux, I don't understand why:
f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE,...
|
by: magnus.lycka |
last post by:
Does anyone recognize this little Python crasher?
I'll file a bug report unless someone notices it as an already
documented bug. I found some...
|
by: Akira Kitada |
last post by:
Hi list,
I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed
to build some of the modules.
"""
Failed to find the necessary...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
| |