-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
Description
Description
When using creat() with mode 0777 in a program compiled with aarch64-pc-cygwin-gcc, the created file ends up having default permissions set to 0644 instead of the expected 0777.
- Attempts to modify the file's permissions using
chmod()orfchmod()also do not succeed in changing the mode, even though these function calls return success (i.e., they do not report any error). - This issue appears to be specific to the Cygwin ARM64 environment, as the same code behaves correctly when compiled with
linux-gcc, where the file is created with the specified0777permissions andchmod()functions as expected.
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
int main() {
const char *filename = "testfile.txt";
int fd = creat(filename, 0777);
if (fd == -1) {
printf("creat failed");
return 1;
} else {
printf("File '%s' created successfully with fd = %d\n", filename, fd);
}
if (chmod(filename, 0777) == -1) {
printf("chmod failed");
return 1;
} else {
printf("File mode changed to 0777 using chmod\n");
}
struct stat st;
if (stat(filename, &st) == -1) {
printf("stat failed");
return 1;
}
printf("File '%s' access mode: %o (octal)\n", filename, st.st_mode & 0777);
return 0;
}
Output of aarch64-pc-cygwin-gcc
File 'testfile.txt' created successfully with fd = 3
File mode changed to 0777 using chmod
File 'testfile.txt' access mode: 644 (octal)
Output of linux gcc
File 'testfile.txt' created successfully with fd = 3
File mode changed to 0777 using chmod
File 'testfile.txt' access mode: 777 (octal)
Acceptance Criteria:
- The
creatfunction must successfully create a file with permission mode0777. - The file’s permissions must be changeable using
fchmodorchmod, and the updated mode should be correctly applied and reflected.