|
@@ -11,14 +11,6 @@
|
|
|
|
|
|
#include <stdint.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
-#if BUILD_TARGET == MEMORY
|
|
|
|
-#include <miniffs/platform/memory.h>
|
|
|
|
-#elif BUILD_TARGET == FILE
|
|
|
|
-#include <miniffs/platform/file.h>
|
|
|
|
-#else
|
|
|
|
-#error Unknown build target
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* The pack(1) may not be needed, but better be safe than sorry to
|
|
* The pack(1) may not be needed, but better be safe than sorry to
|
|
* have a consistent binary representation across architectures
|
|
* have a consistent binary representation across architectures
|
|
@@ -38,21 +30,29 @@ typedef struct miniffs_header_t
|
|
uint32_t entry_count;
|
|
uint32_t entry_count;
|
|
fileentry_t fent[];
|
|
fileentry_t fent[];
|
|
} miniffs_header_t;
|
|
} miniffs_header_t;
|
|
-
|
|
|
|
#pragma pack()
|
|
#pragma pack()
|
|
|
|
|
|
-typedef struct miniffs_t miniffs_t;
|
|
|
|
|
|
+#if BUILD_PLATFORM_MEMORY
|
|
|
|
+#include <platform/memory.h>
|
|
|
|
+#elif BUILD_PLATFORM_FILE
|
|
|
|
+#include <platform/file.h>
|
|
|
|
+#else
|
|
|
|
+#error Unknown build target.
|
|
|
|
+#endif
|
|
|
|
|
|
/* Somewhat similar structure to the plain C FILE structure */
|
|
/* Somewhat similar structure to the plain C FILE structure */
|
|
typedef struct file_t
|
|
typedef struct file_t
|
|
{
|
|
{
|
|
void *private;
|
|
void *private;
|
|
- fileentry_t fent; /***< file linked to this structure */
|
|
|
|
|
|
+ fileentry_t *fent; /***< file linked to this structure */
|
|
uint32_t offset; /***< current position in the file */
|
|
uint32_t offset; /***< current position in the file */
|
|
} file_t;
|
|
} file_t;
|
|
|
|
|
|
-#define MAKE4(_a, _b, _c, _d) ((_a & 0xFF) << 21) | ((_b & 0xFF) << 16) | ((_c & 0xFF) << 8) | (_d & 0xFF)
|
|
|
|
-
|
|
|
|
|
|
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
|
|
+#define MAKE4(_a, _b, _c, _d) (((_a) & 0xFF) << 24) | (((_b) & 0xFF) << 16) | (((_c) & 0xFF) << 8) | ((_d) & 0xFF)
|
|
|
|
+#else
|
|
|
|
+#define MAKE4(_d, _c, _b, _a) (((_a) & 0xFF) << 24) | (((_b) & 0xFF) << 16) | (((_c) & 0xFF) << 8) | ((_d) & 0xFF)
|
|
|
|
+#endif
|
|
#define MINIFFS_MAGIC MAKE4('M', 'F', 'F', 'S')
|
|
#define MINIFFS_MAGIC MAKE4('M', 'F', 'F', 'S')
|
|
|
|
|
|
enum {
|
|
enum {
|
|
@@ -65,8 +65,8 @@ enum {
|
|
* Public functions used reading the filesystem
|
|
* Public functions used reading the filesystem
|
|
* This implementation is system dependant as it relly on how the memory is architectured and where the MiniFFS is stored.
|
|
* This implementation is system dependant as it relly on how the memory is architectured and where the MiniFFS is stored.
|
|
*/
|
|
*/
|
|
-miniffs_t *miniffs_openfs(void *address); /***< Open a MiniFFS filesystem */
|
|
|
|
|
|
|
|
|
|
+/* miniffs_openfs is backend specific and will be found in the backend header file */
|
|
file_t *miniffs_open(miniffs_t *fs, char *filename); /***< Open a file */
|
|
file_t *miniffs_open(miniffs_t *fs, char *filename); /***< Open a file */
|
|
int miniffs_close(file_t *file); /***< Close a file */
|
|
int miniffs_close(file_t *file); /***< Close a file */
|
|
void *miniffs_map(file_t *file); /***< Map a file to memory */
|
|
void *miniffs_map(file_t *file); /***< Map a file to memory */
|
|
@@ -84,7 +84,7 @@ typedef enum miniffs_error_t
|
|
|
|
|
|
miniffs_error_t miniffs_geterror(); /***< Return last error */
|
|
miniffs_error_t miniffs_geterror(); /***< Return last error */
|
|
|
|
|
|
-#ifdef BUILDING_HOST_TOOLS
|
|
|
|
|
|
+#ifdef BUILD_HOST_TOOLS
|
|
/*
|
|
/*
|
|
* Functions used for offline creation of the filesystem
|
|
* Functions used for offline creation of the filesystem
|
|
*/
|
|
*/
|
|
@@ -93,6 +93,15 @@ int miniffs_addfile(miniffs_t *fs, char *name, char *ext, char *host_path);
|
|
int miniffs_delfile(miniffs_t *fs, char *name, char *ext, char *host_path);
|
|
int miniffs_delfile(miniffs_t *fs, char *name, char *ext, char *host_path);
|
|
int miniffs_writeimage(miniffs_t *fs, char *host_path);
|
|
int miniffs_writeimage(miniffs_t *fs, char *host_path);
|
|
int miniffs_closefs(miniffs_t *fs);
|
|
int miniffs_closefs(miniffs_t *fs);
|
|
-#endif /* BUILDING_HOST_TOOLS */
|
|
|
|
|
|
+#endif /* BUILD_HOST_TOOLS */
|
|
|
|
+
|
|
|
|
+#ifdef __miniffs_internal
|
|
|
|
+/*
|
|
|
|
+ * Function that are private to the library
|
|
|
|
+ */
|
|
|
|
+int miniffs_checkfs(miniffs_t *fs);
|
|
|
|
+fileentry_t *miniffs_findfile(miniffs_t *fs, char *filename);
|
|
|
|
+
|
|
|
|
+#endif /* __miniffs_internal */
|
|
|
|
|
|
#endif /* MINIFFS_H */
|
|
#endif /* MINIFFS_H */
|