Pedanitic warning check fixes. Pointer arithmetic, anonymus unions etc
[lwext4.git] / ext4.h
diff --git a/ext4.h b/ext4.h
index 11d33bd5277ef55d85367687fb7817b1f2084bc7..26ac023ce0bc4a4ac00d1dbd3ea18d9de8dfd6d4 100644 (file)
--- a/ext4.h
+++ b/ext4.h
@@ -31,8 +31,8 @@
  */\r
 /**\r
  * @file  ext4.h\r
- * @brief Ext4 high level operations (files, directories, mountpoints...).\r
- *               Client has to include only this file.\r
+ * @brief Ext4 high level operations (files, directories, mount points...).\r
+ *        Client has to include only this file.\r
  */\r
 \r
 #ifndef EXT4_H_\r
 /********************************FILE SEEK FLAGS*****************************/\r
 \r
 #ifndef SEEK_SET\r
-#define SEEK_SET       0\r
+#define SEEK_SET    0\r
 #endif\r
 \r
 #ifndef SEEK_CUR\r
-#define SEEK_CUR       1\r
+#define SEEK_CUR    1\r
 #endif\r
 \r
 #ifndef SEEK_END\r
-#define SEEK_END       2\r
+#define SEEK_END    2\r
 #endif\r
 \r
 /********************************OS LOCK INFERFACE***************************/\r
 \r
-/**@brief      OS dependent lock interface.*/\r
+/**@brief   OS dependent lock interface.*/\r
 struct ext4_lock {\r
 \r
-    /**@brief  Lock access to mountpoint*/\r
+    /**@brief   Lock access to mount point*/\r
     void (*lock)(void);\r
 \r
-    /**@brief  Unlock access to mountpoint*/\r
+    /**@brief   Unlock access to mount point*/\r
     void (*unlock)(void);\r
 };\r
 \r
 \r
 /********************************FILE DESCRIPTOR*****************************/\r
 \r
-/**@brief      File descriptor*/\r
+/**@brief   File descriptor*/\r
 typedef struct ext4_file {\r
 \r
-    /**@brief  Pountpoint handle.*/\r
+    /**@brief   Mount point handle.*/\r
     struct ext4_mountpoint *mp;\r
 \r
-    /**@brief  File inode id*/\r
+    /**@brief   File inode id*/\r
     uint32_t inode;\r
 \r
-    /**@brief  Open flags.*/\r
+    /**@brief   Open flags.*/\r
     uint32_t flags;\r
 \r
-    /**@brief  File size.*/\r
+    /**@brief   File size.*/\r
     uint64_t fsize;\r
 \r
-    /**@brief  File position*/\r
+    /**@brief   File position*/\r
     uint64_t fpos;\r
 }ext4_file;\r
 \r
 /*****************************DIRECTORY DESCRIPTOR***************************/\r
-/**@brief      Directory entry types. Copy from ext4_types.h*/\r
+/**@brief   Directory entry types. Copy from ext4_types.h*/\r
 enum  {\r
     EXT4_DIRENTRY_UNKNOWN = 0,\r
     EXT4_DIRENTRY_REG_FILE,\r
@@ -137,19 +137,16 @@ enum  {
 typedef struct {\r
     uint32_t inode;\r
     uint16_t entry_length;\r
-    uint8_t  name_length;\r
-    union {\r
-        uint8_t name_length_high;\r
-        uint8_t inode_type;\r
-    };\r
+    uint8_t name_length;\r
+    uint8_t inode_type;\r
     uint8_t name[255];\r
 }ext4_direntry;\r
 \r
 typedef struct  {\r
-    /**@brief  File descriptor*/\r
-    ext4_file          f;\r
-    /**@brief  Current direntry.*/\r
-    ext4_direntry      de;\r
+    /**@brief   File descriptor*/\r
+    ext4_file f;\r
+    /**@brief   Current directory entry.*/\r
+    ext4_direntry de;\r
 }ext4_dir;\r
 \r
 /********************************MOUNT OPERATIONS****************************/\r
@@ -158,7 +155,7 @@ typedef struct  {
  *          @warning Block device has to be filled by\r
  *          @ref EXT4_BLOCKDEV_STATIC_INSTANCE. Block cache may be created\r
  *          @ref EXT4_BCACHE_STATIC_INSTANCE.\r
- *          Block cache may by created automaticly when bc parameter is 0.\r
+ *          Block cache may by created automatically when bc parameter is 0.\r
  * @param   bd block device\r
  * @param   bd block device cache (0 = automatic cache mode)\r
  * @param   dev_name register name\r
@@ -166,9 +163,9 @@ typedef struct  {
 int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,\r
         const char *dev_name);\r
 \r
-/**@brief   Mount a block device with EXT4 partition to the mountpoint.\r
- * @param      dev_name block device name (@ref ext4_device_register)\r
- * @param      mount_point pount point, for example\r
+/**@brief   Mount a block device with EXT4 partition to the mount point.\r
+ * @param   dev_name block device name (@ref ext4_device_register)\r
+ * @param   mount_point mount point, for example\r
  *          -   /\r
  *          -   /my_partition/\r
  *          -   /my_second_partition/\r
@@ -177,7 +174,7 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,
 int ext4_mount(const char * dev_name,  char *mount_point);\r
 \r
 /**@brief   Umount operation.\r
- * @param      mount_point mount name\r
+ * @param   mount_point mount name\r
  * @return  standard error code */\r
 int ext4_umount(char *mount_point);\r
 \r
@@ -204,6 +201,44 @@ struct ext4_mount_stats {
 int ext4_mount_point_stats(const char *mount_point,\r
     struct ext4_mount_stats *stats);\r
 \r
+\r
+/**@brief   Enable/disable write back cache mode.\r
+ * @warning Default model of cache is write trough. It means that when You do:\r
+ *\r
+ *          ext4_fopen(...);\r
+ *          ext4_fwrie(...);\r
+ *                           < --- data is flushed to physical drive\r
+ *\r
+ *          When you do:\r
+ *          ext4_cache_write_back(..., 1);\r
+ *          ext4_fopen(...);\r
+ *          ext4_fwrie(...);\r
+ *                           < --- data is NOT flushed to physical drive\r
+ *          ext4_cache_write_back(..., 0);\r
+ *                           < --- when write back mode is disabled all\r
+ *                                 cache data will be flushed\r
+ * To enable write back mode permanently just call this function\r
+ * once after ext4_mount (and disable before ext4_umount).\r
+ *\r
+ * Some of the function use write back cache mode internally.\r
+ * If you enable write back mode twice you have to disable it twice\r
+ * to flush all data:\r
+ *\r
+ *      ext4_cache_write_back(..., 1);\r
+ *      ext4_cache_write_back(..., 1);\r
+ *\r
+ *      ext4_cache_write_back(..., 0);\r
+ *      ext4_cache_write_back(..., 0);\r
+ *\r
+ * Write back mode is useful when you want to create a lot of empty\r
+ * files/directories.\r
+ *\r
+ * @param   path mount point path\r
+ * @param   on enable/disable\r
+ *\r
+ * @return  standard error code */\r
+int ext4_cache_write_back(const char *path, bool on);\r
+\r
 /********************************FILE OPERATIONS*****************************/\r
 \r
 /**@brief   Remove file by path.\r
@@ -212,9 +247,9 @@ int ext4_mount_point_stats(const char *mount_point,
 int ext4_fremove(const char *path);\r
 \r
 /**@brief   File open function.\r
- * @param      filename, (has to start from mountpoint)\r
- *                     /my_partition/my_file\r
- * @param      flags open file flags\r
+ * @param   filename, (has to start from mount point)\r
+ *          /my_partition/my_file\r
+ * @param   flags open file flags\r
  *  |---------------------------------------------------------------|\r
  *  |   r or rb                 O_RDONLY                            |\r
  *  |---------------------------------------------------------------|\r
@@ -229,7 +264,7 @@ int ext4_fremove(const char *path);
  *  |   a+ or ab+ or a+b        O_RDWR|O_CREAT|O_APPEND             |\r
  *  |---------------------------------------------------------------|\r
  *\r
- * @return     standard error code*/\r
+ * @return  standard error code*/\r
 int ext4_fopen (ext4_file *f, const char *path, const char *flags);\r
 \r
 /**@brief   File close function.\r
@@ -241,7 +276,7 @@ int ext4_fclose(ext4_file *f);
  * @param   f file handle\r
  * @param   buf output buffer\r
  * @param   size bytes to read\r
- * @param   rcnt readed bytes (may be NULL)\r
+ * @param   rcnt bytes read (may be NULL)\r
  * @return  standard error code*/\r
 int ext4_fread (ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt);\r
 \r