/**\r
* @file ext4.h\r
* @brief Ext4 high level operations (files, directories, mountpoints...).\r
- * Client has to include only this file.\r
+ * Client has to include only this file.\r
*/\r
\r
#ifndef EXT4_H_\r
#include <ext4_blockdev.h>\r
#include <stdint.h>\r
\r
-/********************************FILE OPEN FLAGS********************************/\r
+/********************************FILE OPEN FLAGS*****************************/\r
\r
#ifndef O_RDONLY\r
-#define O_RDONLY 00\r
+#define O_RDONLY 00\r
#endif\r
\r
#ifndef O_WRONLY\r
-#define O_WRONLY 01\r
+#define O_WRONLY 01\r
#endif\r
\r
#ifndef O_RDWR\r
-#define O_RDWR 02\r
+#define O_RDWR 02\r
#endif\r
\r
#ifndef O_CREAT\r
-#define O_CREAT 0100\r
+#define O_CREAT 0100\r
#endif\r
\r
#ifndef O_EXCL\r
-#define O_EXCL 0200\r
+#define O_EXCL 0200\r
#endif\r
\r
#ifndef O_TRUNC\r
-#define O_TRUNC 01000\r
+#define O_TRUNC 01000\r
#endif\r
\r
#ifndef O_APPEND\r
-#define O_APPEND 02000\r
+#define O_APPEND 02000\r
#endif\r
\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 mountpoint*/\r
void (*lock)(void);\r
\r
- /**@brief Unlock access to mountpoint*/\r
+ /**@brief Unlock access to mountpoint*/\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 Pountpoint 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
EXT4_DIRENTRY_SYMLINK\r
};\r
\r
-/**@brief Directory entry descriptor. Copy from ext4_types.h*/\r
+/**@brief Directory entry descriptor. Copy from ext4_types.h*/\r
typedef struct {\r
uint32_t inode;\r
uint16_t entry_length;\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 direntry.*/\r
+ ext4_direntry de;\r
}ext4_dir;\r
\r
/********************************MOUNT OPERATIONS****************************/\r
\r
-/**@brief Register a block device to a name.\r
+/**@brief Register a block device to a name.\r
* @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
* @param bd block device cache (0 = automatic cache mode)\r
* @param dev_name register name\r
* @param standard error code*/\r
-int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,\r
+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 mountpoint.\r
+ * @param dev_name block device name (@ref ext4_device_register)\r
+ * @param mount_point pount point, for example\r
* - /\r
* - /my_partition/\r
* - /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, char *mount_point);\r
\r
-/**@brief Umount operation.\r
- * @param mount_point mount name\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(char *mount_point);\r
\r
\r
-/**@brief Some of the filesystem params.*/\r
+/**@brief Some of the filesystem stats.*/\r
struct ext4_mount_stats {\r
uint32_t inodes_count;\r
uint32_t free_inodes_count;\r
char volume_name[16];\r
};\r
\r
+/**@brief Get file system params.\r
+ * @param mount_point mount path\r
+ * @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
\r
/********************************FILE OPERATIONS*****************************/\r
\r
-/**@brief */\r
+/**@brief Remove file by path.\r
+ * @param path path to file\r
+ * @return standard error code */\r
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
+/**@brief File open function.\r
+ * @param filename, (has to start from mountpoint)\r
+ * /my_partition/my_file\r
+ * @param flags open file flags\r
* |---------------------------------------------------------------|\r
* | r or rb O_RDONLY |\r
* |---------------------------------------------------------------|\r
* | 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 */\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 */\r
+/**@brief Read data from file.\r
+ * @param f file handle\r
+ * @param buf output buffer\r
+ * @param size bytes to read\r
+ * @param rcnt readed bytes (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
-/**@brief */\r
+/**@brief Write data to file.\r
+ * @param f file handle\r
+ * @param buf data to write\r
+ * @param size write length\r
+ * @param wcnt bytes written (may be NULL)\r
+ * @return standard error code*/\r
int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt);\r
\r
-/**@brief */\r
+/**@brief File seek operation.\r
+ * @param f file handle\r
+ * @param offset offset to seek\r
+ * @param origin seek type:\r
+ * @ref SEEK_SET\r
+ * @ref SEEK_CUR\r
+ * @ref SEEK_END\r
+ * @return standard error code*/\r
int ext4_fseek (ext4_file *f, uint64_t offset, uint32_t origin);\r
\r
-/**@brief */\r
+/**@brief Get file position.\r
+ * @param f file handle\r
+ * @return actual file position */\r
uint64_t ext4_ftell (ext4_file *f);\r
\r
-/**@brief */\r
+/**@brief Get file size.\r
+ * @param f file handle\r
+ * @return file size */\r
uint64_t ext4_fsize (ext4_file *f);\r
\r
/*********************************DIRECTORY OPERATION***********************/\r
-/**@brief */\r
-int ext4_mkdir(const char *path);\r
\r
-/**@brief */\r
-int ext4_rmdir(const char *path);\r
+/**@brief Recursive directory remove.\r
+ * @param path directory path to remove\r
+ * @return standard error code*/\r
+int ext4_dir_rm(const char *path);\r
\r
-/**@brief */\r
+/**@brief Create new directory.\r
+ * @param name new directory name\r
+ * @return standard error code*/\r
+int ext4_dir_mk(const char *path);\r
+\r
+/**@brief Directory open.\r
+ * @param d directory handle\r
+ * @param path directory path\r
+ * @return standard error code*/\r
int ext4_dir_open (ext4_dir *d, const char *path);\r
\r
-/**@brief */\r
+/**@brief Directory close.\r
+ * @param d directory handle\r
+ * @return standard error code*/\r
int ext4_dir_close(ext4_dir *d);\r
\r
-/**@brief */\r
-ext4_direntry* ext4_entry_get(ext4_dir *d, uint32_t id);\r
+\r
+/**@brief Return directory entry by id.\r
+ * @param d directory handle\r
+ * @param id entry id\r
+ * @return directory entry id (NULL id no entry)*/\r
+ext4_direntry* ext4_dir_entry_get(ext4_dir *d, uint32_t id);\r
\r
#endif /* EXT4_H_ */\r
\r