Re: Accessing a File System/ Files from kernel space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Guys,
 
    Ooops looks like I did not enumerate the purpose of the driver. Well the use is simple - I am going to write a driver which reads some(a whole lot still) packet data from a file stored on  a file system - just reading nothing else. The file per se will be created by another application and stored on an ext2FS or FAT32FS . Now, All that I wish to do is access the file from kernel space because a high level user land API will be able to open/read the file. But, again the data will be present in user space . This data has to be moved to kernel space(for my driver) using copy_from_user() and considering the fact that the file itself could be 1 GB + in size  - I believe I might loose a lot of cycles doing this conversion . Please do let me know if there is something else we could do for this in the kernel itself rather than doing it in user land.
Thanks,
G.


Fawad Lateef <fawadlateef@xxxxxxxxx> wrote:
On 3/21/06, Avishay Traeger wrote:
> On Tue, 2006-03-21 at 02:59 -0800, George Joseph wrote:
> > I am a relatively new entry to Linux kernel space programming and
> > have worked on RTOSs like os20,vxworks etc etc...
> >
> > I would like to know whether it is possible to access a file on a
> > filesystem by a driver loaded in the kernel and what would be the
> > issues I face while doing so - practically and theoritically. Sorry
> > the question is a bit blunt since this is a new activity I am planning
> > to pursue. TIA.BTW I am planning to use kernel 2.6.15 for
> > developement.
>
> I don't know much about drivers so I'll let someone else answer that,
> but from a file system perspective:
> 1. I assume this is for an exercise, otherwise, why not just use the
> file system?
> 2. What do you mean by "access"? Do you mean read? Read/write? Stat?
> I'll assume you don't want to make changes to the file system, since you
> will need to duplicate the whole file system within the driver.
> 3. You should be aware that each file system has its own meta-data, it's
> own on-disk format, etc. Unless your driver simply uses the file system
> methods, it will by specific to file systems that use a single format
> that you code.
> 4. You will need to be familiar with where meta-data is stored on the
> file system, how to parse it, how to use it to find data blocks, and any
> other quirks that the specific file system has.
>

I think George wants to access a file (lying on any file system) from
the kernel space or driver. If this is the case then:

1) You can access files from the driver, but it won't be done due to
many issues especially security issues. (just search kernelnewbies and
linux-kernel archieves for reasons in detail)

2) If you want to get data in driver from file then use user space
program to read that file and send data to driver through sysfs or
netlink_sockets. You can also use netlink_sockets to send data from
kernel space or driver to user program and write into the file.

I hope it helps too with Avishay's reply :)

--
Fawad Lateef


Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux