Motherboard Forums


Reply
Thread Tools Display Modes

mmap returning MAP_FAILED

 
 





















Washington Ratso
Guest
Posts: n/a

 
      11-06-2009, 05:24 AM


I am running Linux 2.6.26 on an MPC8248. In my application, mmap is
returning MAP_FAILED. The arguments to mmap are start = 0, length =
2680, prot = 3, flags = MAP_SHARED, fd = 5, offset = 0. errno = 22
"Invalid argument"

I looked at the man page for mmap and don't see a reason why this is
happening. Any ideas?
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      11-06-2009, 09:59 AM
On Nov 5, 9:24*pm, Washington Ratso <jobhunt...@aol.com> wrote:
> I am running Linux 2.6.26 on an MPC8248. * In my application, mmap is
> returning MAP_FAILED. *The arguments to mmap are start = 0, length =
> 2680, prot = 3, flags = MAP_SHARED, fd = 5, offset = 0. *errno = 22
> "Invalid argument"
>
> I looked at the man page for mmap and don't see a reason why this is
> happening. *Any ideas?


It would help if you told us what you were trying to do. What is file
descriptor 5 and how was it opened? Also, I doubt '2680' is a multiple
of your page size, so you cannot create a 2,680-byte mapping.

DS
 
Reply With Quote
 
Washington Ratso
Guest
Posts: n/a

 
      11-07-2009, 02:10 AM
On Nov 6, 1:59*am, David Schwartz <dav...@webmaster.com> wrote:
> On Nov 5, 9:24*pm, Washington Ratso <jobhunt...@aol.com> wrote:
>
> > I am running Linux 2.6.26 on an MPC8248. * In my application, mmap is
> > returning MAP_FAILED. *The arguments to mmap are start = 0, length =
> > 2680, prot = 3, flags = MAP_SHARED, fd = 5, offset = 0. *errno = 22
> > "Invalid argument"

>
> > I looked at the man page for mmap and don't see a reason why this is
> > happening. *Any ideas?

>
> It would help if you told us what you were trying to do. What is file
> descriptor 5 and how was it opened? Also, I doubt '2680' is a multiple
> of your page size, so you cannot create a 2,680-byte mapping.
>
> DS



I am trying to get oprofile to work. The file I am opening is a
sample file. Here is the code for the open:

data->fd = open(filename, flags, 0644);

where filename = "/var/lib/oprofile/samples//current/{kern}/no-vmlinux/
{dep}/{kern}/no-vmlinux/TIMER.0.0.all.all.all"
where flags = O_CREAT | O_RDWR

The file /var/lib/oprofile/samples//current/{kern}/no-vmlinux/{dep}/
{kern}/no-vmlinux/TIMER.0.0.all.all.all does exist.

I changed the length to the page size and it made no difference.
According to http://www.ecst.csuchico.edu/~beej/guide/ipc/mmap.html,
"This can be any length you want. (Aside: if len not a multiple of the
virtual memory page size, you will get a blocksize that is rounded up
to that size. The extra bytes will be 0, and any changes you make to
them will not modify the file.) "

 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      11-07-2009, 03:52 AM
On Nov 6, 6:10*pm, Washington Ratso <jobhunt...@aol.com> wrote:

> I am trying to get oprofile to work. *The file I am opening is a
> sample file. *Here is the code for the open:
>
> data->fd = open(filename, flags, 0644);
>
> where filename = "/var/lib/oprofile/samples//current/{kern}/no-vmlinux/
> {dep}/{kern}/no-vmlinux/TIMER.0.0.all.all.all"
> where flags = O_CREAT | O_RDWR
>
> The file */var/lib/oprofile/samples//current/{kern}/no-vmlinux/{dep}/
> {kern}/no-vmlinux/TIMER.0.0.all.all.all does exist.


What exactly do you think mapping a zero-length file would do?

DS
 
Reply With Quote
 
Shankar
Guest
Posts: n/a

 
      11-08-2009, 09:03 AM
On Nov 5, 9:24*pm, Washington Ratso <jobhunt...@aol.com> wrote:
> I am running Linux 2.6.26 on an MPC8248. * In my application, mmap is
> returning MAP_FAILED. *The arguments to mmap are start = 0, length =
> 2680, prot = 3, flags = MAP_SHARED, fd = 5, offset = 0. *errno = 22
> "Invalid argument"
>
> I looked at the man page for mmap and don't see a reason why this is
> happening. *Any ideas?


prot=3 => would mean PROT_READ|PROT_WRITE

MAP_SHARED I think is a invalid mode if you are trying to map it that
way, Probably you may want to remove PROT_WRITE and see whats
happening.

Thanks

Shankar Easwaran
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a

 
      11-08-2009, 05:09 PM
Shankar <> writes:

> On Nov 5, 9:24*pm, Washington Ratso <jobhunt...@aol.com> wrote:
>> I am running Linux 2.6.26 on an MPC8248. * In my application, mmap is
>> returning MAP_FAILED. *The arguments to mmap are start = 0, length =
>> 2680, prot = 3, flags = MAP_SHARED, fd = 5, offset = 0. *errno = 22
>> "Invalid argument"
>>
>> I looked at the man page for mmap and don't see a reason why this is
>> happening. *Any ideas?

>
> prot=3 => would mean PROT_READ|PROT_WRITE
>
> MAP_SHARED I think is a invalid mode if you are trying to map it that
> way, Probably you may want to remove PROT_WRITE and see whats
> happening.


That would do terrible things to the utility of shared memory -- no,
MAP_SHARED and PROT_WRITE are compatible. Maybe you're thinking of
MAP_SHARED and MAP_ANONYMOUS (which didn't used to be compatible, but is
since 2.4).
--
As we enjoy great advantages from the inventions of others, we should
be glad of an opportunity to serve others by any invention of ours;
and this we should do freely and generously. (Benjamin Franklin)
 
Reply With Quote
 
Cliff Brake
Guest
Posts: n/a

 
      11-09-2009, 03:46 PM
On Nov 6, 9:10*pm, Washington Ratso <jobhunt...@aol.com> wrote:

> I am trying to get oprofile to work. *The file I am opening is a
> sample file. *Here is the code for the open:


Make sure you are not logging data to a JFFS2 file system. JFFS2 does
not support MMAP.

Cliff
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Elizabeth took a fancy towards this handsome gallant. Raleigh wassoon bestowed with honors, a knighthood,a manor house, and more. Raleighreturned these honors by returning often from the Spanish Main, thepredictable wind path across the Atlantic all service0048@watchec.com Dell 0 04-25-2008 09:24 PM
Serillel SATA-to-IDE adapter crashes A8N-SLI returning from sleep or STR crystaldaggerNOSPAM@hotmial.com Asus 1 02-02-2008 04:36 AM
Cancelling (or returning) a notebook Sinclair Dell 7 02-20-2007 03:26 AM
Re: I teach first aid and my students often ask about returning a fracture Jerry Kindall Apple 1 08-31-2003 01:03 AM
Re: I teach first aid and my students often ask about returning a fracture Enough Apple 0 08-28-2003 01:14 PM


All times are GMT. The time now is 06:24 AM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43