LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* create a file in kernel mode. help please!
       [not found] <ee3dc96c0801182116q3d54148dl6773d76ff3160d91@mail.gmail.com>
@ 2008-01-19  5:17 ` Rafael Sisto
  2008-01-21  8:21   ` Joe
  2008-01-23 18:02   ` Jan Kara
  0 siblings, 2 replies; 4+ messages in thread
From: Rafael Sisto @ 2008-01-19  5:17 UTC (permalink / raw)
  To: Linux kernel

Hi there,
obviously this is a newbie question, but I couldn't find any
documentation on how to do it.. I tried several ways but couldnt do
it.
I designed a system call, so a user will call it, and a new file will
be created ('/tmp/filexx'). After that, I have another system call,
that will map the file into the maps of the user process. The idea is
the same as IPC...

I managed to create the file with this function (in the first system call):
        fd = filp_open(path, O_CREAT | O_RDWR , 777);

After that, the user will call another system call, and it will map
this file to the process maps.
something like this:
         filp_open(route, O_RDWR,0 );
         do_mmap(fp, 0, tamano, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_SHARED, 0);

After I call the second system call, the user tries to access the
memory, but gets the message "Bus Error".
I tried to manually create a file with vi, and then use the second
system call, and worked perfectly. I could use the shared memory
without problems.

The problems seems to be in the first system call (with filp_open),
when I try to create a new file... Can somebody suggest me something,
on how I could fix this issue?? It is very important because it is for
a college projects.

Greetings, and thanks in advance for the answers.
Rafael Sisto - Uruguay.-

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

* Re: create a file in kernel mode. help please!
  2008-01-19  5:17 ` create a file in kernel mode. help please! Rafael Sisto
@ 2008-01-21  8:21   ` Joe
  2008-01-21 12:44     ` Rafael Sisto
  2008-01-23 18:02   ` Jan Kara
  1 sibling, 1 reply; 4+ messages in thread
From: Joe @ 2008-01-21  8:21 UTC (permalink / raw)
  To: Rafael Sisto; +Cc: Linux kernel

Hi Rafael.

Probably you haven't got any answers yet because you should NEVER EVER 
(i repeat: NEVER EVER, not even in college projects) go for file I/O in 
the kernel. You might want to think the whole thing over one or two 
times, i think.

If it comes to you that it is absolutely necessary (i repeat again: 
ABSOLUTELY NECESSARY, like a solution to feed the world) then you might 
google for some ancient FAQ of Greg (K-H) (i think he was) where he 
tries to give a little more details about this kind of problem, and also 
gives a possible solution, IIRC. Sorry that i don't remember the exact 
page/adress anymore, for i intend never to look at it again.

Greetz
Joe

Rafael Sisto schrieb:
> Hi there,
> obviously this is a newbie question, but I couldn't find any
> documentation on how to do it.. I tried several ways but couldnt do
> it.
> I designed a system call, so a user will call it, and a new file will
> be created ('/tmp/filexx'). After that, I have another system call,
> that will map the file into the maps of the user process. The idea is
> the same as IPC...
> 
> I managed to create the file with this function (in the first system call):
>         fd = filp_open(path, O_CREAT | O_RDWR , 777);
> 
> After that, the user will call another system call, and it will map
> this file to the process maps.
> something like this:
>          filp_open(route, O_RDWR,0 );
>          do_mmap(fp, 0, tamano, PROT_READ | PROT_WRITE | PROT_EXEC,
> MAP_SHARED, 0);
> 
> After I call the second system call, the user tries to access the
> memory, but gets the message "Bus Error".
> I tried to manually create a file with vi, and then use the second
> system call, and worked perfectly. I could use the shared memory
> without problems.
> 
> The problems seems to be in the first system call (with filp_open),
> when I try to create a new file... Can somebody suggest me something,
> on how I could fix this issue?? It is very important because it is for
> a college projects.
> 
> Greetings, and thanks in advance for the answers.
> Rafael Sisto - Uruguay.-
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


-- 
Sepp "ZaP" Holzmayr

please reply to:
zentrale.at.work@gmail.com

watch out for:
www.rocksociety.de

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

* Re: create a file in kernel mode. help please!
  2008-01-21  8:21   ` Joe
@ 2008-01-21 12:44     ` Rafael Sisto
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael Sisto @ 2008-01-21 12:44 UTC (permalink / raw)
  To: Joe; +Cc: Linux kernel

Thanks Joe for the answer! I will find another work around for my problem, then!

greetings, Rafael Sisto.

On Jan 21, 2008 5:21 AM, Joe <zentrale.at.work@gmail.com> wrote:
> Hi Rafael.
>
> Probably you haven't got any answers yet because you should NEVER EVER
> (i repeat: NEVER EVER, not even in college projects) go for file I/O in
> the kernel. You might want to think the whole thing over one or two
> times, i think.
>
> If it comes to you that it is absolutely necessary (i repeat again:
> ABSOLUTELY NECESSARY, like a solution to feed the world) then you might
> google for some ancient FAQ of Greg (K-H) (i think he was) where he
> tries to give a little more details about this kind of problem, and also
> gives a possible solution, IIRC. Sorry that i don't remember the exact
> page/adress anymore, for i intend never to look at it again.
>
> Greetz
> Joe
>
> Rafael Sisto schrieb:
>
> > Hi there,
> > obviously this is a newbie question, but I couldn't find any
> > documentation on how to do it.. I tried several ways but couldnt do
> > it.
> > I designed a system call, so a user will call it, and a new file will
> > be created ('/tmp/filexx'). After that, I have another system call,
> > that will map the file into the maps of the user process. The idea is
> > the same as IPC...
> >
> > I managed to create the file with this function (in the first system call):
> >         fd = filp_open(path, O_CREAT | O_RDWR , 777);
> >
> > After that, the user will call another system call, and it will map
> > this file to the process maps.
> > something like this:
> >          filp_open(route, O_RDWR,0 );
> >          do_mmap(fp, 0, tamano, PROT_READ | PROT_WRITE | PROT_EXEC,
> > MAP_SHARED, 0);
> >
> > After I call the second system call, the user tries to access the
> > memory, but gets the message "Bus Error".
> > I tried to manually create a file with vi, and then use the second
> > system call, and worked perfectly. I could use the shared memory
> > without problems.
> >
> > The problems seems to be in the first system call (with filp_open),
> > when I try to create a new file... Can somebody suggest me something,
> > on how I could fix this issue?? It is very important because it is for
> > a college projects.
> >
> > Greetings, and thanks in advance for the answers.
> > Rafael Sisto - Uruguay.-
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> >
>
>
> --
> Sepp "ZaP" Holzmayr
>
> please reply to:
> zentrale.at.work@gmail.com
>
> watch out for:
> www.rocksociety.de
>

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

* Re: create a file in kernel mode. help please!
  2008-01-19  5:17 ` create a file in kernel mode. help please! Rafael Sisto
  2008-01-21  8:21   ` Joe
@ 2008-01-23 18:02   ` Jan Kara
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kara @ 2008-01-23 18:02 UTC (permalink / raw)
  To: Rafael Sisto; +Cc: Linux kernel

  Hi,

> obviously this is a newbie question, but I couldn't find any
> documentation on how to do it.. I tried several ways but couldnt do
> it.
> I designed a system call, so a user will call it, and a new file will
> be created ('/tmp/filexx'). After that, I have another system call,
> that will map the file into the maps of the user process. The idea is
> the same as IPC...
> 
> I managed to create the file with this function (in the first system call):
>         fd = filp_open(path, O_CREAT | O_RDWR , 777);
> 
> After that, the user will call another system call, and it will map
> this file to the process maps.
> something like this:
>          filp_open(route, O_RDWR,0 );
>          do_mmap(fp, 0, tamano, PROT_READ | PROT_WRITE | PROT_EXEC,
> MAP_SHARED, 0);
> 
> After I call the second system call, the user tries to access the
> memory, but gets the message "Bus Error".
> I tried to manually create a file with vi, and then use the second
> system call, and worked perfectly. I could use the shared memory
> without problems.
> 
> The problems seems to be in the first system call (with filp_open),
> when I try to create a new file... Can somebody suggest me something,
> on how I could fix this issue?? It is very important because it is for
> a college projects.
  Hmm, I don't quite get what you are trying to achieve? Why can't user
create the file via open(path, O_CREAT...) and then mmap() it? Why do
you need a new system call for that?

								Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

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

end of thread, other threads:[~2008-01-23 18:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ee3dc96c0801182116q3d54148dl6773d76ff3160d91@mail.gmail.com>
2008-01-19  5:17 ` create a file in kernel mode. help please! Rafael Sisto
2008-01-21  8:21   ` Joe
2008-01-21 12:44     ` Rafael Sisto
2008-01-23 18:02   ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).