mmap() ---- Invalid argument(EINVAL) error ..?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > mmap() ---- Invalid argument(EINVAL) error ..?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 12:49 PM

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






[ Post a follow-up to this message ]



    Re: mmap() ---- Invalid argument(EINVAL) error ..?  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 12:49 PM

"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.





[ Post a follow-up to this message ]



    Re: mmap() ---- Invalid argument(EINVAL) error ..?  
Vinu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 12:49 PM

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).






[ Post a follow-up to this message ]



    Re: mmap() ---- Invalid argument(EINVAL) error ..?  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 12:49 PM

"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.





[ Post a follow-up to this message ]



    Re: mmap() ---- Invalid argument(EINVAL) error ..?  
Vinu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 12:49 PM

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






[ Post a follow-up to this message ]



    Re: mmap() ---- Invalid argument(EINVAL) error ..?  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 11:05 PM

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

Please use cross-posting instead of multi-posting.

> mSize is the size which I want to allocate

Casper knows *that*. What he asks is what is the *value* of mSize?

> When I used it like this
>
> pBase =(Ptr) mmap(0, mSize,PROT_NONE,MAP_PRIVATE,-1,0); the error is
>
> EBADF(Bad file number)

That's right. If you want to use -1 as the fd, you *must* have
MAP_ANONYMOUS in the flags.

Try this:

pBase = (Ptr)mmap(0, mSize, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:05 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register