README 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. FUSD: A Linux Framework for User-Space Devices
  2. ----------------------------------------------
  3. Welcome to FUSD!
  4. This is FUSD snapshot 20070111, released 11 January 2007. You can get
  5. the most recent source, along with online documentation, from xiph.org
  6. SVN:
  7. http://svn.xiph.org/trunk/fusd
  8. There is extensive documentation available in the 'doc' directory.
  9. The FUSD User Manual is available in PDF, Postscript, and HTML format.
  10. Most of this documentation dates from earlier versions of fusd; until
  11. it is fully updated, it may not cover all features that exist in the
  12. current version of fusd.
  13. FUSD is free and open source software, released under a BSD-style
  14. license. See the file 'LICENSE' for details.
  15. QUICK START GUIDE
  16. =================
  17. Instructions for the impatient:
  18. 1- Make sure you're using a system running Linux 2.6.x with udev; this
  19. version of fusd is incompatable with the now-deprecated devfs. If the
  20. kernel is a packaged version from a distribution, also verify any
  21. optional packages needed for building new kernel modules are also
  22. installed.
  23. 2- 'make ; make install' builds everything including examples, then
  24. installs the libraries, includes and kernel module.
  25. 3- Update the udev configuration (usually in /etc/udev/rules.d/) to
  26. include the following rule:
  27. # fusd device
  28. SUBSYSTEM=="fusd", NAME="fusd/%k"
  29. After updating, restart udevd (skill udevd; udevd -d).
  30. 4- Insert the FUSD kernel module (modprobe kfusd)
  31. 5- Verify the fusd devices /dev/fusd/status and /dev/fusd/control
  32. exist. If the modprobe succeeds but no fusd devices appear,
  33. doublecheck the udev rule config change and make sure udevd restarted
  34. successfully. The kfusd kernel module must be inserted after udev has
  35. been correctly configured and restarted.
  36. 6- Try running the helloworld example program (examples/helloworld).
  37. When helloworld is running, 'cat /dev/helloworld' should return
  38. 'Hello, world!'.
  39. 7- For more information, read the User's Manual in the 'doc' directory.
  40. WHAT IS FUSD?
  41. =============
  42. FUSD (pronounced "fused") is a Linux framework for proxying device
  43. file callbacks into user-space, allowing device files to be
  44. implemented by daemons instead of kernel code. Despite being
  45. implemented in user-space, FUSD devices can look and act just like any
  46. other file under /dev which is implemented by kernel callbacks.
  47. A user-space device driver can do many of the things that kernel
  48. drivers can't, such as perform a long-running computation, block while
  49. waiting for an event, or read files from the file system. Unlike
  50. kernel drivers, a user-space device driver can use other device
  51. drivers--that is, access the network, talk to a serial port, get
  52. interactive input from the user, pop up GUI windows, or read from
  53. disks. User-space drivers implemented using FUSD can be much easier to
  54. debug; it is impossible for them to crash the machine, are easily
  55. traceable using tools such as gdb, and can be killed and restarted
  56. without rebooting. FUSD drivers don't have to be in C--Perl, Python,
  57. or any other language that knows how to read from and write to a file
  58. descriptor can work with FUSD. User-space drivers can be swapped out,
  59. whereas kernel drivers lock physical memory.
  60. FUSD drivers are conceptually similar to kernel drivers: a set of
  61. callback functions called in response to system calls made on file
  62. descriptors by user programs. FUSD's C library provides a device
  63. registration function, similar to the kernel's devfs_register_chrdev()
  64. function, to create new devices. fusd_register() accepts the device
  65. name and a structure full of pointers. Those pointers are callback
  66. functions which are called in response to certain user system
  67. calls--for example, when a process tries to open, close, read from, or
  68. write to the device file. The callback functions should conform to
  69. the standard definitions of POSIX system call behavior. In many ways,
  70. the user-space FUSD callback functions are identical to their kernel
  71. counterparts.
  72. The proxying of kernel system calls that makes this kind of program
  73. possible is implemented by FUSD, using a combination of a kernel
  74. module and cooperating user-space library. The kernel module
  75. implements a character device, /dev/fusd, which is used as a control
  76. channel between the two. fusd_register() uses this channel to send a
  77. message to the FUSD kernel module, telling the name of the device the
  78. user wants to register. The kernel module, in turn, registers that
  79. device with the kernel proper using devfs. devfs and the kernel don't
  80. know anything unusual is happening; it appears from their point of
  81. view that the registered devices are simply being implemented by the
  82. FUSD module.
  83. Later, when kernel makes a callback due to a system call (e.g. when
  84. the character device file is opened or read), the FUSD kernel module's
  85. callback blocks the calling process, marshals the arguments of the
  86. callback into a message and sends it to user-space. Once there, the
  87. library half of FUSD unmarshals it and calls whatever user-space
  88. callback the FUSD driver passed to fusd_register(). When that
  89. user-space callback returns a value, the process happens in reverse:
  90. the return value and its side-effects are marshaled by the library
  91. and sent to the kernel. The FUSD kernel module unmarshals this
  92. message, matches it up with a corresponding outstanding request, and
  93. completes the system call. The calling process is completely unaware
  94. of this trickery; it simply enters the kernel once, blocks, unblocks,
  95. and returns from the system call---just as it would for any other
  96. blocking call.
  97. One of the primary design goals of FUSD is stability. It should
  98. not be possible for a FUSD driver to corrupt or crash the kernel,
  99. either due to error or malice. Of course, a buggy driver itself may
  100. corrupt itself (e.g., due to a buffer overrun). However, strict error
  101. checking is implemented at the user-kernel boundary which should
  102. prevent drivers from corrupting the kernel or any other user-space
  103. process---including the errant driver's own clients, and other FUSD
  104. drivers.
  105. For more information, please see the comprehensive documentation in
  106. the 'doc' directory.
  107. Jeremy Elson <jelson@circlemud.org>
  108. August 19, 2003
  109. updated,
  110. Monty <monty@xiph.org>
  111. January 11, 2007