 |
|
| Linux Forum Index » Linux Development - System » mmap returning MAP_FAILED... |
|
Page 1 of 1 |
|
| Author |
Message |
| Washington Ratso... |
Posted: Thu Nov 05, 2009 7:24 pm |
|
|
|
Guest
|
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? |
|
|
| Back to top |
|
|
|
| David Schwartz... |
Posted: Thu Nov 05, 2009 11:59 pm |
|
|
|
Guest
|
On Nov 5, 9:24 pm, Washington Ratso <jobhunt... at (no spam) aol.com> wrote:
Quote: 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 |
|
|
| Back to top |
|
|
|
| Washington Ratso... |
Posted: Fri Nov 06, 2009 4:10 pm |
|
|
|
Guest
|
On Nov 6, 1:59 am, David Schwartz <dav... at (no spam) webmaster.com> wrote:
Quote: On Nov 5, 9:24 pm, Washington Ratso <jobhunt... at (no spam) 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.) " |
|
|
| Back to top |
|
|
|
| David Schwartz... |
Posted: Fri Nov 06, 2009 5:52 pm |
|
|
|
Guest
|
On Nov 6, 6:10 pm, Washington Ratso <jobhunt... at (no spam) aol.com> wrote:
Quote: 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 |
|
|
| Back to top |
|
|
|
| Shankar... |
Posted: Sat Nov 07, 2009 11:03 pm |
|
|
|
Guest
|
On Nov 5, 9:24 pm, Washington Ratso <jobhunt... at (no spam) aol.com> wrote:
Quote: 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 |
|
|
| Back to top |
|
|
|
| Joe Pfeiffer... |
Posted: Sun Nov 08, 2009 12:09 pm |
|
|
|
Guest
|
Shankar <shankarke at (no spam) gmail.com> writes:
Quote: On Nov 5, 9:24 pm, Washington Ratso <jobhunt... at (no spam) 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) |
|
|
| Back to top |
|
|
|
| Alan Curry... |
Posted: Sun Nov 08, 2009 12:29 pm |
|
|
|
Guest
|
In article <1br5s9osd7.fsf at (no spam) snowball.wb.pfeifferfamily.net>,
Joe Pfeiffer <pfeiffer at (no spam) cs.nmsu.edu> wrote:
Quote: Shankar <shankarke at (no spam) gmail.com> writes:
On Nov 5, 9:24 pm, Washington Ratso <jobhunt... at (no spam) 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).
Also, MAP_SHARED is the only way to get changes written back into a
memory-mapped file, so sometimes you need MAP_SHARED with PROT_WRITE
even if you don't want shared memory (simultaneously accessible by
multiple processes). It's kind of a misleading name.
--
Alan Curry |
|
|
| Back to top |
|
|
|
| Cliff Brake... |
Posted: Mon Nov 09, 2009 5:46 am |
|
|
|
Guest
|
On Nov 6, 9:10 pm, Washington Ratso <jobhunt... at (no spam) aol.com> wrote:
Quote: 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 |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sun Nov 29, 2009 7:13 am
|
|