* Two questions regarding Opening files within Kernel!
@ 2007-04-07 6:58 JanuGerman
2007-04-07 9:22 ` Roland Kuhn
2007-04-07 11:07 ` Jan Engelhardt
0 siblings, 2 replies; 6+ messages in thread
From: JanuGerman @ 2007-04-07 6:58 UTC (permalink / raw)
To: linuxkernel
Hi Every one,
I have got two questions regarding opening files within the Linux kernel. If some body can help me, in sorting out this problem, i will be very thankful.
1) I have just a file path with me, an absolute path, but no dentry, no inode, no vfsmount object, which function i can call to get a "file" object associated with the absoulte file path. I have surfed arround the source code especially fs/open.c and some other files, but each function requires a parameter "mode" and "fd" beside file path. Actually, i was confuse about the "mode" parameter (and its differece with "flag"), like what to send, and secondly for "fd", i am not sure, what value to send as there is no file infact and only file path exists. Any idea?
2) Any functionality within linux kernel source code, to read one line per file? or some indirect way to set buffer size for one read?. That is, any existing header file for doing text I/O rather than binary within the kernel source code?
Thanks,
JG
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two questions regarding Opening files within Kernel!
2007-04-07 6:58 JanuGerman
@ 2007-04-07 9:22 ` Roland Kuhn
2007-04-07 11:07 ` Jan Engelhardt
1 sibling, 0 replies; 6+ messages in thread
From: Roland Kuhn @ 2007-04-07 9:22 UTC (permalink / raw)
To: JanuGerman; +Cc: linuxkernel
[-- Attachment #1.1: Type: text/plain, Size: 1659 bytes --]
Hi!
On 7 Apr 2007, at 08:58, JanuGerman wrote:
> 1) I have just a file path with me, an absolute path, but no
> dentry, no inode, no vfsmount object, which function i can call to
> get a "file" object associated with the absoulte file path. I have
> surfed arround the source code especially fs/open.c and some other
> files, but each function requires a parameter "mode" and "fd"
> beside file path. Actually, i was confuse about the "mode"
> parameter (and its differece with "flag"), like what to send, and
> secondly for "fd", i am not sure, what value to send as there is no
> file infact and only file path exists. Any idea?
>
No, but I'm no guru either.
> 2) Any functionality within linux kernel source code, to read one
> line per file? or some indirect way to set buffer size for one
> read?. That is, any existing header file for doing text I/O rather
> than binary within the kernel source code?
>
Do you have a compelling reason for not letting userspace feed the
file to your driver? That would be the natural and much easier way, I
suppose...
Ciao,
Roland
--
TU Muenchen, Physik-Department E18, James-Franck-Str., 85748 Garching
Telefon 089/289-12575; Telefax 089/289-12570
--
CERN office: 892-1-D23 phone: +41 22 7676540 mobile: +41 76 487 4482
--
Any society that would give up a little liberty to gain a little
security will deserve neither and lose both. - Benjamin Franklin
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GS/CS/M/MU d-(++) s:+ a-> C+++ UL++++ P+++ L+++ E(+) W+ !N K- w--- M
+ !V Y+
PGP++ t+(++) 5 R+ tv-- b+ DI++ e+++>++++ h---- y+++
------END GEEK CODE BLOCK------
[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4324 bytes --]
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two questions regarding Opening files within Kernel!
2007-04-07 6:58 JanuGerman
2007-04-07 9:22 ` Roland Kuhn
@ 2007-04-07 11:07 ` Jan Engelhardt
1 sibling, 0 replies; 6+ messages in thread
From: Jan Engelhardt @ 2007-04-07 11:07 UTC (permalink / raw)
To: JanuGerman; +Cc: linuxkernel
On Apr 7 2007 06:58, JanuGerman wrote:
>Hi Every one,
>
> I have got two questions regarding opening files within the Linux
> kernel. If some body can help me, in sorting out this problem, i will
> be very thankful.
>
>1) I have just a file path with me, an absolute path, but no dentry,
> no inode, no vfsmount object, which function i can call to get a
> "file" object associated with the absoulte file path. I have surfed
> arround the source code especially fs/open.c and some other files,
> but each function requires a parameter "mode" and "fd" beside file
> path. Actually, i was confuse about the "mode" parameter (and its
> differece with "flag"), like what to send, and secondly for "fd", i
> am not sure, what value to send as there is no file infact and only
> file path exists. Any idea?
Not sure if this is the right function, but it should get you started...
struct dentry *foooobar = lookup_one_len("/foo/bar", current->fs->root);
>2) Any functionality within linux kernel source code, to read one line
> per file? or some indirect way to set buffer size for one read?.
> That is, any existing header file for doing text I/O rather than
> binary within the kernel source code?
http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
(same goes for reading)
Jan
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two questions regarding Opening files within Kernel!
[not found] <fa.9BBqigWhVcsOIUStQ9CipWD6PQo@ifi.uio.no>
@ 2007-04-07 16:50 ` Robert Hancock
0 siblings, 0 replies; 6+ messages in thread
From: Robert Hancock @ 2007-04-07 16:50 UTC (permalink / raw)
To: JanuGerman; +Cc: linuxkernel
JanuGerman wrote:
> Hi Every one,
>
> I have got two questions regarding opening files within the Linux kernel. If some body can help me, in sorting out this problem, i will be very thankful.
First off, likely not something you should be doing:
http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two questions regarding Opening files within Kernel!
@ 2007-04-07 16:57 JanuGerman
2007-04-07 18:44 ` Jan Engelhardt
0 siblings, 1 reply; 6+ messages in thread
From: JanuGerman @ 2007-04-07 16:57 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: linuxkernel
Thanks Jan for the response.
>struct dentry *foooobar = lookup_one_len("/foo/bar", current->fs->root);
But that gives me a dentry, where as file object is still not reachable.
Question: I am currently using a function called fs.h/dentry_open which takes a "dentry", "vfsmount" object and flag (usually RW i.e. 2), and gives me the file object. with your suggested method, vfsmount is still not available. In this regard, any idea about a function, which gives directly the file object instead of dentry will be highly appreciated.
OR, (Kindly see the code below), i need some thing for "missing vfsmount".
struct dentry *foooobar = lookup_one_len("/foo/bar", current->fs->root);
struct file *file1 = dentry_open(foooobar, "missing vfsmount here",2)
Thanks,
JG
___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two questions regarding Opening files within Kernel!
2007-04-07 16:57 JanuGerman
@ 2007-04-07 18:44 ` Jan Engelhardt
0 siblings, 0 replies; 6+ messages in thread
From: Jan Engelhardt @ 2007-04-07 18:44 UTC (permalink / raw)
To: JanuGerman; +Cc: linuxkernel
On Apr 7 2007 16:57, JanuGerman wrote:
>
>Thanks Jan for the response.
>
>>struct dentry *foooobar = lookup_one_len("/foo/bar", current->fs->root);
>
>But that gives me a dentry, where as file object is still not reachable.
So use filp_open.
>Question: I am currently using a function called fs.h/dentry_open which takes
>a "dentry", "vfsmount" object and flag (usually RW i.e. 2), and gives me the
>file object. with your suggested method, vfsmount is still not available. In
>this regard, any idea about a function, which gives directly the file object
>instead of dentry will be highly appreciated.
>
>
>OR, (Kindly see the code below), i need some thing for "missing vfsmount".
>
>
> struct dentry *foooobar = lookup_one_len("/foo/bar", current->fs->root);
> struct file *file1 = dentry_open(foooobar, "missing vfsmount here",2)
>
>
>
>Thanks,
>JG
>
>
>
>
>
>___________________________________________________________
>New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes.
>http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
>
Jan
--
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-04-07 18:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <fa.9BBqigWhVcsOIUStQ9CipWD6PQo@ifi.uio.no>
2007-04-07 16:50 ` Two questions regarding Opening files within Kernel! Robert Hancock
2007-04-07 16:57 JanuGerman
2007-04-07 18:44 ` Jan Engelhardt
-- strict thread matches above, loose matches on Subject: below --
2007-04-07 6:58 JanuGerman
2007-04-07 9:22 ` Roland Kuhn
2007-04-07 11:07 ` Jan Engelhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox