* writing from kernel
@ 2003-01-04 16:02 anil vijarnia
2003-01-04 16:27 ` Christian Vogel
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: anil vijarnia @ 2003-01-04 16:02 UTC (permalink / raw)
To: linux-kernel
can anyone tell me how to write into i file from kernel space.
i tried sys_open,sys_write functions bbbbbut they don't work
from
my module.
anil
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: writing from kernel 2003-01-04 16:02 writing from kernel anil vijarnia @ 2003-01-04 16:27 ` Christian Vogel 2003-01-04 16:39 ` [PATCH] Root Raid Support for DAC960 Driver Richard Muratti ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Christian Vogel @ 2003-01-04 16:27 UTC (permalink / raw) To: linux-kernel Hi, On Sat, Jan 04, 2003 at 04:02:55PM -0000, anil vijarnia wrote: > can anyone tell me how to write into i file from kernel space. > i tried sys_open,sys_write functions bbbbbut they don't work > from my module. As far as I understand the general oppinion on this list :-) the preferred method is to have your module preset a character-device to userspace. Then use a small program to do the I/O. This normally keeps your kernel module simple and allows for arbitrary compex I/O in userspace. Chris -- No keyboard present Hit F1 to continue Zen engineering? -- Jim Griffith ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Root Raid Support for DAC960 Driver 2003-01-04 16:02 writing from kernel anil vijarnia 2003-01-04 16:27 ` Christian Vogel @ 2003-01-04 16:39 ` Richard Muratti 2003-01-04 22:24 ` writing from kernel Kasper Dupont 2003-01-05 0:26 ` Olaf Dietsche 3 siblings, 0 replies; 7+ messages in thread From: Richard Muratti @ 2003-01-04 16:39 UTC (permalink / raw) To: linux-kernel Hi, Patch below will allow for mounting of root from a DAC960 raid device This has been submitted before (Leonard,Oliver,others), but I'll submit it again. Reason: Needed to boot of a DAC960 raid device Precedents/Justification for Patch: Root support for compaq raid is included Root support for ata raid is included DAC960 driver is included but root support is not Cheers Rick diff -ur linux-2.4.20/init/do_mounts.c linux/init/do_mounts.c --- linux-2.4.20/init/do_mounts.c Fri Nov 29 10:53:15 2002 +++ linux/init/do_mounts.c Sat Jan 4 23:59:06 2003 @@ -164,6 +164,24 @@ { "dasdg", (DASD_MAJOR << MINORBITS) + (6 << 2) }, { "dasdh", (DASD_MAJOR << MINORBITS) + (7 << 2) }, #endif +#if defined(CONFIG_BLK_DEV_DAC960) || defined(CONFIG_BLK_DEV_DAC960_MODULE) + { "rd/c0d0p",0x3000 }, + { "rd/c0d1p",0x3008 }, + { "rd/c0d2p",0x3010 }, + { "rd/c0d3p",0x3018 }, + { "rd/c0d4p",0x3020 }, + { "rd/c0d5p",0x3028 }, + { "rd/c0d6p",0x3030 }, + { "rd/c0d7p",0x3038 }, + { "rd/c0d8p",0x3040 }, + { "rd/c0d9p",0x3048 }, + { "rd/c0d10p",0x3050 }, + { "rd/c0d11p",0x3058 }, + { "rd/c0d12p",0x3060 }, + { "rd/c0d13p",0x3068 }, + { "rd/c0d14p",0x3070 }, + { "rd/c0d15p",0x3078 }, +#endif #if defined(CONFIG_BLK_CPQ_DA) || defined(CONFIG_BLK_CPQ_DA_MODULE) { "ida/c0d0p",0x4800 }, { "ida/c0d1p",0x4810 }, ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: writing from kernel 2003-01-04 16:02 writing from kernel anil vijarnia 2003-01-04 16:27 ` Christian Vogel 2003-01-04 16:39 ` [PATCH] Root Raid Support for DAC960 Driver Richard Muratti @ 2003-01-04 22:24 ` Kasper Dupont 2003-01-05 0:26 ` Olaf Dietsche 3 siblings, 0 replies; 7+ messages in thread From: Kasper Dupont @ 2003-01-04 22:24 UTC (permalink / raw) To: anil vijarnia; +Cc: linux-kernel anil vijarnia wrote: > > can anyone tell me how to write into i file from kernel space. > i tried sys_open,sys_write functions bbbbbut they don't work > from my module. That is rarely a good idea. But if you insist on doing it anyway, you could use filp_open and the methods in the returned struct. I have an old code example here: http://www.daimi.au.dk/~kasperd/linux_kernel/kcp.c -- Kasper Dupont -- der bruger for meget tid på usenet. For sending spam use mailto:aaarep@daimi.au.dk for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: writing from kernel 2003-01-04 16:02 writing from kernel anil vijarnia ` (2 preceding siblings ...) 2003-01-04 22:24 ` writing from kernel Kasper Dupont @ 2003-01-05 0:26 ` Olaf Dietsche 3 siblings, 0 replies; 7+ messages in thread From: Olaf Dietsche @ 2003-01-05 0:26 UTC (permalink / raw) To: anil vijarnia; +Cc: linux-kernel "anil vijarnia" <linux_ker@rediffmail.com> writes: > can anyone tell me how to write into i file from kernel space. > i tried sys_open,sys_write functions bbbbbut they don't work > from > my module. As others already pointed out, it's not always a good idea to do this from kernel space. However, if you still want to do it, see snippet below. If you want to write, you have to copy kernel_read() from fs/exec.c and modify it for writing. Regards, Olaf. --cut here-->8-- #include <linux/fs.h> struct file *filp; unsigned long offset = 0; char buf[1024]; int n; filp = filp_open("/path/to/some/file", O_RDONLY, 0); if (!filp || IS_ERR(filp)) { /* do some error handling */ } n = kernel_read(filp, offset, buf, sizeof(buf)); if (n != sizeof(buf)) { /* do some checking */ } filp_close(filp, 0); --8<--cut here-- ^ permalink raw reply [flat|nested] 7+ messages in thread
* writing from kernel @ 2003-01-04 16:05 anil vijarnia 0 siblings, 0 replies; 7+ messages in thread From: anil vijarnia @ 2003-01-04 16:05 UTC (permalink / raw) To: linux-kernel can any one tell me how to write into files from kernel space. i tried sys_open(),sys_write() from my module but they don't work. anil ^ permalink raw reply [flat|nested] 7+ messages in thread
* writing from kernel @ 2003-01-04 16:11 anil vijarnia 0 siblings, 0 replies; 7+ messages in thread From: anil vijarnia @ 2003-01-04 16:11 UTC (permalink / raw) To: linux-kernel can any one tell me how to write into files from kernel space.i tried sys_open(),sys_write() from my module but they don't work. anil ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-01-05 0:18 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-01-04 16:02 writing from kernel anil vijarnia 2003-01-04 16:27 ` Christian Vogel 2003-01-04 16:39 ` [PATCH] Root Raid Support for DAC960 Driver Richard Muratti 2003-01-04 22:24 ` writing from kernel Kasper Dupont 2003-01-05 0:26 ` Olaf Dietsche -- strict thread matches above, loose matches on Subject: below -- 2003-01-04 16:05 anil vijarnia 2003-01-04 16:11 anil vijarnia
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox