mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 00:33:33 +08:00
Fixed passed ot open() for O_CREAT
In nuttx the mode parameter to open is not required but in Linux, and per the POSIX spec, mode is required if the O_CREAT flag is passed. The mode flags are different for NuttX and Linux so a new set of PX4 defines was added: PX4_O_MODE_777 - read, write, execute for user, group and other PX4_O_MODE_666 - read, and write for user, group and other PX4_O_MODE_600 - read, and write for user Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Lorenz Meier
parent
c6b36073fe
commit
872a26e6da
@@ -202,7 +202,7 @@ static int
|
||||
do_save(const char *param_file_name)
|
||||
{
|
||||
/* create the file */
|
||||
int fd = open(param_file_name, O_WRONLY | O_CREAT, 0x777);
|
||||
int fd = open(param_file_name, O_WRONLY | O_CREAT, PX4_O_MODE_666);
|
||||
|
||||
if (fd < 0) {
|
||||
warn("opening '%s' failed", param_file_name);
|
||||
|
||||
@@ -73,7 +73,7 @@ static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t
|
||||
filename, (unsigned)write_chunk, (unsigned)write_size);
|
||||
|
||||
uint32_t ofs = 0;
|
||||
int fd = open(filename, O_CREAT | O_RDWR | O_TRUNC);
|
||||
int fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, PX4_O_MODE_666);
|
||||
|
||||
if (fd == -1) {
|
||||
perror(filename);
|
||||
|
||||
@@ -163,7 +163,7 @@ test_mount(int argc, char *argv[])
|
||||
} else {
|
||||
|
||||
/* this must be the first iteration, do something */
|
||||
cmd_fd = open(cmd_filename, O_TRUNC | O_WRONLY | O_CREAT);
|
||||
cmd_fd = open(cmd_filename, O_TRUNC | O_WRONLY | O_CREAT, PX4_O_MODE_666);
|
||||
|
||||
warnx("First iteration of file test\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user