# fdescfs



## fullauto2012 (Jul 5, 2016)

I've working on getting authpf working and the man page says it requires fdescfs to be mounted to run... I'm a completely unaware of what fdescfs even does? Been looking around, but everything I found with a reference to fdescfs just assumes you know what it does and why it's required... 

Can anyone shed some light on this?


----------



## wblock@ (Jul 5, 2016)

Well, there's fdescfs(5)...


----------



## fullauto2012 (Jul 5, 2016)

"The file-descriptor file system, or *fdescfs*, provides access to the per-
     process file descriptor namespace in the global file system namespace.
     The conventional mount point is _/dev/fd_.

     The file system's contents    appear as a list of numbered files which cor-
     respond to    the open files of the process reading the directory.  The
     files _/dev/fd/0_ through _/dev/fd/#_ refer to    file descriptors which can be
     accessed through the file system.    If the file descriptor is open and the
     mode the file is being opened with    is a subset of the mode    of the exist-
     ing descriptor, the call:"

Ok... I guess what I'm asking is what is the file descriptor namespace  that is mentioned?
I read this, and that seems to be where I got hung up...


----------



## Murph (Jul 5, 2016)

File descriptors are just an integer index into a per-process array in the kernel of all of the process' open files and file-like devices.  Members of that array are data structures used by the kernel to direct the I/O between devices / files and user code.  It starts with stdin == 0, stdout == 1, stderr ==2, then the next file opened by the process will be 3, and so on.


----------



## kpa (Jul 5, 2016)

This is something I've wondering, how is fdescfs(5) any different from the devfs(8) created /dev/fd directory? As far as I can see the file descriptors provided by  devfs(8) do exactly what you'd expect them to do.


----------



## Murph (Jul 5, 2016)

kpa said:


> This is something I've wondering, how is fdescfs(5) any different from the devfs(8) created /dev/fd directory? As far as I can see the file descriptors provided by  devfs(8) do exactly what you'd expect them to do.



I believe that devfs(5) only has stdin, stdout, and stderr by default, created in 
sys/kern/kern_descrip.c:fildesc_drvinit().

fdescfs(5) dynamically populates the directory at runtime, in sys/fs/fdescfs/fdesc_vnops.c, where the implementation of lookup() and readdir() reference the current set of FDs on each call.


----------

