You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/06/01 04:09:41 UTC

[incubator-nuttx] branch master updated: Add preprocessor directive __attribute__((packed)) to cromfs_node_s

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new bfde3c007d Add preprocessor directive __attribute__((packed)) to cromfs_node_s
bfde3c007d is described below

commit bfde3c007dcfc10c7eb994db0656f4c0af75e4d0
Author: vxj9800 <va...@mavs.uta.edu>
AuthorDate: Tue May 31 07:40:55 2022 -0500

    Add preprocessor directive __attribute__((packed)) to cromfs_node_s
    
    This directive tells the compiler that cromfs_node_s might be located at a memory
    address which is not word aligned. This resolves the hardFault caused by unaligned
    memory access on armv6-m architecture which doesn't support it.
---
 fs/cromfs/cromfs.h | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/fs/cromfs/cromfs.h b/fs/cromfs/cromfs.h
index 35ecbcdebe..a50135ba74 100644
--- a/fs/cromfs/cromfs.h
+++ b/fs/cromfs/cromfs.h
@@ -71,12 +71,12 @@
 
 struct cromfs_volume_s
 {
-  uint32_t cv_magic;     /* Must be first.  Must be CROMFS_MAGIC */
-  uint16_t cv_nnodes;    /* Total number of nodes in-use */
-  uint16_t cv_nblocks;   /* Total number of data blocks in-use */
-  uint32_t cv_root;      /* Offset to the first node in the root file system */
-  uint32_t cv_fsize;     /* Size of the compressed file system image */
-  uint32_t cv_bsize;     /* Optimal block size for transfers */
+  uint32_t cv_magic;   /* Must be first.  Must be CROMFS_MAGIC */
+  uint16_t cv_nnodes;  /* Total number of nodes in-use */
+  uint16_t cv_nblocks; /* Total number of data blocks in-use */
+  uint32_t cv_root;    /* Offset to the first node in the root file system */
+  uint32_t cv_fsize;   /* Size of the compressed file system image */
+  uint32_t cv_bsize;   /* Optimal block size for transfers */
 };
 
 /* This describes one node in the CROMFS file system. It holds node meta data
@@ -102,20 +102,20 @@ struct cromfs_volume_s
  *                Return 0
  */
 
-struct cromfs_node_s
+begin_packed_struct 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) */
-  uint32_t cn_peer;      /* Offset to next node in this directory (for readdir()) */
+  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) */
+  uint32_t cn_peer; /* Offset to next node in this directory (for readdir()) */
   union
   {
-    uint32_t cn_child;   /* Offset to first node in sub-directory (directories only) */
-    uint32_t cn_link;    /* Offset to an arbitrary node (for hard link) */
-    uint32_t cn_blocks;  /* Offset to first block of compressed data (for read) */
+    uint32_t cn_child;  /* Offset to first node in sub-directory (directories only) */
+    uint32_t cn_link;   /* Offset to an arbitrary node (for hard link) */
+    uint32_t cn_blocks; /* Offset to first block of compressed data (for read) */
   } u;
-};
+} end_packed_struct;    /* Use packed access since cromfs nodes may be unaligned */
 
 #endif /* __FS_CROMFS_CROMFS_H */