mknod vs devfs: why mknod-ed device not opened?

Greetings!

Can anybody explain me such effect?

FreeBSD 8.2, devfs.

Simple code:

Code:
/*
    test.c -- very simple, tries to open() file, shows 
    file descriptor and error if occured during open
*/

#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
#include <fcntl.h>

int
main(int argc, char *argv[]) {

	int fd, en;

	if(argc != 2) {
		printf("usage: %s <file>\n", argv[0]);
		return 255;
	}

	fd = open(argv[1], O_RDWR);
	en = errno;
	printf("open('%s') = %d\n", argv[1], fd);
	if(fd < 0) {
		printf("errno=%d ('%s')\n", en, strerror(en));
		return 1;
	} else {
		close(fd);
	}
	return 0;
}

Compiling, then run:

Code:
[root@vbox ~]# cc -o test test.c 
[root@vbox ~]# ./test /dev/null
open('/dev/null') = 3
[root@vbox ~]# ls -l /dev/null
crw-rw-rw-  1 root  wheel    0,   6 May  4 23:33 /dev/null
[root@vbox ~]# mknod null1 c 0 6
[root@vbox ~]# chmod 0666 null1 
[root@vbox ~]# ls -l null1 
crw-rw-rw-  1 root  wheel  -   0,   6 May  4 23:41 null1
[root@vbox ~]# ./test null1
open('null1') = -1
errno=45 ('Operation not supported')
[root@vbox ~]# mount     
/dev/ad0s1a on / (ufs, local)
...

So, that is a question: why is a mknod-ed device not opened while a similar one on devfs with the same type, major and minor opens?
 
From mknod(8):
Code:
  ... As of FreeBSD 5.0, device nodes are managed by the device file
  system devfs(5), making the mknod utility superfluous. As of FreeBSD 6.0
  device nodes may be created in regular file systems but such nodes cannot
  be used to access devices.
Hence there's once option nodev for mount(), which no longer valid now.
 
aa said:
From mknod(8):
Code:
  ... As of FreeBSD 5.0, device nodes are managed by the device file
  system devfs(5), making the mknod utility superfluous. As of FreeBSD 6.0
  device nodes may be created in regular file systems but such nodes cannot
  be used to access devices.
Hence there's once option nodev for mount(), which no longer valid now.

Yes, I'd found it too, after a message was posted. Unfortunately, there is no "edit message" option. Anyway -- thanks.
 
Back
Top