Re: Opening a /dev file from Kernel space




John Reiser wrote:
I want to open the serilal driver (/dev/ttyS0) from the kernel space.
I need to write a character driver in the kernel (the requirements of
the project insist that it will be inside the kernel) that gets special
strings from user and pass them to the serial.

In order to implement that I thought of opening the serial driver as if
I was a user and with the file descriptor to read()/write()/ioctl()
etc...

Can I do this from the kernel space?
Do you have maybe a better idea how to implement?

This sounds like a "line discipline" for a serial device: a special way
to interpret the byte stream flowing between the user and the device:
something other than uninterpreted, 1-for-1 transport.

The most common line discipline is the code for a VGA text console
which performs character echoing (so you can see what you type), handles
backspace-as-delete, rings the bell for control-G, sends SIGINT for
control-C, turns <Enter> ('\r') into newline ('\n') on input, turns
newline ('\n') into carriage_return + linefeed ("\r\n") on ouput, etc.

The user opens the device, performs an ioctl() to choose the line
discipline, then transfers data using read() or write(). The line
discipline is a "filter" which resides inside the kernel, instead
of in a shell pipeline. See linux/Documentation/tty.txt.

--

Thanks but the serial driver is just one of the drivers I want to open
from the kernel space.
I need a generic way to open devices (via /dev) from the kernel space.
The projetc requirments defines that user should open my special driver
and do some operations on the device.
Anyway, I thought about opening the /dev/KernelDriver (like ttyS0 or
dv1394) from my special driver. User shall open my driver and
send/receive like it was the kernel driver. I will pass the
send/receivew of the user to the kernel driver I have opened from the
kernel.
What do u say?
Is there any way to do it?
open the device and get the file descriptor to use in read() write()???

.



Relevant Pages

  • Re: 2.6.30-rc4 kernel
    ... I think there may be a problem with the 2.6.30 kernel that is ... # Generic Driver Options ... # PCI IDE chipsets support ... # Other IDE chipsets support ...
    (Linux-Kernel)
  • 2.6.30-rc4 kernel
    ... kernel panic - not syncing: ... # Generic Driver Options ... # PCI IDE chipsets support ... # Other IDE chipsets support ...
    (Linux-Kernel)
  • [PATCH 18-rc2] Fix typos in /Documentation : N-P
    ... Again, if you're not gonna do synchronization with disk drives (dang, ... -the kernel. ... There are two options specific to PSX driver portion. ... The driver uses the settings from the EEPROM set in the SCSI BIOS ...
    (Linux-Kernel)
  • two scary syslog kernel messages
    ... Sep 20 03:46:06 marvin kernel: kernel BUG at mm/rmap.c:482! ... ACPI: Local APIC address 0xfee00000 ... Allocating PCI resources starting at 80000000 ... ** driver failed to call pci_enable_device. ...
    (Debian-User)
  • Re: [PATCH, RFT, v4] sata_mv: convert to new EH
    ... check both new and old drives with SMART ... Use a HIGHMEM enabled kernel. ... ACPI: PM-Timer IO Port: 0xe408 ... Real Time Clock Driver v1.12ac ...
    (Linux-Kernel)