Linux codestyle format (tabs indenation)
[lwext4.git] / lwext4 / ext4.h
index 3a69d286f9bbe939cba4019bdf62f6f5ed48a4dd..a0fae642bb5f5ceceb90be4100f125f7066d623a 100644 (file)
@@ -39,6 +39,7 @@
 #define EXT4_H_\r
 \r
 #include "ext4_config.h"\r
+#include "ext4_types.h"\r
 #include "ext4_blockdev.h"\r
 \r
 #include <stdint.h>\r
 /**@brief   OS dependent lock interface.*/\r
 struct ext4_lock {\r
 \r
-    /**@brief   Lock access to mount point*/\r
-    void (*lock)(void);\r
+       /**@brief   Lock access to mount point*/\r
+       void (*lock)(void);\r
 \r
-    /**@brief   Unlock access to mount point*/\r
-    void (*unlock)(void);\r
+       /**@brief   Unlock access to mount point*/\r
+       void (*unlock)(void);\r
 };\r
 \r
 /********************************FILE DESCRIPTOR*****************************/\r
@@ -104,51 +105,49 @@ struct ext4_lock {
 /**@brief   File descriptor*/\r
 typedef struct ext4_file {\r
 \r
-    /**@brief   Mount point handle.*/\r
-    struct ext4_mountpoint *mp;\r
+       /**@brief   Mount point handle.*/\r
+       struct ext4_mountpoint *mp;\r
 \r
-    /**@brief   File inode id*/\r
-    uint32_t inode;\r
+       /**@brief   File inode id*/\r
+       uint32_t inode;\r
 \r
-    /**@brief   Open flags.*/\r
-    uint32_t flags;\r
+       /**@brief   Open flags.*/\r
+       uint32_t flags;\r
 \r
-    /**@brief   File size.*/\r
-    uint64_t fsize;\r
+       /**@brief   File size.*/\r
+       uint64_t fsize;\r
 \r
-    /**@brief   File position*/\r
-    uint64_t fpos;\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
-enum {\r
-    EXT4_DIRENTRY_UNKNOWN = 0,\r
-    EXT4_DIRENTRY_REG_FILE,\r
-    EXT4_DIRENTRY_DIR,\r
-    EXT4_DIRENTRY_CHRDEV,\r
-    EXT4_DIRENTRY_BLKDEV,\r
-    EXT4_DIRENTRY_FIFO,\r
-    EXT4_DIRENTRY_SOCK,\r
-    EXT4_DIRENTRY_SYMLINK\r
-};\r
+enum { EXT4_DIRENTRY_UNKNOWN = 0,\r
+       EXT4_DIRENTRY_REG_FILE,\r
+       EXT4_DIRENTRY_DIR,\r
+       EXT4_DIRENTRY_CHRDEV,\r
+       EXT4_DIRENTRY_BLKDEV,\r
+       EXT4_DIRENTRY_FIFO,\r
+       EXT4_DIRENTRY_SOCK,\r
+       EXT4_DIRENTRY_SYMLINK };\r
 \r
 /**@brief   Directory entry descriptor. Copy from ext4_types.h*/\r
 typedef struct {\r
-    uint32_t inode;\r
-    uint16_t entry_length;\r
-    uint8_t name_length;\r
-    uint8_t inode_type;\r
-    uint8_t name[255];\r
+       uint32_t inode;\r
+       uint16_t entry_length;\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 directory entry.*/\r
-    ext4_direntry de;\r
-    /**@brief   Next entry offset*/\r
-    uint64_t next_off;\r
+       /**@brief   File descriptor*/\r
+       ext4_file f;\r
+       /**@brief   Current directory entry.*/\r
+       ext4_direntry de;\r
+       /**@brief   Next entry offset*/\r
+       uint64_t next_off;\r
 } ext4_dir;\r
 \r
 /********************************MOUNT OPERATIONS****************************/\r
@@ -163,7 +162,7 @@ typedef struct {
  * @param   dev_name register name\r
  * @param   standard error code*/\r
 int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,\r
-                         const char *dev_name);\r
+                        const char *dev_name);\r
 \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
@@ -173,26 +172,26 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,
  *          -   /my_second_partition/\r
  *\r
  * @return standard error code */\r
-int ext4_mount(const char *dev_name, char *mount_point);\r
+int ext4_mount(const char *dev_name, const char *mount_point);\r
 \r
 /**@brief   Umount operation.\r
  * @param   mount_point mount name\r
  * @return  standard error code */\r
-int ext4_umount(char *mount_point);\r
+int ext4_umount(const char *mount_point);\r
 \r
 /**@brief   Some of the filesystem stats.*/\r
 struct ext4_mount_stats {\r
-    uint32_t inodes_count;\r
-    uint32_t free_inodes_count;\r
-    uint64_t blocks_count;\r
-    uint64_t free_blocks_count;\r
+       uint32_t inodes_count;\r
+       uint32_t free_inodes_count;\r
+       uint64_t blocks_count;\r
+       uint64_t free_blocks_count;\r
 \r
-    uint32_t block_size;\r
-    uint32_t block_group_count;\r
-    uint32_t blocks_per_group;\r
-    uint32_t inodes_per_group;\r
+       uint32_t block_size;\r
+       uint32_t block_group_count;\r
+       uint32_t blocks_per_group;\r
+       uint32_t inodes_per_group;\r
 \r
-    char volume_name[16];\r
+       char volume_name[16];\r
 };\r
 \r
 /**@brief   Get file system params.\r
@@ -200,14 +199,20 @@ struct ext4_mount_stats {
  * @param   stats ext fs stats\r
  * @return  standard error code */\r
 int ext4_mount_point_stats(const char *mount_point,\r
-                           struct ext4_mount_stats *stats);\r
+                          struct ext4_mount_stats *stats);\r
 \r
 /**@brief   Setup OS lock routines.\r
  * @param   mount_point mount path\r
  * @param   locks - lock and unlock functions\r
  * @return  standard error code */\r
 int ext4_mount_setup_locks(const char *mount_point,\r
-                           const struct ext4_lock *locks);\r
+                          const struct ext4_lock *locks);\r
+\r
+/**@brief   Acquire the filesystem superblock pointer of a mp.\r
+ * @param   mount_point mount path\r
+ * @param   superblock pointer\r
+ * @return  standard error code */\r
+int ext4_get_sblock(const char *mount_point, struct ext4_sblock **sb);\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
@@ -253,6 +258,12 @@ int ext4_cache_write_back(const char *path, bool on);
  * @return  standard error code */\r
 int ext4_fremove(const char *path);\r
 \r
+/**@brief Rename file\r
+ * @param path source\r
+ * @param new_path destination\r
+ * @return  standard error code */\r
+int ext4_frename(const char *path, const char *new_path);\r
+\r
 /**@brief   File open function.\r
  * @param   filename, (has to start from mount point)\r
  *          /my_partition/my_file\r
@@ -274,11 +285,32 @@ int ext4_fremove(const char *path);
  * @return  standard error code*/\r
 int ext4_fopen(ext4_file *f, const char *path, const char *flags);\r
 \r
+/**@brief   Alternate file open function.\r
+ * @param   filename, (has to start from mount point)\r
+ *          /my_partition/my_file\r
+ * @param   flags open file flags\r
+ * @return  standard error code*/\r
+int ext4_fopen2(ext4_file *f, const char *path, int flags, bool file_expect);\r
+\r
 /**@brief   File close function.\r
  * @param   f file handle\r
  * @return  standard error code*/\r
 int ext4_fclose(ext4_file *f);\r
 \r
+/**@brief   Fill in the ext4_inode buffer.\r
+ * @param   mount_point\r
+ * @param   inode no.\r
+ * @param   ext4_inode buffer\r
+ * @return  standard error code*/\r
+int ext4_fill_raw_inode(const char *mount_point, uint32_t ino,\r
+                       struct ext4_inode *inode);\r
+\r
+/**@brief   File truncate function.\r
+ * @param   f file handle\r
+ * @param   new file size\r
+ * @return  standard error code*/\r
+int ext4_ftruncate(ext4_file *f, uint64_t size);\r
+\r
 /**@brief   Read data from file.\r
  * @param   f file handle\r
  * @param   buf output buffer\r
@@ -315,6 +347,12 @@ uint64_t ext4_ftell(ext4_file *f);
  * @return  file size */\r
 uint64_t ext4_fsize(ext4_file *f);\r
 \r
+int ext4_fchmod(ext4_file *f, uint32_t mode);\r
+int ext4_fchown(ext4_file *f, uint32_t uid, uint32_t gid);\r
+int ext4_file_set_atime(ext4_file *f, uint32_t atime);\r
+int ext4_file_set_mtime(ext4_file *f, uint32_t mtime);\r
+int ext4_file_set_ctime(ext4_file *f, uint32_t ctime);\r
+\r
 /*********************************DIRECTORY OPERATION***********************/\r
 \r
 /**@brief   Recursive directory remove.\r
@@ -342,7 +380,7 @@ int ext4_dir_close(ext4_dir *d);
  * @param   d directory handle\r
  * @param   id entry id\r
  * @return  directory entry id (NULL if no entry)*/\r
-ext4_direntry *ext4_dir_entry_next(ext4_dir *d);\r
+const ext4_direntry *ext4_dir_entry_next(ext4_dir *d);\r
 \r
 #endif /* EXT4_H_ */\r
 \r