Experimental virtual file support

QuRT does not have a filesystem, so creating a virtual filesystem
that could be implemented as an in-memory file or a remote file
over fastRPC.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-06 22:12:45 -07:00
parent 35e6822d95
commit 6db77dc8bb
11 changed files with 206 additions and 23 deletions
+4 -3
View File
@@ -37,6 +37,7 @@
* A simple subset SAX-style BSON parser and generator.
*/
#include <px4_posix.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
@@ -59,7 +60,7 @@ read_x(bson_decoder_t decoder, void *p, size_t s)
CODER_CHECK(decoder);
if (decoder->fd > -1)
return (read(decoder->fd, p, s) == (int)s) ? 0 : -1;
return (px4_read(decoder->fd, p, s) == (int)s) ? 0 : -1;
if (decoder->buf != NULL) {
/* staged operations to avoid integer overflow for corrupt data */
@@ -301,7 +302,7 @@ write_x(bson_encoder_t encoder, const void *p, size_t s)
CODER_CHECK(encoder);
if (encoder->fd > -1)
return (write(encoder->fd, p, s) == (int)s) ? 0 : -1;
return (px4_write(encoder->fd, p, s) == (int)s) ? 0 : -1;
/* do we need to extend the buffer? */
while ((encoder->bufpos + s) > encoder->bufsize) {
@@ -408,7 +409,7 @@ bson_encoder_fini(bson_encoder_t encoder)
}
/* sync file */
fsync(encoder->fd);
px4_fsync(encoder->fd);
return 0;
}
+6 -4
View File
@@ -43,6 +43,7 @@
//#include <debug.h>
#include <px4_defines.h>
#include <px4_posix.h>
#include <string.h>
#include <stdbool.h>
#include <fcntl.h>
@@ -684,7 +685,7 @@ param_save_default(void)
const char *filename = param_get_default_file();
/* write parameters to temp file */
fd = open(filename, O_WRONLY | O_CREAT, 0x777);
fd = px4_open(filename, O_WRONLY | O_CREAT, 0x777);
if (fd < 0) {
warn("failed to open param file: %s", filename);
@@ -697,7 +698,7 @@ param_save_default(void)
warnx("failed to write parameters to file: %s", filename);
}
close(fd);
px4_close(fd);
return res;
}
@@ -708,7 +709,8 @@ param_save_default(void)
int
param_load_default(void)
{
int fd_load = open(param_get_default_file(), O_RDONLY);
warnx("param_load_default\n");
int fd_load = px4_open(param_get_default_file(), O_RDONLY);
if (fd_load < 0) {
/* no parameter file is OK, otherwise this is an error */
@@ -720,7 +722,7 @@ param_load_default(void)
}
int result = param_load(fd_load);
close(fd_load);
px4_close(fd_load);
if (result != 0) {
warn("error reading parameters from '%s'", param_get_default_file());