DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
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.
[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.]
...
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>
|
...