mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 06:53:34 +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
@@ -672,12 +672,7 @@ task_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Open or create the data manager file */
|
||||
g_task_fd = open(k_data_manager_device_path, O_RDWR | O_CREAT | O_BINARY
|
||||
#ifdef __PX4_LINUX
|
||||
// Open with read/write permission for user
|
||||
, S_IRUSR | S_IWUSR
|
||||
#endif
|
||||
);
|
||||
g_task_fd = open(k_data_manager_device_path, O_RDWR | O_CREAT | O_BINARY, PX4_O_MODE_666);
|
||||
|
||||
if (g_task_fd < 0) {
|
||||
warnx("Could not open data manager file %s", k_data_manager_device_path);
|
||||
|
||||
@@ -455,7 +455,8 @@ MavlinkFTP::_workOpen(PayloadHeader* payload, int oflag)
|
||||
}
|
||||
fileSize = st.st_size;
|
||||
|
||||
int fd = ::open(filename, oflag);
|
||||
// Set mode to 666 incase oflag has O_CREAT
|
||||
int fd = ::open(filename, oflag, PX4_O_MODE_666);
|
||||
if (fd < 0) {
|
||||
return kErrFailErrno;
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ int open_log_file()
|
||||
}
|
||||
}
|
||||
|
||||
int fd = open(log_file_path, O_CREAT | O_WRONLY | O_DSYNC, 0x0777);
|
||||
int fd = open(log_file_path, O_CREAT | O_WRONLY | O_DSYNC, PX4_O_MODE_666);
|
||||
|
||||
if (fd < 0) {
|
||||
mavlink_and_console_log_critical(mavlink_fd, "[sdlog2] failed opening: %s", log_file_name);
|
||||
|
||||
@@ -728,7 +728,7 @@ param_save_default(void)
|
||||
const char *filename = param_get_default_file();
|
||||
|
||||
/* write parameters to temp file */
|
||||
fd = PARAM_OPEN(filename, O_WRONLY | O_CREAT, 0x777);
|
||||
fd = PARAM_OPEN(filename, O_WRONLY | O_CREAT, PX4_O_MODE_666);
|
||||
|
||||
if (fd < 0) {
|
||||
warn("failed to open param file: %s", filename);
|
||||
|
||||
Reference in New Issue
Block a user