mmap() ---- Invalid argument(EINVAL) error ..?

  • Follow


Hi
	I am using mmap() like this my intension is to allocate (mSize)memory
with no memory protection and without file descriptor like this:

 pBase =(Ptr) mmap(0, mSize,PROT_NONE,MAP_ANONYMOUS,0,0);

but I am getting an error Invalid argument(EINVAL). Can anybody give
the correct way of doing this? I am using gcc in SOLARIS environment.

Thanks,
Vinu

0
Reply vinuwarrier (42) 9/20/2005 8:46:17 AM

"Vinu" <vinuwarrier@yahoo.com> writes:

>Hi
>	I am using mmap() like this my intension is to allocate (mSize)memory
>with no memory protection and without file descriptor like this:

> pBase =(Ptr) mmap(0, mSize,PROT_NONE,MAP_ANONYMOUS,0,0);

>but I am getting an error Invalid argument(EINVAL). Can anybody give
>the correct way of doing this? I am using gcc in SOLARIS environment.


The file descriptor needs to be -1 when you want anonymous memory
from the paging system.

Casper
-- 
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
0
Reply Casper 9/20/2005 9:36:02 AM


I used it in this way also

pBase =(Ptr) mmap(0, mSize,PROT_NONE,MAP_ANONYMOUS,-1,0);  still the
result(error) is same Invalid argument(EINVAL).

0
Reply Vinu 9/20/2005 10:05:39 AM

"Vinu" <vinuwarrier@yahoo.com> writes:

>I used it in this way also

>pBase =(Ptr) mmap(0, mSize,PROT_NONE,MAP_ANONYMOUS,-1,0);  still the
>result(error) is same Invalid argument(EINVAL).


What's "mSize"?  Oh, you need to specify exactly one of
MAP_SHARED or MAP_PRIVATE.

Casper
-- 
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
0
Reply Casper 9/20/2005 11:22:31 AM

Hi,

mSize is the size which I want to allocate
When I used it like this

pBase =(Ptr) mmap(0, mSize,PROT_NONE,MAP_PRIVATE,-1,0); the error is

EBADF(Bad file number)

Thanks,
Vinu

0
Reply Vinu 9/20/2005 12:30:19 PM

4 Replies
1462 Views

(page loaded in 0.165 seconds)

Similiar Articles:













7/20/2012 10:01:26 AM


Reply: