The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/miscfs/devfs/

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

Name Size Last modified (GMT) Description
Back Parent directory 2008-12-15 12:26:16
File README 5436 bytes 1995-09-07 06:16:28
C file devfs_proto.h 1249 bytes 1996-11-23 08:32:08
C file devfs_tree.c 30438 bytes 1999-09-05 08:16:26
C file devfs_vfsops.c 7788 bytes 1999-09-05 08:16:27
C file devfs_vnops.c 46787 bytes 1999-09-05 08:16:29
C file devfsdefs.h 5192 bytes 1999-09-05 08:16:30
File reproto.sh 913 bytes 1996-04-07 01:15:03

    1 this file is: /sys/miscfs/devfs/README
    2 
    3 to enable: add
    4 options DEVFS
    5 
    6 to your config file..
    7 expect it to be highly useless for a while,
    8 as the only devices that register themselves are the floppy,
    9 the pcaudio stuff, speaker, null,mem,zero,io,kmem.
   10 
   11 it works like this:
   12 
   13 There is a tree of nodes that describe the layout of the DEVFS as seen by
   14 the drivers.. they add nodes to this tree. This is called the 'back' layer
   15 for reasons that will become obvious in a second. Think of it as a
   16 BLUEPRINT of the DEVFS tree. Each back node has associated with it 
   17 a "devnode" struct, that holds information about the device
   18 (or directory) and a pointer to the vnode if one has been associated 
   19 with that node. The back node itself can be considered to be 
   20 a directory entry, and contains the default name of the device,
   21 and a link to the directory that holds it. It is sometimes refered
   22 to in the code as the dev_name. The devnode can be considered the inode.
   23 
   24 When you mount the devfs somewhere (you can mount it multiple times in
   25 multiple places), a front layer is created that contains a tree of 'front'
   26 nodes.
   27 
   28 Think of this as a Transparency, layed over the top of the blueprint.
   29 (or possibly a photocopy).
   30 
   31 The front and back nodes are identical in type, but the back nodes
   32 are reserved for kernel use only, and are protected from the user.
   33 The back plane has a mount structure and all that stuff, but it is in
   34 fact not really mounted. (and is thus not reachable via namei).
   35 Internal kernel routines can open devices in this plane
   36 even if the external devfs has not been mounted yet :)
   37 (e.g. to find the root device)
   38 
   39 To start with there is a 1:1 relationship between the front nodes
   40 and the backing nodes, however once the front plane has been created
   41 the nodes can be moved around within that plane (or deleted).
   42 Think of this as the ability to revise a transparency...
   43 the blueprint is untouched.
   44 
   45 There is a "devnode" struct associated with each front note also.
   46 Front nodes that refer to devices, use the same "devnode" struct that is used 
   47 by their associated backing node, so that multiple front nodes that
   48 point to the same device will use the same "devnode" struct, and through
   49 that, the same vnode, ops, modification times, flags, owner and group.
   50 Front nodes representing directories and symlinks have their own
   51 "devnode" structs, and may therefore differ. (have different vnodes)
   52 i.e. if you have two devfs trees mounted, you can change the 
   53 directories in one without changing the other. 
   54 e.g. remove or rename nodes
   55 
   56 Multiple mountings are like multiple transparencies,
   57 each showing through to the original blueprint.
   58 
   59 Information that is to be shared between these mounts is stored
   60 in the 'backing' node for that object.  Once you have erased 'front'
   61 object, there is no memory of where the backing object was, and
   62 except for the possibility of searching the entire backing tree
   63 for the node with the correct major/minor/type, I don't see that
   64 it is easily recovered.. Particularly as there will eventually be
   65 (I hope) devices that go direct from the backing node to the driver
   66 without going via the cdevsw table.. they may not even have
   67 major/minor numbers.
   68 
   69 I see 'mount -u' as a possible solution to recovering a broken dev tree.
   70 (though umount+mount would do the same)
   71 
   72 Because non device nodes (directories and symlinks) have their own
   73 "devnode" structs on each layer, these may have different
   74 flags, owners, and contents on each layer.
   75 e.g. if you have a chroot tree like erf.tfs.com has, you
   76 may want different permissions or owners on the chroot mount of the DEVFS
   77 than you want in the real one. You might also want to delete some sensitive
   78 devices from the chroot tree.
   79 
   80 Directories also have backing nodes but there is nothing to stop
   81 the user from removing a front node from the directory front node.
   82 (except permissions of course).  This is because the front directory
   83 nodes keep their own records as to which front nodes are members
   84 of that directory and do not refer to their original backing node
   85 for this information.
   86 
   87 The front nodes may be moved to other directories (including
   88 directories) however this does not break the linkage between the
   89 backing nodes and the front nodes. The backing node never moves. If
   90 a driver decides to remove a device from the backing tree, the FS
   91 code follows the links to all the front nodes linked to that backing
   92 node, and deletes them, no matter where they've been moved to.
   93 (active vnodes are redirected to point to the deadfs).
   94 
   95 If a directory has been moved, and a new backing node is inserted
   96 into it's own back node, the new front node will appear in that front
   97 directory, even though it's been moved, because the directory that
   98 gets the front node is found via the links and not by name.
   99 
  100 a mount -u might be considered to be a request to 'refresh' the
  101 plane that controls to the mount being updated.. that would have the
  102 effect of 're-propogating' through any backing nodes that find they
  103 have no front nodes in that plane.
  104 
  105 
  106 NOTES FOR RELEASE 1.2
  107 1/ this is very preliminary
  108 2/ the routines have greatly simplified since release 1.1
  109 (I guess the break did me good :)
  110 3/ many features are not present yet..
  111 e.g. symlinks, a comprehensive registration interface (only a crude one)
  112 ability to unlink and mv nodes.
  113 4/ I'm pretty sure my use of vnodes is bad and it may be 'losing'
  114 them, or alternatively, corrupting things.. I need a vnode specialist
  115 to look at this.
  116 

[ source navigation ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.