Creating a file with open() or creat() has fewer permission bits set than I asked for
问题 I am writing a program to mimic the cp utility. However, I cannot get the file permissions to work correctly. I know that they are stored in the structure stat and stored in the st_mode field with stat . My issue is that I do not get the write permission for the group or other categories, i.e. I get -rwxr-xr-x as the permissions for the file even though the source file is -rwxrwxrwx . The statement where I set the permissions is below. if ( (dest_fd = open(dest_file, O_WRONLY|O_CREAT, (stats