Re: Two questions regarding Opening files within Kernel!

From: Jan Engelhardt
Date: Sat Apr 07 2007 - 07:08:08 EST



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
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/