All of lore.kernel.org
 help / color / mirror / Atom feed
* Accessing file mapped data inside the kernel
@ 2005-11-09 20:15 Paulo da Silva
  2005-11-09 20:46 ` linux-os (Dick Johnson)
  2005-11-09 21:44 ` Anton Altaparmakov
  0 siblings, 2 replies; 6+ messages in thread
From: Paulo da Silva @ 2005-11-09 20:15 UTC (permalink / raw)
  To: linux-kernel

Hi.

I posted about this a few days ago but got no responses
so far! I think this should be a trivial question for those
involved in the kernel internals. May be I didn't develop
the problem enough to be understood.

So, here is the question reformulated.

A given file system must supply a procedure for mmap.

int <fsname>_file_mmap(struct file * file, struct vm_area_struct * vma)
{
   int addr;
   addr=generic_file_mmap(file,vma);
   <Code to access addr pointed bytes or vma->vm_start>
   return addr;
}

I could verify that "addr" is what is returned to the user as
a pointer to a string of bytes that maps a file when a user
program calls mmap or mmap2.

In the user program, I can access those bytes (read/write)
as, for ex., a char pointer.

I don't know how to access those bytes inside the kernel
at the point <Code to access addr pointed bytes or vma->vm_start>

First trys led the program that invoked mmap to block.
I thought that there's something to do with a previous
    down_write(&current->mm->mmap_sem);
If I execute
    up_write(&current->mm->mmap_sem);
before accessing the data the block situation does not
occur anymore. I would like to hear something about
this.

Anyway, I tryed to use "copy_from_user" but I got
garbage, not the file contents! Using "strncpy" crashes
the kernel (UML)!

Can someone please write a fragment of code to safely
access those bytes, copying them to and from a
kernel char pointed area so that they are read/written
to the file?

Thank you very much.
Paulo


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

end of thread, other threads:[~2005-11-10 23:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-09 20:15 Accessing file mapped data inside the kernel Paulo da Silva
2005-11-09 20:46 ` linux-os (Dick Johnson)
2005-11-09 21:44 ` Anton Altaparmakov
2005-11-10  1:44   ` Paulo da Silva
2005-11-10  9:24     ` Anton Altaparmakov
2005-11-10 23:20       ` Paulo da Silva

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.