Greetings!
Can anybody explain me such effect?
FreeBSD 8.2, devfs.
Simple code:
Compiling, then run:
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?
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?