I am trying to change file permissions using chmod function in C program
chmod("/tmp/toBoard", S_IRWXU | S_IRWXG | S_IRWXO);
But after program run I check permissions and get only
-rwxr-xr-x 1 root root
I run this program on Linux embedded board. toBoard is a file copied inside the program from other file from /var directory, source file has all permissions(set manually from terminal). When I tried to copy it manually and set permissions it worked, but when I copy the file and try give it all permissions - it fails without errors
copy("/var/www/defaults.dat", "/tmp/toBoard");
int err;
if(err = chmod("/tmp/toBoard", S_IRWXU | S_IRWXG | S_IRWXO)){
perror("chmod");
}
struct stat buffer;
int status = stat("/tmp/toBoard", &buffer);
How can I set all permissions to green light?