I am trying to access /proc/net/dev file with -r--r--r-- 1 root root 0 privileges using popen. The code is as fairly as:
main(){
FILE *f;
f=popen("/proc/net/dev","r");
pclose(f);}
logged in as a root,after compiling & running the program, I get this:
sh: /proc/net/dev: Permission denied.
Can you please help me through this problem?
thank you
popen()is for opening a pipe to another process, the path provided must be to an executable file, not a device entry. You probably wantopen()orfopen()instead.