Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Special Files

...

in Unix-like File Systems

In Unix-like operating systems, a special file is an interface for a device driver that appears in a file system as if it were an ordinary file. Special files are a feature built into Unix-like file systems such as EXT2.

See also Wikipedia article.

Special Files in Other File Systems

Some other file systems systems, such as NTFS, also have some more limited and incompatible notion of special files. Others, such as FAT, do not have any such concept. Unix-like environments such as Cygwin that run on these other file systems have to do things a little differently: The have to emulate special files using the resources of the file system that they operate on. This may mean creating regular files with special naming conventions or with special content that can be used to emulate the behavior of special files.

Special Files and NuttX

NuttX has done things in a very different way. There are no special files supported in any file system. Rather, special files can exist only in the NuttX pseudo file system. This was a decision that was made in the initial design to simplify things for resource limited plaforms yet still provide a mostly standard Unix-like/POSIX programming environment.

...

The only other consequence that I aware of is that NuttX cannot support the POSIX requirement for the st_dev field in the struct stat structure.

Device Files and Device Numbers

In a Unix-like system, devices are access special device files. In a Unix-like system, device files can reside in any compatible file system but, by convention, are always placed in the /dev directory. NuttX achieves programming compatibility with this convention because the top-level, root file system is the psuedo-file system and /dev is part of the pseudo-file system.

...

So the when you open a device driver in NuttX, many fewer steps are involved: The system must still open the device file, but then since the pseudo-file system is the device registry, all of the device driver information is available and open operation completes with no further actions.

Named Resources

This use of the pseudo-file system in NuttX to manage device files is consistent with a core NuttX device philosophy: The NuttX VFS and the pseudo-file system in particular, are used to manage all named OS resources. That applies not only to device files and other special files but also to such things named message queues and named semaphores (which can be found in the pseduo-file system in the /var directory.