#include <string.h>
#include <fcntl.h>
-/**@brief Default filename.*/
+/**@brief Default filename.*/
static const char *fname = "ext2";
-/**@brief Image block size.*/
-#define EXT4_FILEDEV_BSIZE 512
+/**@brief Image block size.*/
+#define EXT4_FILEDEV_BSIZE 512
-/**@brief Image file descriptor.*/
-static FILE *dev_file;
+/**@brief Image file descriptor.*/
+static FILE *dev_file;
#define DROP_LINUXCACHE_BUFFERS 1
/**********************BLOCKDEV INTERFACE**************************************/
static int filedev_open(struct ext4_blockdev *bdev);
static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
- uint32_t blk_cnt);
+ uint32_t blk_cnt);
static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf,
- uint64_t blk_id, uint32_t blk_cnt);
+ uint64_t blk_id, uint32_t blk_cnt);
static int filedev_close(struct ext4_blockdev *bdev);
/******************************************************************************/
EXT4_BLOCKDEV_STATIC_INSTANCE(
- _filedev,
- EXT4_FILEDEV_BSIZE,
- 0,
- filedev_open,
- filedev_bread,
- filedev_bwrite,
- filedev_close
+ _filedev,
+ EXT4_FILEDEV_BSIZE,
+ 0,
+ filedev_open,
+ filedev_bread,
+ filedev_bwrite,
+ filedev_close
);
/******************************************************************************/
/******************************************************************************/
static int filedev_open(struct ext4_blockdev *bdev)
{
- dev_file = fopen(fname, "r+b");
+ dev_file = fopen(fname, "r+b");
- if(!dev_file)
- return EIO;
+ if(!dev_file)
+ return EIO;
- /*No buffering at file.*/
- setbuf(dev_file, 0);
+ /*No buffering at file.*/
+ setbuf(dev_file, 0);
- if(fseek(dev_file, 0, SEEK_END))
- return EFAULT;
+ if(fseek(dev_file, 0, SEEK_END))
+ return EFAULT;
- _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize;
+ _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize;
- return EOK;
+ return EOK;
}
/******************************************************************************/
static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
- uint32_t blk_cnt)
+ uint32_t blk_cnt)
{
- if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
- return EIO;
+ if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
+ return EIO;
- if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))
- return EIO;
+ if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))
+ return EIO;
- return EOK;
+ return EOK;
}
static void drop_cache(void)
/******************************************************************************/
static int filedev_close(struct ext4_blockdev *bdev)
{
- fclose(dev_file);
- return EOK;
+ fclose(dev_file);
+ return EOK;
}
/******************************************************************************/
-struct ext4_bcache* ext4_filecache_get(void)
+struct ext4_bcache* ext4_filecache_get(void)
{
- return &__cache;
+ return &__cache;
}
/******************************************************************************/
-struct ext4_blockdev* ext4_filedev_get(void)
+struct ext4_blockdev* ext4_filedev_get(void)
{
- return &_filedev;
+ return &_filedev;
}
/******************************************************************************/
void ext4_filedev_filename(const char *n)
{
- fname = n;
+ fname = n;
}
/******************************************************************************/
#include <stdint.h>
#include <stdbool.h>
-/**@brief Filecache get.*/
-struct ext4_bcache* ext4_filecache_get(void);
+/**@brief Filecache get.*/
+struct ext4_bcache* ext4_filecache_get(void);
-/**@brief File blockdev get.*/
-struct ext4_blockdev* ext4_filedev_get(void);
+/**@brief File blockdev get.*/
+struct ext4_blockdev* ext4_filedev_get(void);
-void ext4_filedev_filename(const char *n);
+void ext4_filedev_filename(const char *n);
#endif /* EXT4_FILEDEV_H_ */
/**@brief Input stream name.*/\r
char input_name[128] = "ext2";\r
\r
-/**@brief Read-write size*/\r
+/**@brief Read-write size*/\r
static int rw_szie = 1024 * 1024;\r
\r
-/**@brief Read-write size*/\r
+/**@brief Read-write size*/\r
static int rw_count = 10;\r
\r
/**@brief Directory test count*/\r
/**@brief Indicates that input is windows partition.*/\r
static bool winpart = false;\r
\r
-/**@brief File write buffer*/\r
-static uint8_t *wr_buff;\r
+/**@brief File write buffer*/\r
+static uint8_t *wr_buff;\r
\r
-/**@brief File read buffer.*/\r
-static uint8_t *rd_buff;\r
+/**@brief File read buffer.*/\r
+static uint8_t *rd_buff;\r
\r
-/**@brief Block device handle.*/\r
+/**@brief Block device handle.*/\r
static struct ext4_blockdev *bd;\r
\r
-/**@brief Block cache handle.*/\r
+/**@brief Block cache handle.*/\r
static struct ext4_bcache *bc;\r
\r
static const char *usage = " \n\\r
\r
static char* entry_to_str(uint8_t type)\r
{\r
- switch(type){\r
- case EXT4_DIRENTRY_UNKNOWN:\r
- return "[UNK] ";\r
- case EXT4_DIRENTRY_REG_FILE:\r
- return "[FIL] ";\r
- case EXT4_DIRENTRY_DIR:\r
- return "[DIR] ";\r
- case EXT4_DIRENTRY_CHRDEV:\r
- return "[CHA] ";\r
- case EXT4_DIRENTRY_BLKDEV:\r
- return "[BLK] ";\r
- case EXT4_DIRENTRY_FIFO:\r
- return "[FIF] ";\r
- case EXT4_DIRENTRY_SOCK:\r
- return "[SOC] ";\r
- case EXT4_DIRENTRY_SYMLINK:\r
- return "[SYM] ";\r
- default:\r
- break;\r
- }\r
- return "[???]";\r
+ switch(type){\r
+ case EXT4_DIRENTRY_UNKNOWN:\r
+ return "[UNK] ";\r
+ case EXT4_DIRENTRY_REG_FILE:\r
+ return "[FIL] ";\r
+ case EXT4_DIRENTRY_DIR:\r
+ return "[DIR] ";\r
+ case EXT4_DIRENTRY_CHRDEV:\r
+ return "[CHA] ";\r
+ case EXT4_DIRENTRY_BLKDEV:\r
+ return "[BLK] ";\r
+ case EXT4_DIRENTRY_FIFO:\r
+ return "[FIF] ";\r
+ case EXT4_DIRENTRY_SOCK:\r
+ return "[SOC] ";\r
+ case EXT4_DIRENTRY_SYMLINK:\r
+ return "[SYM] ";\r
+ default:\r
+ break;\r
+ }\r
+ return "[???]";\r
}\r
\r
static void dir_ls(const char *path)\r
{\r
- int j = 0;\r
- char sss[255];\r
- ext4_dir d;\r
- ext4_direntry *de;\r
-\r
- printf("**********************************************\n");\r
-\r
- ext4_dir_open(&d, path);\r
- de = ext4_dir_entry_get(&d, j++);\r
- printf("ls %s\n", path);\r
-\r
- while(de){\r
- memcpy(sss, de->name, de->name_length);\r
- sss[de->name_length] = 0;\r
- printf("%s", entry_to_str(de->inode_type));\r
- printf("%s", sss);\r
- printf("\n");\r
- de = ext4_dir_entry_get(&d, j++);\r
- }\r
- printf("**********************************************\n");\r
- ext4_dir_close(&d);\r
+ int j = 0;\r
+ char sss[255];\r
+ ext4_dir d;\r
+ ext4_direntry *de;\r
+\r
+ printf("**********************************************\n");\r
+\r
+ ext4_dir_open(&d, path);\r
+ de = ext4_dir_entry_get(&d, j++);\r
+ printf("ls %s\n", path);\r
+\r
+ while(de){\r
+ memcpy(sss, de->name, de->name_length);\r
+ sss[de->name_length] = 0;\r
+ printf("%s", entry_to_str(de->inode_type));\r
+ printf("%s", sss);\r
+ printf("\n");\r
+ de = ext4_dir_entry_get(&d, j++);\r
+ }\r
+ printf("**********************************************\n");\r
+ ext4_dir_close(&d);\r
}\r
\r
static void mp_stats(void)\r
{\r
int r;\r
if(winpart){\r
- if(!open_winpartition())\r
- return false;\r
+ if(!open_winpartition())\r
+ return false;\r
}else{\r
if(!open_filedev())\r
return false;\r
int c;\r
\r
static struct option long_options[] =\r
- {\r
- {"in", required_argument, 0, 'a'},\r
- {"rws", required_argument, 0, 'b'},\r
- {"rwc", required_argument, 0, 'c'},\r
- {"cache", required_argument, 0, 'd'},\r
- {"dirs", required_argument, 0, 'e'},\r
- {"clean", no_argument, 0, 'f'},\r
- {"bstat", no_argument, 0, 'g'},\r
- {"sbstat", no_argument, 0, 'h'},\r
- {"wpart", no_argument, 0, 'i'},\r
- {0, 0, 0, 0}\r
- };\r
+ {\r
+ {"in", required_argument, 0, 'a'},\r
+ {"rws", required_argument, 0, 'b'},\r
+ {"rwc", required_argument, 0, 'c'},\r
+ {"cache", required_argument, 0, 'd'},\r
+ {"dirs", required_argument, 0, 'e'},\r
+ {"clean", no_argument, 0, 'f'},\r
+ {"bstat", no_argument, 0, 'g'},\r
+ {"sbstat", no_argument, 0, 'h'},\r
+ {"wpart", no_argument, 0, 'i'},\r
+ {0, 0, 0, 0}\r
+ };\r
\r
while(-1 != (c = getopt_long (argc, argv, "a:b:c:d:e:fghi", long_options, &option_index))) {\r
\r
switch(c){\r
- case 'a':\r
- strcpy(input_name, optarg);\r
- break;\r
- case 'b':\r
- rw_szie = atoi(optarg);\r
- break;\r
- case 'c':\r
- rw_count = atoi(optarg);\r
- break;\r
- case 'd':\r
- cache_mode = atoi(optarg);\r
- break;\r
- case 'e':\r
- dir_cnt = atoi(optarg);\r
- break;\r
- case 'f':\r
- cleanup_flag = true;\r
- break;\r
- case 'g':\r
- bstat = true;\r
- break;\r
- case 'h':\r
- sbstat = true;\r
- break;\r
- case 'i':\r
- winpart = true;\r
- break;\r
- default:\r
- printf("%s", usage);\r
- return false;\r
+ case 'a':\r
+ strcpy(input_name, optarg);\r
+ break;\r
+ case 'b':\r
+ rw_szie = atoi(optarg);\r
+ break;\r
+ case 'c':\r
+ rw_count = atoi(optarg);\r
+ break;\r
+ case 'd':\r
+ cache_mode = atoi(optarg);\r
+ break;\r
+ case 'e':\r
+ dir_cnt = atoi(optarg);\r
+ break;\r
+ case 'f':\r
+ cleanup_flag = true;\r
+ break;\r
+ case 'g':\r
+ bstat = true;\r
+ break;\r
+ case 'h':\r
+ sbstat = true;\r
+ break;\r
+ case 'i':\r
+ winpart = true;\r
+ break;\r
+ default:\r
+ printf("%s", usage);\r
+ return false;\r
\r
}\r
}\r
dir_ls("/mp/");\r
fflush(stdout);\r
if(!dir_test(dir_cnt))\r
- return EXIT_FAILURE;\r
+ return EXIT_FAILURE;\r
\r
fflush(stdout);\r
- if(!file_test())\r
- return EXIT_FAILURE;\r
+ if(!file_test())\r
+ return EXIT_FAILURE;\r
\r
- fflush(stdout);\r
- dir_ls("/mp/");\r
+ fflush(stdout);\r
+ dir_ls("/mp/");\r
\r
- if(sbstat)\r
- mp_stats();\r
+ if(sbstat)\r
+ mp_stats();\r
\r
- if(cleanup_flag)\r
- cleanup();\r
+ if(cleanup_flag)\r
+ cleanup();\r
\r
if(bstat)\r
block_stats();\r
/**\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
/********************************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;\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
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
+ * @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
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
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 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 File close function.\r
/**@brief Mount point descrpitor.*/\r
struct ext4_mountpoint {\r
\r
- /**@brief Mount point name (@ref ext4_mount)*/\r
+ /**@brief Mount point name (@ref ext4_mount)*/\r
const char *name;\r
\r
- /**@brief Os dependent lock/unlock functions.*/\r
+ /**@brief Os dependent lock/unlock functions.*/\r
struct ext4_lock *os_locks;\r
\r
- /**@brief Ext4 filesystem internals.*/\r
+ /**@brief Ext4 filesystem internals.*/\r
struct ext4_fs fs;\r
\r
- /**@brief Dynamic alocation cache flag.*/\r
+ /**@brief Dynamic alocation cache flag.*/\r
bool cache_dynamic;\r
};\r
\r
/**@brief Block devices descriptor.*/\r
-struct _ext4_devices {\r
+struct _ext4_devices {\r
\r
/**@brief Block device name (@ref ext4_device_register)*/\r
const char *name;\r
struct ext4_bcache *bc;\r
};\r
\r
-/**@brief Block devices.*/\r
-struct _ext4_devices _bdevices[CONFIG_EXT4_BLOCKDEVS_COUNT];\r
+/**@brief Block devices.*/\r
+struct _ext4_devices _bdevices[CONFIG_EXT4_BLOCKDEVS_COUNT];\r
\r
\r
-/**@brief Mountpoints.*/\r
+/**@brief Mountpoints.*/\r
struct ext4_mountpoint _mp[CONFIG_EXT4_MOUNTPOINTS_COUNT];\r
\r
\r
for (i = 0; i < CONFIG_EXT4_BLOCKDEVS_COUNT; ++i) {\r
if(!_bdevices[i].name){\r
_bdevices[i].name = dev_name;\r
- _bdevices[i].bd = bd;\r
- _bdevices[i].bc = bc;\r
+ _bdevices[i].bd = bd;\r
+ _bdevices[i].bc = bc;\r
return EOK;\r
}\r
}\r
}\r
\r
\r
-int ext4_umount(char *mount_point)\r
+int ext4_umount(char *mount_point)\r
{\r
- int i;\r
- int r = EOK;\r
- struct ext4_mountpoint *mp = 0;\r
+ int i;\r
+ int r = EOK;\r
+ struct ext4_mountpoint *mp = 0;\r
\r
for (i = 0; i < CONFIG_EXT4_MOUNTPOINTS_COUNT; ++i) {\r
if(_mp[i].name){\r
}\r
\r
if(!strcmp(flags, "a") || !strcmp(flags, "ab")){\r
- *file_flags = O_WRONLY | O_CREAT | O_APPEND ;\r
+ *file_flags = O_WRONLY | O_CREAT | O_APPEND;\r
return true;\r
}\r
\r
{\r
struct ext4_mountpoint *mp = ext4_get_mount(path);\r
struct ext4_directory_search_result result;\r
- struct ext4_inode_ref ref;\r
- bool is_goal = false;\r
- uint8_t inode_type = EXT4_DIRECTORY_FILETYPE_DIR;\r
- int r = ENOENT;\r
+ struct ext4_inode_ref ref;\r
+ bool is_goal = false;\r
+ uint8_t inode_type = EXT4_DIRECTORY_FILETYPE_DIR;\r
+ int r = ENOENT;\r
uint32_t next_inode;\r
\r
f->mp = 0;\r
break;\r
\r
/*O_CREAT allows create new entry*/\r
- struct ext4_inode_ref child_ref;\r
+ struct ext4_inode_ref child_ref;\r
r = ext4_fs_alloc_inode(&mp->fs, &child_ref, is_goal ? !file_expect : true);\r
if(r != EOK)\r
break;\r
uint32_t fblock_start;\r
uint32_t fblock_cnt;\r
struct ext4_block b;\r
- uint8_t *u8_buf = buf;\r
+ uint8_t *u8_buf = buf;\r
struct ext4_inode_ref ref;\r
uint32_t sblock;\r
uint32_t sblock_end;\r
\r
block_size = ext4_sb_get_block_size(&f->mp->fs.sb);\r
size = size > (f->fsize - f->fpos) ? (f->fsize - f->fpos) : size;\r
- sblock = (f->fpos) / block_size;\r
+ sblock = (f->fpos) / block_size;\r
sblock_end = (f->fpos + size) / block_size;\r
u = (f->fpos) % block_size;\r
\r
return r;\r
}\r
\r
-int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt)\r
+int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt)\r
{\r
int r = EOK;\r
uint32_t u;\r
uint32_t fblock;\r
struct ext4_block b;\r
- uint8_t *u8_buf = buf;\r
+ uint8_t *u8_buf = buf;\r
struct ext4_inode_ref ref;\r
uint32_t sblock;\r
uint32_t sblock_end;\r
if(f->fsize % block_size)\r
file_blocks++;\r
\r
- sblock = (f->fpos) / block_size;\r
+ sblock = (f->fpos) / block_size;\r
\r
u = (f->fpos) % block_size;\r
\r
uint32_t ext4_balloc_get_first_data_block_in_group(struct ext4_sblock *s,
struct ext4_block_group_ref * bg_ref)
{
- uint32_t block_group_count = ext4_block_group_cnt(s);
+ uint32_t block_group_count = ext4_block_group_cnt(s);
uint32_t inode_table_first_block =
ext4_bg_get_inode_table_first_block(bg_ref->block_group, s);
- uint32_t block_size = ext4_sb_get_block_size(s);
+ uint32_t block_size = ext4_sb_get_block_size(s);
- uint16_t inode_size = ext4_get16(s, inode_size);
+ uint16_t inode_size = ext4_get16(s, inode_size);
uint32_t inodes_per_group = ext4_get32(s, inodes_per_group);
uint32_t inode_table_bytes;
inode_table_bytes = inodes_per_group * inode_size;
} else {
/* Last block group could be smaller */
- uint32_t inodes_count_total = ext4_get32(s, inodes_count);
+ uint32_t inodes_count_total = ext4_get32(s, inodes_count);
inode_table_bytes =
(inodes_count_total - ((block_group_count - 1) *
inodes_per_group)) * inode_size;
int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref, uint32_t baddr)
{
- struct ext4_fs *fs = inode_ref->fs;
- struct ext4_sblock *sb = &fs->sb;
+ struct ext4_fs *fs = inode_ref->fs;
+ struct ext4_sblock *sb = &fs->sb;
uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, baddr);
- uint32_t index_in_group = ext4_fs_baddr2_index_in_group(sb, baddr);
+ uint32_t index_in_group = ext4_fs_baddr2_index_in_group(sb, baddr);
/* Load block group reference */
struct ext4_block_group_ref bg_ref;
uint32_t bitmap_block_addr =
ext4_bg_get_block_bitmap(bg_ref.block_group, sb);
- struct ext4_block bitmap_block;
+ struct ext4_block bitmap_block;
rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr);
if (rc != EOK)
uint32_t bitmap_block_addr =
ext4_bg_get_block_bitmap(bg_ref.block_group, sb);
- struct ext4_block bitmap_block;
+ struct ext4_block bitmap_block;
rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr);
if (rc != EOK)
uint32_t bitmap_block_addr;
uint32_t rel_block_idx = 0;
- struct ext4_block bitmap_block;
+ struct ext4_block bitmap_block;
/* Find GOAL */
uint32_t goal = ext4_balloc_find_goal(inode_ref);
ext4_bg_get_block_bitmap(bg_ref.block_group, sb);
- struct ext4_block bitmap_block;
+ struct ext4_block bitmap_block;
rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr);
if (rc != EOK)
#include <stdbool.h>
-/**@brief Get first datablock in block group
- * @param s superblock descriptor
- * @param bg_ref block group reference
- * @return block id of the first datablock in block group*/
+/**@brief Get first datablock in block group
+ * @param s superblock descriptor
+ * @param bg_ref block group reference
+ * @return block id of the first datablock in block group*/
uint32_t ext4_balloc_get_first_data_block_in_group(struct ext4_sblock *s,
struct ext4_block_group_ref * bg_ref);
-/**@brief Free block from inode.
- * @param inode_ref inode reference
- * @param baddr block address
- * @return standard error code*/
+/**@brief Free block from inode.
+ * @param inode_ref inode reference
+ * @param baddr block address
+ * @return standard error code*/
int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref,
uint32_t baddr);
-/**@brief Free blocks from inode.
- * @param inode_ref inode reference
- * @param baddr block address
- * @return standard error code*/
+/**@brief Free blocks from inode.
+ * @param inode_ref inode reference
+ * @param baddr block address
+ * @return standard error code*/
int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref,
uint32_t first, uint32_t count);
-/**@brief Allocate block procedure.
- * @param inode_ref inode reference
- * @param baddr allocated block address
- * @return standard error code*/
+/**@brief Allocate block procedure.
+ * @param inode_ref inode reference
+ * @param baddr allocated block address
+ * @return standard error code*/
int ext4_balloc_alloc_block(struct ext4_inode_ref *inode_ref,
uint32_t *baddr);
-/**@brief Try allocate selected block.
- * @param inode_ref inode reference
- * @param baddr block address to allocate
- * @param free if baddr is not allocated
- * @return standard error code*/
+/**@brief Try allocate selected block.
+ * @param inode_ref inode reference
+ * @param baddr block address to allocate
+ * @param free if baddr is not allocated
+ * @return standard error code*/
int ext4_balloc_try_alloc_block(struct ext4_inode_ref *inode_ref,
uint32_t baddr, bool *free);
#include <stdlib.h>\r
\r
\r
-int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
+int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
uint32_t itemsize)\r
{\r
ext4_assert(bc && cnt && itemsize);\r
return ENOMEM;\r
}\r
\r
-int ext4_bcache_fini_dynamic(struct ext4_bcache *bc)\r
+int ext4_bcache_fini_dynamic(struct ext4_bcache *bc)\r
{\r
if(bc->refctr)\r
free(bc->refctr);\r
\r
if(cache_id != bc->cnt){\r
/*There was unreferenced block*/\r
- bc->lba[cache_id] = b->lb_id;\r
- bc->refctr[cache_id] = 1;\r
+ bc->lba[cache_id] = b->lb_id;\r
+ bc->refctr[cache_id] = 1;\r
bc->lru_id[cache_id] = ++bc->lru_ctr;\r
\r
/*Set valid cache data and id*/\r
if(!bc->refctr[b->cache_id] && !bc->free_delay[b->cache_id])\r
bc->ref_blocks--;\r
\r
- b->lb_id = 0;\r
- b->data = 0;\r
+ b->lb_id = 0;\r
+ b->data = 0;\r
b->cache_id = 0;\r
\r
return EOK;\r
#include <stdint.h>\r
#include <stdbool.h>\r
\r
-/**@brief Single block descriptor.*/\r
-struct ext4_block {\r
- /**@brief Dirty flag.*/\r
- bool dirty;\r
+/**@brief Single block descriptor.*/\r
+struct ext4_block {\r
+ /**@brief Dirty flag.*/\r
+ bool dirty;\r
\r
- /**@brief Logical block ID*/\r
- uint64_t lb_id;\r
+ /**@brief Logical block ID*/\r
+ uint64_t lb_id;\r
\r
/**@brief Cache id*/\r
- uint32_t cache_id;\r
+ uint32_t cache_id;\r
\r
- /**@brief Data buffer.*/\r
- uint8_t *data;\r
+ /**@brief Data buffer.*/\r
+ uint8_t *data;\r
};\r
\r
\r
-/**@brief Block cache descriptor.*/\r
-struct ext4_bcache {\r
+/**@brief Block cache descriptor.*/\r
+struct ext4_bcache {\r
\r
- /**@brief Item count in block cache*/\r
- uint32_t cnt;\r
+ /**@brief Item count in block cache*/\r
+ uint32_t cnt;\r
\r
- /**@brief Item size in block cache*/\r
- uint32_t itemsize;\r
+ /**@brief Item size in block cache*/\r
+ uint32_t itemsize;\r
\r
- /**@brief Last recently used counter.*/\r
- uint32_t lru_ctr;\r
+ /**@brief Last recently used counter.*/\r
+ uint32_t lru_ctr;\r
\r
- /**@brief Reference count table (cnt).*/\r
- uint32_t *refctr;\r
+ /**@brief Reference count table (cnt).*/\r
+ uint32_t *refctr;\r
\r
- /**@brief Last recently used ID table (cnt)*/\r
- uint32_t *lru_id;\r
+ /**@brief Last recently used ID table (cnt)*/\r
+ uint32_t *lru_id;\r
\r
- /**@brief Free delay mode table (cnt)*/\r
- uint8_t *free_delay;\r
+ /**@brief Free delay mode table (cnt)*/\r
+ uint8_t *free_delay;\r
\r
- /**@brief Logical block table (cnt).*/\r
- uint64_t *lba;\r
+ /**@brief Logical block table (cnt).*/\r
+ uint64_t *lba;\r
\r
- /**@brief Cache data buffers (cnt * itemsize)*/\r
- uint8_t *data;\r
+ /**@brief Cache data buffers (cnt * itemsize)*/\r
+ uint8_t *data;\r
\r
- /**@brief Currently referenced datablocks*/\r
- uint32_t ref_blocks;\r
+ /**@brief Currently referenced datablocks*/\r
+ uint32_t ref_blocks;\r
\r
- /**@brief Maximum referenced datablocks*/\r
- uint32_t max_ref_blocks;\r
+ /**@brief Maximum referenced datablocks*/\r
+ uint32_t max_ref_blocks;\r
\r
};\r
\r
-/**@brief Static initializer of block cache structure.*/\r
+/**@brief Static initializer of block cache structure.*/\r
#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize) \\r
- static uint32_t __name##_refctr[(__cnt)]; \\r
- static uint32_t __name##_lru_id[(__cnt)]; \\r
- static uint8_t __name##_free_delay[(__cnt)]; \\r
- static uint64_t __name##_lba[(__cnt)]; \\r
- static uint8_t __name##_data[(__cnt) * (__itemsize)]; \\r
- static struct ext4_bcache __name = { \\r
- .cnt = __cnt, \\r
+ static uint32_t __name##_refctr[(__cnt)]; \\r
+ static uint32_t __name##_lru_id[(__cnt)]; \\r
+ static uint8_t __name##_free_delay[(__cnt)]; \\r
+ static uint64_t __name##_lba[(__cnt)]; \\r
+ static uint8_t __name##_data[(__cnt) * (__itemsize)]; \\r
+ static struct ext4_bcache __name = { \\r
+ .cnt = __cnt, \\r
.itemsize = __itemsize, \\r
.lru_ctr = 0, \\r
- .refctr = __name##_refctr, \\r
+ .refctr = __name##_refctr, \\r
.lru_id = __name##_lru_id, \\r
- .lba = __name##_lba, \\r
+ .lba = __name##_lba, \\r
.free_delay= __name##_free_delay, \\r
- .data = __name##_data, \\r
+ .data = __name##_data, \\r
}\r
\r
\r
-/**@brief Dynamic initialization of block cache.\r
- * @param bc block cache descriptor\r
- * @param cnt items count in block cache\r
- * @param itemsize single item size (in bytes)\r
- * @return standard error code*/\r
-int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
+/**@brief Dynamic initialization of block cache.\r
+ * @param bc block cache descriptor\r
+ * @param cnt items count in block cache\r
+ * @param itemsize single item size (in bytes)\r
+ * @return standard error code*/\r
+int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
uint32_t itemsize);\r
\r
-/**@brief Dynamic de-initialization of block cache.\r
- * @param bc block cache descriptor\r
- * @return standard error code*/\r
-int ext4_bcache_fini_dynamic(struct ext4_bcache *bc);\r
+/**@brief Dynamic de-initialization of block cache.\r
+ * @param bc block cache descriptor\r
+ * @return standard error code*/\r
+int ext4_bcache_fini_dynamic(struct ext4_bcache *bc);\r
\r
-/**@brief Allocate block from block cache memory.\r
+/**@brief Allocate block from block cache memory.\r
* Unreferenced block allocation is based on LRU\r
* (Last Recently Used) algorithm.\r
- * @param bc block cache descriptor\r
- * @param b block to alloc\r
- * @param is_new block is new (needs to be read)\r
+ * @param bc block cache descriptor\r
+ * @param b block to alloc\r
+ * @param is_new block is new (needs to be read)\r
* @return standard error code*/\r
int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,\r
bool *is_new);\r
\r
-/**@brief Free block from cache memory (decrement reference counter).\r
- * @param bc block cache descriptor\r
- * @param b block to free\r
+/**@brief Free block from cache memory (decrement reference counter).\r
+ * @param bc block cache descriptor\r
+ * @param b block to free\r
* @return standard error code*/\r
int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b,\r
uint8_t free_delay);\r
\r
\r
-/**@brief Return a full status of block cache.\r
- * @param bc block cache descriptor\r
- * @return full status*/\r
+/**@brief Return a full status of block cache.\r
+ * @param bc block cache descriptor\r
+ * @return full status*/\r
bool ext4_bcache_is_full(struct ext4_bcache *bc);\r
\r
#endif /* EXT4_BCACHE_H_ */\r
#include <stdint.h>
#include <stdbool.h>
-/**@brief Set bitmap bit.
- * @param bmap bitmap
- * @param bit bit to set*/
+/**@brief Set bitmap bit.
+ * @param bmap bitmap
+ * @param bit bit to set*/
static inline void ext4_bmap_bit_set(uint8_t *bmap, uint32_t bit)
{
*(bmap + (bit >> 3)) |= (1 << (bit & 7));
}
-/**@brief Clear bitmap bit.
- * @param bmap bitmap buffer
- * @param bit bit to clear*/
+/**@brief Clear bitmap bit.
+ * @param bmap bitmap buffer
+ * @param bit bit to clear*/
static inline void ext4_bmap_bit_clr(uint8_t *bmap, uint32_t bit)
{
*(bmap + (bit >> 3)) &= ~(1 << (bit & 7));
}
-/**@brief Check if the bitmap bit is set.
- * @param bmap bitmap buffer
- * @param bit bit to check*/
+/**@brief Check if the bitmap bit is set.
+ * @param bmap bitmap buffer
+ * @param bit bit to check*/
static inline bool ext4_bmap_is_bit_set(uint8_t *bmap, uint32_t bit)
{
return (*(bmap + (bit >> 3)) & (1 << (bit & 7)));
}
-/**@brief Check if the bitmap bit is clear.
- * @param bmap bitmap buffer
- * @param bit bit to check*/
+/**@brief Check if the bitmap bit is clear.
+ * @param bmap bitmap buffer
+ * @param bit bit to check*/
static inline bool ext4_bmap_is_bit_clr(uint8_t *bmap, uint32_t bit)
{
return !ext4_bmap_is_bit_set(bmap, bit);
}
-/**@brief Free range of bits in bitmap.
- * @param bmap bitmap buffer
- * @param sbit start bit
- * @param bcnt bit count*/
+/**@brief Free range of bits in bitmap.
+ * @param bmap bitmap buffer
+ * @param sbit start bit
+ * @param bcnt bit count*/
void ext4_bmap_bits_free(uint8_t *bmap, uint32_t sbit, uint32_t bcnt);
-/**@brief Find first clear bit in bitmap.
- * @param sbit start bit of search
- * @param ebit end bit of search
- * @param bit_id output parameter (first free bit)
- * @return standard error code*/
+/**@brief Find first clear bit in bitmap.
+ * @param sbit start bit of search
+ * @param ebit end bit of search
+ * @param bit_id output parameter (first free bit)
+ * @return standard error code*/
int ext4_bmap_bit_find_clr(uint8_t *bmap, uint32_t sbit, uint32_t ebit,
uint32_t *bit_id);
-int ext4_block_init(struct ext4_blockdev *bdev)
+int ext4_block_init(struct ext4_blockdev *bdev)
{
int rc;
ext4_assert(bdev);
bdev->flags |= EXT4_BDEV_INITIALIZED;
- return EOK;
+ return EOK;
}
int ext4_block_bind_bcache(struct ext4_blockdev *bdev, struct ext4_bcache *bc)
return EOK;
}
-void ext4_block_set_lb_size(struct ext4_blockdev *bdev, uint64_t lb_bsize)
+void ext4_block_set_lb_size(struct ext4_blockdev *bdev, uint64_t lb_bsize)
{
/*Logical block size has to be multiply of physical */
ext4_assert(!(lb_bsize % bdev->ph_bsize));
}
-int ext4_block_fini(struct ext4_blockdev *bdev)
+int ext4_block_fini(struct ext4_blockdev *bdev)
{
ext4_assert(bdev);
}
-int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b,
+int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b,
uint64_t lba)
{
uint64_t pba;
return EOK;
}
-int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b)
+int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b)
{
uint64_t pba;
uint32_t pb_cnt;
return EOK;
}
-int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf,
+int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf,
uint64_t lba, uint32_t cnt)
{
uint64_t pba;
return bdev->bread(bdev, buf, pba, pb_cnt * cnt);
}
-int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf,
+int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf,
uint64_t lba, uint32_t cnt)
{
uint64_t pba;
}
-int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off,
+int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off,
const void *buf, uint32_t len)
{
uint64_t block_idx;
uint32_t unalg;
int r = EOK;
- const uint8_t *p = (void *)buf;
+ const uint8_t *p = (void *)buf;
ext4_assert(bdev && buf);
block_end = block_idx + len / bdev->ph_bsize;
if(!(block_end < bdev->ph_bcnt))
- return EINVAL; /*Ups. Out of range operation*/
+ return EINVAL; /*Ups. Out of range operation*/
/*OK lets deal with the first possible unaligned block*/
unalg = (off & (bdev->ph_bsize - 1));
-int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf,
+int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf,
uint32_t len)
{
uint64_t block_idx;
uint32_t unalg;
int r = EOK;
- uint8_t *p = (void *)buf;
+ uint8_t *p = (void *)buf;
ext4_assert(bdev && buf);
block_end = block_idx + len / bdev->ph_bsize;
if(!(block_end < bdev->ph_bcnt))
- return EINVAL; /*Ups. Out of range operation*/
+ return EINVAL; /*Ups. Out of range operation*/
/*OK lets deal with the first possible unaligned block*/
unalg = (off & (bdev->ph_bsize - 1));
if(r != EOK)
return r;
- p += bdev->ph_bsize * blen;
+ p += bdev->ph_bsize * blen;
len -= bdev->ph_bsize * blen;
block_idx += blen;
return r;
}
-int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev,
+int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev,
uint8_t on_off)
{
int r;
#include <stdbool.h>
#include <stdint.h>
-/**@brief Initialization status flag*/
-#define EXT4_BDEV_INITIALIZED (1 << 0)
+/**@brief Initialization status flag*/
+#define EXT4_BDEV_INITIALIZED (1 << 0)
-/**@brief Definiton of the simple block device.*/
-struct ext4_blockdev {
+/**@brief Definiton of the simple block device.*/
+struct ext4_blockdev {
- /**@brief Open device function
- * @param bdev block device.*/
- int (*open)(struct ext4_blockdev *bdev);
+ /**@brief Open device function
+ * @param bdev block device.*/
+ int (*open)(struct ext4_blockdev *bdev);
- /**@brief Block read function.
- * @param bdev block device
- * @param buf output buffer
- * @param blk_id block id
- * @param blk_cnt block count*/
- int (*bread)(struct ext4_blockdev *bdev, void *buf,
+ /**@brief Block read function.
+ * @param bdev block device
+ * @param buf output buffer
+ * @param blk_id block id
+ * @param blk_cnt block count*/
+ int (*bread)(struct ext4_blockdev *bdev, void *buf,
uint64_t blk_id, uint32_t blk_cnt);
- /**@brief Block write function.
- * @param buf input buffer
- * @param blk_id block id
- * @param blk_cnt block count*/
- int (*bwrite)(struct ext4_blockdev *bdev, const void *buf,
+ /**@brief Block write function.
+ * @param buf input buffer
+ * @param blk_id block id
+ * @param blk_cnt block count*/
+ int (*bwrite)(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt);
- /**@brief Close device function.
- * @param bdev block device.*/
- int (*close)(struct ext4_blockdev *bdev);
+ /**@brief Close device function.
+ * @param bdev block device.*/
+ int (*close)(struct ext4_blockdev *bdev);
/**@brief Block cache.*/
struct ext4_bcache *bc;
- /**@brief Block size (bytes): physical*/
- uint32_t ph_bsize;
+ /**@brief Block size (bytes): physical*/
+ uint32_t ph_bsize;
- /**@brief Block count: physical.*/
- uint64_t ph_bcnt;
+ /**@brief Block count: physical.*/
+ uint64_t ph_bcnt;
- /**@brief Block size buffer: physical.*/
- uint8_t *ph_bbuf;
+ /**@brief Block size buffer: physical.*/
+ uint8_t *ph_bbuf;
- /**@brief Block size (bytes) logical*/
- uint32_t lg_bsize;
+ /**@brief Block size (bytes) logical*/
+ uint32_t lg_bsize;
- /**@brief Block count: phisical.*/
- uint64_t lg_bcnt;
+ /**@brief Block count: phisical.*/
+ uint64_t lg_bcnt;
- /**@brief Flags of te block device.*/
- uint8_t flags;
+ /**@brief Flags of te block device.*/
+ uint8_t flags;
/**@brief Cache flush delay mode flag.*/
- uint8_t cache_flush_delay;
+ uint8_t cache_flush_delay;
/**@brief Physical read counter*/
- uint32_t bread_ctr;
+ uint32_t bread_ctr;
/**@brief Physical write counter*/
- uint32_t bwrite_ctr;
+ uint32_t bwrite_ctr;
};
-/**@brief Static initialization fo the block device.*/
+/**@brief Static initialization fo the block device.*/
#define EXT4_BLOCKDEV_STATIC_INSTANCE(__name, __bsize, __bcnt, __open, \
- __bread, __bwrite, __close) \
- static uint8_t __name##_ph_bbuf[(__bsize)]; \
- static struct ext4_blockdev __name = { \
+ __bread, __bwrite, __close) \
+ static uint8_t __name##_ph_bbuf[(__bsize)]; \
+ static struct ext4_blockdev __name = { \
.open = __open, \
.bread = __bread, \
.bwrite = __bwrite, \
.ph_bbuf = __name##_ph_bbuf, \
}
-/**@brief Block device initialization.
- * @param bdev block device descriptor
- * @param bg_bsize logical block size
- * @param bdev block device descriptor
- * @return standard error code*/
-int ext4_block_init(struct ext4_blockdev *bdev);
+/**@brief Block device initialization.
+ * @param bdev block device descriptor
+ * @param bg_bsize logical block size
+ * @param bdev block device descriptor
+ * @return standard error code*/
+int ext4_block_init(struct ext4_blockdev *bdev);
-/**@brief Binds a bcache to block device.
- * @param bdev block device descriptor
- * @param bc block cache descriptor
- * @return standard error code*/
+/**@brief Binds a bcache to block device.
+ * @param bdev block device descriptor
+ * @param bc block cache descriptor
+ * @return standard error code*/
int ext4_block_bind_bcache(struct ext4_blockdev *bdev,
struct ext4_bcache *bc);
-/**@brief Close block device
- * @param bdev block device descriptor
- * @return standard error code*/
-int ext4_block_fini(struct ext4_blockdev *bdev);
+/**@brief Close block device
+ * @param bdev block device descriptor
+ * @return standard error code*/
+int ext4_block_fini(struct ext4_blockdev *bdev);
-/**@brief Set logical block size in block device.
- * @param bdev block device descriptor
- * @param lb_size ligical block size (in bytes)
- * @return standard error code*/
-void ext4_block_set_lb_size(struct ext4_blockdev *bdev,
+/**@brief Set logical block size in block device.
+ * @param bdev block device descriptor
+ * @param lb_size ligical block size (in bytes)
+ * @return standard error code*/
+void ext4_block_set_lb_size(struct ext4_blockdev *bdev,
uint64_t lb_bsize);
-/**@brief Block get function (through cache).
- * @param bdev block device descriptor
- * @param b block descriptor
- * @param lba logical block address
- * @return standard error code*/
-int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b,
+/**@brief Block get function (through cache).
+ * @param bdev block device descriptor
+ * @param b block descriptor
+ * @param lba logical block address
+ * @return standard error code*/
+int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b,
uint64_t lba);
-/**@brief Block set procedure (through cache).
- * @param bdev block device descriptor
- * @param b block descriptor
- * @return standard error code*/
-int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b);
+/**@brief Block set procedure (through cache).
+ * @param bdev block device descriptor
+ * @param b block descriptor
+ * @return standard error code*/
+int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b);
-/**@brief Block read procedure (without cache)
- * @param bdev block device descriptor
- * @param buf output buffer
- * @param lba logical block adderss
- * @return standard error code*/
+/**@brief Block read procedure (without cache)
+ * @param bdev block device descriptor
+ * @param buf output buffer
+ * @param lba logical block adderss
+ * @return standard error code*/
int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf,
uint64_t lba, uint32_t cnt);
-/**@brief Block write procedure (without cache)
- * @param bdev block device descriptor
- * @param buf output buffer
- * @param lba logical block address
- * @return standard error code*/
-int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf,
+/**@brief Block write procedure (without cache)
+ * @param bdev block device descriptor
+ * @param buf output buffer
+ * @param lba logical block address
+ * @return standard error code*/
+int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf,
uint64_t lba, uint32_t cnt);
-/**@brief Write to block device (by direct adress).
- * @param bdev block device descriptor
- * @param off byte offset in block device
- * @param buf input buffer
- * @param len length of the write nuffer
- * @return EOK when sucess*/
-int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off,
+/**@brief Write to block device (by direct adress).
+ * @param bdev block device descriptor
+ * @param off byte offset in block device
+ * @param buf input buffer
+ * @param len length of the write nuffer
+ * @return EOK when sucess*/
+int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off,
const void *buf, uint32_t len);
-/**@brief Read freom block device (by direct adress).
- * @param bdev block device descriptor
- * @param off byte offset in block device
- * @param buf input buffer
- * @param len length of the write nuffer
- * @return EOK when sucess*/
-int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off,
+/**@brief Read freom block device (by direct adress).
+ * @param bdev block device descriptor
+ * @param off byte offset in block device
+ * @param buf input buffer
+ * @param len length of the write nuffer
+ * @return EOK when sucess*/
+int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off,
void *buf, uint32_t len);
-/**@brief Enable/disable delayed cache flush mode.
- * @param bdev block device descriptor
- * @param on_off
- * !0 - ENABLE
- * 0 - DISABLE (all delayed cache buffers will be flushed)
- * @return standard error code*/
-int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, uint8_t on_off);
+/**@brief Enable/disable delayed cache flush mode.
+ * @param bdev block device descriptor
+ * @param on_off
+ * !0 - ENABLE
+ * 0 - DISABLE (all delayed cache buffers will be flushed)
+ * @return standard error code*/
+int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, uint8_t on_off);
#endif /* EXT4_BLOCKDEV_H_ */
#endif
-/**@brief Enable directory indexing feature (EXT3 feature)*/
+/**@brief Enable directory indexing feature (EXT3 feature)*/
#ifndef CONFIG_DIR_INDEX_ENABLE
#define CONFIG_DIR_INDEX_ENABLE 1
#endif
-/**@brief Enable extents feature (EXT4 feature)*/
+/**@brief Enable extents feature (EXT4 feature)*/
#ifndef CONFIG_EXTENT_ENABLE
#define CONFIG_EXTENT_ENABLE 1
#endif
-/**@brief Include error codes from ext4_errno or sandard library.*/
+/**@brief Include error codes from ext4_errno or sandard library.*/
#ifndef CONFIG_HAVE_OWN_ERRNO
#define CONFIG_HAVE_OWN_ERRNO 1
#endif
-/**@brief Debug printf enable (stdout)*/
+/**@brief Debug printf enable (stdout)*/
#ifndef CONFIG_DEBUG_PRINTF
#define CONFIG_DEBUG_PRINTF 1
#endif
-/**@brief Assert printf enable (stdout)*/
+/**@brief Assert printf enable (stdout)*/
#ifndef CONFIG_DEBUG_ASSERT
#define CONFIG_DEBUG_ASSERT 1
#endif
-/**@brief Statistics of block device*/
+/**@brief Statistics of block device*/
#ifndef CONFIG_BLOCK_DEV_ENABLE_STATS
#define CONFIG_BLOCK_DEV_ENABLE_STATS 1
#endif
-/**@brief Cache size of block device.*/
+/**@brief Cache size of block device.*/
#ifndef CONFIG_BLOCK_DEV_CACHE_SIZE
#define CONFIG_BLOCK_DEV_CACHE_SIZE 8
#endif
-/**@brief Ilosc urzadzen blokowych.*/
+/**@brief Ilosc urzadzen blokowych.*/
#ifndef CONFIG_EXT4_BLOCKDEVS_COUNT
#define CONFIG_EXT4_BLOCKDEVS_COUNT 2
#endif
-/**@brief Ilosc punktow montowania systemu plikow*/
+/**@brief Ilosc punktow montowania systemu plikow*/
#ifndef CONFIG_EXT4_MOUNTPOINTS_COUNT
#define CONFIG_EXT4_MOUNTPOINTS_COUNT 2
#endif
#include <stdio.h>
/**@brief Debug mask: ext4_blockdev.c*/
-#define EXT4_DEBUG_BLOCKDEV (1 << 0)
+#define EXT4_DEBUG_BLOCKDEV (1 << 0)
/**@brief Debug mask: ext4_fs.c*/
-#define EXT4_DEBUG_FS (1 << 1)
+#define EXT4_DEBUG_FS (1 << 1)
/**@brief Debug mask: ext4_balloc.c*/
-#define EXT4_DEBUG_BALLOC (1 << 2)
+#define EXT4_DEBUG_BALLOC (1 << 2)
/**@brief Debug mask: ext4_bitmap.c*/
-#define EXT4_DEBUG_BITMAP (1 << 3)
+#define EXT4_DEBUG_BITMAP (1 << 3)
/**@brief Debug mask: ext4_dir_idx.c*/
-#define EXT4_DEBUG_DIR_IDX (1 << 4)
+#define EXT4_DEBUG_DIR_IDX (1 << 4)
/**@brief Debug mask: ext4_dir.c*/
-#define EXT4_DEBUG_DIR (1 << 5)
+#define EXT4_DEBUG_DIR (1 << 5)
/**@brief Debug mask: ext4_ialloc.c*/
-#define EXT4_DEBUG_IALLOC (1 << 6)
+#define EXT4_DEBUG_IALLOC (1 << 6)
/**@brief Debug mask: ext4_inode.c*/
-#define EXT4_DEBUG_INODE (1 << 7)
+#define EXT4_DEBUG_INODE (1 << 7)
/**@brief Debug mask: ext4_super.c*/
-#define EXT4_DEBUG_SUPER (1 << 8)
+#define EXT4_DEBUG_SUPER (1 << 8)
/**@brief Debug mask: ext4_bcache.c*/
-#define EXT4_DEBUG_BCACHE (1 << 9)
+#define EXT4_DEBUG_BCACHE (1 << 9)
/**@brief Debug mask: ext4_extents.c*/
#define EXT4_DEBUG_EXTENTS (1 << 10)
-/**@brief All debug printf enabled.*/
-#define EXT4_DEBUG_ALL (0xFFFFFFFF)
+/**@brief All debug printf enabled.*/
+#define EXT4_DEBUG_ALL (0xFFFFFFFF)
-/**@brief Global mask debug settings.
- * @brief m new debug mask.*/
+/**@brief Global mask debug settings.
+ * @brief m new debug mask.*/
void ext4_dmask_set(uint32_t m);
-/**@brief Global debug mask get.
- * @return debug mask*/
+/**@brief Global debug mask get.
+ * @return debug mask*/
uint32_t ext4_dmask_get(void);
#if CONFIG_DEBUG_PRINTF
-/**@brief Debug printf.*/
-#define ext4_dprintf(m, ...) do { \
+/**@brief Debug printf.*/
+#define ext4_dprintf(m, ...) do { \
(m & ext4_dmask_get()) ? printf(__VA_ARGS__) : (void)0; \
fflush(stdout); \
}while(0)
#else
-#define ext4_dprintf(m, ...)
+#define ext4_dprintf(m, ...)
#endif
#if CONFIG_DEBUG_ASSERT
/**@brief Debug asseration.*/
-#define ext4_assert(_v) do { \
+#define ext4_assert(_v) do { \
if(!(_v)){ \
printf("Assertion failed:\nmodule: %s\nfunc: %s\nline: %d\n", \
__FILE__, __FUNCTION__, __LINE__); \
\r
/* Entry was not found */\r
\r
- result->block.lb_id = 0;\r
- result->dentry = NULL;\r
+ result->block.lb_id = 0;\r
+ result->dentry = NULL;\r
\r
return ENOENT;\r
}\r
\r
/* Initialize pointers, stop means to upper bound */\r
struct ext4_directory_entry_ll *dentry = (void *)target_block->data;\r
- struct ext4_directory_entry_ll *stop =\r
+ struct ext4_directory_entry_ll *stop =\r
(void *)(target_block->data + block_size);\r
\r
/*\r
return root_info->indirect_levels;\r
}\r
\r
-void ext4_dir_dx_root_info_set_indirect_levels(\r
+void ext4_dir_dx_root_info_set_indirect_levels(\r
struct ext4_directory_dx_root_info *root_info, uint8_t lvl)\r
{\r
root_info->indirect_levels = lvl;\r
\r
\r
\r
-int ext4_dir_dx_find_entry(struct ext4_directory_search_result * result,\r
+int ext4_dir_dx_find_entry(struct ext4_directory_search_result * result,\r
struct ext4_inode_ref *inode_ref, size_t name_len, const char *name)\r
{\r
/* Load direct block 0 (index root) */\r
if (rc != EOK)\r
return rc;\r
\r
- struct ext4_directory_dx_node *new_node = (void *)new_block.data;\r
+ struct ext4_directory_dx_node *new_node = (void *)new_block.data;\r
struct ext4_directory_dx_entry *new_entries = new_node->entries;\r
\r
memset(&new_node->fake, 0, sizeof(struct ext4_fake_directory_entry));\r
#ifndef CONFIG_HAVE_OWN_ERRNO
#include <errno.h>
#else
-#define EPERM 1 /* Operation not permitted */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Argument list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No child processes */
-#define EAGAIN 11 /* Try again */
-#define ENOMEM 12 /* Out of memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#define ENOTBLK 15 /* Block device required */
-#define EBUSY 16 /* Device or resource busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* File table overflow */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math argument out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-#define ENOTSUP 95 /* Not supported */
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No child processes */
+#define EAGAIN 11 /* Try again */
+#define ENOMEM 12 /* Out of memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device or resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math argument out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+#define ENOTSUP 95 /* Not supported */
#endif
#ifndef EOK
{
struct ext4_sblock *sb = &bg_ref->fs->sb;
- uint32_t inode_size = ext4_get32(sb, inode_size);
- uint32_t block_size = ext4_sb_get_block_size(sb);
+ uint32_t inode_size = ext4_get32(sb, inode_size);
+ uint32_t block_size = ext4_sb_get_block_size(sb);
uint32_t inodes_per_block = block_size / inode_size;
uint32_t inodes_in_group = ext4_inodes_in_group_cnt(sb, bg_ref->index);
uint32_t table_blocks = inodes_in_group / inodes_per_block;
ext4_inode_set_uid(inode, 0);
ext4_inode_set_gid(inode, 0);
ext4_inode_set_size(inode, 0);
- ext4_inode_set_access_time(inode, 0);
+ ext4_inode_set_access_time(inode, 0);
ext4_inode_set_change_inode_time(inode, 0);
ext4_inode_set_modification_time(inode, 0);
- ext4_inode_set_deletion_time(inode, 0);
+ ext4_inode_set_deletion_time(inode, 0);
ext4_inode_set_blocks_count(&fs->sb, inode, 0);
ext4_inode_set_flags(inode, 0);
ext4_inode_set_generation(inode, 0);
uint32_t block_size = ext4_sb_get_block_size(&fs->sb);
uint32_t count = block_size / sizeof(uint32_t);
- struct ext4_block block;
+ struct ext4_block block;
/* 2) Double indirect */
fblock = ext4_inode_get_indirect_block(inode_ref->inode, 1);
}
/* 3) Tripple indirect */
- struct ext4_block subblock;
+ struct ext4_block subblock;
fblock = ext4_inode_get_indirect_block(inode_ref->inode, 2);
if (fblock != 0) {
int rc = ext4_block_get(fs->bdev, &block, fblock);
return EOK;
}
- struct ext4_block block;
+ struct ext4_block block;
/*
* Navigate through other levels, until we find the block number
uint32_t new_block_addr;
- struct ext4_block block;
- struct ext4_block new_block;
+ struct ext4_block block;
+ struct ext4_block new_block;
/* Is needed to allocate indirect block on the i-node level */
if (current_block == 0) {
* Navigate through other levels, until we find the block number
* or find null reference meaning we are dealing with sparse file
*/
- struct ext4_block block;
+ struct ext4_block block;
while (level > 0) {
\r
#include <stdint.h>\r
\r
-/**@brief Directory entry name hash function.\r
- * @param name entry name\r
- * @param len entry name length\r
- * @param hash_seed (from superblock)\r
- * @param hash version (from superblock)\r
- * @param hash_minor output value\r
- * @param hash_major output value\r
- * @return standard error code*/\r
+/**@brief Directory entry name hash function.\r
+ * @param name entry name\r
+ * @param len entry name length\r
+ * @param hash_seed (from superblock)\r
+ * @param hash version (from superblock)\r
+ * @param hash_minor output value\r
+ * @param hash_major output value\r
+ * @return standard error code*/\r
int ext2_htree_hash(const char *name, int len,\r
const uint32_t *hash_seed, int hash_version,\r
uint32_t *hash_major, uint32_t *hash_minor);\r
uint32_t bitmap_block_addr = ext4_bg_get_inode_bitmap(\r
bg_ref.block_group, sb);\r
\r
- struct ext4_block bitmap_block;\r
+ struct ext4_block bitmap_block;\r
rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr);\r
if (rc != EOK)\r
return rc;\r
uint32_t bitmap_block_addr = ext4_bg_get_inode_bitmap(\r
bg_ref.block_group, sb);\r
\r
- struct ext4_block bitmap_block;\r
+ struct ext4_block bitmap_block;\r
rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr);\r
if (rc != EOK)\r
return rc;\r
return v;\r
}\r
\r
-void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,\r
+void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,\r
uint32_t mode)\r
{\r
inode->mode = to_le16((mode << 16) >> 16);\r
return to_le32(inode->uid);\r
}\r
\r
-void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid)\r
+void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid)\r
{\r
inode->uid = to_le32(uid);\r
}\r
}\r
void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid)\r
{\r
- inode->gid = to_le32(gid);\r
+ inode->gid = to_le32(gid);\r
}\r
\r
uint16_t ext4_inode_get_links_count(struct ext4_inode *inode)\r
}\r
void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags)\r
{\r
- inode->flags = to_le32(flags);\r
+ inode->flags = to_le32(flags);\r
}\r
\r
uint32_t ext4_inode_get_generation(struct ext4_inode *inode)\r
{\r
return to_le32(inode->generation);\r
}\r
-void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen)\r
+void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen)\r
{\r
inode->generation = to_le32(gen);\r
}\r
uint32_t ext4_blocks_in_group_cnt(struct ext4_sblock *s, uint32_t bgid)
{
uint32_t block_group_count = ext4_block_group_cnt(s);
- uint32_t blocks_per_group = ext4_get32(s, blocks_per_group);
- uint64_t total_blocks = ext4_sb_get_blocks_cnt(s);
+ uint32_t blocks_per_group = ext4_get32(s, blocks_per_group);
+ uint64_t total_blocks = ext4_sb_get_blocks_cnt(s);
if (bgid < block_group_count - 1)
return blocks_per_group;
return (total_inodes - ((block_group_count - 1) * inodes_per_group));
}
-int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s)
+int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s)
{
return ext4_block_writebytes(bdev, EXT4_SUPERBLOCK_OFFSET,
s, EXT4_SUPERBLOCK_SIZE);
}
-int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s)
+int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s)
{
return ext4_block_readbytes(bdev, EXT4_SUPERBLOCK_OFFSET,
s, EXT4_SUPERBLOCK_SIZE);
* @param bdev block device descriptor.
* @param s superblock descruptor
* @return Standard error code */
-int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s);
+int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s);
/**@brief Superblock read.
* @param bdev block device descriptor.
* @param s superblock descruptor
* @return Standard error code */
-int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s);
+int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s);
/**@brief Superblock simple validation.
* @param s superblock dsecriptor
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
struct ext4_fs {
- struct ext4_blockdev *bdev;
- struct ext4_sblock sb;
+ struct ext4_blockdev*bdev;
+ struct ext4_sblock sb;
uint64_t inode_block_limits[4];
uint64_t inode_blocks_per_level[4];
} ;
struct ext4_block_group_ref {
- struct ext4_block block;
- struct ext4_bgroup *block_group;
- struct ext4_fs *fs;
- uint32_t index;
- bool dirty;
+ struct ext4_block block;
+ struct ext4_bgroup *block_group;
+ struct ext4_fs *fs;
+ uint32_t index;
+ bool dirty;
};
#define EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE 32
#define EXT4_INODE_ROOT_INDEX 2
struct ext4_inode_ref {
- struct ext4_block block;
- struct ext4_inode *inode;
+ struct ext4_block block;
+ struct ext4_inode *inode;
struct ext4_fs *fs;
uint32_t index;
bool dirty;
} __attribute__((packed)) ;
struct ext4_directory_iterator {
- struct ext4_inode_ref *inode_ref;
- struct ext4_block current_block;
- uint64_t current_offset;
+ struct ext4_inode_ref *inode_ref;
+ struct ext4_block current_block;
+ uint64_t current_offset;
struct ext4_directory_entry_ll *current;
};
struct ext4_directory_search_result {
- struct ext4_block block;
- struct ext4_directory_entry_ll *dentry;
+ struct ext4_block block;
+ struct ext4_directory_entry_ll *dentry;
};
/* Structures for indexed directory */
};
struct ext4_directory_dx_block {
- struct ext4_block block;
+ struct ext4_block block;
struct ext4_directory_dx_entry *entries;
struct ext4_directory_dx_entry *position;
} ;
} ;
struct ext4_extent_path {
- struct ext4_block block;
- uint16_t depth;
+ struct ext4_block block;
+ uint16_t depth;
struct ext4_extent_header *header;
- struct ext4_extent_index *index;
- struct ext4_extent *extent;
+ struct ext4_extent_index *index;
+ struct ext4_extent *extent;
} ;
#define EXT4_EXTENT_MAGIC 0xF30A
-#define EXT4_EXTENT_FIRST(header) \
+#define EXT4_EXTENT_FIRST(header) \
((struct ext4_extent *) (((void *) (header)) + sizeof(struct ext4_extent_header)))
-#define EXT4_EXTENT_FIRST_INDEX(header) \
+#define EXT4_EXTENT_FIRST_INDEX(header) \
((struct ext4_extent_index *) (((void *) (header)) + sizeof(struct ext4_extent_header)))
/* EXT3 HTree directory indexing */
-#define EXT2_HTREE_LEGACY 0
-#define EXT2_HTREE_HALF_MD4 1
-#define EXT2_HTREE_TEA 2
-#define EXT2_HTREE_LEGACY_UNSIGNED 3
-#define EXT2_HTREE_HALF_MD4_UNSIGNED 4
-#define EXT2_HTREE_TEA_UNSIGNED 5
+#define EXT2_HTREE_LEGACY 0
+#define EXT2_HTREE_HALF_MD4 1
+#define EXT2_HTREE_TEA 2
+#define EXT2_HTREE_LEGACY_UNSIGNED 3
+#define EXT2_HTREE_HALF_MD4_UNSIGNED 4
+#define EXT2_HTREE_TEA_UNSIGNED 5
-#define EXT2_HTREE_EOF 0x7FFFFFFF
+#define EXT2_HTREE_EOF 0x7FFFFFFF
struct ext4_hash_info {
static inline uint32_t to_le32(uint32_t n)
{
- return ((n & 0xff) << 24) |
+ return ((n & 0xff) << 24) |
((n & 0xff00) << 8) |
((n & 0xff0000) >> 8) |
((n & 0xff000000) >> 24);
static inline uint16_t to_le16(uint16_t n)
{
- return ((n & 0xff) << 8) |
+ return ((n & 0xff) << 8) |
((n & 0xff00) >> 8);
}
#else
-#define to_le64(_n) _n
-#define to_le32(_n) _n
-#define to_le16(_n) _n
+#define to_le64(_n) _n
+#define to_le32(_n) _n
+#define to_le16(_n) _n
#endif
/****************************Access macros to ext4 structures*****************/
-#define ext4_get32(s, f) to_le32((s)->f)
-#define ext4_get16(s, f) to_le16((s)->f)
-#define ext4_get8(s, f) (s)->f
+#define ext4_get32(s, f) to_le32((s)->f)
+#define ext4_get16(s, f) to_le16((s)->f)
+#define ext4_get8(s, f) (s)->f
-#define ext4_set32(s, f, v) do { (s)->f = to_le32(v); }while(0)
-#define ext4_set16(s, f, v) do { (s)->f = to_le16(v); }while(0)
-#define ext4_set8 (s, f, v) do { (s)->f = (v); }while(0)
+#define ext4_set32(s, f, v) do { (s)->f = to_le32(v); }while(0)
+#define ext4_set16(s, f, v) do { (s)->f = to_le16(v); }while(0)
+#define ext4_set8 (s, f, v) do { (s)->f = (v); }while(0)
#endif /* EXT4_TYPES_H_ */
- DIR_PREALLOC: no\r
- IMAGIC_INODES: no\r
- HAS_JOURNAL: no\r
- - EXT_ATTR: no\r
+ - EXT_ATTR: no\r
- RESIZE_INODE: no\r
- DIR_INDEX: yes\r
\r
- EXTRA_ISIZE: yes\r
\r
Supported filetypes:\r
- - FIFO: no\r
- - CHARDEV: no\r
+ - FIFO: no\r
+ - CHARDEV: no\r
- DIRECTORY: yes\r
- BLOCKDEV: no\r
- FILE: yes\r
\r
+toolchain - specific toolchain cmake files\r
\r
-+ext4.h - lwext4 client library header\r
++ext4.h - lwext4 client library header\r
CMakeLists.txt - CMake config file\r
ext_images.7z - ext2/3/4 100MB images\r
Makefile - helper makefile to call cmake\r
set(CMAKE_SYSTEM_PROCESSOR bf518)\r
\r
# Toolchain settings\r
-set(CMAKE_C_COMPILER bfin-elf-gcc)\r
-set(CMAKE_CXX_COMPILER bfin-elf-g++)\r
+set(CMAKE_C_COMPILER bfin-elf-gcc)\r
+set(CMAKE_CXX_COMPILER bfin-elf-g++)\r
set(AS bfin-elf--gcc)\r
-set(AR bfin-elf-ar)\r
-set(OBJCOPY bfin-elf-objcopy)\r
-set(OBJDUMP bfin-elf-objdump)\r
+set(AR bfin-elf-ar)\r
+set(OBJCOPY bfin-elf-objcopy)\r
+set(OBJDUMP bfin-elf-objdump)\r
set(SIZE bfin-elf-size)\r
\r
-set(CMAKE_C_FLAGS "-mcpu=bf518 -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
-set(CMAKE_CXX_FLAGS "-mcpu=bf518 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
+set(CMAKE_C_FLAGS "-mcpu=bf518 -Os -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
+set(CMAKE_CXX_FLAGS "-mcpu=bf518 -Os -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
set(CMAKE_ASM_FLAGS "-mcpu=bf518 -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")\r
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mcpu=bf592" CACHE INTERNAL "exe link flags")\r
- \r
- \r
- \r
- \r
-
\ No newline at end of file
set(CMAKE_SYSTEM_PROCESSOR cortex-m3)\r
\r
# Toolchain settings\r
-set(CMAKE_C_COMPILER arm-none-eabi-gcc)\r
-set(CMAKE_CXX_COMPILER arm-none-eabi-g++)\r
-set(AS arm-none-eabi-as)\r
-set(AR arm-none-eabi-ar)\r
-set(OBJCOPY arm-none-eabi-objcopy)\r
-set(OBJDUMP arm-none-eabi-objdump)\r
+set(CMAKE_C_COMPILER arm-none-eabi-gcc)\r
+set(CMAKE_CXX_COMPILER arm-none-eabi-g++)\r
+set(AS arm-none-eabi-as)\r
+set(AR arm-none-eabi-ar)\r
+set(OBJCOPY arm-none-eabi-objcopy)\r
+set(OBJDUMP arm-none-eabi-objdump)\r
set(SIZE arm-none-eabi-size)\r
\r
-set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
-set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
+set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m3 -Os -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
+set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -Os -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m3" CACHE INTERNAL "asm compiler flags")\r
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m3" CACHE INTERNAL "exe link flags")\r
\r
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)\r
\r
# Toolchain settings\r
-set(CMAKE_C_COMPILER arm-none-eabi-gcc)\r
-set(CMAKE_CXX_COMPILER arm-none-eabi-g++)\r
-set(AS arm-none-eabi-as)\r
-set(AR arm-none-eabi-ar)\r
-set(OBJCOPY arm-none-eabi-objcopy)\r
-set(OBJDUMP arm-none-eabi-objdump)\r
+set(CMAKE_C_COMPILER arm-none-eabi-gcc)\r
+set(CMAKE_CXX_COMPILER arm-none-eabi-g++)\r
+set(AS arm-none-eabi-as)\r
+set(AR arm-none-eabi-ar)\r
+set(OBJCOPY arm-none-eabi-objcopy)\r
+set(OBJDUMP arm-none-eabi-objdump)\r
set(SIZE arm-none-eabi-size)\r
\r
-set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
-set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
+set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m4 -Os -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
+set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -Os -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m4" CACHE INTERNAL "asm compiler flags")\r
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m4" CACHE INTERNAL "exe link flags")\r
\r