fs/cromfs: Block length only needs to be uint16_t, not uint32_t. Add pading to node structure to assue that alignment is the same on all platforms. tools/gencromfs.c: Fix the target offset of the '.' hard link.
This commit is contained in:
parent
853c1234ac
commit
67e0603b5a
|
@ -249,6 +249,8 @@ configuration:
|
|||
|
||||
Or the apps/examples/elf example if you like:
|
||||
|
||||
CONFIG_ELF=y
|
||||
# CONFIG_BINFMT_DISABLE is not set
|
||||
CONFIG_EXAMPLES_ELF=y
|
||||
CONFIG_EXAMPLES_ELF_CROMFS=y
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ struct cromfs_volume_s
|
|||
struct cromfs_node_s
|
||||
{
|
||||
uint16_t cn_mode; /* File type, attributes, and access mode bits */
|
||||
uint16_t cn_pad; /* Not used */
|
||||
uint32_t cn_name; /* Offset from the beginning of the volume header to the
|
||||
* node name string. NUL-terminated. */
|
||||
uint32_t cn_size; /* Size of the uncompressed data (in bytes) */
|
||||
|
|
|
@ -71,9 +71,9 @@
|
|||
struct cromfs_file_s
|
||||
{
|
||||
FAR const struct cromfs_node_s *ff_node; /* The open file node */
|
||||
uint32_t ff_offset; /* Cached offset (zero means none) */
|
||||
uint32_t ff_ulen; /* Length of uncompressed data in cache */
|
||||
FAR uint8_t *ff_buffer; /* Decompression buffer */
|
||||
uint32_t ff_offset; /* Cached block offset (zero means none) */
|
||||
uint16_t ff_ulen; /* Length of decompressed data in cache */
|
||||
FAR uint8_t *ff_buffer; /* Cached, decompressed data */
|
||||
};
|
||||
|
||||
/* This is the form of the callback from cromfs_foreach_node(): */
|
||||
|
|
|
@ -160,6 +160,7 @@ struct cromfs_volume_s
|
|||
struct cromfs_node_s
|
||||
{
|
||||
uint16_t cn_mode; /* File type, attributes, and access mode bits */
|
||||
uint16_t cn_pad; /* Not used */
|
||||
uint32_t cn_name; /* Offset from the beginning of the volume header to the
|
||||
* node name string. NUL-terminated. */
|
||||
uint32_t cn_size; /* Size of the uncompressed data (in bytes) */
|
||||
|
@ -920,6 +921,7 @@ static void gen_dirlink(const char *name, uint32_t tgtoffs, bool dirempty)
|
|||
(unsigned long)g_offset, name);
|
||||
|
||||
node.cn_mode = TGT_UINT16(DIRLINK_MODEFLAGS);
|
||||
node.cn_pad = 0;
|
||||
|
||||
g_offset += sizeof(struct cromfs_node_s);
|
||||
node.cn_name = TGT_UINT32(g_offset);
|
||||
|
@ -954,17 +956,17 @@ static void gen_directory(const char *path, const char *name, mode_t mode,
|
|||
subtree_stream = open_tmpfile();
|
||||
g_tmpstream = subtree_stream;
|
||||
|
||||
/* Update offsets for the subdirectory */
|
||||
|
||||
g_parent_offset = g_diroffset; /* New offset for '..' */
|
||||
g_diroffset = g_offset; /* New offset for '.' */
|
||||
|
||||
/* Update the offset to account for the file node which we have not yet
|
||||
* written (we can't, we don't have enough information yet)
|
||||
*/
|
||||
|
||||
g_offset += sizeof(struct cromfs_node_s) + namlen;
|
||||
|
||||
/* Update offsets for the subdirectory */
|
||||
|
||||
g_parent_offset = g_diroffset; /* New offset for '..' */
|
||||
g_diroffset = g_offset; /* New offset for '.' */
|
||||
|
||||
/* We are going to traverse the new directory twice; the first time just
|
||||
* see if the directory is empty. The second time is the real thing.
|
||||
*/
|
||||
|
@ -1002,6 +1004,7 @@ static void gen_directory(const char *path, const char *name, mode_t mode,
|
|||
(unsigned long)save_offset, path);
|
||||
|
||||
node.cn_mode = TGT_UINT16(NUTTX_IFDIR | get_mode(mode));
|
||||
node.cn_pad = 0;
|
||||
|
||||
save_offset += sizeof(struct cromfs_node_s);
|
||||
node.cn_name = TGT_UINT32(save_offset);
|
||||
|
@ -1118,6 +1121,7 @@ static void gen_file(const char *path, const char *name, mode_t mode,
|
|||
(unsigned long)blktotal);
|
||||
|
||||
node.cn_mode = TGT_UINT16(NUTTX_IFREG | get_mode(mode));
|
||||
node.cn_pad = 0;
|
||||
|
||||
nodeoffs += sizeof(struct cromfs_node_s);
|
||||
node.cn_name = TGT_UINT32(nodeoffs);
|
||||
|
|
Loading…
Reference in New Issue