* mmap on jffs2
@ 2003-04-20 14:00 leeyang
2003-04-22 9:33 ` Jörn Engel
0 siblings, 1 reply; 6+ messages in thread
From: leeyang @ 2003-04-20 14:00 UTC (permalink / raw)
To: linux-mtd
I am using jffs2 on a ppc860 system(amd29lv160).
Things seems ok,but when I am trying mmap.
I want to mmap a file in flash,so i can treat
the file like some records.
I mean operation like
fd = open("/usr/dat/sot.dat",O_RDWR,FILEMODE);
ptr1=mmap(NULL,filesize,PROT_READ|PROT_WRITE,
MAP_SHARED,fd,0);
fd returns 3 and it is ok,however ptr1 returns -1.
I checked the errno it said invalid argument.
I have to say arguments "filesize" above is not
aligment to any requirements,just the real file
size?Does it matter?
The same procedure can done on common ext2
so i wonder jffs2 implement all the features like
ext2?
leeyang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mmap on jffs2
2003-04-20 14:00 leeyang
@ 2003-04-22 9:33 ` Jörn Engel
2003-04-23 7:30 ` David Woodhouse
0 siblings, 1 reply; 6+ messages in thread
From: Jörn Engel @ 2003-04-22 9:33 UTC (permalink / raw)
To: leeyang; +Cc: linux-mtd
On Sun, 20 April 2003 22:00:51 +0800, leeyang wrote:
>
> I am using jffs2 on a ppc860 system(amd29lv160).
> Things seems ok,but when I am trying mmap.
>
> I want to mmap a file in flash,so i can treat
> the file like some records.
>
> I mean operation like
> fd = open("/usr/dat/sot.dat",O_RDWR,FILEMODE);
>
> ptr1=mmap(NULL,filesize,PROT_READ|PROT_WRITE,
> MAP_SHARED,fd,0);
>
> fd returns 3 and it is ok,however ptr1 returns -1.
> I checked the errno it said invalid argument.
>
> I have to say arguments "filesize" above is not
> aligment to any requirements,just the real file
> size?Does it matter?
>
> The same procedure can done on common ext2
> so i wonder jffs2 implement all the features like
> ext2?
AFAIK (someone please correct me) jffs2 does not support mmap. I don't
remember any technical reason, so it seems as if noone cared enough to
implement it.
You can do the work yourself, pay someone to do it or wait and hope
that someone else does it. As always.
Jörn
--
It's just what we asked for, but not what we want!
-- anonymous
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mmap on jffs2
2003-04-22 9:33 ` Jörn Engel
@ 2003-04-23 7:30 ` David Woodhouse
0 siblings, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2003-04-23 7:30 UTC (permalink / raw)
To: Jörn Engel; +Cc: leeyang, linux-mtd
On Tue, 2003-04-22 at 10:33, Jörn Engel wrote:
> AFAIK (someone please correct me) jffs2 does not support mmap. I don't
> remember any technical reason, so it seems as if noone cared enough to
> implement it.
We support readonly mmap. What we don't support is shared writable mmap,
where any time you change a byte in your mapped version, you end up
writing the _whole_ page out to flash, because we can't tell how dirty
the page is.
This is for three reasons -- firstly it's hard to ensure that we'll
actually have enough space on the flash to write out a page when it's
dirty. Secondly it's _very_ hard to make sure we've allocated all the
memory in advance that we'll need for node information, because the
writepage() function would get called under memory pressure and we
mustn't reenter the allocation routines, and thirdly if you're writing
to a flash file system you really ought to be paying more attention and
limiting your writes.
I suggest you do what Berkeley DB does -- mmap the file readonly for
direct access, but do writes with a write() system call. It does that on
all file systems anyway, for reasons of reliability.
> You can do the work yourself, pay someone to do it or wait and hope
> that someone else does it. As always.
It's a _lot_ of work, for little perceivable gain.
--
dwmw2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mmap on jffs2
2004-07-21 18:23 mmap on jffs2 dibacco
@ 2004-07-21 12:52 ` Carlos Manuel Duclos Vergara
2004-07-21 18:37 ` David Woodhouse
1 sibling, 0 replies; 6+ messages in thread
From: Carlos Manuel Duclos Vergara @ 2004-07-21 12:52 UTC (permalink / raw)
To: linux-mtd
El Miércoles, 21 de Julio de 2004 20:23, dibacco@inwind.it escribió:
> Hi,
>
Hi,
> I have a problem mapping a file opened with flag O_RDWR. This file is
> housed on a jffs2 file system that currently lives on simple ram. Could you
> give me an hint where to search for a possible solution? If I open the file
> in O_RDONLY mode the mapping is done, instead with O_RDWR mmap returns
> -EINVAL.
>
i'm not sure, but it could be because of the 'j' (Journaling). A journaling
filesystem is different from another kind of filesystem, and i'm not sure
about what it could mean mmap for a file in a journal filesystem.
A journal filesystem uses two stages for writing, the journal and the real
data. So when you try to mmap a file for writing in a journal filesystem it
can be very tricky to implement, but for reading there is no problem because
when you read a file you get the file from the data, not from the journal.
My $1
--
Carlos Manuel Duclos Vergara
carlos@embedded.cl
^ permalink raw reply [flat|nested] 6+ messages in thread
* mmap on jffs2
@ 2004-07-21 18:23 dibacco
2004-07-21 12:52 ` Carlos Manuel Duclos Vergara
2004-07-21 18:37 ` David Woodhouse
0 siblings, 2 replies; 6+ messages in thread
From: dibacco @ 2004-07-21 18:23 UTC (permalink / raw)
To: linux-mtd
Hi,
I have a problem mapping a file opened with flag O_RDWR. This file is housed on a jffs2 file system that currently lives on simple ram. Could you give me an hint where to search for a possible solution? If I open the file in O_RDONLY mode the mapping is done, instead with O_RDWR mmap returns -EINVAL.
Thanks in advance,
Antonio.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: mmap on jffs2
2004-07-21 18:23 mmap on jffs2 dibacco
2004-07-21 12:52 ` Carlos Manuel Duclos Vergara
@ 2004-07-21 18:37 ` David Woodhouse
1 sibling, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2004-07-21 18:37 UTC (permalink / raw)
To: dibacco@inwind.it; +Cc: linux-mtd
On Wed, 2004-07-21 at 20:23 +0200, dibacco@inwind.it wrote:
> Hi,
>
> I have a problem mapping a file opened with flag O_RDWR. This file is
> housed on a jffs2 file system that currently lives on simple ram.
> Could you give me an hint where to search for a possible solution? If
> I open the file in O_RDONLY mode the mapping is done, instead with
> O_RDWR mmap returns -EINVAL.
JFFS2 does not support shared writable mapping. This is a feature :)
Use MAP_PRIVATE instead of MAP_SHARED.
--
dwmw2
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-07-21 18:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-21 18:23 mmap on jffs2 dibacco
2004-07-21 12:52 ` Carlos Manuel Duclos Vergara
2004-07-21 18:37 ` David Woodhouse
-- strict thread matches above, loose matches on Subject: below --
2003-04-20 14:00 leeyang
2003-04-22 9:33 ` Jörn Engel
2003-04-23 7:30 ` David Woodhouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox