Unified · Split
| @@ -33,14 +33,14 @@ · 32 unmodified lines | ||
| 33 | 33 | #include <string.h> |
| 34 | 34 | #include <fcntl.h> |
| 35 | 35 | |
| 36 | −/**@brief Default filename.*/ | |
| 36 | +/**@brief Default filename.*/ | |
| 37 | 37 | static const char *fname = "ext2"; |
| 38 | 38 | |
| 39 | −/**@brief Image block size.*/ | |
| 40 | −#define EXT4_FILEDEV_BSIZE 512 | |
| 39 | +/**@brief Image block size.*/ | |
| 40 | +#define EXT4_FILEDEV_BSIZE 512 | |
| 41 | 41 | |
| 42 | −/**@brief Image file descriptor.*/ | |
| 43 | −static FILE *dev_file; | |
| 42 | +/**@brief Image file descriptor.*/ | |
| 43 | +static FILE *dev_file; | |
| 44 | 44 | |
| 45 | 45 | #define DROP_LINUXCACHE_BUFFERS 1 |
| 46 | 46 | |
| @@ -48,21 +48,21 @@ static FILE *dev_file; · 1 unmodified line | ||
| 48 | 48 | /**********************BLOCKDEV INTERFACE**************************************/ |
| 49 | 49 | static int filedev_open(struct ext4_blockdev *bdev); |
| 50 | 50 | static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id, |
| 51 | − uint32_t blk_cnt); | |
| 51 | + uint32_t blk_cnt); | |
| 52 | 52 | static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf, |
| 53 | − uint64_t blk_id, uint32_t blk_cnt); | |
| 53 | + uint64_t blk_id, uint32_t blk_cnt); | |
| 54 | 54 | static int filedev_close(struct ext4_blockdev *bdev); |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | /******************************************************************************/ |
| 58 | 58 | EXT4_BLOCKDEV_STATIC_INSTANCE( |
| 59 | − _filedev, | |
| 60 | − EXT4_FILEDEV_BSIZE, | |
| 61 | − 0, | |
| 62 | − filedev_open, | |
| 63 | − filedev_bread, | |
| 64 | − filedev_bwrite, | |
| 65 | − filedev_close | |
| 59 | + _filedev, | |
| 60 | + EXT4_FILEDEV_BSIZE, | |
| 61 | + 0, | |
| 62 | + filedev_open, | |
| 63 | + filedev_bread, | |
| 64 | + filedev_bwrite, | |
| 65 | + filedev_close | |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | 68 | /******************************************************************************/ |
| @@ -71,34 +71,34 @@ EXT4_BCACHE_STATIC_INSTANCE(__cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024); · 2 unmodified lines | ||
| 71 | 71 | /******************************************************************************/ |
| 72 | 72 | static int filedev_open(struct ext4_blockdev *bdev) |
| 73 | 73 | { |
| 74 | − dev_file = fopen(fname, "r+b"); | |
| 74 | + dev_file = fopen(fname, "r+b"); | |
| 75 | 75 | |
| 76 | − if(!dev_file) | |
| 77 | − return EIO; | |
| 76 | + if(!dev_file) | |
| 77 | + return EIO; | |
| 78 | 78 | |
| 79 | − /*No buffering at file.*/ | |
| 80 | − setbuf(dev_file, 0); | |
| 79 | + /*No buffering at file.*/ | |
| 80 | + setbuf(dev_file, 0); | |
| 81 | 81 | |
| 82 | − if(fseek(dev_file, 0, SEEK_END)) | |
| 83 | − return EFAULT; | |
| 82 | + if(fseek(dev_file, 0, SEEK_END)) | |
| 83 | + return EFAULT; | |
| 84 | 84 | |
| 85 | − _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize; | |
| 85 | + _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize; | |
| 86 | 86 | |
| 87 | − return EOK; | |
| 87 | + return EOK; | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /******************************************************************************/ |
| 91 | 91 | |
| 92 | 92 | static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id, |
| 93 | − uint32_t blk_cnt) | |
| 93 | + uint32_t blk_cnt) | |
| 94 | 94 | { |
| 95 | − if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET)) | |
| 96 | − return EIO; | |
| 95 | + if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET)) | |
| 96 | + return EIO; | |
| 97 | 97 | |
| 98 | − if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file)) | |
| 99 | − return EIO; | |
| 98 | + if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file)) | |
| 99 | + return EIO; | |
| 100 | 100 | |
| 101 | − return EOK; | |
| 101 | + return EOK; | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | static void drop_cache(void) |
| @@ -130,26 +130,26 @@ static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf, · 25 unmodified lines | ||
| 130 | 130 | /******************************************************************************/ |
| 131 | 131 | static int filedev_close(struct ext4_blockdev *bdev) |
| 132 | 132 | { |
| 133 | − fclose(dev_file); | |
| 134 | − return EOK; | |
| 133 | + fclose(dev_file); | |
| 134 | + return EOK; | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | /******************************************************************************/ |
| 139 | 139 | |
| 140 | −struct ext4_bcache* ext4_filecache_get(void) | |
| 140 | +struct ext4_bcache* ext4_filecache_get(void) | |
| 141 | 141 | { |
| 142 | − return &__cache; | |
| 142 | + return &__cache; | |
| 143 | 143 | } |
| 144 | 144 | /******************************************************************************/ |
| 145 | −struct ext4_blockdev* ext4_filedev_get(void) | |
| 145 | +struct ext4_blockdev* ext4_filedev_get(void) | |
| 146 | 146 | { |
| 147 | − return &_filedev; | |
| 147 | + return &_filedev; | |
| 148 | 148 | } |
| 149 | 149 | /******************************************************************************/ |
| 150 | 150 | void ext4_filedev_filename(const char *n) |
| 151 | 151 | { |
| 152 | − fname = n; | |
| 152 | + fname = n; | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /******************************************************************************/ |
| @@ -34,12 +34,12 @@ · 33 unmodified lines | ||
| 34 | 34 | #include <stdint.h> |
| 35 | 35 | #include <stdbool.h> |
| 36 | 36 | |
| 37 | −/**@brief Filecache get.*/ | |
| 38 | −struct ext4_bcache* ext4_filecache_get(void); | |
| 37 | +/**@brief Filecache get.*/ | |
| 38 | +struct ext4_bcache* ext4_filecache_get(void); | |
| 39 | 39 | |
| 40 | −/**@brief File blockdev get.*/ | |
| 41 | −struct ext4_blockdev* ext4_filedev_get(void); | |
| 40 | +/**@brief File blockdev get.*/ | |
| 41 | +struct ext4_blockdev* ext4_filedev_get(void); | |
| 42 | 42 | |
| 43 | −void ext4_filedev_filename(const char *n); | |
| 43 | +void ext4_filedev_filename(const char *n); | |
| 44 | 44 | |
| 45 | 45 | #endif /* EXT4_FILEDEV_H_ */ |
| @@ -46,10 +46,10 @@ · 45 unmodified lines | ||
| 46 | 46 | /**@brief Input stream name.*/ |
| 47 | 47 | char input_name[128] = "ext2"; |
| 48 | 48 | |
| 49 | −/**@brief Read-write size*/ | |
| 49 | +/**@brief Read-write size*/ | |
| 50 | 50 | static int rw_szie = 1024 * 1024; |
| 51 | 51 | |
| 52 | −/**@brief Read-write size*/ | |
| 52 | +/**@brief Read-write size*/ | |
| 53 | 53 | static int rw_count = 10; |
| 54 | 54 | |
| 55 | 55 | /**@brief Directory test count*/ |
| @@ -70,16 +70,16 @@ static bool sbstat = false; · 14 unmodified lines | ||
| 70 | 70 | /**@brief Indicates that input is windows partition.*/ |
| 71 | 71 | static bool winpart = false; |
| 72 | 72 | |
| 73 | −/**@brief File write buffer*/ | |
| 74 | −static uint8_t *wr_buff; | |
| 73 | +/**@brief File write buffer*/ | |
| 74 | +static uint8_t *wr_buff; | |
| 75 | 75 | |
| 76 | −/**@brief File read buffer.*/ | |
| 77 | −static uint8_t *rd_buff; | |
| 76 | +/**@brief File read buffer.*/ | |
| 77 | +static uint8_t *rd_buff; | |
| 78 | 78 | |
| 79 | −/**@brief Block device handle.*/ | |
| 79 | +/**@brief Block device handle.*/ | |
| 80 | 80 | static struct ext4_blockdev *bd; |
| 81 | 81 | |
| 82 | −/**@brief Block cache handle.*/ | |
| 82 | +/**@brief Block cache handle.*/ | |
| 83 | 83 | static struct ext4_bcache *bc; |
| 84 | 84 | |
| 85 | 85 | static const char *usage = " \n\ |
| @@ -99,52 +99,52 @@ Usage: \n\ · 13 unmodified lines | ||
| 99 | 99 | |
| 100 | 100 | static char* entry_to_str(uint8_t type) |
| 101 | 101 | { |
| 102 | − switch(type){ | |
| 103 | − case EXT4_DIRENTRY_UNKNOWN: | |
| 104 | − return "[UNK] "; | |
| 105 | − case EXT4_DIRENTRY_REG_FILE: | |
| 106 | − return "[FIL] "; | |
| 107 | − case EXT4_DIRENTRY_DIR: | |
| 108 | − return "[DIR] "; | |
| 109 | − case EXT4_DIRENTRY_CHRDEV: | |
| 110 | − return "[CHA] "; | |
| 111 | − case EXT4_DIRENTRY_BLKDEV: | |
| 112 | − return "[BLK] "; | |
| 113 | − case EXT4_DIRENTRY_FIFO: | |
| 114 | − return "[FIF] "; | |
| 115 | − case EXT4_DIRENTRY_SOCK: | |
| 116 | − return "[SOC] "; | |
| 117 | − case EXT4_DIRENTRY_SYMLINK: | |
| 118 | − return "[SYM] "; | |
| 119 | − default: | |
| 120 | − break; | |
| 121 | − } | |
| 122 | − return "[???]"; | |
| 102 | + switch(type){ | |
| 103 | + case EXT4_DIRENTRY_UNKNOWN: | |
| 104 | + return "[UNK] "; | |
| 105 | + case EXT4_DIRENTRY_REG_FILE: | |
| 106 | + return "[FIL] "; | |
| 107 | + case EXT4_DIRENTRY_DIR: | |
| 108 | + return "[DIR] "; | |
| 109 | + case EXT4_DIRENTRY_CHRDEV: | |
| 110 | + return "[CHA] "; | |
| 111 | + case EXT4_DIRENTRY_BLKDEV: | |
| 112 | + return "[BLK] "; | |
| 113 | + case EXT4_DIRENTRY_FIFO: | |
| 114 | + return "[FIF] "; | |
| 115 | + case EXT4_DIRENTRY_SOCK: | |
| 116 | + return "[SOC] "; | |
| 117 | + case EXT4_DIRENTRY_SYMLINK: | |
| 118 | + return "[SYM] "; | |
| 119 | + default: | |
| 120 | + break; | |
| 121 | + } | |
| 122 | + return "[???]"; | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | static void dir_ls(const char *path) |
| 126 | 126 | { |
| 127 | − int j = 0; | |
| 128 | − char sss[255]; | |
| 129 | − ext4_dir d; | |
| 130 | − ext4_direntry *de; | |
| 131 | − | |
| 132 | − printf("**********************************************\n"); | |
| 133 | − | |
| 134 | − ext4_dir_open(&d, path); | |
| 135 | − de = ext4_dir_entry_get(&d, j++); | |
| 136 | − printf("ls %s\n", path); | |
| 137 | − | |
| 138 | − while(de){ | |
| 139 | − memcpy(sss, de->name, de->name_length); | |
| 140 | − sss[de->name_length] = 0; | |
| 141 | − printf("%s", entry_to_str(de->inode_type)); | |
| 142 | − printf("%s", sss); | |
| 143 | − printf("\n"); | |
| 144 | − de = ext4_dir_entry_get(&d, j++); | |
| 145 | − } | |
| 146 | − printf("**********************************************\n"); | |
| 147 | − ext4_dir_close(&d); | |
| 127 | + int j = 0; | |
| 128 | + char sss[255]; | |
| 129 | + ext4_dir d; | |
| 130 | + ext4_direntry *de; | |
| 131 | + | |
| 132 | + printf("**********************************************\n"); | |
| 133 | + | |
| 134 | + ext4_dir_open(&d, path); | |
| 135 | + de = ext4_dir_entry_get(&d, j++); | |
| 136 | + printf("ls %s\n", path); | |
| 137 | + | |
| 138 | + while(de){ | |
| 139 | + memcpy(sss, de->name, de->name_length); | |
| 140 | + sss[de->name_length] = 0; | |
| 141 | + printf("%s", entry_to_str(de->inode_type)); | |
| 142 | + printf("%s", sss); | |
| 143 | + printf("\n"); | |
| 144 | + de = ext4_dir_entry_get(&d, j++); | |
| 145 | + } | |
| 146 | + printf("**********************************************\n"); | |
| 147 | + ext4_dir_close(&d); | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | static void mp_stats(void) |
| @@ -397,8 +397,8 @@ static bool mount(void) · 246 unmodified lines | ||
| 397 | 397 | { |
| 398 | 398 | int r; |
| 399 | 399 | if(winpart){ |
| 400 | − if(!open_winpartition()) | |
| 401 | − return false; | |
| 400 | + if(!open_winpartition()) | |
| 401 | + return false; | |
| 402 | 402 | }else{ |
| 403 | 403 | if(!open_filedev()) |
| 404 | 404 | return false; |
| @@ -445,52 +445,52 @@ static bool parse_opt(int argc, char **argv) · 40 unmodified lines | ||
| 445 | 445 | int c; |
| 446 | 446 | |
| 447 | 447 | static struct option long_options[] = |
| 448 | − { | |
| 449 | − {"in", required_argument, 0, 'a'}, | |
| 450 | − {"rws", required_argument, 0, 'b'}, | |
| 451 | − {"rwc", required_argument, 0, 'c'}, | |
| 452 | − {"cache", required_argument, 0, 'd'}, | |
| 453 | − {"dirs", required_argument, 0, 'e'}, | |
| 454 | − {"clean", no_argument, 0, 'f'}, | |
| 455 | − {"bstat", no_argument, 0, 'g'}, | |
| 456 | − {"sbstat", no_argument, 0, 'h'}, | |
| 457 | − {"wpart", no_argument, 0, 'i'}, | |
| 458 | − {0, 0, 0, 0} | |
| 459 | − }; | |
| 448 | + { | |
| 449 | + {"in", required_argument, 0, 'a'}, | |
| 450 | + {"rws", required_argument, 0, 'b'}, | |
| 451 | + {"rwc", required_argument, 0, 'c'}, | |
| 452 | + {"cache", required_argument, 0, 'd'}, | |
| 453 | + {"dirs", required_argument, 0, 'e'}, | |
| 454 | + {"clean", no_argument, 0, 'f'}, | |
| 455 | + {"bstat", no_argument, 0, 'g'}, | |
| 456 | + {"sbstat", no_argument, 0, 'h'}, | |
| 457 | + {"wpart", no_argument, 0, 'i'}, | |
| 458 | + {0, 0, 0, 0} | |
| 459 | + }; | |
| 460 | 460 | |
| 461 | 461 | while(-1 != (c = getopt_long (argc, argv, "a:b:c:d:e:fghi", long_options, &option_index))) { |
| 462 | 462 | |
| 463 | 463 | switch(c){ |
| 464 | − case 'a': | |
| 465 | − strcpy(input_name, optarg); | |
| 466 | − break; | |
| 467 | − case 'b': | |
| 468 | − rw_szie = atoi(optarg); | |
| 469 | − break; | |
| 470 | − case 'c': | |
| 471 | − rw_count = atoi(optarg); | |
| 472 | − break; | |
| 473 | − case 'd': | |
| 474 | − cache_mode = atoi(optarg); | |
| 475 | − break; | |
| 476 | − case 'e': | |
| 477 | − dir_cnt = atoi(optarg); | |
| 478 | − break; | |
| 479 | − case 'f': | |
| 480 | − cleanup_flag = true; | |
| 481 | − break; | |
| 482 | − case 'g': | |
| 483 | − bstat = true; | |
| 484 | − break; | |
| 485 | − case 'h': | |
| 486 | − sbstat = true; | |
| 487 | − break; | |
| 488 | − case 'i': | |
| 489 | − winpart = true; | |
| 490 | − break; | |
| 491 | − default: | |
| 492 | − printf("%s", usage); | |
| 493 | − return false; | |
| 464 | + case 'a': | |
| 465 | + strcpy(input_name, optarg); | |
| 466 | + break; | |
| 467 | + case 'b': | |
| 468 | + rw_szie = atoi(optarg); | |
| 469 | + break; | |
| 470 | + case 'c': | |
| 471 | + rw_count = atoi(optarg); | |
| 472 | + break; | |
| 473 | + case 'd': | |
| 474 | + cache_mode = atoi(optarg); | |
| 475 | + break; | |
| 476 | + case 'e': | |
| 477 | + dir_cnt = atoi(optarg); | |
| 478 | + break; | |
| 479 | + case 'f': | |
| 480 | + cleanup_flag = true; | |
| 481 | + break; | |
| 482 | + case 'g': | |
| 483 | + bstat = true; | |
| 484 | + break; | |
| 485 | + case 'h': | |
| 486 | + sbstat = true; | |
| 487 | + break; | |
| 488 | + case 'i': | |
| 489 | + winpart = true; | |
| 490 | + break; | |
| 491 | + default: | |
| 492 | + printf("%s", usage); | |
| 493 | + return false; | |
| 494 | 494 | |
| 495 | 495 | } |
| 496 | 496 | } |
| @@ -520,20 +520,20 @@ int main(int argc, char **argv) · 23 unmodified lines | ||
| 520 | 520 | dir_ls("/mp/"); |
| 521 | 521 | fflush(stdout); |
| 522 | 522 | if(!dir_test(dir_cnt)) |
| 523 | − return EXIT_FAILURE; | |
| 523 | + return EXIT_FAILURE; | |
| 524 | 524 | |
| 525 | 525 | fflush(stdout); |
| 526 | − if(!file_test()) | |
| 527 | − return EXIT_FAILURE; | |
| 526 | + if(!file_test()) | |
| 527 | + return EXIT_FAILURE; | |
| 528 | 528 | |
| 529 | − fflush(stdout); | |
| 530 | − dir_ls("/mp/"); | |
| 529 | + fflush(stdout); | |
| 530 | + dir_ls("/mp/"); | |
| 531 | 531 | |
| 532 | − if(sbstat) | |
| 533 | − mp_stats(); | |
| 532 | + if(sbstat) | |
| 533 | + mp_stats(); | |
| 534 | 534 | |
| 535 | − if(cleanup_flag) | |
| 536 | − cleanup(); | |
| 535 | + if(cleanup_flag) | |
| 536 | + cleanup(); | |
| 537 | 537 | |
| 538 | 538 | if(bstat) |
| 539 | 539 | block_stats(); |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | /** |
| 33 | 33 | * @file ext4.h |
| 34 | 34 | * @brief Ext4 high level operations (files, directories, mountpoints...). |
| 35 | − * Client has to include only this file. | |
| 35 | + * Client has to include only this file. | |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | 38 | #ifndef EXT4_H_ |
| @@ -75,53 +75,53 @@ · 36 unmodified lines | ||
| 75 | 75 | /********************************FILE SEEK FLAGS*****************************/ |
| 76 | 76 | |
| 77 | 77 | #ifndef SEEK_SET |
| 78 | −#define SEEK_SET 0 | |
| 78 | +#define SEEK_SET 0 | |
| 79 | 79 | #endif |
| 80 | 80 | |
| 81 | 81 | #ifndef SEEK_CUR |
| 82 | −#define SEEK_CUR 1 | |
| 82 | +#define SEEK_CUR 1 | |
| 83 | 83 | #endif |
| 84 | 84 | |
| 85 | 85 | #ifndef SEEK_END |
| 86 | −#define SEEK_END 2 | |
| 86 | +#define SEEK_END 2 | |
| 87 | 87 | #endif |
| 88 | 88 | |
| 89 | 89 | /********************************OS LOCK INFERFACE***************************/ |
| 90 | 90 | |
| 91 | −/**@brief OS dependent lock interface.*/ | |
| 91 | +/**@brief OS dependent lock interface.*/ | |
| 92 | 92 | struct ext4_lock { |
| 93 | 93 | |
| 94 | − /**@brief Lock access to mountpoint*/ | |
| 94 | + /**@brief Lock access to mountpoint*/ | |
| 95 | 95 | void (*lock)(void); |
| 96 | 96 | |
| 97 | − /**@brief Unlock access to mountpoint*/ | |
| 97 | + /**@brief Unlock access to mountpoint*/ | |
| 98 | 98 | void (*unlock)(void); |
| 99 | 99 | }; |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | /********************************FILE DESCRIPTOR*****************************/ |
| 103 | 103 | |
| 104 | −/**@brief File descriptor*/ | |
| 104 | +/**@brief File descriptor*/ | |
| 105 | 105 | typedef struct ext4_file { |
| 106 | 106 | |
| 107 | − /**@brief Pountpoint handle.*/ | |
| 107 | + /**@brief Pountpoint handle.*/ | |
| 108 | 108 | struct ext4_mountpoint *mp; |
| 109 | 109 | |
| 110 | − /**@brief File inode id*/ | |
| 110 | + /**@brief File inode id*/ | |
| 111 | 111 | uint32_t inode; |
| 112 | 112 | |
| 113 | − /**@brief Open flags.*/ | |
| 113 | + /**@brief Open flags.*/ | |
| 114 | 114 | uint32_t flags; |
| 115 | 115 | |
| 116 | − /**@brief File size.*/ | |
| 116 | + /**@brief File size.*/ | |
| 117 | 117 | uint64_t fsize; |
| 118 | 118 | |
| 119 | − /**@brief File position*/ | |
| 119 | + /**@brief File position*/ | |
| 120 | 120 | uint64_t fpos; |
| 121 | 121 | }ext4_file; |
| 122 | 122 | |
| 123 | 123 | /*****************************DIRECTORY DESCRIPTOR***************************/ |
| 124 | −/**@brief Directory entry types. Copy from ext4_types.h*/ | |
| 124 | +/**@brief Directory entry types. Copy from ext4_types.h*/ | |
| 125 | 125 | enum { |
| 126 | 126 | EXT4_DIRENTRY_UNKNOWN = 0, |
| 127 | 127 | EXT4_DIRENTRY_REG_FILE, |
| @@ -146,10 +146,10 @@ typedef struct { · 18 unmodified lines | ||
| 146 | 146 | }ext4_direntry; |
| 147 | 147 | |
| 148 | 148 | typedef struct { |
| 149 | − /**@brief File descriptor*/ | |
| 150 | − ext4_file f; | |
| 151 | − /**@brief Current direntry.*/ | |
| 152 | − ext4_direntry de; | |
| 149 | + /**@brief File descriptor*/ | |
| 150 | + ext4_file f; | |
| 151 | + /**@brief Current direntry.*/ | |
| 152 | + ext4_direntry de; | |
| 153 | 153 | }ext4_dir; |
| 154 | 154 | |
| 155 | 155 | /********************************MOUNT OPERATIONS****************************/ |
| @@ -167,8 +167,8 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, · 11 unmodified lines | ||
| 167 | 167 | const char *dev_name); |
| 168 | 168 | |
| 169 | 169 | /**@brief Mount a block device with EXT4 partition to the mountpoint. |
| 170 | − * @param dev_name block device name (@ref ext4_device_register) | |
| 171 | − * @param mount_point pount point, for example | |
| 170 | + * @param dev_name block device name (@ref ext4_device_register) | |
| 171 | + * @param mount_point pount point, for example | |
| 172 | 172 | * - / |
| 173 | 173 | * - /my_partition/ |
| 174 | 174 | * - /my_second_partition/ |
| @@ -177,7 +177,7 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, · 2 unmodified lines | ||
| 177 | 177 | int ext4_mount(const char * dev_name, char *mount_point); |
| 178 | 178 | |
| 179 | 179 | /**@brief Umount operation. |
| 180 | − * @param mount_point mount name | |
| 180 | + * @param mount_point mount name | |
| 181 | 181 | * @return standard error code */ |
| 182 | 182 | int ext4_umount(char *mount_point); |
| 183 | 183 | |
| @@ -212,9 +212,9 @@ int ext4_mount_point_stats(const char *mount_point, · 28 unmodified lines | ||
| 212 | 212 | int ext4_fremove(const char *path); |
| 213 | 213 | |
| 214 | 214 | /**@brief File open function. |
| 215 | − * @param filename, (has to start from mountpoint) | |
| 216 | − * /my_partition/my_file | |
| 217 | − * @param flags open file flags | |
| 215 | + * @param filename, (has to start from mountpoint) | |
| 216 | + * /my_partition/my_file | |
| 217 | + * @param flags open file flags | |
| 218 | 218 | * |---------------------------------------------------------------| |
| 219 | 219 | * | r or rb O_RDONLY | |
| 220 | 220 | * |---------------------------------------------------------------| |
| @@ -229,7 +229,7 @@ int ext4_fremove(const char *path); · 8 unmodified lines | ||
| 229 | 229 | * | a+ or ab+ or a+b O_RDWR|O_CREAT|O_APPEND | |
| 230 | 230 | * |---------------------------------------------------------------| |
| 231 | 231 | * |
| 232 | − * @return standard error code*/ | |
| 232 | + * @return standard error code*/ | |
| 233 | 233 | int ext4_fopen (ext4_file *f, const char *path, const char *flags); |
| 234 | 234 | |
| 235 | 235 | /**@brief File close function. |
| @@ -61,21 +61,21 @@ · 60 unmodified lines | ||
| 61 | 61 | /**@brief Mount point descrpitor.*/ |
| 62 | 62 | struct ext4_mountpoint { |
| 63 | 63 | |
| 64 | − /**@brief Mount point name (@ref ext4_mount)*/ | |
| 64 | + /**@brief Mount point name (@ref ext4_mount)*/ | |
| 65 | 65 | const char *name; |
| 66 | 66 | |
| 67 | − /**@brief Os dependent lock/unlock functions.*/ | |
| 67 | + /**@brief Os dependent lock/unlock functions.*/ | |
| 68 | 68 | struct ext4_lock *os_locks; |
| 69 | 69 | |
| 70 | − /**@brief Ext4 filesystem internals.*/ | |
| 70 | + /**@brief Ext4 filesystem internals.*/ | |
| 71 | 71 | struct ext4_fs fs; |
| 72 | 72 | |
| 73 | − /**@brief Dynamic alocation cache flag.*/ | |
| 73 | + /**@brief Dynamic alocation cache flag.*/ | |
| 74 | 74 | bool cache_dynamic; |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | 77 | /**@brief Block devices descriptor.*/ |
| 78 | −struct _ext4_devices { | |
| 78 | +struct _ext4_devices { | |
| 79 | 79 | |
| 80 | 80 | /**@brief Block device name (@ref ext4_device_register)*/ |
| 81 | 81 | const char *name; |
| @@ -87,11 +87,11 @@ struct _ext4_devices { · 5 unmodified lines | ||
| 87 | 87 | struct ext4_bcache *bc; |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | −/**@brief Block devices.*/ | |
| 91 | −struct _ext4_devices _bdevices[CONFIG_EXT4_BLOCKDEVS_COUNT]; | |
| 90 | +/**@brief Block devices.*/ | |
| 91 | +struct _ext4_devices _bdevices[CONFIG_EXT4_BLOCKDEVS_COUNT]; | |
| 92 | 92 | |
| 93 | 93 | |
| 94 | −/**@brief Mountpoints.*/ | |
| 94 | +/**@brief Mountpoints.*/ | |
| 95 | 95 | struct ext4_mountpoint _mp[CONFIG_EXT4_MOUNTPOINTS_COUNT]; |
| 96 | 96 | |
| 97 | 97 | |
| @@ -105,8 +105,8 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, · 7 unmodified lines | ||
| 105 | 105 | for (i = 0; i < CONFIG_EXT4_BLOCKDEVS_COUNT; ++i) { |
| 106 | 106 | if(!_bdevices[i].name){ |
| 107 | 107 | _bdevices[i].name = dev_name; |
| 108 | − _bdevices[i].bd = bd; | |
| 109 | − _bdevices[i].bc = bc; | |
| 108 | + _bdevices[i].bd = bd; | |
| 109 | + _bdevices[i].bc = bc; | |
| 110 | 110 | return EOK; |
| 111 | 111 | } |
| 112 | 112 | } |
| @@ -388,11 +388,11 @@ int ext4_mount(const char * dev_name, char *mount_point) · 275 unmodified lines | ||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | |
| 391 | −int ext4_umount(char *mount_point) | |
| 391 | +int ext4_umount(char *mount_point) | |
| 392 | 392 | { |
| 393 | − int i; | |
| 394 | − int r = EOK; | |
| 395 | − struct ext4_mountpoint *mp = 0; | |
| 393 | + int i; | |
| 394 | + int r = EOK; | |
| 395 | + struct ext4_mountpoint *mp = 0; | |
| 396 | 396 | |
| 397 | 397 | for (i = 0; i < CONFIG_EXT4_MOUNTPOINTS_COUNT; ++i) { |
| 398 | 398 | if(_mp[i].name){ |
| @@ -502,7 +502,7 @@ static bool ext4_parse_flags(const char *flags, uint32_t *file_flags) · 103 unmodified lines | ||
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | if(!strcmp(flags, "a") || !strcmp(flags, "ab")){ |
| 505 | − *file_flags = O_WRONLY | O_CREAT | O_APPEND ; | |
| 505 | + *file_flags = O_WRONLY | O_CREAT | O_APPEND; | |
| 506 | 506 | return true; |
| 507 | 507 | } |
| 508 | 508 | |
| @@ -531,10 +531,10 @@ static int ext4_generic_open (ext4_file *f, const char *path, · 22 unmodified lines | ||
| 531 | 531 | { |
| 532 | 532 | struct ext4_mountpoint *mp = ext4_get_mount(path); |
| 533 | 533 | struct ext4_directory_search_result result; |
| 534 | − struct ext4_inode_ref ref; | |
| 535 | − bool is_goal = false; | |
| 536 | − uint8_t inode_type = EXT4_DIRECTORY_FILETYPE_DIR; | |
| 537 | − int r = ENOENT; | |
| 534 | + struct ext4_inode_ref ref; | |
| 535 | + bool is_goal = false; | |
| 536 | + uint8_t inode_type = EXT4_DIRECTORY_FILETYPE_DIR; | |
| 537 | + int r = ENOENT; | |
| 538 | 538 | uint32_t next_inode; |
| 539 | 539 | |
| 540 | 540 | f->mp = 0; |
| @@ -585,7 +585,7 @@ static int ext4_generic_open (ext4_file *f, const char *path, · 44 unmodified lines | ||
| 585 | 585 | break; |
| 586 | 586 | |
| 587 | 587 | /*O_CREAT allows create new entry*/ |
| 588 | − struct ext4_inode_ref child_ref; | |
| 588 | + struct ext4_inode_ref child_ref; | |
| 589 | 589 | r = ext4_fs_alloc_inode(&mp->fs, &child_ref, is_goal ? !file_expect : true); |
| 590 | 590 | if(r != EOK) |
| 591 | 591 | break; |
| @@ -790,7 +790,7 @@ int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt) · 198 unmodified lines | ||
| 790 | 790 | uint32_t fblock_start; |
| 791 | 791 | uint32_t fblock_cnt; |
| 792 | 792 | struct ext4_block b; |
| 793 | − uint8_t *u8_buf = buf; | |
| 793 | + uint8_t *u8_buf = buf; | |
| 794 | 794 | struct ext4_inode_ref ref; |
| 795 | 795 | uint32_t sblock; |
| 796 | 796 | uint32_t sblock_end; |
| @@ -821,7 +821,7 @@ int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt) · 24 unmodified lines | ||
| 821 | 821 | |
| 822 | 822 | block_size = ext4_sb_get_block_size(&f->mp->fs.sb); |
| 823 | 823 | size = size > (f->fsize - f->fpos) ? (f->fsize - f->fpos) : size; |
| 824 | − sblock = (f->fpos) / block_size; | |
| 824 | + sblock = (f->fpos) / block_size; | |
| 825 | 825 | sblock_end = (f->fpos + size) / block_size; |
| 826 | 826 | u = (f->fpos) % block_size; |
| 827 | 827 | |
| @@ -916,13 +916,13 @@ int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt) · 88 unmodified lines | ||
| 916 | 916 | return r; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | −int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt) | |
| 919 | +int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt) | |
| 920 | 920 | { |
| 921 | 921 | int r = EOK; |
| 922 | 922 | uint32_t u; |
| 923 | 923 | uint32_t fblock; |
| 924 | 924 | struct ext4_block b; |
| 925 | − uint8_t *u8_buf = buf; | |
| 925 | + uint8_t *u8_buf = buf; | |
| 926 | 926 | struct ext4_inode_ref ref; |
| 927 | 927 | uint32_t sblock; |
| 928 | 928 | uint32_t sblock_end; |
| @@ -962,7 +962,7 @@ int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt) · 33 unmodified lines | ||
| 962 | 962 | if(f->fsize % block_size) |
| 963 | 963 | file_blocks++; |
| 964 | 964 | |
| 965 | − sblock = (f->fpos) / block_size; | |
| 965 | + sblock = (f->fpos) / block_size; | |
| 966 | 966 | |
| 967 | 967 | u = (f->fpos) % block_size; |
| 968 | 968 | |
| @@ -62,12 +62,12 @@ static uint32_t ext4_balloc_get_bgid_of_block(struct ext4_sblock *s, · 61 unmodified lines | ||
| 62 | 62 | uint32_t ext4_balloc_get_first_data_block_in_group(struct ext4_sblock *s, |
| 63 | 63 | struct ext4_block_group_ref * bg_ref) |
| 64 | 64 | { |
| 65 | − uint32_t block_group_count = ext4_block_group_cnt(s); | |
| 65 | + uint32_t block_group_count = ext4_block_group_cnt(s); | |
| 66 | 66 | uint32_t inode_table_first_block = |
| 67 | 67 | ext4_bg_get_inode_table_first_block(bg_ref->block_group, s); |
| 68 | − uint32_t block_size = ext4_sb_get_block_size(s); | |
| 68 | + uint32_t block_size = ext4_sb_get_block_size(s); | |
| 69 | 69 | |
| 70 | − uint16_t inode_size = ext4_get16(s, inode_size); | |
| 70 | + uint16_t inode_size = ext4_get16(s, inode_size); | |
| 71 | 71 | uint32_t inodes_per_group = ext4_get32(s, inodes_per_group); |
| 72 | 72 | |
| 73 | 73 | uint32_t inode_table_bytes; |
| @@ -77,7 +77,7 @@ uint32_t ext4_balloc_get_first_data_block_in_group(struct ext4_sblock *s, · 3 unmodified lines | ||
| 77 | 77 | inode_table_bytes = inodes_per_group * inode_size; |
| 78 | 78 | } else { |
| 79 | 79 | /* Last block group could be smaller */ |
| 80 | − uint32_t inodes_count_total = ext4_get32(s, inodes_count); | |
| 80 | + uint32_t inodes_count_total = ext4_get32(s, inodes_count); | |
| 81 | 81 | inode_table_bytes = |
| 82 | 82 | (inodes_count_total - ((block_group_count - 1) * |
| 83 | 83 | inodes_per_group)) * inode_size; |
| @@ -93,12 +93,12 @@ uint32_t ext4_balloc_get_first_data_block_in_group(struct ext4_sblock *s, · 9 unmodified lines | ||
| 93 | 93 | |
| 94 | 94 | int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref, uint32_t baddr) |
| 95 | 95 | { |
| 96 | − struct ext4_fs *fs = inode_ref->fs; | |
| 97 | − struct ext4_sblock *sb = &fs->sb; | |
| 96 | + struct ext4_fs *fs = inode_ref->fs; | |
| 97 | + struct ext4_sblock *sb = &fs->sb; | |
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, baddr); |
| 101 | − uint32_t index_in_group = ext4_fs_baddr2_index_in_group(sb, baddr); | |
| 101 | + uint32_t index_in_group = ext4_fs_baddr2_index_in_group(sb, baddr); | |
| 102 | 102 | |
| 103 | 103 | /* Load block group reference */ |
| 104 | 104 | struct ext4_block_group_ref bg_ref; |
| @@ -110,7 +110,7 @@ int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref, uint32_t baddr) · 5 unmodified lines | ||
| 110 | 110 | uint32_t bitmap_block_addr = |
| 111 | 111 | ext4_bg_get_block_bitmap(bg_ref.block_group, sb); |
| 112 | 112 | |
| 113 | − struct ext4_block bitmap_block; | |
| 113 | + struct ext4_block bitmap_block; | |
| 114 | 114 | |
| 115 | 115 | rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr); |
| 116 | 116 | if (rc != EOK) |
| @@ -187,7 +187,7 @@ int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref, uint32_t first, · 70 unmodified lines | ||
| 187 | 187 | uint32_t bitmap_block_addr = |
| 188 | 188 | ext4_bg_get_block_bitmap(bg_ref.block_group, sb); |
| 189 | 189 | |
| 190 | − struct ext4_block bitmap_block; | |
| 190 | + struct ext4_block bitmap_block; | |
| 191 | 191 | |
| 192 | 192 | rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr); |
| 193 | 193 | if (rc != EOK) |
| @@ -315,7 +315,7 @@ int ext4_balloc_alloc_block(struct ext4_inode_ref *inode_ref, · 121 unmodified lines | ||
| 315 | 315 | uint32_t bitmap_block_addr; |
| 316 | 316 | uint32_t rel_block_idx = 0; |
| 317 | 317 | |
| 318 | − struct ext4_block bitmap_block; | |
| 318 | + struct ext4_block bitmap_block; | |
| 319 | 319 | |
| 320 | 320 | /* Find GOAL */ |
| 321 | 321 | uint32_t goal = ext4_balloc_find_goal(inode_ref); |
| @@ -550,7 +550,7 @@ int ext4_balloc_try_alloc_block(struct ext4_inode_ref *inode_ref, · 228 unmodified lines | ||
| 550 | 550 | ext4_bg_get_block_bitmap(bg_ref.block_group, sb); |
| 551 | 551 | |
| 552 | 552 | |
| 553 | − struct ext4_block bitmap_block; | |
| 553 | + struct ext4_block bitmap_block; | |
| 554 | 554 | |
| 555 | 555 | rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr); |
| 556 | 556 | if (rc != EOK) |
| @@ -49,39 +49,39 @@ · 48 unmodified lines | ||
| 49 | 49 | #include <stdbool.h> |
| 50 | 50 | |
| 51 | 51 | |
| 52 | −/**@brief Get first datablock in block group | |
| 53 | − * @param s superblock descriptor | |
| 54 | − * @param bg_ref block group reference | |
| 55 | − * @return block id of the first datablock in block group*/ | |
| 52 | +/**@brief Get first datablock in block group | |
| 53 | + * @param s superblock descriptor | |
| 54 | + * @param bg_ref block group reference | |
| 55 | + * @return block id of the first datablock in block group*/ | |
| 56 | 56 | uint32_t ext4_balloc_get_first_data_block_in_group(struct ext4_sblock *s, |
| 57 | 57 | struct ext4_block_group_ref * bg_ref); |
| 58 | 58 | |
| 59 | −/**@brief Free block from inode. | |
| 60 | − * @param inode_ref inode reference | |
| 61 | − * @param baddr block address | |
| 62 | − * @return standard error code*/ | |
| 59 | +/**@brief Free block from inode. | |
| 60 | + * @param inode_ref inode reference | |
| 61 | + * @param baddr block address | |
| 62 | + * @return standard error code*/ | |
| 63 | 63 | int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref, |
| 64 | 64 | uint32_t baddr); |
| 65 | 65 | |
| 66 | −/**@brief Free blocks from inode. | |
| 67 | − * @param inode_ref inode reference | |
| 68 | − * @param baddr block address | |
| 69 | − * @return standard error code*/ | |
| 66 | +/**@brief Free blocks from inode. | |
| 67 | + * @param inode_ref inode reference | |
| 68 | + * @param baddr block address | |
| 69 | + * @return standard error code*/ | |
| 70 | 70 | int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref, |
| 71 | 71 | uint32_t first, uint32_t count); |
| 72 | 72 | |
| 73 | −/**@brief Allocate block procedure. | |
| 74 | − * @param inode_ref inode reference | |
| 75 | − * @param baddr allocated block address | |
| 76 | − * @return standard error code*/ | |
| 73 | +/**@brief Allocate block procedure. | |
| 74 | + * @param inode_ref inode reference | |
| 75 | + * @param baddr allocated block address | |
| 76 | + * @return standard error code*/ | |
| 77 | 77 | int ext4_balloc_alloc_block(struct ext4_inode_ref *inode_ref, |
| 78 | 78 | uint32_t *baddr); |
| 79 | 79 | |
| 80 | −/**@brief Try allocate selected block. | |
| 81 | − * @param inode_ref inode reference | |
| 82 | − * @param baddr block address to allocate | |
| 83 | − * @param free if baddr is not allocated | |
| 84 | − * @return standard error code*/ | |
| 80 | +/**@brief Try allocate selected block. | |
| 81 | + * @param inode_ref inode reference | |
| 82 | + * @param baddr block address to allocate | |
| 83 | + * @param free if baddr is not allocated | |
| 84 | + * @return standard error code*/ | |
| 85 | 85 | int ext4_balloc_try_alloc_block(struct ext4_inode_ref *inode_ref, |
| 86 | 86 | uint32_t baddr, bool *free); |
| 87 | 87 | |
| @@ -43,7 +43,7 @@ · 42 unmodified lines | ||
| 43 | 43 | #include <stdlib.h> |
| 44 | 44 | |
| 45 | 45 | |
| 46 | −int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, | |
| 46 | +int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, | |
| 47 | 47 | uint32_t itemsize) |
| 48 | 48 | { |
| 49 | 49 | ext4_assert(bc && cnt && itemsize); |
| @@ -104,7 +104,7 @@ int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, · 54 unmodified lines | ||
| 104 | 104 | return ENOMEM; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | −int ext4_bcache_fini_dynamic(struct ext4_bcache *bc) | |
| 107 | +int ext4_bcache_fini_dynamic(struct ext4_bcache *bc) | |
| 108 | 108 | { |
| 109 | 109 | if(bc->refctr) |
| 110 | 110 | free(bc->refctr); |
| @@ -195,8 +195,8 @@ int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, · 84 unmodified lines | ||
| 195 | 195 | |
| 196 | 196 | if(cache_id != bc->cnt){ |
| 197 | 197 | /*There was unreferenced block*/ |
| 198 | − bc->lba[cache_id] = b->lb_id; | |
| 199 | − bc->refctr[cache_id] = 1; | |
| 198 | + bc->lba[cache_id] = b->lb_id; | |
| 199 | + bc->refctr[cache_id] = 1; | |
| 200 | 200 | bc->lru_id[cache_id] = ++bc->lru_ctr; |
| 201 | 201 | |
| 202 | 202 | /*Set valid cache data and id*/ |
| @@ -245,8 +245,8 @@ int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b, · 42 unmodified lines | ||
| 245 | 245 | if(!bc->refctr[b->cache_id] && !bc->free_delay[b->cache_id]) |
| 246 | 246 | bc->ref_blocks--; |
| 247 | 247 | |
| 248 | − b->lb_id = 0; | |
| 249 | − b->data = 0; | |
| 248 | + b->lb_id = 0; | |
| 249 | + b->data = 0; | |
| 250 | 250 | b->cache_id = 0; |
| 251 | 251 | |
| 252 | 252 | return EOK; |
| @@ -42,110 +42,110 @@ · 41 unmodified lines | ||
| 42 | 42 | #include <stdint.h> |
| 43 | 43 | #include <stdbool.h> |
| 44 | 44 | |
| 45 | −/**@brief Single block descriptor.*/ | |
| 46 | −struct ext4_block { | |
| 47 | − /**@brief Dirty flag.*/ | |
| 48 | − bool dirty; | |
| 45 | +/**@brief Single block descriptor.*/ | |
| 46 | +struct ext4_block { | |
| 47 | + /**@brief Dirty flag.*/ | |
| 48 | + bool dirty; | |
| 49 | 49 | |
| 50 | − /**@brief Logical block ID*/ | |
| 51 | − uint64_t lb_id; | |
| 50 | + /**@brief Logical block ID*/ | |
| 51 | + uint64_t lb_id; | |
| 52 | 52 | |
| 53 | 53 | /**@brief Cache id*/ |
| 54 | − uint32_t cache_id; | |
| 54 | + uint32_t cache_id; | |
| 55 | 55 | |
| 56 | − /**@brief Data buffer.*/ | |
| 57 | − uint8_t *data; | |
| 56 | + /**@brief Data buffer.*/ | |
| 57 | + uint8_t *data; | |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 | |
| 61 | −/**@brief Block cache descriptor.*/ | |
| 62 | −struct ext4_bcache { | |
| 61 | +/**@brief Block cache descriptor.*/ | |
| 62 | +struct ext4_bcache { | |
| 63 | 63 | |
| 64 | − /**@brief Item count in block cache*/ | |
| 65 | − uint32_t cnt; | |
| 64 | + /**@brief Item count in block cache*/ | |
| 65 | + uint32_t cnt; | |
| 66 | 66 | |
| 67 | − /**@brief Item size in block cache*/ | |
| 68 | − uint32_t itemsize; | |
| 67 | + /**@brief Item size in block cache*/ | |
| 68 | + uint32_t itemsize; | |
| 69 | 69 | |
| 70 | − /**@brief Last recently used counter.*/ | |
| 71 | − uint32_t lru_ctr; | |
| 70 | + /**@brief Last recently used counter.*/ | |
| 71 | + uint32_t lru_ctr; | |
| 72 | 72 | |
| 73 | − /**@brief Reference count table (cnt).*/ | |
| 74 | − uint32_t *refctr; | |
| 73 | + /**@brief Reference count table (cnt).*/ | |
| 74 | + uint32_t *refctr; | |
| 75 | 75 | |
| 76 | − /**@brief Last recently used ID table (cnt)*/ | |
| 77 | − uint32_t *lru_id; | |
| 76 | + /**@brief Last recently used ID table (cnt)*/ | |
| 77 | + uint32_t *lru_id; | |
| 78 | 78 | |
| 79 | − /**@brief Free delay mode table (cnt)*/ | |
| 80 | − uint8_t *free_delay; | |
| 79 | + /**@brief Free delay mode table (cnt)*/ | |
| 80 | + uint8_t *free_delay; | |
| 81 | 81 | |
| 82 | − /**@brief Logical block table (cnt).*/ | |
| 83 | − uint64_t *lba; | |
| 82 | + /**@brief Logical block table (cnt).*/ | |
| 83 | + uint64_t *lba; | |
| 84 | 84 | |
| 85 | − /**@brief Cache data buffers (cnt * itemsize)*/ | |
| 86 | − uint8_t *data; | |
| 85 | + /**@brief Cache data buffers (cnt * itemsize)*/ | |
| 86 | + uint8_t *data; | |
| 87 | 87 | |
| 88 | − /**@brief Currently referenced datablocks*/ | |
| 89 | − uint32_t ref_blocks; | |
| 88 | + /**@brief Currently referenced datablocks*/ | |
| 89 | + uint32_t ref_blocks; | |
| 90 | 90 | |
| 91 | − /**@brief Maximum referenced datablocks*/ | |
| 92 | − uint32_t max_ref_blocks; | |
| 91 | + /**@brief Maximum referenced datablocks*/ | |
| 92 | + uint32_t max_ref_blocks; | |
| 93 | 93 | |
| 94 | 94 | }; |
| 95 | 95 | |
| 96 | −/**@brief Static initializer of block cache structure.*/ | |
| 96 | +/**@brief Static initializer of block cache structure.*/ | |
| 97 | 97 | #define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize) \ |
| 98 | − static uint32_t __name##_refctr[(__cnt)]; \ | |
| 99 | − static uint32_t __name##_lru_id[(__cnt)]; \ | |
| 100 | − static uint8_t __name##_free_delay[(__cnt)]; \ | |
| 101 | − static uint64_t __name##_lba[(__cnt)]; \ | |
| 102 | − static uint8_t __name##_data[(__cnt) * (__itemsize)]; \ | |
| 103 | − static struct ext4_bcache __name = { \ | |
| 104 | − .cnt = __cnt, \ | |
| 98 | + static uint32_t __name##_refctr[(__cnt)]; \ | |
| 99 | + static uint32_t __name##_lru_id[(__cnt)]; \ | |
| 100 | + static uint8_t __name##_free_delay[(__cnt)]; \ | |
| 101 | + static uint64_t __name##_lba[(__cnt)]; \ | |
| 102 | + static uint8_t __name##_data[(__cnt) * (__itemsize)]; \ | |
| 103 | + static struct ext4_bcache __name = { \ | |
| 104 | + .cnt = __cnt, \ | |
| 105 | 105 | .itemsize = __itemsize, \ |
| 106 | 106 | .lru_ctr = 0, \ |
| 107 | − .refctr = __name##_refctr, \ | |
| 107 | + .refctr = __name##_refctr, \ | |
| 108 | 108 | .lru_id = __name##_lru_id, \ |
| 109 | − .lba = __name##_lba, \ | |
| 109 | + .lba = __name##_lba, \ | |
| 110 | 110 | .free_delay= __name##_free_delay, \ |
| 111 | − .data = __name##_data, \ | |
| 111 | + .data = __name##_data, \ | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | −/**@brief Dynamic initialization of block cache. | |
| 116 | − * @param bc block cache descriptor | |
| 117 | − * @param cnt items count in block cache | |
| 118 | − * @param itemsize single item size (in bytes) | |
| 119 | − * @return standard error code*/ | |
| 120 | −int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, | |
| 115 | +/**@brief Dynamic initialization of block cache. | |
| 116 | + * @param bc block cache descriptor | |
| 117 | + * @param cnt items count in block cache | |
| 118 | + * @param itemsize single item size (in bytes) | |
| 119 | + * @return standard error code*/ | |
| 120 | +int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, | |
| 121 | 121 | uint32_t itemsize); |
| 122 | 122 | |
| 123 | −/**@brief Dynamic de-initialization of block cache. | |
| 124 | − * @param bc block cache descriptor | |
| 125 | − * @return standard error code*/ | |
| 126 | −int ext4_bcache_fini_dynamic(struct ext4_bcache *bc); | |
| 123 | +/**@brief Dynamic de-initialization of block cache. | |
| 124 | + * @param bc block cache descriptor | |
| 125 | + * @return standard error code*/ | |
| 126 | +int ext4_bcache_fini_dynamic(struct ext4_bcache *bc); | |
| 127 | 127 | |
| 128 | −/**@brief Allocate block from block cache memory. | |
| 128 | +/**@brief Allocate block from block cache memory. | |
| 129 | 129 | * Unreferenced block allocation is based on LRU |
| 130 | 130 | * (Last Recently Used) algorithm. |
| 131 | − * @param bc block cache descriptor | |
| 132 | − * @param b block to alloc | |
| 133 | − * @param is_new block is new (needs to be read) | |
| 131 | + * @param bc block cache descriptor | |
| 132 | + * @param b block to alloc | |
| 133 | + * @param is_new block is new (needs to be read) | |
| 134 | 134 | * @return standard error code*/ |
| 135 | 135 | int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, |
| 136 | 136 | bool *is_new); |
| 137 | 137 | |
| 138 | −/**@brief Free block from cache memory (decrement reference counter). | |
| 139 | − * @param bc block cache descriptor | |
| 140 | − * @param b block to free | |
| 138 | +/**@brief Free block from cache memory (decrement reference counter). | |
| 139 | + * @param bc block cache descriptor | |
| 140 | + * @param b block to free | |
| 141 | 141 | * @return standard error code*/ |
| 142 | 142 | int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b, |
| 143 | 143 | uint8_t free_delay); |
| 144 | 144 | |
| 145 | 145 | |
| 146 | −/**@brief Return a full status of block cache. | |
| 147 | − * @param bc block cache descriptor | |
| 148 | − * @return full status*/ | |
| 146 | +/**@brief Return a full status of block cache. | |
| 147 | + * @param bc block cache descriptor | |
| 148 | + * @return full status*/ | |
| 149 | 149 | bool ext4_bcache_is_full(struct ext4_bcache *bc); |
| 150 | 150 | |
| 151 | 151 | #endif /* EXT4_BCACHE_H_ */ |
| @@ -42,50 +42,50 @@ · 41 unmodified lines | ||
| 42 | 42 | #include <stdint.h> |
| 43 | 43 | #include <stdbool.h> |
| 44 | 44 | |
| 45 | −/**@brief Set bitmap bit. | |
| 46 | − * @param bmap bitmap | |
| 47 | − * @param bit bit to set*/ | |
| 45 | +/**@brief Set bitmap bit. | |
| 46 | + * @param bmap bitmap | |
| 47 | + * @param bit bit to set*/ | |
| 48 | 48 | static inline void ext4_bmap_bit_set(uint8_t *bmap, uint32_t bit) |
| 49 | 49 | { |
| 50 | 50 | *(bmap + (bit >> 3)) |= (1 << (bit & 7)); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | −/**@brief Clear bitmap bit. | |
| 54 | − * @param bmap bitmap buffer | |
| 55 | − * @param bit bit to clear*/ | |
| 53 | +/**@brief Clear bitmap bit. | |
| 54 | + * @param bmap bitmap buffer | |
| 55 | + * @param bit bit to clear*/ | |
| 56 | 56 | static inline void ext4_bmap_bit_clr(uint8_t *bmap, uint32_t bit) |
| 57 | 57 | { |
| 58 | 58 | *(bmap + (bit >> 3)) &= ~(1 << (bit & 7)); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | −/**@brief Check if the bitmap bit is set. | |
| 63 | − * @param bmap bitmap buffer | |
| 64 | − * @param bit bit to check*/ | |
| 62 | +/**@brief Check if the bitmap bit is set. | |
| 63 | + * @param bmap bitmap buffer | |
| 64 | + * @param bit bit to check*/ | |
| 65 | 65 | static inline bool ext4_bmap_is_bit_set(uint8_t *bmap, uint32_t bit) |
| 66 | 66 | { |
| 67 | 67 | return (*(bmap + (bit >> 3)) & (1 << (bit & 7))); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | −/**@brief Check if the bitmap bit is clear. | |
| 71 | − * @param bmap bitmap buffer | |
| 72 | − * @param bit bit to check*/ | |
| 70 | +/**@brief Check if the bitmap bit is clear. | |
| 71 | + * @param bmap bitmap buffer | |
| 72 | + * @param bit bit to check*/ | |
| 73 | 73 | static inline bool ext4_bmap_is_bit_clr(uint8_t *bmap, uint32_t bit) |
| 74 | 74 | { |
| 75 | 75 | return !ext4_bmap_is_bit_set(bmap, bit); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | −/**@brief Free range of bits in bitmap. | |
| 79 | − * @param bmap bitmap buffer | |
| 80 | − * @param sbit start bit | |
| 81 | − * @param bcnt bit count*/ | |
| 78 | +/**@brief Free range of bits in bitmap. | |
| 79 | + * @param bmap bitmap buffer | |
| 80 | + * @param sbit start bit | |
| 81 | + * @param bcnt bit count*/ | |
| 82 | 82 | void ext4_bmap_bits_free(uint8_t *bmap, uint32_t sbit, uint32_t bcnt); |
| 83 | 83 | |
| 84 | −/**@brief Find first clear bit in bitmap. | |
| 85 | − * @param sbit start bit of search | |
| 86 | − * @param ebit end bit of search | |
| 87 | − * @param bit_id output parameter (first free bit) | |
| 88 | − * @return standard error code*/ | |
| 84 | +/**@brief Find first clear bit in bitmap. | |
| 85 | + * @param sbit start bit of search | |
| 86 | + * @param ebit end bit of search | |
| 87 | + * @param bit_id output parameter (first free bit) | |
| 88 | + * @return standard error code*/ | |
| 89 | 89 | int ext4_bmap_bit_find_clr(uint8_t *bmap, uint32_t sbit, uint32_t ebit, |
| 90 | 90 | uint32_t *bit_id); |
| 91 | 91 | |
| @@ -44,7 +44,7 @@ · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | −int ext4_block_init(struct ext4_blockdev *bdev) | |
| 47 | +int ext4_block_init(struct ext4_blockdev *bdev) | |
| 48 | 48 | { |
| 49 | 49 | int rc; |
| 50 | 50 | ext4_assert(bdev); |
| @@ -58,7 +58,7 @@ int ext4_block_init(struct ext4_blockdev *bdev) · 7 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | bdev->flags |= EXT4_BDEV_INITIALIZED; |
| 60 | 60 | |
| 61 | − return EOK; | |
| 61 | + return EOK; | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | int ext4_block_bind_bcache(struct ext4_blockdev *bdev, struct ext4_bcache *bc) |
| @@ -68,7 +68,7 @@ int ext4_block_bind_bcache(struct ext4_blockdev *bdev, struct ext4_bcache *bc) · 3 unmodified lines | ||
| 68 | 68 | return EOK; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | −void ext4_block_set_lb_size(struct ext4_blockdev *bdev, uint64_t lb_bsize) | |
| 71 | +void ext4_block_set_lb_size(struct ext4_blockdev *bdev, uint64_t lb_bsize) | |
| 72 | 72 | { |
| 73 | 73 | /*Logical block size has to be multiply of physical */ |
| 74 | 74 | ext4_assert(!(lb_bsize % bdev->ph_bsize)); |
| @@ -78,7 +78,7 @@ void ext4_block_set_lb_size(struct ext4_blockdev *bdev, uint64_t lb_bsize) · 3 unmodified lines | ||
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | −int ext4_block_fini(struct ext4_blockdev *bdev) | |
| 81 | +int ext4_block_fini(struct ext4_blockdev *bdev) | |
| 82 | 82 | { |
| 83 | 83 | ext4_assert(bdev); |
| 84 | 84 | |
| @@ -89,7 +89,7 @@ int ext4_block_fini(struct ext4_blockdev *bdev) · 4 unmodified lines | ||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | −int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, | |
| 92 | +int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, | |
| 93 | 93 | uint64_t lba) |
| 94 | 94 | { |
| 95 | 95 | uint64_t pba; |
| @@ -164,7 +164,7 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, · 68 unmodified lines | ||
| 164 | 164 | return EOK; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | −int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b) | |
| 167 | +int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b) | |
| 168 | 168 | { |
| 169 | 169 | uint64_t pba; |
| 170 | 170 | uint32_t pb_cnt; |
| @@ -206,7 +206,7 @@ int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b) · 35 unmodified lines | ||
| 206 | 206 | return EOK; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | −int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf, | |
| 209 | +int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf, | |
| 210 | 210 | uint64_t lba, uint32_t cnt) |
| 211 | 211 | { |
| 212 | 212 | uint64_t pba; |
| @@ -221,7 +221,7 @@ int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf, · 8 unmodified lines | ||
| 221 | 221 | return bdev->bread(bdev, buf, pba, pb_cnt * cnt); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | −int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, | |
| 224 | +int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, | |
| 225 | 225 | uint64_t lba, uint32_t cnt) |
| 226 | 226 | { |
| 227 | 227 | uint64_t pba; |
| @@ -238,7 +238,7 @@ int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, · 10 unmodified lines | ||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
| 241 | −int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, | |
| 241 | +int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, | |
| 242 | 242 | const void *buf, uint32_t len) |
| 243 | 243 | { |
| 244 | 244 | uint64_t block_idx; |
| @@ -247,7 +247,7 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, · 2 unmodified lines | ||
| 247 | 247 | uint32_t unalg; |
| 248 | 248 | int r = EOK; |
| 249 | 249 | |
| 250 | − const uint8_t *p = (void *)buf; | |
| 250 | + const uint8_t *p = (void *)buf; | |
| 251 | 251 | |
| 252 | 252 | ext4_assert(bdev && buf); |
| 253 | 253 | |
| @@ -258,7 +258,7 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, · 4 unmodified lines | ||
| 258 | 258 | block_end = block_idx + len / bdev->ph_bsize; |
| 259 | 259 | |
| 260 | 260 | if(!(block_end < bdev->ph_bcnt)) |
| 261 | − return EINVAL; /*Ups. Out of range operation*/ | |
| 261 | + return EINVAL; /*Ups. Out of range operation*/ | |
| 262 | 262 | |
| 263 | 263 | /*OK lets deal with the first possible unaligned block*/ |
| 264 | 264 | unalg = (off & (bdev->ph_bsize - 1)); |
| @@ -317,7 +317,7 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, · 52 unmodified lines | ||
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | |
| 320 | −int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, | |
| 320 | +int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, | |
| 321 | 321 | uint32_t len) |
| 322 | 322 | { |
| 323 | 323 | uint64_t block_idx; |
| @@ -326,7 +326,7 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, · 2 unmodified lines | ||
| 326 | 326 | uint32_t unalg; |
| 327 | 327 | int r = EOK; |
| 328 | 328 | |
| 329 | − uint8_t *p = (void *)buf; | |
| 329 | + uint8_t *p = (void *)buf; | |
| 330 | 330 | |
| 331 | 331 | ext4_assert(bdev && buf); |
| 332 | 332 | |
| @@ -337,7 +337,7 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, · 4 unmodified lines | ||
| 337 | 337 | block_end = block_idx + len / bdev->ph_bsize; |
| 338 | 338 | |
| 339 | 339 | if(!(block_end < bdev->ph_bcnt)) |
| 340 | − return EINVAL; /*Ups. Out of range operation*/ | |
| 340 | + return EINVAL; /*Ups. Out of range operation*/ | |
| 341 | 341 | |
| 342 | 342 | /*OK lets deal with the first possible unaligned block*/ |
| 343 | 343 | unalg = (off & (bdev->ph_bsize - 1)); |
| @@ -365,7 +365,7 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, · 21 unmodified lines | ||
| 365 | 365 | if(r != EOK) |
| 366 | 366 | return r; |
| 367 | 367 | |
| 368 | − p += bdev->ph_bsize * blen; | |
| 368 | + p += bdev->ph_bsize * blen; | |
| 369 | 369 | len -= bdev->ph_bsize * blen; |
| 370 | 370 | |
| 371 | 371 | block_idx += blen; |
| @@ -383,7 +383,7 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, · 11 unmodified lines | ||
| 383 | 383 | return r; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | −int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, | |
| 386 | +int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, | |
| 387 | 387 | uint8_t on_off) |
| 388 | 388 | { |
| 389 | 389 | int r; |
| @@ -44,73 +44,73 @@ · 43 unmodified lines | ||
| 44 | 44 | #include <stdbool.h> |
| 45 | 45 | #include <stdint.h> |
| 46 | 46 | |
| 47 | −/**@brief Initialization status flag*/ | |
| 48 | −#define EXT4_BDEV_INITIALIZED (1 << 0) | |
| 47 | +/**@brief Initialization status flag*/ | |
| 48 | +#define EXT4_BDEV_INITIALIZED (1 << 0) | |
| 49 | 49 | |
| 50 | 50 | |
| 51 | −/**@brief Definiton of the simple block device.*/ | |
| 52 | −struct ext4_blockdev { | |
| 51 | +/**@brief Definiton of the simple block device.*/ | |
| 52 | +struct ext4_blockdev { | |
| 53 | 53 | |
| 54 | − /**@brief Open device function | |
| 55 | − * @param bdev block device.*/ | |
| 56 | − int (*open)(struct ext4_blockdev *bdev); | |
| 54 | + /**@brief Open device function | |
| 55 | + * @param bdev block device.*/ | |
| 56 | + int (*open)(struct ext4_blockdev *bdev); | |
| 57 | 57 | |
| 58 | − /**@brief Block read function. | |
| 59 | − * @param bdev block device | |
| 60 | − * @param buf output buffer | |
| 61 | − * @param blk_id block id | |
| 62 | − * @param blk_cnt block count*/ | |
| 63 | − int (*bread)(struct ext4_blockdev *bdev, void *buf, | |
| 58 | + /**@brief Block read function. | |
| 59 | + * @param bdev block device | |
| 60 | + * @param buf output buffer | |
| 61 | + * @param blk_id block id | |
| 62 | + * @param blk_cnt block count*/ | |
| 63 | + int (*bread)(struct ext4_blockdev *bdev, void *buf, | |
| 64 | 64 | uint64_t blk_id, uint32_t blk_cnt); |
| 65 | 65 | |
| 66 | − /**@brief Block write function. | |
| 67 | − * @param buf input buffer | |
| 68 | − * @param blk_id block id | |
| 69 | − * @param blk_cnt block count*/ | |
| 70 | − int (*bwrite)(struct ext4_blockdev *bdev, const void *buf, | |
| 66 | + /**@brief Block write function. | |
| 67 | + * @param buf input buffer | |
| 68 | + * @param blk_id block id | |
| 69 | + * @param blk_cnt block count*/ | |
| 70 | + int (*bwrite)(struct ext4_blockdev *bdev, const void *buf, | |
| 71 | 71 | uint64_t blk_id, uint32_t blk_cnt); |
| 72 | 72 | |
| 73 | − /**@brief Close device function. | |
| 74 | − * @param bdev block device.*/ | |
| 75 | − int (*close)(struct ext4_blockdev *bdev); | |
| 73 | + /**@brief Close device function. | |
| 74 | + * @param bdev block device.*/ | |
| 75 | + int (*close)(struct ext4_blockdev *bdev); | |
| 76 | 76 | |
| 77 | 77 | /**@brief Block cache.*/ |
| 78 | 78 | struct ext4_bcache *bc; |
| 79 | 79 | |
| 80 | − /**@brief Block size (bytes): physical*/ | |
| 81 | − uint32_t ph_bsize; | |
| 80 | + /**@brief Block size (bytes): physical*/ | |
| 81 | + uint32_t ph_bsize; | |
| 82 | 82 | |
| 83 | − /**@brief Block count: physical.*/ | |
| 84 | − uint64_t ph_bcnt; | |
| 83 | + /**@brief Block count: physical.*/ | |
| 84 | + uint64_t ph_bcnt; | |
| 85 | 85 | |
| 86 | − /**@brief Block size buffer: physical.*/ | |
| 87 | − uint8_t *ph_bbuf; | |
| 86 | + /**@brief Block size buffer: physical.*/ | |
| 87 | + uint8_t *ph_bbuf; | |
| 88 | 88 | |
| 89 | − /**@brief Block size (bytes) logical*/ | |
| 90 | − uint32_t lg_bsize; | |
| 89 | + /**@brief Block size (bytes) logical*/ | |
| 90 | + uint32_t lg_bsize; | |
| 91 | 91 | |
| 92 | − /**@brief Block count: phisical.*/ | |
| 93 | − uint64_t lg_bcnt; | |
| 92 | + /**@brief Block count: phisical.*/ | |
| 93 | + uint64_t lg_bcnt; | |
| 94 | 94 | |
| 95 | − /**@brief Flags of te block device.*/ | |
| 96 | − uint8_t flags; | |
| 95 | + /**@brief Flags of te block device.*/ | |
| 96 | + uint8_t flags; | |
| 97 | 97 | |
| 98 | 98 | /**@brief Cache flush delay mode flag.*/ |
| 99 | − uint8_t cache_flush_delay; | |
| 99 | + uint8_t cache_flush_delay; | |
| 100 | 100 | |
| 101 | 101 | /**@brief Physical read counter*/ |
| 102 | − uint32_t bread_ctr; | |
| 102 | + uint32_t bread_ctr; | |
| 103 | 103 | |
| 104 | 104 | /**@brief Physical write counter*/ |
| 105 | − uint32_t bwrite_ctr; | |
| 105 | + uint32_t bwrite_ctr; | |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | |
| 109 | −/**@brief Static initialization fo the block device.*/ | |
| 109 | +/**@brief Static initialization fo the block device.*/ | |
| 110 | 110 | #define EXT4_BLOCKDEV_STATIC_INSTANCE(__name, __bsize, __bcnt, __open, \ |
| 111 | − __bread, __bwrite, __close) \ | |
| 112 | − static uint8_t __name##_ph_bbuf[(__bsize)]; \ | |
| 113 | − static struct ext4_blockdev __name = { \ | |
| 111 | + __bread, __bwrite, __close) \ | |
| 112 | + static uint8_t __name##_ph_bbuf[(__bsize)]; \ | |
| 113 | + static struct ext4_blockdev __name = { \ | |
| 114 | 114 | .open = __open, \ |
| 115 | 115 | .bread = __bread, \ |
| 116 | 116 | .bwrite = __bwrite, \ |
| @@ -120,93 +120,93 @@ struct ext4_blockdev { · 3 unmodified lines | ||
| 120 | 120 | .ph_bbuf = __name##_ph_bbuf, \ |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | −/**@brief Block device initialization. | |
| 124 | − * @param bdev block device descriptor | |
| 125 | − * @param bg_bsize logical block size | |
| 126 | − * @param bdev block device descriptor | |
| 127 | − * @return standard error code*/ | |
| 128 | −int ext4_block_init(struct ext4_blockdev *bdev); | |
| 123 | +/**@brief Block device initialization. | |
| 124 | + * @param bdev block device descriptor | |
| 125 | + * @param bg_bsize logical block size | |
| 126 | + * @param bdev block device descriptor | |
| 127 | + * @return standard error code*/ | |
| 128 | +int ext4_block_init(struct ext4_blockdev *bdev); | |
| 129 | 129 | |
| 130 | 130 | |
| 131 | −/**@brief Binds a bcache to block device. | |
| 132 | − * @param bdev block device descriptor | |
| 133 | − * @param bc block cache descriptor | |
| 134 | − * @return standard error code*/ | |
| 131 | +/**@brief Binds a bcache to block device. | |
| 132 | + * @param bdev block device descriptor | |
| 133 | + * @param bc block cache descriptor | |
| 134 | + * @return standard error code*/ | |
| 135 | 135 | int ext4_block_bind_bcache(struct ext4_blockdev *bdev, |
| 136 | 136 | struct ext4_bcache *bc); |
| 137 | 137 | |
| 138 | −/**@brief Close block device | |
| 139 | − * @param bdev block device descriptor | |
| 140 | − * @return standard error code*/ | |
| 141 | −int ext4_block_fini(struct ext4_blockdev *bdev); | |
| 138 | +/**@brief Close block device | |
| 139 | + * @param bdev block device descriptor | |
| 140 | + * @return standard error code*/ | |
| 141 | +int ext4_block_fini(struct ext4_blockdev *bdev); | |
| 142 | 142 | |
| 143 | 143 | |
| 144 | −/**@brief Set logical block size in block device. | |
| 145 | − * @param bdev block device descriptor | |
| 146 | − * @param lb_size ligical block size (in bytes) | |
| 147 | − * @return standard error code*/ | |
| 148 | −void ext4_block_set_lb_size(struct ext4_blockdev *bdev, | |
| 144 | +/**@brief Set logical block size in block device. | |
| 145 | + * @param bdev block device descriptor | |
| 146 | + * @param lb_size ligical block size (in bytes) | |
| 147 | + * @return standard error code*/ | |
| 148 | +void ext4_block_set_lb_size(struct ext4_blockdev *bdev, | |
| 149 | 149 | uint64_t lb_bsize); |
| 150 | 150 | |
| 151 | −/**@brief Block get function (through cache). | |
| 152 | − * @param bdev block device descriptor | |
| 153 | − * @param b block descriptor | |
| 154 | − * @param lba logical block address | |
| 155 | − * @return standard error code*/ | |
| 156 | −int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, | |
| 151 | +/**@brief Block get function (through cache). | |
| 152 | + * @param bdev block device descriptor | |
| 153 | + * @param b block descriptor | |
| 154 | + * @param lba logical block address | |
| 155 | + * @return standard error code*/ | |
| 156 | +int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, | |
| 157 | 157 | uint64_t lba); |
| 158 | 158 | |
| 159 | −/**@brief Block set procedure (through cache). | |
| 160 | − * @param bdev block device descriptor | |
| 161 | − * @param b block descriptor | |
| 162 | − * @return standard error code*/ | |
| 163 | −int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b); | |
| 159 | +/**@brief Block set procedure (through cache). | |
| 160 | + * @param bdev block device descriptor | |
| 161 | + * @param b block descriptor | |
| 162 | + * @return standard error code*/ | |
| 163 | +int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b); | |
| 164 | 164 | |
| 165 | 165 | |
| 166 | −/**@brief Block read procedure (without cache) | |
| 167 | − * @param bdev block device descriptor | |
| 168 | − * @param buf output buffer | |
| 169 | − * @param lba logical block adderss | |
| 170 | − * @return standard error code*/ | |
| 166 | +/**@brief Block read procedure (without cache) | |
| 167 | + * @param bdev block device descriptor | |
| 168 | + * @param buf output buffer | |
| 169 | + * @param lba logical block adderss | |
| 170 | + * @return standard error code*/ | |
| 171 | 171 | int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf, |
| 172 | 172 | uint64_t lba, uint32_t cnt); |
| 173 | 173 | |
| 174 | 174 | |
| 175 | −/**@brief Block write procedure (without cache) | |
| 176 | − * @param bdev block device descriptor | |
| 177 | − * @param buf output buffer | |
| 178 | − * @param lba logical block address | |
| 179 | − * @return standard error code*/ | |
| 180 | −int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, | |
| 175 | +/**@brief Block write procedure (without cache) | |
| 176 | + * @param bdev block device descriptor | |
| 177 | + * @param buf output buffer | |
| 178 | + * @param lba logical block address | |
| 179 | + * @return standard error code*/ | |
| 180 | +int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, | |
| 181 | 181 | uint64_t lba, uint32_t cnt); |
| 182 | 182 | |
| 183 | −/**@brief Write to block device (by direct adress). | |
| 184 | − * @param bdev block device descriptor | |
| 185 | − * @param off byte offset in block device | |
| 186 | − * @param buf input buffer | |
| 187 | − * @param len length of the write nuffer | |
| 188 | − * @return EOK when sucess*/ | |
| 189 | −int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, | |
| 183 | +/**@brief Write to block device (by direct adress). | |
| 184 | + * @param bdev block device descriptor | |
| 185 | + * @param off byte offset in block device | |
| 186 | + * @param buf input buffer | |
| 187 | + * @param len length of the write nuffer | |
| 188 | + * @return EOK when sucess*/ | |
| 189 | +int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, | |
| 190 | 190 | const void *buf, uint32_t len); |
| 191 | 191 | |
| 192 | 192 | |
| 193 | 193 | |
| 194 | −/**@brief Read freom block device (by direct adress). | |
| 195 | − * @param bdev block device descriptor | |
| 196 | − * @param off byte offset in block device | |
| 197 | − * @param buf input buffer | |
| 198 | − * @param len length of the write nuffer | |
| 199 | − * @return EOK when sucess*/ | |
| 200 | −int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, | |
| 194 | +/**@brief Read freom block device (by direct adress). | |
| 195 | + * @param bdev block device descriptor | |
| 196 | + * @param off byte offset in block device | |
| 197 | + * @param buf input buffer | |
| 198 | + * @param len length of the write nuffer | |
| 199 | + * @return EOK when sucess*/ | |
| 200 | +int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, | |
| 201 | 201 | void *buf, uint32_t len); |
| 202 | 202 | |
| 203 | −/**@brief Enable/disable delayed cache flush mode. | |
| 204 | − * @param bdev block device descriptor | |
| 205 | − * @param on_off | |
| 206 | − * !0 - ENABLE | |
| 207 | − * 0 - DISABLE (all delayed cache buffers will be flushed) | |
| 208 | − * @return standard error code*/ | |
| 209 | −int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, uint8_t on_off); | |
| 203 | +/**@brief Enable/disable delayed cache flush mode. | |
| 204 | + * @param bdev block device descriptor | |
| 205 | + * @param on_off | |
| 206 | + * !0 - ENABLE | |
| 207 | + * 0 - DISABLE (all delayed cache buffers will be flushed) | |
| 208 | + * @return standard error code*/ | |
| 209 | +int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, uint8_t on_off); | |
| 210 | 210 | |
| 211 | 211 | #endif /* EXT4_BLOCKDEV_H_ */ |
| 212 | 212 | |
| @@ -42,51 +42,51 @@ · 41 unmodified lines | ||
| 42 | 42 | #endif |
| 43 | 43 | |
| 44 | 44 | |
| 45 | −/**@brief Enable directory indexing feature (EXT3 feature)*/ | |
| 45 | +/**@brief Enable directory indexing feature (EXT3 feature)*/ | |
| 46 | 46 | #ifndef CONFIG_DIR_INDEX_ENABLE |
| 47 | 47 | #define CONFIG_DIR_INDEX_ENABLE 1 |
| 48 | 48 | #endif |
| 49 | 49 | |
| 50 | −/**@brief Enable extents feature (EXT4 feature)*/ | |
| 50 | +/**@brief Enable extents feature (EXT4 feature)*/ | |
| 51 | 51 | #ifndef CONFIG_EXTENT_ENABLE |
| 52 | 52 | #define CONFIG_EXTENT_ENABLE 1 |
| 53 | 53 | #endif |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | −/**@brief Include error codes from ext4_errno or sandard library.*/ | |
| 57 | +/**@brief Include error codes from ext4_errno or sandard library.*/ | |
| 58 | 58 | #ifndef CONFIG_HAVE_OWN_ERRNO |
| 59 | 59 | #define CONFIG_HAVE_OWN_ERRNO 1 |
| 60 | 60 | #endif |
| 61 | 61 | |
| 62 | 62 | |
| 63 | −/**@brief Debug printf enable (stdout)*/ | |
| 63 | +/**@brief Debug printf enable (stdout)*/ | |
| 64 | 64 | #ifndef CONFIG_DEBUG_PRINTF |
| 65 | 65 | #define CONFIG_DEBUG_PRINTF 1 |
| 66 | 66 | #endif |
| 67 | 67 | |
| 68 | −/**@brief Assert printf enable (stdout)*/ | |
| 68 | +/**@brief Assert printf enable (stdout)*/ | |
| 69 | 69 | #ifndef CONFIG_DEBUG_ASSERT |
| 70 | 70 | #define CONFIG_DEBUG_ASSERT 1 |
| 71 | 71 | #endif |
| 72 | 72 | |
| 73 | −/**@brief Statistics of block device*/ | |
| 73 | +/**@brief Statistics of block device*/ | |
| 74 | 74 | #ifndef CONFIG_BLOCK_DEV_ENABLE_STATS |
| 75 | 75 | #define CONFIG_BLOCK_DEV_ENABLE_STATS 1 |
| 76 | 76 | #endif |
| 77 | 77 | |
| 78 | −/**@brief Cache size of block device.*/ | |
| 78 | +/**@brief Cache size of block device.*/ | |
| 79 | 79 | #ifndef CONFIG_BLOCK_DEV_CACHE_SIZE |
| 80 | 80 | #define CONFIG_BLOCK_DEV_CACHE_SIZE 8 |
| 81 | 81 | #endif |
| 82 | 82 | |
| 83 | 83 | |
| 84 | −/**@brief Ilosc urzadzen blokowych.*/ | |
| 84 | +/**@brief Ilosc urzadzen blokowych.*/ | |
| 85 | 85 | #ifndef CONFIG_EXT4_BLOCKDEVS_COUNT |
| 86 | 86 | #define CONFIG_EXT4_BLOCKDEVS_COUNT 2 |
| 87 | 87 | #endif |
| 88 | 88 | |
| 89 | −/**@brief Ilosc punktow montowania systemu plikow*/ | |
| 89 | +/**@brief Ilosc punktow montowania systemu plikow*/ | |
| 90 | 90 | #ifndef CONFIG_EXT4_MOUNTPOINTS_COUNT |
| 91 | 91 | #define CONFIG_EXT4_MOUNTPOINTS_COUNT 2 |
| 92 | 92 | #endif |
| @@ -43,67 +43,67 @@ · 42 unmodified lines | ||
| 43 | 43 | #include <stdio.h> |
| 44 | 44 | |
| 45 | 45 | /**@brief Debug mask: ext4_blockdev.c*/ |
| 46 | −#define EXT4_DEBUG_BLOCKDEV (1 << 0) | |
| 46 | +#define EXT4_DEBUG_BLOCKDEV (1 << 0) | |
| 47 | 47 | |
| 48 | 48 | /**@brief Debug mask: ext4_fs.c*/ |
| 49 | −#define EXT4_DEBUG_FS (1 << 1) | |
| 49 | +#define EXT4_DEBUG_FS (1 << 1) | |
| 50 | 50 | |
| 51 | 51 | /**@brief Debug mask: ext4_balloc.c*/ |
| 52 | −#define EXT4_DEBUG_BALLOC (1 << 2) | |
| 52 | +#define EXT4_DEBUG_BALLOC (1 << 2) | |
| 53 | 53 | |
| 54 | 54 | /**@brief Debug mask: ext4_bitmap.c*/ |
| 55 | −#define EXT4_DEBUG_BITMAP (1 << 3) | |
| 55 | +#define EXT4_DEBUG_BITMAP (1 << 3) | |
| 56 | 56 | |
| 57 | 57 | /**@brief Debug mask: ext4_dir_idx.c*/ |
| 58 | −#define EXT4_DEBUG_DIR_IDX (1 << 4) | |
| 58 | +#define EXT4_DEBUG_DIR_IDX (1 << 4) | |
| 59 | 59 | |
| 60 | 60 | /**@brief Debug mask: ext4_dir.c*/ |
| 61 | −#define EXT4_DEBUG_DIR (1 << 5) | |
| 61 | +#define EXT4_DEBUG_DIR (1 << 5) | |
| 62 | 62 | |
| 63 | 63 | /**@brief Debug mask: ext4_ialloc.c*/ |
| 64 | −#define EXT4_DEBUG_IALLOC (1 << 6) | |
| 64 | +#define EXT4_DEBUG_IALLOC (1 << 6) | |
| 65 | 65 | |
| 66 | 66 | /**@brief Debug mask: ext4_inode.c*/ |
| 67 | −#define EXT4_DEBUG_INODE (1 << 7) | |
| 67 | +#define EXT4_DEBUG_INODE (1 << 7) | |
| 68 | 68 | |
| 69 | 69 | /**@brief Debug mask: ext4_super.c*/ |
| 70 | −#define EXT4_DEBUG_SUPER (1 << 8) | |
| 70 | +#define EXT4_DEBUG_SUPER (1 << 8) | |
| 71 | 71 | |
| 72 | 72 | /**@brief Debug mask: ext4_bcache.c*/ |
| 73 | −#define EXT4_DEBUG_BCACHE (1 << 9) | |
| 73 | +#define EXT4_DEBUG_BCACHE (1 << 9) | |
| 74 | 74 | |
| 75 | 75 | /**@brief Debug mask: ext4_extents.c*/ |
| 76 | 76 | #define EXT4_DEBUG_EXTENTS (1 << 10) |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | −/**@brief All debug printf enabled.*/ | |
| 81 | −#define EXT4_DEBUG_ALL (0xFFFFFFFF) | |
| 80 | +/**@brief All debug printf enabled.*/ | |
| 81 | +#define EXT4_DEBUG_ALL (0xFFFFFFFF) | |
| 82 | 82 | |
| 83 | −/**@brief Global mask debug settings. | |
| 84 | − * @brief m new debug mask.*/ | |
| 83 | +/**@brief Global mask debug settings. | |
| 84 | + * @brief m new debug mask.*/ | |
| 85 | 85 | void ext4_dmask_set(uint32_t m); |
| 86 | 86 | |
| 87 | −/**@brief Global debug mask get. | |
| 88 | − * @return debug mask*/ | |
| 87 | +/**@brief Global debug mask get. | |
| 88 | + * @return debug mask*/ | |
| 89 | 89 | uint32_t ext4_dmask_get(void); |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | #if CONFIG_DEBUG_PRINTF |
| 93 | −/**@brief Debug printf.*/ | |
| 94 | −#define ext4_dprintf(m, ...) do { \ | |
| 93 | +/**@brief Debug printf.*/ | |
| 94 | +#define ext4_dprintf(m, ...) do { \ | |
| 95 | 95 | (m & ext4_dmask_get()) ? printf(__VA_ARGS__) : (void)0; \ |
| 96 | 96 | fflush(stdout); \ |
| 97 | 97 | }while(0) |
| 98 | 98 | #else |
| 99 | −#define ext4_dprintf(m, ...) | |
| 99 | +#define ext4_dprintf(m, ...) | |
| 100 | 100 | #endif |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | #if CONFIG_DEBUG_ASSERT |
| 105 | 105 | /**@brief Debug asseration.*/ |
| 106 | −#define ext4_assert(_v) do { \ | |
| 106 | +#define ext4_assert(_v) do { \ | |
| 107 | 107 | if(!(_v)){ \ |
| 108 | 108 | printf("Assertion failed:\nmodule: %s\nfunc: %s\nline: %d\n", \ |
| 109 | 109 | __FILE__, __FUNCTION__, __LINE__); \ |
| @@ -439,8 +439,8 @@ int ext4_dir_find_entry(struct ext4_directory_search_result *result, · 438 unmodified lines | ||
| 439 | 439 | |
| 440 | 440 | /* Entry was not found */ |
| 441 | 441 | |
| 442 | − result->block.lb_id = 0; | |
| 443 | − result->dentry = NULL; | |
| 442 | + result->block.lb_id = 0; | |
| 443 | + result->dentry = NULL; | |
| 444 | 444 | |
| 445 | 445 | return ENOENT; |
| 446 | 446 | } |
| @@ -513,7 +513,7 @@ int ext4_dir_try_insert_entry(struct ext4_sblock *sb, · 66 unmodified lines | ||
| 513 | 513 | |
| 514 | 514 | /* Initialize pointers, stop means to upper bound */ |
| 515 | 515 | struct ext4_directory_entry_ll *dentry = (void *)target_block->data; |
| 516 | − struct ext4_directory_entry_ll *stop = | |
| 516 | + struct ext4_directory_entry_ll *stop = | |
| 517 | 517 | (void *)(target_block->data + block_size); |
| 518 | 518 | |
| 519 | 519 | /* |
| @@ -89,7 +89,7 @@ uint8_t ext4_dir_dx_root_info_get_indirect_levels( · 88 unmodified lines | ||
| 89 | 89 | return root_info->indirect_levels; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | −void ext4_dir_dx_root_info_set_indirect_levels( | |
| 92 | +void ext4_dir_dx_root_info_set_indirect_levels( | |
| 93 | 93 | struct ext4_directory_dx_root_info *root_info, uint8_t lvl) |
| 94 | 94 | { |
| 95 | 95 | root_info->indirect_levels = lvl; |
| @@ -430,7 +430,7 @@ static int ext4_dir_dx_next_block(struct ext4_inode_ref *inode_ref, · 334 unmodified lines | ||
| 430 | 430 | |
| 431 | 431 | |
| 432 | 432 | |
| 433 | −int ext4_dir_dx_find_entry(struct ext4_directory_search_result * result, | |
| 433 | +int ext4_dir_dx_find_entry(struct ext4_directory_search_result * result, | |
| 434 | 434 | struct ext4_inode_ref *inode_ref, size_t name_len, const char *name) |
| 435 | 435 | { |
| 436 | 436 | /* Load direct block 0 (index root) */ |
| @@ -799,7 +799,7 @@ static int ext4_dir_dx_split_index(struct ext4_inode_ref *inode_ref, · 362 unmodified lines | ||
| 799 | 799 | if (rc != EOK) |
| 800 | 800 | return rc; |
| 801 | 801 | |
| 802 | − struct ext4_directory_dx_node *new_node = (void *)new_block.data; | |
| 802 | + struct ext4_directory_dx_node *new_node = (void *)new_block.data; | |
| 803 | 803 | struct ext4_directory_dx_entry *new_entries = new_node->entries; |
| 804 | 804 | |
| 805 | 805 | memset(&new_node->fake, 0, sizeof(struct ext4_fake_directory_entry)); |
| @@ -41,41 +41,41 @@ · 40 unmodified lines | ||
| 41 | 41 | #ifndef CONFIG_HAVE_OWN_ERRNO |
| 42 | 42 | #include <errno.h> |
| 43 | 43 | #else |
| 44 | −#define EPERM 1 /* Operation not permitted */ | |
| 45 | −#define ENOENT 2 /* No such file or directory */ | |
| 46 | −#define ESRCH 3 /* No such process */ | |
| 47 | −#define EINTR 4 /* Interrupted system call */ | |
| 48 | −#define EIO 5 /* I/O error */ | |
| 49 | −#define ENXIO 6 /* No such device or address */ | |
| 50 | −#define E2BIG 7 /* Argument list too long */ | |
| 51 | −#define ENOEXEC 8 /* Exec format error */ | |
| 52 | −#define EBADF 9 /* Bad file number */ | |
| 53 | −#define ECHILD 10 /* No child processes */ | |
| 54 | −#define EAGAIN 11 /* Try again */ | |
| 55 | −#define ENOMEM 12 /* Out of memory */ | |
| 56 | −#define EACCES 13 /* Permission denied */ | |
| 57 | −#define EFAULT 14 /* Bad address */ | |
| 58 | −#define ENOTBLK 15 /* Block device required */ | |
| 59 | −#define EBUSY 16 /* Device or resource busy */ | |
| 60 | −#define EEXIST 17 /* File exists */ | |
| 61 | −#define EXDEV 18 /* Cross-device link */ | |
| 62 | −#define ENODEV 19 /* No such device */ | |
| 63 | −#define ENOTDIR 20 /* Not a directory */ | |
| 64 | −#define EISDIR 21 /* Is a directory */ | |
| 65 | −#define EINVAL 22 /* Invalid argument */ | |
| 66 | −#define ENFILE 23 /* File table overflow */ | |
| 67 | −#define EMFILE 24 /* Too many open files */ | |
| 68 | −#define ENOTTY 25 /* Not a typewriter */ | |
| 69 | −#define ETXTBSY 26 /* Text file busy */ | |
| 70 | −#define EFBIG 27 /* File too large */ | |
| 71 | −#define ENOSPC 28 /* No space left on device */ | |
| 72 | −#define ESPIPE 29 /* Illegal seek */ | |
| 73 | −#define EROFS 30 /* Read-only file system */ | |
| 74 | −#define EMLINK 31 /* Too many links */ | |
| 75 | −#define EPIPE 32 /* Broken pipe */ | |
| 76 | −#define EDOM 33 /* Math argument out of domain of func */ | |
| 77 | −#define ERANGE 34 /* Math result not representable */ | |
| 78 | −#define ENOTSUP 95 /* Not supported */ | |
| 44 | +#define EPERM 1 /* Operation not permitted */ | |
| 45 | +#define ENOENT 2 /* No such file or directory */ | |
| 46 | +#define ESRCH 3 /* No such process */ | |
| 47 | +#define EINTR 4 /* Interrupted system call */ | |
| 48 | +#define EIO 5 /* I/O error */ | |
| 49 | +#define ENXIO 6 /* No such device or address */ | |
| 50 | +#define E2BIG 7 /* Argument list too long */ | |
| 51 | +#define ENOEXEC 8 /* Exec format error */ | |
| 52 | +#define EBADF 9 /* Bad file number */ | |
| 53 | +#define ECHILD 10 /* No child processes */ | |
| 54 | +#define EAGAIN 11 /* Try again */ | |
| 55 | +#define ENOMEM 12 /* Out of memory */ | |
| 56 | +#define EACCES 13 /* Permission denied */ | |
| 57 | +#define EFAULT 14 /* Bad address */ | |
| 58 | +#define ENOTBLK 15 /* Block device required */ | |
| 59 | +#define EBUSY 16 /* Device or resource busy */ | |
| 60 | +#define EEXIST 17 /* File exists */ | |
| 61 | +#define EXDEV 18 /* Cross-device link */ | |
| 62 | +#define ENODEV 19 /* No such device */ | |
| 63 | +#define ENOTDIR 20 /* Not a directory */ | |
| 64 | +#define EISDIR 21 /* Is a directory */ | |
| 65 | +#define EINVAL 22 /* Invalid argument */ | |
| 66 | +#define ENFILE 23 /* File table overflow */ | |
| 67 | +#define EMFILE 24 /* Too many open files */ | |
| 68 | +#define ENOTTY 25 /* Not a typewriter */ | |
| 69 | +#define ETXTBSY 26 /* Text file busy */ | |
| 70 | +#define EFBIG 27 /* File too large */ | |
| 71 | +#define ENOSPC 28 /* No space left on device */ | |
| 72 | +#define ESPIPE 29 /* Illegal seek */ | |
| 73 | +#define EROFS 30 /* Read-only file system */ | |
| 74 | +#define EMLINK 31 /* Too many links */ | |
| 75 | +#define EPIPE 32 /* Broken pipe */ | |
| 76 | +#define EDOM 33 /* Math argument out of domain of func */ | |
| 77 | +#define ERANGE 34 /* Math result not representable */ | |
| 78 | +#define ENOTSUP 95 /* Not supported */ | |
| 79 | 79 | #endif |
| 80 | 80 | |
| 81 | 81 | #ifndef EOK |
| @@ -384,8 +384,8 @@ static int ext4_fs_init_inode_table(struct ext4_block_group_ref *bg_ref) · 383 unmodified lines | ||
| 384 | 384 | { |
| 385 | 385 | struct ext4_sblock *sb = &bg_ref->fs->sb; |
| 386 | 386 | |
| 387 | − uint32_t inode_size = ext4_get32(sb, inode_size); | |
| 388 | − uint32_t block_size = ext4_sb_get_block_size(sb); | |
| 387 | + uint32_t inode_size = ext4_get32(sb, inode_size); | |
| 388 | + uint32_t block_size = ext4_sb_get_block_size(sb); | |
| 389 | 389 | uint32_t inodes_per_block = block_size / inode_size; |
| 390 | 390 | uint32_t inodes_in_group = ext4_inodes_in_group_cnt(sb, bg_ref->index); |
| 391 | 391 | uint32_t table_blocks = inodes_in_group / inodes_per_block; |
| @@ -670,10 +670,10 @@ int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref, · 278 unmodified lines | ||
| 670 | 670 | ext4_inode_set_uid(inode, 0); |
| 671 | 671 | ext4_inode_set_gid(inode, 0); |
| 672 | 672 | ext4_inode_set_size(inode, 0); |
| 673 | − ext4_inode_set_access_time(inode, 0); | |
| 673 | + ext4_inode_set_access_time(inode, 0); | |
| 674 | 674 | ext4_inode_set_change_inode_time(inode, 0); |
| 675 | 675 | ext4_inode_set_modification_time(inode, 0); |
| 676 | − ext4_inode_set_deletion_time(inode, 0); | |
| 676 | + ext4_inode_set_deletion_time(inode, 0); | |
| 677 | 677 | ext4_inode_set_blocks_count(&fs->sb, inode, 0); |
| 678 | 678 | ext4_inode_set_flags(inode, 0); |
| 679 | 679 | ext4_inode_set_generation(inode, 0); |
| @@ -737,7 +737,7 @@ int ext4_fs_free_inode(struct ext4_inode_ref *inode_ref) · 57 unmodified lines | ||
| 737 | 737 | uint32_t block_size = ext4_sb_get_block_size(&fs->sb); |
| 738 | 738 | uint32_t count = block_size / sizeof(uint32_t); |
| 739 | 739 | |
| 740 | − struct ext4_block block; | |
| 740 | + struct ext4_block block; | |
| 741 | 741 | |
| 742 | 742 | /* 2) Double indirect */ |
| 743 | 743 | fblock = ext4_inode_get_indirect_block(inode_ref->inode, 1); |
| @@ -768,7 +768,7 @@ int ext4_fs_free_inode(struct ext4_inode_ref *inode_ref) · 24 unmodified lines | ||
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /* 3) Tripple indirect */ |
| 771 | − struct ext4_block subblock; | |
| 771 | + struct ext4_block subblock; | |
| 772 | 772 | fblock = ext4_inode_get_indirect_block(inode_ref->inode, 2); |
| 773 | 773 | if (fblock != 0) { |
| 774 | 774 | int rc = ext4_block_get(fs->bdev, &block, fblock); |
| @@ -971,7 +971,7 @@ int ext4_fs_get_inode_data_block_index(struct ext4_inode_ref *inode_ref, · 196 unmodified lines | ||
| 971 | 971 | return EOK; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | − struct ext4_block block; | |
| 974 | + struct ext4_block block; | |
| 975 | 975 | |
| 976 | 976 | /* |
| 977 | 977 | * Navigate through other levels, until we find the block number |
| @@ -1065,8 +1065,8 @@ int ext4_fs_set_inode_data_block_index(struct ext4_inode_ref *inode_ref, · 87 unmodified lines | ||
| 1065 | 1065 | |
| 1066 | 1066 | uint32_t new_block_addr; |
| 1067 | 1067 | |
| 1068 | − struct ext4_block block; | |
| 1069 | − struct ext4_block new_block; | |
| 1068 | + struct ext4_block block; | |
| 1069 | + struct ext4_block new_block; | |
| 1070 | 1070 | |
| 1071 | 1071 | /* Is needed to allocate indirect block on the i-node level */ |
| 1072 | 1072 | if (current_block == 0) { |
| @@ -1224,7 +1224,7 @@ int ext4_fs_release_inode_block(struct ext4_inode_ref *inode_ref, · 151 unmodified lines | ||
| 1224 | 1224 | * Navigate through other levels, until we find the block number |
| 1225 | 1225 | * or find null reference meaning we are dealing with sparse file |
| 1226 | 1226 | */ |
| 1227 | − struct ext4_block block; | |
| 1227 | + struct ext4_block block; | |
| 1228 | 1228 | |
| 1229 | 1229 | while (level > 0) { |
| 1230 | 1230 | |
| @@ -41,14 +41,14 @@ · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | #include <stdint.h> |
| 43 | 43 | |
| 44 | −/**@brief Directory entry name hash function. | |
| 45 | − * @param name entry name | |
| 46 | − * @param len entry name length | |
| 47 | − * @param hash_seed (from superblock) | |
| 48 | − * @param hash version (from superblock) | |
| 49 | − * @param hash_minor output value | |
| 50 | − * @param hash_major output value | |
| 51 | − * @return standard error code*/ | |
| 44 | +/**@brief Directory entry name hash function. | |
| 45 | + * @param name entry name | |
| 46 | + * @param len entry name length | |
| 47 | + * @param hash_seed (from superblock) | |
| 48 | + * @param hash version (from superblock) | |
| 49 | + * @param hash_minor output value | |
| 50 | + * @param hash_major output value | |
| 51 | + * @return standard error code*/ | |
| 52 | 52 | int ext2_htree_hash(const char *name, int len, |
| 53 | 53 | const uint32_t *hash_seed, int hash_version, |
| 54 | 54 | uint32_t *hash_major, uint32_t *hash_minor); |
| @@ -86,7 +86,7 @@ int ext4_ialloc_free_inode(struct ext4_fs *fs, uint32_t index, bool is_dir) · 85 unmodified lines | ||
| 86 | 86 | uint32_t bitmap_block_addr = ext4_bg_get_inode_bitmap( |
| 87 | 87 | bg_ref.block_group, sb); |
| 88 | 88 | |
| 89 | − struct ext4_block bitmap_block; | |
| 89 | + struct ext4_block bitmap_block; | |
| 90 | 90 | rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr); |
| 91 | 91 | if (rc != EOK) |
| 92 | 92 | return rc; |
| @@ -173,7 +173,7 @@ int ext4_ialloc_alloc_inode(struct ext4_fs *fs, uint32_t *index, bool is_dir) · 80 unmodified lines | ||
| 173 | 173 | uint32_t bitmap_block_addr = ext4_bg_get_inode_bitmap( |
| 174 | 174 | bg_ref.block_group, sb); |
| 175 | 175 | |
| 176 | − struct ext4_block bitmap_block; | |
| 176 | + struct ext4_block bitmap_block; | |
| 177 | 177 | rc = ext4_block_get(fs->bdev, &bitmap_block, bitmap_block_addr); |
| 178 | 178 | if (rc != EOK) |
| 179 | 179 | return rc; |
| @@ -69,7 +69,7 @@ uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode) · 68 unmodified lines | ||
| 69 | 69 | return v; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | −void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode, | |
| 72 | +void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode, | |
| 73 | 73 | uint32_t mode) |
| 74 | 74 | { |
| 75 | 75 | inode->mode = to_le16((mode << 16) >> 16); |
| @@ -83,7 +83,7 @@ uint32_t ext4_inode_get_uid(struct ext4_inode *inode) · 7 unmodified lines | ||
| 83 | 83 | return to_le32(inode->uid); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | −void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid) | |
| 86 | +void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid) | |
| 87 | 87 | { |
| 88 | 88 | inode->uid = to_le32(uid); |
| 89 | 89 | } |
| @@ -154,7 +154,7 @@ uint32_t ext4_inode_get_gid(struct ext4_inode *inode) · 64 unmodified lines | ||
| 154 | 154 | } |
| 155 | 155 | void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid) |
| 156 | 156 | { |
| 157 | − inode->gid = to_le32(gid); | |
| 157 | + inode->gid = to_le32(gid); | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | uint16_t ext4_inode_get_links_count(struct ext4_inode *inode) |
| @@ -234,14 +234,14 @@ uint32_t ext4_inode_get_flags(struct ext4_inode *inode) · 73 unmodified lines | ||
| 234 | 234 | } |
| 235 | 235 | void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags) |
| 236 | 236 | { |
| 237 | − inode->flags = to_le32(flags); | |
| 237 | + inode->flags = to_le32(flags); | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | uint32_t ext4_inode_get_generation(struct ext4_inode *inode) |
| 241 | 241 | { |
| 242 | 242 | return to_le32(inode->generation); |
| 243 | 243 | } |
| 244 | −void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen) | |
| 244 | +void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen) | |
| 245 | 245 | { |
| 246 | 246 | inode->generation = to_le32(gen); |
| 247 | 247 | } |
| @@ -59,8 +59,8 @@ uint32_t ext4_block_group_cnt(struct ext4_sblock *s) · 58 unmodified lines | ||
| 59 | 59 | uint32_t ext4_blocks_in_group_cnt(struct ext4_sblock *s, uint32_t bgid) |
| 60 | 60 | { |
| 61 | 61 | uint32_t block_group_count = ext4_block_group_cnt(s); |
| 62 | − uint32_t blocks_per_group = ext4_get32(s, blocks_per_group); | |
| 63 | − uint64_t total_blocks = ext4_sb_get_blocks_cnt(s); | |
| 62 | + uint32_t blocks_per_group = ext4_get32(s, blocks_per_group); | |
| 63 | + uint64_t total_blocks = ext4_sb_get_blocks_cnt(s); | |
| 64 | 64 | |
| 65 | 65 | if (bgid < block_group_count - 1) |
| 66 | 66 | return blocks_per_group; |
| @@ -82,13 +82,13 @@ uint32_t ext4_inodes_in_group_cnt(struct ext4_sblock *s, uint32_t bgid) · 15 unmodified lines | ||
| 82 | 82 | return (total_inodes - ((block_group_count - 1) * inodes_per_group)); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | −int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s) | |
| 85 | +int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s) | |
| 86 | 86 | { |
| 87 | 87 | return ext4_block_writebytes(bdev, EXT4_SUPERBLOCK_OFFSET, |
| 88 | 88 | s, EXT4_SUPERBLOCK_SIZE); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | −int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s) | |
| 91 | +int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s) | |
| 92 | 92 | { |
| 93 | 93 | return ext4_block_readbytes(bdev, EXT4_SUPERBLOCK_OFFSET, |
| 94 | 94 | s, EXT4_SUPERBLOCK_SIZE); |
| @@ -165,13 +165,13 @@ uint32_t ext4_inodes_in_group_cnt(struct ext4_sblock *s, uint32_t bgid); · 164 unmodified lines | ||
| 165 | 165 | * @param bdev block device descriptor. |
| 166 | 166 | * @param s superblock descruptor |
| 167 | 167 | * @return Standard error code */ |
| 168 | −int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s); | |
| 168 | +int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s); | |
| 169 | 169 | |
| 170 | 170 | /**@brief Superblock read. |
| 171 | 171 | * @param bdev block device descriptor. |
| 172 | 172 | * @param s superblock descruptor |
| 173 | 173 | * @return Standard error code */ |
| 174 | −int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s); | |
| 174 | +int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s); | |
| 175 | 175 | |
| 176 | 176 | /**@brief Superblock simple validation. |
| 177 | 177 | * @param s superblock dsecriptor |
| @@ -230,8 +230,8 @@ struct ext4_sblock { · 229 unmodified lines | ||
| 230 | 230 | EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE) |
| 231 | 231 | |
| 232 | 232 | struct ext4_fs { |
| 233 | − struct ext4_blockdev *bdev; | |
| 234 | − struct ext4_sblock sb; | |
| 233 | + struct ext4_blockdev*bdev; | |
| 234 | + struct ext4_sblock sb; | |
| 235 | 235 | |
| 236 | 236 | uint64_t inode_block_limits[4]; |
| 237 | 237 | uint64_t inode_blocks_per_level[4]; |
| @@ -270,11 +270,11 @@ struct ext4_bgroup { · 32 unmodified lines | ||
| 270 | 270 | } ; |
| 271 | 271 | |
| 272 | 272 | struct ext4_block_group_ref { |
| 273 | − struct ext4_block block; | |
| 274 | − struct ext4_bgroup *block_group; | |
| 275 | − struct ext4_fs *fs; | |
| 276 | − uint32_t index; | |
| 277 | − bool dirty; | |
| 273 | + struct ext4_block block; | |
| 274 | + struct ext4_bgroup *block_group; | |
| 275 | + struct ext4_fs *fs; | |
| 276 | + uint32_t index; | |
| 277 | + bool dirty; | |
| 278 | 278 | }; |
| 279 | 279 | |
| 280 | 280 | #define EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE 32 |
| @@ -384,8 +384,8 @@ struct ext4_inode { · 103 unmodified lines | ||
| 384 | 384 | #define EXT4_INODE_ROOT_INDEX 2 |
| 385 | 385 | |
| 386 | 386 | struct ext4_inode_ref { |
| 387 | − struct ext4_block block; | |
| 388 | − struct ext4_inode *inode; | |
| 387 | + struct ext4_block block; | |
| 388 | + struct ext4_inode *inode; | |
| 389 | 389 | struct ext4_fs *fs; |
| 390 | 390 | uint32_t index; |
| 391 | 391 | bool dirty; |
| @@ -420,15 +420,15 @@ struct ext4_directory_entry_ll { · 28 unmodified lines | ||
| 420 | 420 | } __attribute__((packed)) ; |
| 421 | 421 | |
| 422 | 422 | struct ext4_directory_iterator { |
| 423 | − struct ext4_inode_ref *inode_ref; | |
| 424 | − struct ext4_block current_block; | |
| 425 | − uint64_t current_offset; | |
| 423 | + struct ext4_inode_ref *inode_ref; | |
| 424 | + struct ext4_block current_block; | |
| 425 | + uint64_t current_offset; | |
| 426 | 426 | struct ext4_directory_entry_ll *current; |
| 427 | 427 | }; |
| 428 | 428 | |
| 429 | 429 | struct ext4_directory_search_result { |
| 430 | − struct ext4_block block; | |
| 431 | − struct ext4_directory_entry_ll *dentry; | |
| 430 | + struct ext4_block block; | |
| 431 | + struct ext4_directory_entry_ll *dentry; | |
| 432 | 432 | }; |
| 433 | 433 | |
| 434 | 434 | /* Structures for indexed directory */ |
| @@ -478,7 +478,7 @@ struct ext4_directory_dx_node { · 43 unmodified lines | ||
| 478 | 478 | }; |
| 479 | 479 | |
| 480 | 480 | struct ext4_directory_dx_block { |
| 481 | − struct ext4_block block; | |
| 481 | + struct ext4_block block; | |
| 482 | 482 | struct ext4_directory_dx_entry *entries; |
| 483 | 483 | struct ext4_directory_dx_entry *position; |
| 484 | 484 | } ; |
| @@ -526,31 +526,31 @@ struct ext4_extent_header { · 41 unmodified lines | ||
| 526 | 526 | } ; |
| 527 | 527 | |
| 528 | 528 | struct ext4_extent_path { |
| 529 | − struct ext4_block block; | |
| 530 | − uint16_t depth; | |
| 529 | + struct ext4_block block; | |
| 530 | + uint16_t depth; | |
| 531 | 531 | struct ext4_extent_header *header; |
| 532 | − struct ext4_extent_index *index; | |
| 533 | − struct ext4_extent *extent; | |
| 532 | + struct ext4_extent_index *index; | |
| 533 | + struct ext4_extent *extent; | |
| 534 | 534 | } ; |
| 535 | 535 | |
| 536 | 536 | #define EXT4_EXTENT_MAGIC 0xF30A |
| 537 | 537 | |
| 538 | −#define EXT4_EXTENT_FIRST(header) \ | |
| 538 | +#define EXT4_EXTENT_FIRST(header) \ | |
| 539 | 539 | ((struct ext4_extent *) (((void *) (header)) + sizeof(struct ext4_extent_header))) |
| 540 | 540 | |
| 541 | −#define EXT4_EXTENT_FIRST_INDEX(header) \ | |
| 541 | +#define EXT4_EXTENT_FIRST_INDEX(header) \ | |
| 542 | 542 | ((struct ext4_extent_index *) (((void *) (header)) + sizeof(struct ext4_extent_header))) |
| 543 | 543 | |
| 544 | 544 | |
| 545 | 545 | /* EXT3 HTree directory indexing */ |
| 546 | −#define EXT2_HTREE_LEGACY 0 | |
| 547 | −#define EXT2_HTREE_HALF_MD4 1 | |
| 548 | −#define EXT2_HTREE_TEA 2 | |
| 549 | −#define EXT2_HTREE_LEGACY_UNSIGNED 3 | |
| 550 | −#define EXT2_HTREE_HALF_MD4_UNSIGNED 4 | |
| 551 | −#define EXT2_HTREE_TEA_UNSIGNED 5 | |
| 546 | +#define EXT2_HTREE_LEGACY 0 | |
| 547 | +#define EXT2_HTREE_HALF_MD4 1 | |
| 548 | +#define EXT2_HTREE_TEA 2 | |
| 549 | +#define EXT2_HTREE_LEGACY_UNSIGNED 3 | |
| 550 | +#define EXT2_HTREE_HALF_MD4_UNSIGNED 4 | |
| 551 | +#define EXT2_HTREE_TEA_UNSIGNED 5 | |
| 552 | 552 | |
| 553 | −#define EXT2_HTREE_EOF 0x7FFFFFFF | |
| 553 | +#define EXT2_HTREE_EOF 0x7FFFFFFF | |
| 554 | 554 | |
| 555 | 555 | |
| 556 | 556 | struct ext4_hash_info { |
| @@ -578,7 +578,7 @@ static inline uint64_t to_le64(uint64_t n) · 21 unmodified lines | ||
| 578 | 578 | |
| 579 | 579 | static inline uint32_t to_le32(uint32_t n) |
| 580 | 580 | { |
| 581 | − return ((n & 0xff) << 24) | | |
| 581 | + return ((n & 0xff) << 24) | | |
| 582 | 582 | ((n & 0xff00) << 8) | |
| 583 | 583 | ((n & 0xff0000) >> 8) | |
| 584 | 584 | ((n & 0xff000000) >> 24); |
| @@ -586,27 +586,27 @@ static inline uint32_t to_le32(uint32_t n) · 1 unmodified line | ||
| 586 | 586 | |
| 587 | 587 | static inline uint16_t to_le16(uint16_t n) |
| 588 | 588 | { |
| 589 | − return ((n & 0xff) << 8) | | |
| 589 | + return ((n & 0xff) << 8) | | |
| 590 | 590 | ((n & 0xff00) >> 8); |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | |
| 594 | 594 | #else |
| 595 | −#define to_le64(_n) _n | |
| 596 | −#define to_le32(_n) _n | |
| 597 | −#define to_le16(_n) _n | |
| 595 | +#define to_le64(_n) _n | |
| 596 | +#define to_le32(_n) _n | |
| 597 | +#define to_le16(_n) _n | |
| 598 | 598 | #endif |
| 599 | 599 | |
| 600 | 600 | /****************************Access macros to ext4 structures*****************/ |
| 601 | 601 | |
| 602 | −#define ext4_get32(s, f) to_le32((s)->f) | |
| 603 | −#define ext4_get16(s, f) to_le16((s)->f) | |
| 604 | −#define ext4_get8(s, f) (s)->f | |
| 602 | +#define ext4_get32(s, f) to_le32((s)->f) | |
| 603 | +#define ext4_get16(s, f) to_le16((s)->f) | |
| 604 | +#define ext4_get8(s, f) (s)->f | |
| 605 | 605 | |
| 606 | 606 | |
| 607 | −#define ext4_set32(s, f, v) do { (s)->f = to_le32(v); }while(0) | |
| 608 | −#define ext4_set16(s, f, v) do { (s)->f = to_le16(v); }while(0) | |
| 609 | −#define ext4_set8 (s, f, v) do { (s)->f = (v); }while(0) | |
| 607 | +#define ext4_set32(s, f, v) do { (s)->f = to_le32(v); }while(0) | |
| 608 | +#define ext4_set16(s, f, v) do { (s)->f = to_le16(v); }while(0) | |
| 609 | +#define ext4_set8 (s, f, v) do { (s)->f = (v); }while(0) | |
| 610 | 610 | |
| 611 | 611 | #endif /* EXT4_TYPES_H_ */ |
| 612 | 612 | |
| @@ -53,7 +53,7 @@ FEATURE_INCOMPAT (able to mount with unsupported feature): · 52 unmodified lines | ||
| 53 | 53 | - DIR_PREALLOC: no |
| 54 | 54 | - IMAGIC_INODES: no |
| 55 | 55 | - HAS_JOURNAL: no |
| 56 | − - EXT_ATTR: no | |
| 56 | + - EXT_ATTR: no | |
| 57 | 57 | - RESIZE_INODE: no |
| 58 | 58 | - DIR_INDEX: yes |
| 59 | 59 | |
| @@ -67,8 +67,8 @@ FEATURE_RO (able to mount in read only with unsupported feature): · 7 unmodified lines | ||
| 67 | 67 | - EXTRA_ISIZE: yes |
| 68 | 68 | |
| 69 | 69 | Supported filetypes: |
| 70 | − - FIFO: no | |
| 71 | − - CHARDEV: no | |
| 70 | + - FIFO: no | |
| 71 | + - CHARDEV: no | |
| 72 | 72 | - DIRECTORY: yes |
| 73 | 73 | - BLOCKDEV: no |
| 74 | 74 | - FILE: yes |
| @@ -94,7 +94,7 @@ lwext4 project tree · 19 unmodified lines | ||
| 94 | 94 | |
| 95 | 95 | +toolchain - specific toolchain cmake files |
| 96 | 96 | |
| 97 | −+ext4.h - lwext4 client library header | |
| 97 | ++ext4.h - lwext4 client library header | |
| 98 | 98 | CMakeLists.txt - CMake config file |
| 99 | 99 | ext_images.7z - ext2/3/4 100MB images |
| 100 | 100 | Makefile - helper makefile to call cmake |
| @@ -3,20 +3,15 @@ SET(CMAKE_SYSTEM_NAME Generic) · 2 unmodified lines | ||
| 3 | 3 | set(CMAKE_SYSTEM_PROCESSOR bf518) |
| 4 | 4 | |
| 5 | 5 | # Toolchain settings |
| 6 | −set(CMAKE_C_COMPILER bfin-elf-gcc) | |
| 7 | −set(CMAKE_CXX_COMPILER bfin-elf-g++) | |
| 6 | +set(CMAKE_C_COMPILER bfin-elf-gcc) | |
| 7 | +set(CMAKE_CXX_COMPILER bfin-elf-g++) | |
| 8 | 8 | set(AS bfin-elf--gcc) |
| 9 | −set(AR bfin-elf-ar) | |
| 10 | −set(OBJCOPY bfin-elf-objcopy) | |
| 11 | −set(OBJDUMP bfin-elf-objdump) | |
| 9 | +set(AR bfin-elf-ar) | |
| 10 | +set(OBJCOPY bfin-elf-objcopy) | |
| 11 | +set(OBJDUMP bfin-elf-objdump) | |
| 12 | 12 | set(SIZE bfin-elf-size) |
| 13 | 13 | |
| 14 | −set(CMAKE_C_FLAGS "-mcpu=bf518 -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") | |
| 15 | −set(CMAKE_CXX_FLAGS "-mcpu=bf518 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") | |
| 14 | +set(CMAKE_C_FLAGS "-mcpu=bf518 -Os -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") | |
| 15 | +set(CMAKE_CXX_FLAGS "-mcpu=bf518 -Os -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") | |
| 16 | 16 | set(CMAKE_ASM_FLAGS "-mcpu=bf518 -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags") |
| 17 | 17 | set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mcpu=bf592" CACHE INTERNAL "exe link flags") |
| 18 | − | |
| 19 | − | |
| 20 | − | |
| 21 | − | |
| 22 | − | |
| @@ -3,16 +3,16 @@ SET(CMAKE_SYSTEM_NAME Generic) · 2 unmodified lines | ||
| 3 | 3 | set(CMAKE_SYSTEM_PROCESSOR cortex-m3) |
| 4 | 4 | |
| 5 | 5 | # Toolchain settings |
| 6 | −set(CMAKE_C_COMPILER arm-none-eabi-gcc) | |
| 7 | −set(CMAKE_CXX_COMPILER arm-none-eabi-g++) | |
| 8 | −set(AS arm-none-eabi-as) | |
| 9 | −set(AR arm-none-eabi-ar) | |
| 10 | −set(OBJCOPY arm-none-eabi-objcopy) | |
| 11 | −set(OBJDUMP arm-none-eabi-objdump) | |
| 6 | +set(CMAKE_C_COMPILER arm-none-eabi-gcc) | |
| 7 | +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) | |
| 8 | +set(AS arm-none-eabi-as) | |
| 9 | +set(AR arm-none-eabi-ar) | |
| 10 | +set(OBJCOPY arm-none-eabi-objcopy) | |
| 11 | +set(OBJDUMP arm-none-eabi-objdump) | |
| 12 | 12 | set(SIZE arm-none-eabi-size) |
| 13 | 13 | |
| 14 | −set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") | |
| 15 | −set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") | |
| 14 | +set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m3 -Os -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") | |
| 15 | +set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -Os -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") | |
| 16 | 16 | set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m3" CACHE INTERNAL "asm compiler flags") |
| 17 | 17 | set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m3" CACHE INTERNAL "exe link flags") |
| 18 | 18 | |
| @@ -3,16 +3,16 @@ SET(CMAKE_SYSTEM_NAME Generic) · 2 unmodified lines | ||
| 3 | 3 | set(CMAKE_SYSTEM_PROCESSOR cortex-m4) |
| 4 | 4 | |
| 5 | 5 | # Toolchain settings |
| 6 | −set(CMAKE_C_COMPILER arm-none-eabi-gcc) | |
| 7 | −set(CMAKE_CXX_COMPILER arm-none-eabi-g++) | |
| 8 | −set(AS arm-none-eabi-as) | |
| 9 | −set(AR arm-none-eabi-ar) | |
| 10 | −set(OBJCOPY arm-none-eabi-objcopy) | |
| 11 | −set(OBJDUMP arm-none-eabi-objdump) | |
| 6 | +set(CMAKE_C_COMPILER arm-none-eabi-gcc) | |
| 7 | +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) | |
| 8 | +set(AS arm-none-eabi-as) | |
| 9 | +set(AR arm-none-eabi-ar) | |
| 10 | +set(OBJCOPY arm-none-eabi-objcopy) | |
| 11 | +set(OBJDUMP arm-none-eabi-objdump) | |
| 12 | 12 | set(SIZE arm-none-eabi-size) |
| 13 | 13 | |
| 14 | −set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") | |
| 15 | −set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") | |
| 14 | +set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m4 -Os -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") | |
| 15 | +set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -Os -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") | |
| 16 | 16 | set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m4" CACHE INTERNAL "asm compiler flags") |
| 17 | 17 | set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m4" CACHE INTERNAL "exe link flags") |
| 18 | 18 | |