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