Can I do ioctl() on a device file from inside a module?

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

 



I want to write a module that opens up a device (known to the userland
filesystem as "/dev/mtd/0"), runs some ioctl()s on it, and writes some
data to it.

There are two problems:

1. the functions I want to use (which are defined in
   drivers/mtd/mtdchar.c) are static, so my module can't link to them.
   I guess I could get to them by somehow searching the VFS dispatch
   table (which I don't really understand).

2. these mtd functions need arguments like "struct file *file" which
   are normally passed by the kernel when a userspace program invokes
   write() or ioctl().  My module doesn't have those either.

It seems to me that if it is easy in userspace it should also be easy
in a module.  What's the best way to call write() and ioctl() on a
device from my module?

Thanks,
Dave


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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