/dev/null: Invalid argument

I am writing a program that uses chroot, I have created a /dev/null in my chroot (let's say it's called /my/chroot/), with the command mknod /my/chroot/dev/null c 15 0 root:wheel

But any time I try and direct output to /dev/null I get this error:
root@testZFS:~ # chroot /my/chroot/
root@testZFS:/ # echo 1 > /dev/null
/dev/null: Invalid argument.


Anyone got any ideas? Driving me mad!

P.S - please don't lecture me on using chroot and not jails, I need to use chroot in this instance trust me! :D
 
... I have created a /dev/null in my chroot (let's say it's called /my/chroot/), with the command mknod /my/chroot/dev/null c 15 0 root:wheel

Where did you get the device numbers major=15 and minor=0 from? If you had done an ls -l on the newly created device and on /dev/null, the difference would have been obvious. In FreeBSD 11.0, the correct numbers are major=0 and minor=33 (or 0x21). The following command works for me: mknod /tmp/testnull c 0 33.

Also, don't forget to check the permissions of the newly made device. It needs to be writeable. Here is a directory listing that shows workable permissions:
Code:
# ls -l /dev/null /tmp/testnull
crw-rw-rw-  1 root  wheel  0x21 Jul  2 17:26 /dev/null
crw-rw-rw-  1 root  wheel  0x21 Jul  2 17:25 /tmp/testnull
 
Where did you get the device numbers major=15 and minor=0 from? If you had done an ls -l on the newly created device and on /dev/null, the difference would have been obvious. In FreeBSD 11.0, the correct numbers are major=0 and minor=33 (or 0x21). The following command works for me: mknod /tmp/testnull c 0 33.

Also, don't forget to check the permissions of the newly made device. It needs to be writeable. Here is a directory listing that shows workable permissions:
Code:
# ls -l /dev/null /tmp/testnull
crw-rw-rw-  1 root  wheel  0x21 Jul  2 17:26 /dev/null
crw-rw-rw-  1 root  wheel  0x21 Jul  2 17:25 /tmp/testnull

I had no idea how to get the numbers so I was just copying examples from the net.

Working now - thanks!
 
Back
Top