All of lore.kernel.org
 help / color / mirror / Atom feed
* mmap question
@ 2002-06-04 13:22 Frederic Gobry
  2002-07-01 13:14 ` Frederic Gobry
  0 siblings, 1 reply; 21+ messages in thread
From: Frederic Gobry @ 2002-06-04 13:22 UTC (permalink / raw)
  To: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]

Hi,

I need to port an in-memory database so that it can use mtd
devices. The program currently uses mmap in order to access a file as
permanent storage. I discovered that using this capability is not
possible on jffs2, as mmap does not accept MAP_SHARED.

In my framework, write operations are performed by explicit calls, but
the data must be readable as if it were in a direct-access
memory. Would it be possible to do that on jffs2 (for instance,
open/write/close sessions to modify the data, but with immediate
update on the mmapped version of the file)

Alternatively, would it possible to use a raw MTD device to provide
the equivalent service ? I don't need filesystem semantic, as the
program already considers the data as a sequence of pages on a
flash-like device.

Thanks for any suggestion,

Frédéric

-- 
Frédéric Gobry    SMARTDATA    	  
      ---         http://www.smartdata.ch
Software Engineer Lausanne - Switzerland
                  +41 21 693 84 98

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread
* mmap question
@ 2002-09-24  7:26 Der Herr Hofrat
  2002-09-24  8:54 ` Der Herr Hofrat
  2002-09-24  9:37 ` Zhonghua Dai
  0 siblings, 2 replies; 21+ messages in thread
From: Der Herr Hofrat @ 2002-09-24  7:26 UTC (permalink / raw)
  To: linux-kernel


Hi !

 trying to write up a simple mmap for a pseudo device that accesses a 
 kmalloc'ed area.

 The driver is a character driver that only has mmap implemented - the kmalloc
 is done in init module and the pointer to the buffer is in global context.
 I expected to be able to write to the mmap'ed area from user-space but it
 never shows up in kernel space (the printk in driver_mmap always shows the
 init_msg passed in init_module). 

 the basic framework I'm using is below - can anybody point me to an obvious
 error or to some docs that would explain how to share an kmalloc'ed area
 with user-space via mmap ? 

thx !
hofrat
 
---driver---
char *kmalloc_area;
...
static int
driver_mmap(struct file *file,
	struct vm_area_struct *vma)
{
	vma->vm_flags |= VM_LOCKED|VM_SHARED;

	printk("message buffer: %s\",kmalloc_area); 
	remap_page_range(vma->vm_start,
		virt_to_phys(kmalloc_area),
		LEN,
		PAGE_SHARED);
	return 0;
}
	
static struct file_operations simple_fops={
    mmap:	driver_mmap,
};

int
init_module(void){
	...
	kmalloc_area=kmalloc(LEN,GFP_USER);
	strncpy(kmalloc_area,init_msg,sizeof(init_msg));
	...
}

---user-app---

int main(void)
{
	int fd;
	char msg[]="some message - should appear in kernel space";
	unsigned int *addr;

	if((fd=open("/dev/simple-device", O_RDWR))<0)
	addr = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	memset(addr,0,LEN); 
	strncpy(addr,msg,sizeof(msg));
	return 0;
}

^ permalink raw reply	[flat|nested] 21+ messages in thread
* mmap question
@ 2005-03-21 17:59 Eric Van Hensbergen
  2005-03-21 21:33 ` Bryan Henderson
  2005-03-21 23:56 ` Martin Jambor
  0 siblings, 2 replies; 21+ messages in thread
From: Eric Van Hensbergen @ 2005-03-21 17:59 UTC (permalink / raw)
  To: linux-fsdevel

I'm trying to implement a completely synchronous mmap in my
filesystem, but am running into some difficulty and was wondering if
someone could give me some insight/clue.

I want all my file system's operations to be complete uncached and
synchronous, but I also want to support mmap.  The problem is that
mmap writes don't seem to register right away.  If I have a test app:

        start = mmap(0, 8192, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
        if((int)start==-1) {
                perror("mmap:");
                exit(-1);
        }
        memcpy(buffer, start, 10);
        buffer[10] = 0;
        printf("reply: (%s)\n", buffer);
        sprintf(start, "hello world\n");
        memcpy(buffer, start, 10);
        buffer[10] = 0;
        printf("reply2: (%s)\n", buffer);
        munmap(start, 8192);
        close(fd);

I get the right results (because the read is also an mmap through the
buffer, but it looks like I don't see the file's set_page_dirty method
called until after I see the second read.  If I do use normal reads
(instead of mmap reads) I get the wrong results because my normal file
read method doesn't go through the page cache.

What am I doing wrong?  Is what I'm trying to do impossible, and if
so, how can I get as close as possible?

Thanks in advance for any help.

      -eric

^ permalink raw reply	[flat|nested] 21+ messages in thread
* mmap question
@ 2005-08-02 22:44 Ruslan Nikolaev
  0 siblings, 0 replies; 21+ messages in thread
From: Ruslan Nikolaev @ 2005-08-02 22:44 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]

OK. Possible I'll get free time next week and can do something :)

I have some questions:

1. Memory limit that was argued not long ago. I think that memory size
variable should be 64-bit size and also full mmap support would come... I
can try to do it.

2. Also I have a question about disk offsets. Now it is 32-bit and it's
OK for dos and apple maps but doesn't enough for another partitions map
such as LDM. Of course LDM doesn't available for GRUB now but perhaps it
will come in future. Replacing to 64-bit offsets seems to be not very
hard but a complex work. Also it seems that block_list stores block
number as 32-bit.

3. amd64 compilation. It seems to be not available now. One more question
I have... Linux gets device geometry througth the ioctl call. Does the
"long" type for "start
 field in "hd_geometry" struct (that used is util/i386/pc/biosdisk.c) is
always long type (that means it is 64-bit for amd64) or just 32-bit type?
I'm not Linux specialist and don't know...

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


[-- Attachment #2: Type: text/html, Size: 1321 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2005-08-02 22:57 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-04 13:22 mmap question Frederic Gobry
2002-07-01 13:14 ` Frederic Gobry
2002-07-11 16:19   ` Frederic Gobry
2002-07-11 19:15     ` Jörn Engel
2002-07-12  7:57       ` Frederic Gobry
2002-07-12 15:08         ` Jörn Engel
2002-07-15  7:41           ` Frederic Gobry
2002-07-12 15:21         ` David Woodhouse
  -- strict thread matches above, loose matches on Subject: below --
2002-09-24  7:26 Der Herr Hofrat
2002-09-24  8:54 ` Der Herr Hofrat
2002-09-24  9:37 ` Zhonghua Dai
2005-03-21 17:59 Eric Van Hensbergen
2005-03-21 21:33 ` Bryan Henderson
2005-03-21 22:23   ` Matthew Wilcox
2005-03-21 23:18     ` Bryan Henderson
     [not found]   ` <a4e6962a05032114575776f94b@mail.gmail.com>
2005-03-21 22:57     ` Eric Van Hensbergen
2005-03-21 23:24       ` Bryan Henderson
2005-03-21 23:27       ` Bryan Henderson
2005-03-22 21:05         ` Eric Van Hensbergen
2005-03-21 23:56 ` Martin Jambor
2005-08-02 22:44 Ruslan Nikolaev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.