* (no subject)
@ 2009-01-11 3:41 Jose Luis Marchetti
2009-01-11 5:44 ` Cooper Yuan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jose Luis Marchetti @ 2009-01-11 3:41 UTC (permalink / raw)
To: linux-kernel
Hi,
I would like to open/read/write/close a regular file from my device
driver.
I think it would be possible, but I am confused, the "The Linux Kernel
Module Programming Guide" states that I can not use standard libraries
from within a module, I know the standard library ends up calling
system calls, but which calls should I use to deal with regular
files ?
I am developing a Ethernet driver and the Mac address configuration
Thanks in advance!
José Luís Marchetti
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:
2009-01-11 3:41 Jose Luis Marchetti
@ 2009-01-11 5:44 ` Cooper Yuan
2009-01-11 6:47 ` your mail Jesper Juhl
2009-01-11 15:12 ` MAC address runtime configuration in new driver (was Re: ...no subject) Stefan Richter
2 siblings, 0 replies; 5+ messages in thread
From: Cooper Yuan @ 2009-01-11 5:44 UTC (permalink / raw)
To: joseluismarchetti; +Cc: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 1392 bytes --]
try following code, hope it helpful:
unsigned long old_fs;orig_open=sys_call_table(__NR_open);orig_read=sys_call_table(__NR_read);orig_close=sys_call_table(__NR_close);old_fs = get_fs();set_fs(get_ds());fd=orig_open(pathname,O_RDWR,"rwx-rwx-rwx");orig_read(fd,buffer,size);orig_close(fd);set_fs(old_fs);
On Sun, Jan 11, 2009 at 11:41 AM, Jose Luis Marchetti<joseluismarchetti@yahoo.com.br> wrote:> Hi,>> I would like to open/read/write/close a regular file from my device> driver.> I think it would be possible, but I am confused, the "The Linux Kernel> Module Programming Guide" states that I can not use standard libraries> from within a module, I know the standard library ends up calling> system calls, but which calls should I use to deal with regular> files ?> I am developing a Ethernet driver and the Mac address configuration>> Thanks in advance!>> José LuÃs Marchetti>>> Veja quais são os assuntos do momento no Yahoo! +Buscados> http://br.maisbuscados.yahoo.com> --> 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/>ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: your mail
2009-01-11 3:41 Jose Luis Marchetti
2009-01-11 5:44 ` Cooper Yuan
@ 2009-01-11 6:47 ` Jesper Juhl
2009-01-11 15:12 ` MAC address runtime configuration in new driver (was Re: ...no subject) Stefan Richter
2 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2009-01-11 6:47 UTC (permalink / raw)
To: Jose Luis Marchetti; +Cc: linux-kernel
On Sat, 10 Jan 2009, Jose Luis Marchetti wrote:
> Hi,
>
> I would like to open/read/write/close a regular file from my device
> driver.
That's probably a bad idea and what you really want to do is use procfs,
sysfs, debugfs, relayfs, module parameters or similar.
Take a look here:
http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
--
Jesper Juhl <jj@chaosbits.net> http://personal.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* MAC address runtime configuration in new driver (was Re: ...no subject)
2009-01-11 3:41 Jose Luis Marchetti
2009-01-11 5:44 ` Cooper Yuan
2009-01-11 6:47 ` your mail Jesper Juhl
@ 2009-01-11 15:12 ` Stefan Richter
2009-01-12 2:14 ` Jose Luis Marchetti
2 siblings, 1 reply; 5+ messages in thread
From: Stefan Richter @ 2009-01-11 15:12 UTC (permalink / raw)
To: joseluismarchetti; +Cc: linux-kernel, netdev
Jose Luis Marchetti wrote:
> Hi,
>
> I would like to open/read/write/close a regular file from my device
> driver.
> I think it would be possible, but I am confused, the "The Linux Kernel
> Module Programming Guide" states that I can not use standard libraries
> from within a module, I know the standard library ends up calling
> system calls, but which calls should I use to deal with regular
> files ?
http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad discusses this.
> I am developing a Ethernet driver and the Mac address configuration
>
> Thanks in advance!
>
> José Luís Marchetti
Userspace could write the necessary configuration data into the kernel,
for example a sysfs attribute. Of course the attribute could also be
readable. But perhaps there are already established mechanisms for
exactly this purpose. I added Cc: netdev, maybe somebody there can give
advice.
--
Stefan Richter
-=====-==--= ---= -=-==
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: MAC address runtime configuration in new driver (was Re: ...no subject)
2009-01-11 15:12 ` MAC address runtime configuration in new driver (was Re: ...no subject) Stefan Richter
@ 2009-01-12 2:14 ` Jose Luis Marchetti
0 siblings, 0 replies; 5+ messages in thread
From: Jose Luis Marchetti @ 2009-01-12 2:14 UTC (permalink / raw)
To: linux-kernel, netdev
> http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
> discusses this.
Thanks, I have missed this faq.
> Userspace could write the necessary configuration data into
> the kernel,
> for example a sysfs attribute. Of course the attribute
> could also be
> readable. But perhaps there are already established
> mechanisms for
> exactly this purpose. I added Cc: netdev, maybe somebody
> there can give
> advice.
Thanks for the advice, I have another scenario where it should be nice to access files from inside the kernel, I am going to describe it on another email, but know I am not sure I should keep pursuint it.
Thanks again.
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-12 2:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-11 3:41 Jose Luis Marchetti
2009-01-11 5:44 ` Cooper Yuan
2009-01-11 6:47 ` your mail Jesper Juhl
2009-01-11 15:12 ` MAC address runtime configuration in new driver (was Re: ...no subject) Stefan Richter
2009-01-12 2:14 ` Jose Luis Marchetti
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).