file paths: add PX4_STORAGEDIR & use it where appropriate

This commit is contained in:
Beat Küng
2018-08-04 12:54:09 +02:00
committed by Lorenz Meier
parent 57a85fbc61
commit c0cac0594e
17 changed files with 33 additions and 50 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ static inline unsigned int time_fsync(int fd);
__EXPORT int sd_bench_main(int argc, char *argv[]);
static const char *BENCHMARK_FILE = PX4_ROOTFSDIR"/fs/microsd/benchmark.tmp";
static const char *BENCHMARK_FILE = PX4_STORAGEDIR"/benchmark.tmp";
static int num_runs; ///< number of runs
static int run_duration; ///< duration of a single run [ms]
+9 -9
View File
@@ -98,7 +98,7 @@ test_file(int argc, char *argv[])
/* check if microSD card is mounted */
struct stat buffer;
if (stat(PX4_ROOTFSDIR "/fs/microsd/", &buffer)) {
if (stat(PX4_STORAGEDIR "/", &buffer)) {
warnx("no microSD card mounted, aborting file test");
return 1;
}
@@ -126,7 +126,7 @@ test_file(int argc, char *argv[])
uint8_t read_buf[chunk_sizes[c] + alignments] __attribute__((aligned(64)));
hrt_abstime start, end;
int fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
int fd = px4_open(PX4_STORAGEDIR "/testfile", O_TRUNC | O_WRONLY | O_CREAT);
warnx("testing unaligned writes - please wait..");
@@ -158,7 +158,7 @@ test_file(int argc, char *argv[])
warnx("write took %" PRIu64 " us", (end - start));
px4_close(fd);
fd = open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
fd = open(PX4_STORAGEDIR "/testfile", O_RDONLY);
/* read back data for validation */
for (unsigned i = 0; i < iterations; i++) {
@@ -196,8 +196,8 @@ test_file(int argc, char *argv[])
*/
close(fd);
int ret = unlink(PX4_ROOTFSDIR "/fs/microsd/testfile");
fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
int ret = unlink(PX4_STORAGEDIR "/testfile");
fd = px4_open(PX4_STORAGEDIR "/testfile", O_TRUNC | O_WRONLY | O_CREAT);
warnx("testing aligned writes - please wait.. (CTRL^C to abort)");
@@ -220,7 +220,7 @@ test_file(int argc, char *argv[])
warnx("reading data aligned..");
px4_close(fd);
fd = open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
fd = open(PX4_STORAGEDIR "/testfile", O_RDONLY);
bool align_read_ok = true;
@@ -257,7 +257,7 @@ test_file(int argc, char *argv[])
warnx("reading data unaligned..");
close(fd);
fd = open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
fd = open(PX4_STORAGEDIR "/testfile", O_RDONLY);
bool unalign_read_ok = true;
int unalign_read_err_count = 0;
@@ -298,7 +298,7 @@ test_file(int argc, char *argv[])
}
ret = unlink(PX4_ROOTFSDIR "/fs/microsd/testfile");
ret = unlink(PX4_STORAGEDIR "/testfile");
close(fd);
if (ret) {
@@ -311,7 +311,7 @@ test_file(int argc, char *argv[])
/* list directory */
DIR *d;
struct dirent *dir;
d = opendir(PX4_ROOTFSDIR "/fs/microsd");
d = opendir(PX4_STORAGEDIR);
if (d) {
+1 -5
View File
@@ -54,11 +54,7 @@
#define FLAG_FSYNC 1
#define FLAG_LSEEK 2
#ifdef __PX4_POSIX
#define LOG_PATH PX4_ROOTFSDIR "/log/"
#else
#define LOG_PATH PX4_ROOTFSDIR "/fs/microsd/"
#endif
#define LOG_PATH PX4_STORAGEDIR
/*
return a predictable value for any file offset to allow detection of corruption
+5 -5
View File
@@ -70,7 +70,7 @@ test_mount(int argc, char *argv[])
/* check if microSD card is mounted */
struct stat buffer;
if (stat(PX4_ROOTFSDIR "/fs/microsd/", &buffer)) {
if (stat(PX4_STORAGEDIR "/", &buffer)) {
PX4_ERR("no microSD card mounted, aborting file test");
return 1;
}
@@ -78,7 +78,7 @@ test_mount(int argc, char *argv[])
/* list directory */
DIR *d;
struct dirent *dir;
d = opendir(PX4_ROOTFSDIR "/fs/microsd");
d = opendir(PX4_STORAGEDIR);
if (d) {
@@ -202,7 +202,7 @@ test_mount(int argc, char *argv[])
uint8_t read_buf[chunk_sizes[c] + alignments] __attribute__((aligned(64)));
int fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
int fd = px4_open(PX4_STORAGEDIR "/testfile", O_TRUNC | O_WRONLY | O_CREAT);
for (unsigned i = 0; i < iterations; i++) {
@@ -239,7 +239,7 @@ test_mount(int argc, char *argv[])
usleep(200000);
px4_close(fd);
fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
fd = px4_open(PX4_STORAGEDIR "/testfile", O_RDONLY);
/* read back data for validation */
for (unsigned i = 0; i < iterations; i++) {
@@ -268,7 +268,7 @@ test_mount(int argc, char *argv[])
}
int ret = unlink(PX4_ROOTFSDIR "/fs/microsd/testfile");
int ret = unlink(PX4_STORAGEDIR "/testfile");
px4_close(fd);
if (ret) {
+1 -1
View File
@@ -312,7 +312,7 @@ bool ParameterTest::exportImportAll()
static constexpr float MAGIC_FLOAT_VAL = 0.217828f;
// backup current parameters
const char *param_file_name = PX4_ROOTFSDIR "/fs/microsd/param_backup";
const char *param_file_name = PX4_STORAGEDIR "/param_backup";
int fd = open(param_file_name, O_WRONLY | O_CREAT, PX4_O_MODE_666);
if (fd < 0) {