Versions Compared

Key

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

Overview

...

Pseudo Root File System

NuttX includes an optional, scalable file system. This file system may be omitted altogether; NuttX does not depend on the presence of any file system.

Pseudo Root File System

Or,   As a mimimun, this may be  a simple in-memory, pseudo file system can be enabled. This simple file system can be enabled setting the CONFIG_NFILE_DESCRIPTORS option to a non-zero value (see Appendix A). This   This is an in-memory file system because it does not require any storage medium or block driver support.  Rather, file system contents are generated on-the-fly as referenced via standard file system operations (open, close, read, write, etc.). In this sense, the file system is a pseudo file system (in the same sense that the Linux /proc file system is also referred to as a pseudo file system).

Any user supplied data or logic can be accessed via the pseudo-file system. Built in support is provided for character and block , block, and MTD (Memory Technoldogy Device) drivers in the /dev pseudo file system directory.

...

NuttX does, however, support Linux-like special device node, character driver, and block driver files (as well as NuttX-specific mountpoint, named semaphore, message queue, and shared memory special files). However, these are not special files in sense that the term special files is used in a POSIX environment: In NuttX these special files may only be created in the root pseudo-file system. For the case of device nodes, see Device Nodes for further information.

In NuttX, the underlying principle is that all named resources appear as special files in the root pseudo-file system and are managed by the VFS.

...

Question: I'm wondering why I can't create a directory. If I try to create a dir.

Code Block

  mkdir /mnt

I get this,

Code Block

  nsh: mkdir: mkdir failed: 2

although if I do this it creates both directorydirectories, mnt & and sda

Code Block

  mount -t vfat /dev/mmcsd0 /mnt/sda

Answer:  This is because the top level directories are part of a pseudo-filesystem – like the Linux proc/ or sys/ file systems.
  But the NuttX pseudo-file system begins at the top level /.

What that really means is that you do must have CONFIG_DISABLE_PSEUDOFS_OPERATIONS selected.  Because you can normally create directories in the pseudo-filesystem with not problem:

Code Block
NuttShell (NSH) NuttX-9.0.0
nsh> mkdir /mnt
nsh> ls
/:
 dev/
 etc/
 mnt/
 proc/
 tmp/
nsh> ls mnt
/mnt:
nsh>

But lets assume that you do have operations on the pseudo-file system disabled.  Why doesn't it work?   There is no real media there so you cannot create a file there or create any directories there.
  The mount command is special, it knows how to create mount points in the pseudo-file system.

The pseudo-file system is just a tree structure in RAM.
  It serves two purposes:
  (1) you don't have to have a real file system to use NuttX.
It comes up out-of-the-box with usable (but limited) pseudo-file system.
  That allows a little more civilized programming environment on even very resource limited MCUs.
  And (2) this pseudo-file system is a place where all special NuttX files are retained:
  Character drivers, block drivers, and mount points.

The NuttX top-level pseudo-filesystem creates the illusion of directories and provides a consistent, seamless semantic for interacting with mounted file systems.
  If there is a file called hello.txt in your volume mounted at /mnt/sda, then:

...

This is a little different from Linux: Linux always has to boot up with a real file system – even if it is only a initrd RAM disk.
In Linux, these special files (links, drivers, pipes, etc.) reside on real media and can reside in any Linux-compatible filesystem.

Normal mkdir can only work if there is a real filesystem at the location.
  There are no real directories in the psuedo-filesystem.
  The pseudo-filesystem does support nodes that look like directories and have some of the properties of directories (like the node /mnt mentioned above).
  But this is really an illusion.I suppose that one could add

If CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not enabled,  then NuttX adds the capability to create new, empty nodes in the pseudo-filesystem using 'mkdir'
but I am not sure that this would really serve any purpose other than , completing the illusion.

Wiki Markup\[On the other hand, all directories are really an _illusion_ in a way and I suppose that in that sense these nodes the pseudo-filesystem are just as _real_ as any other directory.]

After you mount the SD card at /mnt/sda, then you can do:

Code Block
mkdir /mnt/sda/newdir

...


That should work fine and should create a directory at the relative path newdir in the mounted volume.

There are a few other special NSH commands like mount that can change the pseudo-filesystem. Like losetup,{{ mkfifo}}, mkrd, umount, etc.
In fact, these commands only work in the pseudo-filesystem.
  Try them in /mnt/sda... they won't work.

But none of the normal commands that modify files or directories will work in the pseudo-filesystem: mkdir, mv, rm, rmdir.
  These all require real media.
  They will not work in the psuedo-filesystem, but will work in /mnt/sda.

And trying to pipe to something in the pseudo-filesystem will also fail
You cannot do this, for example:

Code Block

  NuttShell (NSH) NuttX-6.20
  nsh> cat "Hello, World!" >/hello.text
  nsh: cat: open failed: 22
  nsh>

See also http://nuttx.org/Documentation/NuttxPortingGuide.html#NxFileSystemImage Removed.NxFileSystem in Porting Guide