since EXT4_DIRECTORY_FILETYPE_* are duplication of EXT4_DIRENTRY_*, the former is...
[lwext4.git] / lwext4 / ext4.h
index 26ac023ce0bc4a4ac00d1dbd3ea18d9de8dfd6d4..fb653789c828112c83259feb5471c4c10e206341 100644 (file)
-/*\r
- * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * - Redistributions of source code must retain the above copyright\r
- *   notice, this list of conditions and the following disclaimer.\r
- * - Redistributions in binary form must reproduce the above copyright\r
- *   notice, this list of conditions and the following disclaimer in the\r
- *   documentation and/or other materials provided with the distribution.\r
- * - The name of the author may not be used to endorse or promote products\r
- *   derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-/** @addtogroup lwext4\r
- * @{\r
- */\r
-/**\r
- * @file  ext4.h\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
-#define EXT4_H_\r
-\r
-#include <ext4_config.h>\r
-#include <ext4_blockdev.h>\r
-#include <stdint.h>\r
-\r
-/********************************FILE OPEN FLAGS*****************************/\r
-\r
-#ifndef O_RDONLY\r
-#define O_RDONLY    00\r
-#endif\r
-\r
-#ifndef O_WRONLY\r
-#define O_WRONLY    01\r
-#endif\r
-\r
-#ifndef O_RDWR\r
-#define O_RDWR      02\r
-#endif\r
-\r
-#ifndef O_CREAT\r
-#define O_CREAT     0100\r
-#endif\r
-\r
-#ifndef O_EXCL\r
-#define O_EXCL      0200\r
-#endif\r
-\r
-#ifndef O_TRUNC\r
-#define O_TRUNC     01000\r
-#endif\r
-\r
-#ifndef O_APPEND\r
-#define O_APPEND    02000\r
-#endif\r
-\r
-/********************************FILE SEEK FLAGS*****************************/\r
-\r
-#ifndef SEEK_SET\r
-#define SEEK_SET    0\r
-#endif\r
-\r
-#ifndef SEEK_CUR\r
-#define SEEK_CUR    1\r
-#endif\r
-\r
-#ifndef SEEK_END\r
-#define SEEK_END    2\r
-#endif\r
-\r
-/********************************OS LOCK INFERFACE***************************/\r
-\r
-/**@brief   OS dependent lock interface.*/\r
-struct ext4_lock {\r
-\r
-    /**@brief   Lock access to mount point*/\r
-    void (*lock)(void);\r
-\r
-    /**@brief   Unlock access to mount point*/\r
-    void (*unlock)(void);\r
-};\r
-\r
-\r
-/********************************FILE DESCRIPTOR*****************************/\r
-\r
-/**@brief   File descriptor*/\r
-typedef struct ext4_file {\r
-\r
-    /**@brief   Mount point handle.*/\r
-    struct ext4_mountpoint *mp;\r
-\r
-    /**@brief   File inode id*/\r
-    uint32_t inode;\r
-\r
-    /**@brief   Open flags.*/\r
-    uint32_t flags;\r
-\r
-    /**@brief   File size.*/\r
-    uint64_t fsize;\r
-\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
-\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
-}ext4_direntry;\r
-\r
-typedef struct  {\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
-\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
- *          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
- * @param   standard error code*/\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 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
- *\r
- * @return standard error code */\r
-int ext4_mount(const char * dev_name,  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
-\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
-\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
-};\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
-\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
- * @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 mount point)\r
- *          /my_partition/my_file\r
- * @param   flags open file flags\r
- *  |---------------------------------------------------------------|\r
- *  |   r or rb                 O_RDONLY                            |\r
- *  |---------------------------------------------------------------|\r
- *  |   w or wb                 O_WRONLY|O_CREAT|O_TRUNC            |\r
- *  |---------------------------------------------------------------|\r
- *  |   a or ab                 O_WRONLY|O_CREAT|O_APPEND           |\r
- *  |---------------------------------------------------------------|\r
- *  |   r+ or rb+ or r+b        O_RDWR                              |\r
- *  |---------------------------------------------------------------|\r
- *  |   w+ or wb+ or w+b        O_RDWR|O_CREAT|O_TRUNC              |\r
- *  |---------------------------------------------------------------|\r
- *  |   a+ or ab+ or a+b        O_RDWR|O_CREAT|O_APPEND             |\r
- *  |---------------------------------------------------------------|\r
- *\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
- * @param   f file handle\r
- * @return  standard error code*/\r
-int ext4_fclose(ext4_file *f);\r
-\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 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
-/**@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   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   Get file position.\r
- * @param   f file handle\r
- * @return  actual file position */\r
-uint64_t ext4_ftell (ext4_file *f);\r
-\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
-\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   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   Directory close.\r
- * @param   d directory handle\r
- * @return  standard error code*/\r
-int ext4_dir_close(ext4_dir *d);\r
-\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
-/**\r
- * @}\r
- */\r
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup lwext4
+ * @{
+ */
+/**
+ * @file  ext4.h
+ * @brief Ext4 high level operations (files, directories, mount points...).
+ *        Client has to include only this file.
+ */
+
+#ifndef EXT4_H_
+#define EXT4_H_
+
+#include "ext4_config.h"
+#include "ext4_types.h"
+#include "ext4_blockdev.h"
+
+#include <stdint.h>
+#include <stddef.h>
+
+/********************************FILE OPEN FLAGS*****************************/
+
+#ifndef O_RDONLY
+#define O_RDONLY 00
+#endif
+
+#ifndef O_WRONLY
+#define O_WRONLY 01
+#endif
+
+#ifndef O_RDWR
+#define O_RDWR 02
+#endif
+
+#ifndef O_CREAT
+#define O_CREAT 0100
+#endif
+
+#ifndef O_EXCL
+#define O_EXCL 0200
+#endif
+
+#ifndef O_TRUNC
+#define O_TRUNC 01000
+#endif
+
+#ifndef O_APPEND
+#define O_APPEND 02000
+#endif
+
+/********************************FILE SEEK FLAGS*****************************/
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END 2
+#endif
+
+/********************************OS LOCK INFERFACE***************************/
+
+/**@brief   OS dependent lock interface.*/
+struct ext4_lock {
+
+       /**@brief   Lock access to mount point*/
+       void (*lock)(void);
+
+       /**@brief   Unlock access to mount point*/
+       void (*unlock)(void);
+};
+
+/********************************FILE DESCRIPTOR*****************************/
+
+/**@brief   File descriptor*/
+typedef struct ext4_file {
+
+       /**@brief   Mount point handle.*/
+       struct ext4_mountpoint *mp;
+
+       /**@brief   File inode id*/
+       uint32_t inode;
+
+       /**@brief   Open flags.*/
+       uint32_t flags;
+
+       /**@brief   File size.*/
+       uint64_t fsize;
+
+       /**@brief   File position*/
+       uint64_t fpos;
+} ext4_file;
+
+/*****************************DIRECTORY DESCRIPTOR***************************/
+
+/**@brief   Directory entry descriptor. Copy from ext4_types.h*/
+typedef struct {
+       uint32_t inode;
+       uint16_t entry_length;
+       uint8_t name_length;
+       uint8_t inode_type;
+       uint8_t name[255];
+} ext4_direntry;
+
+typedef struct {
+       /**@brief   File descriptor*/
+       ext4_file f;
+       /**@brief   Current directory entry.*/
+       ext4_direntry de;
+       /**@brief   Next entry offset*/
+       uint64_t next_off;
+} ext4_dir;
+
+/********************************MOUNT OPERATIONS****************************/
+
+/**@brief   Register a block device to a name.
+ *          @warning Block device has to be filled by
+ *          @ref EXT4_BLOCKDEV_STATIC_INSTANCE. Block cache may be created
+ *          @ref EXT4_BCACHE_STATIC_INSTANCE.
+ *          Block cache may by created automatically when bc parameter is 0.
+ * @param   bd block device
+ * @param   bd block device cache (0 = automatic cache mode)
+ * @param   dev_name register name
+ * @param   standard error code*/
+int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,
+                        const char *dev_name);
+
+/**@brief   Mount a block device with EXT4 partition to the mount point.
+ * @param   dev_name block device name (@ref ext4_device_register)
+ * @param   mount_point mount point, for example
+ *          -   /
+ *          -   /my_partition/
+ *          -   /my_second_partition/
+ *
+ * @return standard error code */
+int ext4_mount(const char *dev_name, const char *mount_point);
+
+/**@brief   Umount operation.
+ * @param   mount_point mount name
+ * @return  standard error code */
+int ext4_umount(const char *mount_point);
+
+/**@brief   Some of the filesystem stats.*/
+struct ext4_mount_stats {
+       uint32_t inodes_count;
+       uint32_t free_inodes_count;
+       uint64_t blocks_count;
+       uint64_t free_blocks_count;
+
+       uint32_t block_size;
+       uint32_t block_group_count;
+       uint32_t blocks_per_group;
+       uint32_t inodes_per_group;
+
+       char volume_name[16];
+};
+
+/**@brief   Get file system params.
+ * @param   mount_point mount path
+ * @param   stats ext fs stats
+ * @return  standard error code */
+int ext4_mount_point_stats(const char *mount_point,
+                          struct ext4_mount_stats *stats);
+
+/**@brief   Setup OS lock routines.
+ * @param   mount_point mount path
+ * @param   locks - lock and unlock functions
+ * @return  standard error code */
+int ext4_mount_setup_locks(const char *mount_point,
+                          const struct ext4_lock *locks);
+
+/**@brief   Acquire the filesystem superblock pointer of a mp.
+ * @param   mount_point mount path
+ * @param   superblock pointer
+ * @return  standard error code */
+int ext4_get_sblock(const char *mount_point, struct ext4_sblock **sb);
+
+/**@brief   Enable/disable write back cache mode.
+ * @warning Default model of cache is write trough. It means that when You do:
+ *
+ *          ext4_fopen(...);
+ *          ext4_fwrie(...);
+ *                           < --- data is flushed to physical drive
+ *
+ *          When you do:
+ *          ext4_cache_write_back(..., 1);
+ *          ext4_fopen(...);
+ *          ext4_fwrie(...);
+ *                           < --- data is NOT flushed to physical drive
+ *          ext4_cache_write_back(..., 0);
+ *                           < --- when write back mode is disabled all
+ *                                 cache data will be flushed
+ * To enable write back mode permanently just call this function
+ * once after ext4_mount (and disable before ext4_umount).
+ *
+ * Some of the function use write back cache mode internally.
+ * If you enable write back mode twice you have to disable it twice
+ * to flush all data:
+ *
+ *      ext4_cache_write_back(..., 1);
+ *      ext4_cache_write_back(..., 1);
+ *
+ *      ext4_cache_write_back(..., 0);
+ *      ext4_cache_write_back(..., 0);
+ *
+ * Write back mode is useful when you want to create a lot of empty
+ * files/directories.
+ *
+ * @param   path mount point path
+ * @param   on enable/disable
+ *
+ * @return  standard error code */
+int ext4_cache_write_back(const char *path, bool on);
+
+/********************************FILE OPERATIONS*****************************/
+
+/**@brief   Remove file by path.
+ * @param   path path to file
+ * @return  standard error code */
+int ext4_fremove(const char *path);
+
+/**@brief   create a hardlink for a file.
+ * @param   path path to file
+ * @param   hardlink_path path of hardlink
+ * @return  standard error code */
+int ext4_flink(const char *path, const char *hardlink_path);
+
+/**@brief Rename file
+ * @param path source
+ * @param new_path destination
+ * @return  standard error code */
+int ext4_frename(const char *path, const char *new_path);
+
+/**@brief   File open function.
+ * @param   filename, (has to start from mount point)
+ *          /my_partition/my_file
+ * @param   flags open file flags
+ *  |---------------------------------------------------------------|
+ *  |   r or rb                 O_RDONLY                            |
+ *  |---------------------------------------------------------------|
+ *  |   w or wb                 O_WRONLY|O_CREAT|O_TRUNC            |
+ *  |---------------------------------------------------------------|
+ *  |   a or ab                 O_WRONLY|O_CREAT|O_APPEND           |
+ *  |---------------------------------------------------------------|
+ *  |   r+ or rb+ or r+b        O_RDWR                              |
+ *  |---------------------------------------------------------------|
+ *  |   w+ or wb+ or w+b        O_RDWR|O_CREAT|O_TRUNC              |
+ *  |---------------------------------------------------------------|
+ *  |   a+ or ab+ or a+b        O_RDWR|O_CREAT|O_APPEND             |
+ *  |---------------------------------------------------------------|
+ *
+ * @return  standard error code*/
+int ext4_fopen(ext4_file *f, const char *path, const char *flags);
+
+/**@brief   Alternate file open function.
+ * @param   filename, (has to start from mount point)
+ *          /my_partition/my_file
+ * @param   flags open file flags
+ * @return  standard error code*/
+int ext4_fopen2(ext4_file *f, const char *path, int flags);
+
+/**@brief   File close function.
+ * @param   f file handle
+ * @return  standard error code*/
+int ext4_fclose(ext4_file *f);
+
+/**@brief   Fill in the ext4_inode buffer.
+ * @param   path fetch inode data of the path
+ * @param   ret_ino the inode id of the path
+ * @param   ext4_inode buffer
+ * @return  standard error code*/
+int ext4_fill_raw_inode(const char *path,
+                       uint32_t *ret_ino,
+                       struct ext4_inode *inode);
+
+/**@brief   File truncate function.
+ * @param   f file handle
+ * @param   new file size
+ * @return  standard error code*/
+int ext4_ftruncate(ext4_file *f, uint64_t size);
+
+/**@brief   Read data from file.
+ * @param   f file handle
+ * @param   buf output buffer
+ * @param   size bytes to read
+ * @param   rcnt bytes read (may be NULL)
+ * @return  standard error code*/
+int ext4_fread(ext4_file *f, void *buf, size_t size, size_t *rcnt);
+
+/**@brief   Write data to file.
+ * @param   f file handle
+ * @param   buf data to write
+ * @param   size write length
+ * @param   wcnt bytes written (may be NULL)
+ * @return  standard error code*/
+int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt);
+
+/**@brief   File seek operation.
+ * @param   f file handle
+ * @param   offset offset to seek
+ * @param   origin seek type:
+ *              @ref SEEK_SET
+ *              @ref SEEK_CUR
+ *              @ref SEEK_END
+ * @return  standard error code*/
+int ext4_fseek(ext4_file *f, uint64_t offset, uint32_t origin);
+
+/**@brief   Get file position.
+ * @param   f file handle
+ * @return  actual file position */
+uint64_t ext4_ftell(ext4_file *f);
+
+/**@brief   Get file size.
+ * @param   f file handle
+ * @return  file size */
+uint64_t ext4_fsize(ext4_file *f);
+
+int ext4_chmod(const char *path, uint32_t mode);
+int ext4_chown(const char *path, uint32_t uid, uint32_t gid);
+int ext4_file_set_atime(const char *path, uint32_t atime);
+int ext4_file_set_mtime(const char *path, uint32_t mtime);
+int ext4_file_set_ctime(const char *path, uint32_t ctime);
+
+int ext4_fsymlink(const char *target, const char *path);
+
+int ext4_readlink(const char *path, char *buf, size_t bufsize, size_t *rcnt);
+
+/*********************************DIRECTORY OPERATION***********************/
+
+/**@brief   Recursive directory remove.
+ * @param   path directory path to remove
+ * @return  standard error code*/
+int ext4_dir_rm(const char *path);
+
+/**@brief   Create new directory.
+ * @param   name new directory name
+ * @return  standard error code*/
+int ext4_dir_mk(const char *path);
+
+/**@brief   Directory open.
+ * @param   d directory handle
+ * @param   path directory path
+ * @return  standard error code*/
+int ext4_dir_open(ext4_dir *d, const char *path);
+
+/**@brief   Directory close.
+ * @param   d directory handle
+ * @return  standard error code*/
+int ext4_dir_close(ext4_dir *d);
+
+/**@brief   Return next directory entry.
+ * @param   d directory handle
+ * @param   id entry id
+ * @return  directory entry id (NULL if no entry)*/
+const ext4_direntry *ext4_dir_entry_next(ext4_dir *d);
+
+#endif /* EXT4_H_ */
+
+/**
+ * @}
+ */