linux - Using mknod on Ubuntu in c program -
i trying make c program using mknod command like
#include<stdio.h> #include<fcntl.h> #include<string.h> char info[50]; main() { int fdr; int rc = mknod("testfile",'b',0); if(rc<0) { perror("error in mnod"); } fdr=open("testfile",o_rdonly); read(fdr,info,50); printf("\n received message=%s",info); printf("\n"); }
and stuff. works on red hat system, fails on ubuntu giving error invalid argument.
mknod
deprecated; should not using it. if want create fifo, use standard mkfifo
. if want create ordinary file, use creat
or open
o_creat
. yes mknod
can create device nodes, , on systems might still way it, on modern linux system rely on kernel and/or udevd
handle this.
Comments
Post a Comment