• Home
  • Raw
  • Download

Lines Matching refs:fs

39 	ext2_filsys		fs;  member
52 errcode_t (*done_group)(ext2_filsys fs,
65 errcode_t ext2fs_flush_icache(ext2_filsys fs) in ext2fs_flush_icache() argument
69 if (!fs->icache) in ext2fs_flush_icache()
72 for (i=0; i < fs->icache->cache_size; i++) in ext2fs_flush_icache()
73 fs->icache->cache[i].ino = 0; in ext2fs_flush_icache()
75 fs->icache->buffer_blk = 0; in ext2fs_flush_icache()
98 errcode_t ext2fs_create_inode_cache(ext2_filsys fs, unsigned int cache_size) in ext2fs_create_inode_cache() argument
103 if (fs->icache) in ext2fs_create_inode_cache()
105 retval = ext2fs_get_mem(sizeof(struct ext2_inode_cache), &fs->icache); in ext2fs_create_inode_cache()
109 memset(fs->icache, 0, sizeof(struct ext2_inode_cache)); in ext2fs_create_inode_cache()
110 retval = ext2fs_get_mem(fs->blocksize, &fs->icache->buffer); in ext2fs_create_inode_cache()
114 fs->icache->buffer_blk = 0; in ext2fs_create_inode_cache()
115 fs->icache->cache_last = -1; in ext2fs_create_inode_cache()
116 fs->icache->cache_size = cache_size; in ext2fs_create_inode_cache()
117 fs->icache->refcount = 1; in ext2fs_create_inode_cache()
118 retval = ext2fs_get_array(fs->icache->cache_size, in ext2fs_create_inode_cache()
120 &fs->icache->cache); in ext2fs_create_inode_cache()
124 for (i = 0; i < fs->icache->cache_size; i++) { in ext2fs_create_inode_cache()
125 retval = ext2fs_get_mem(EXT2_INODE_SIZE(fs->super), in ext2fs_create_inode_cache()
126 &fs->icache->cache[i].inode); in ext2fs_create_inode_cache()
131 ext2fs_flush_icache(fs); in ext2fs_create_inode_cache()
134 ext2fs_free_inode_cache(fs->icache); in ext2fs_create_inode_cache()
135 fs->icache = 0; in ext2fs_create_inode_cache()
139 errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, in ext2fs_open_inode_scan() argument
146 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_open_inode_scan()
152 if (fs->badblocks == 0) { in ext2fs_open_inode_scan()
157 save_get_blocks = fs->get_blocks; in ext2fs_open_inode_scan()
158 fs->get_blocks = 0; in ext2fs_open_inode_scan()
159 retval = ext2fs_read_bb_inode(fs, &fs->badblocks); in ext2fs_open_inode_scan()
160 if (retval && fs->badblocks) { in ext2fs_open_inode_scan()
161 ext2fs_badblocks_list_free(fs->badblocks); in ext2fs_open_inode_scan()
162 fs->badblocks = 0; in ext2fs_open_inode_scan()
164 fs->get_blocks = save_get_blocks; in ext2fs_open_inode_scan()
173 scan->fs = fs; in ext2fs_open_inode_scan()
174 scan->inode_size = EXT2_INODE_SIZE(fs->super); in ext2fs_open_inode_scan()
177 scan->groups_left = fs->group_desc_count - 1; in ext2fs_open_inode_scan()
180 scan->current_block = ext2fs_inode_table_loc(scan->fs, in ext2fs_open_inode_scan()
183 ((scan->current_block < fs->super->s_first_data_block) || in ext2fs_open_inode_scan()
184 (scan->current_block + fs->inode_blocks_per_group - 1 >= in ext2fs_open_inode_scan()
185 ext2fs_blocks_count(fs->super)))) { in ext2fs_open_inode_scan()
190 scan->inodes_left = EXT2_INODES_PER_GROUP(scan->fs->super); in ext2fs_open_inode_scan()
191 scan->blocks_left = scan->fs->inode_blocks_per_group; in ext2fs_open_inode_scan()
192 if (ext2fs_has_group_desc_csum(fs)) { in ext2fs_open_inode_scan()
193 __u32 unused = ext2fs_bg_itable_unused(fs, scan->current_group); in ext2fs_open_inode_scan()
200 (fs->blocksize / scan->inode_size - 1)) * in ext2fs_open_inode_scan()
201 scan->inode_size / fs->blocksize; in ext2fs_open_inode_scan()
203 retval = io_channel_alloc_buf(fs->io, scan->inode_buffer_blocks, in ext2fs_open_inode_scan()
220 if (scan->fs->badblocks && scan->fs->badblocks->num) in ext2fs_open_inode_scan()
222 if (ext2fs_has_group_desc_csum(fs)) in ext2fs_open_inode_scan()
242 errcode_t (*done_group)(ext2_filsys fs, in ext2fs_set_inode_callback() argument
275 ext2_filsys fs = scan->fs; in get_next_blockgroup() local
280 scan->current_block = ext2fs_inode_table_loc(scan->fs, in get_next_blockgroup()
283 EXT2_INODES_PER_GROUP(fs->super); in get_next_blockgroup()
286 scan->inodes_left = EXT2_INODES_PER_GROUP(fs->super); in get_next_blockgroup()
287 scan->blocks_left = fs->inode_blocks_per_group; in get_next_blockgroup()
288 if (ext2fs_has_group_desc_csum(fs)) { in get_next_blockgroup()
289 __u32 unused = ext2fs_bg_itable_unused(fs, scan->current_group); in get_next_blockgroup()
296 (fs->blocksize / scan->inode_size - 1)) * in get_next_blockgroup()
297 scan->inode_size / fs->blocksize; in get_next_blockgroup()
300 ((scan->current_block < fs->super->s_first_data_block) || in get_next_blockgroup()
301 (scan->current_block + fs->inode_blocks_per_group - 1 >= in get_next_blockgroup()
302 ext2fs_blocks_count(fs->super)))) in get_next_blockgroup()
311 scan->groups_left = scan->fs->group_desc_count - group; in ext2fs_inode_scan_goto_blockgroup()
326 badblocks_list bb = scan->fs->badblocks; in check_for_inode_bad_blocks()
376 static int block_map_looks_insane(ext2_filsys fs, in block_map_looks_insane() argument
400 (inode->i_block[i] < fs->super->s_first_data_block || in block_map_looks_insane()
401 inode->i_block[i] >= ext2fs_blocks_count(fs->super))) in block_map_looks_insane()
434 inodes_in_buf = num_blocks * scan->fs->blocksize / scan->inode_size; in check_inode_block_sanity()
443 inodes_per_block = EXT2_INODES_PER_BLOCK(scan->fs->super); in check_inode_block_sanity()
449 if (ext2fs_get_mem(EXT2_INODE_SIZE(scan->fs->super), &inode)) in check_inode_block_sanity()
454 blk = (p - (char *)scan->inode_buffer) / scan->fs->blocksize; in check_inode_block_sanity()
455 bad_csum = ext2fs_inode_csum_verify(scan->fs, ino, in check_inode_block_sanity()
459 ext2fs_swap_inode_full(scan->fs, in check_inode_block_sanity()
462 0, EXT2_INODE_SIZE(scan->fs->super)); in check_inode_block_sanity()
472 block_map_looks_insane(scan->fs, inode)) in check_inode_block_sanity()
546 (size_t) num_blocks * scan->fs->blocksize); in get_next_blocks()
548 retval = io_channel_read_blk64(scan->fs->io, in get_next_blocks()
558 scan->bytes_left = num_blocks * scan->fs->blocksize; in get_next_blocks()
599 length = EXT2_INODE_SIZE(scan->fs->super); in ext2fs_get_next_inode_full()
609 (scan->fs, scan, scan->current_group, in ext2fs_get_next_inode_full()
627 (ext2fs_bg_flags_test(scan->fs, scan->current_group, EXT2_BG_INODE_UNINIT) in ext2fs_get_next_inode_full()
669 iblk = scan->current_inode % EXT2_INODES_PER_GROUP(scan->fs->super) / in ext2fs_get_next_inode_full()
670 EXT2_INODES_PER_BLOCK(scan->fs->super) % in ext2fs_get_next_inode_full()
680 !(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) && in ext2fs_get_next_inode_full()
681 !ext2fs_inode_csum_verify(scan->fs, scan->current_inode + 1, in ext2fs_get_next_inode_full()
687 ext2fs_swap_inode_full(scan->fs, in ext2fs_get_next_inode_full()
700 !(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) && in ext2fs_get_next_inode_full()
701 !ext2fs_inode_csum_verify(scan->fs, scan->current_inode + 1, in ext2fs_get_next_inode_full()
707 ext2fs_swap_inode_full(scan->fs, in ext2fs_get_next_inode_full()
743 errcode_t ext2fs_read_inode2(ext2_filsys fs, ext2_ino_t ino, in ext2fs_read_inode2() argument
755 int length = EXT2_INODE_SIZE(fs->super); in ext2fs_read_inode2()
759 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_read_inode2()
762 if (fs->read_inode && in ext2fs_read_inode2()
764 (EXT2_INODE_SIZE(fs->super) == sizeof(struct ext2_inode)))) { in ext2fs_read_inode2()
765 retval = (fs->read_inode)(fs, ino, inode); in ext2fs_read_inode2()
769 if ((ino == 0) || (ino > fs->super->s_inodes_count)) in ext2fs_read_inode2()
772 if (!fs->icache) { in ext2fs_read_inode2()
773 retval = ext2fs_create_inode_cache(fs, 4); in ext2fs_read_inode2()
778 for (i = 0; i < fs->icache->cache_size; i++) { in ext2fs_read_inode2()
779 if (fs->icache->cache[i].ino == ino) { in ext2fs_read_inode2()
780 memcpy(inode, fs->icache->cache[i].inode, in ext2fs_read_inode2()
785 if (fs->flags & EXT2_FLAG_IMAGE_FILE) { in ext2fs_read_inode2()
786 inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super); in ext2fs_read_inode2()
787 block_nr = ext2fs_le32_to_cpu(fs->image_header->offset_inode) / fs->blocksize; in ext2fs_read_inode2()
790 EXT2_INODE_SIZE(fs->super); in ext2fs_read_inode2()
791 io = fs->image_io; in ext2fs_read_inode2()
793 group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); in ext2fs_read_inode2()
794 if (group > fs->group_desc_count) in ext2fs_read_inode2()
796 offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * in ext2fs_read_inode2()
797 EXT2_INODE_SIZE(fs->super); in ext2fs_read_inode2()
798 block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); in ext2fs_read_inode2()
799 block_nr = ext2fs_inode_table_loc(fs, group); in ext2fs_read_inode2()
802 if ((block_nr < fs->super->s_first_data_block) || in ext2fs_read_inode2()
803 (block_nr + fs->inode_blocks_per_group - 1 >= in ext2fs_read_inode2()
804 ext2fs_blocks_count(fs->super))) in ext2fs_read_inode2()
807 io = fs->io; in ext2fs_read_inode2()
809 offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); in ext2fs_read_inode2()
811 cache_slot = (fs->icache->cache_last + 1) % fs->icache->cache_size; in ext2fs_read_inode2()
812 iptr = (struct ext2_inode_large *)fs->icache->cache[cache_slot].inode; in ext2fs_read_inode2()
817 if ((offset + length) > fs->blocksize) in ext2fs_read_inode2()
818 clen = fs->blocksize - offset; in ext2fs_read_inode2()
820 if (block_nr != fs->icache->buffer_blk) { in ext2fs_read_inode2()
822 fs->icache->buffer); in ext2fs_read_inode2()
825 fs->icache->buffer_blk = block_nr; in ext2fs_read_inode2()
828 memcpy(ptr, ((char *) fs->icache->buffer) + (unsigned) offset, in ext2fs_read_inode2()
836 length = EXT2_INODE_SIZE(fs->super); in ext2fs_read_inode2()
839 fail_csum = !ext2fs_inode_csum_verify(fs, ino, iptr); in ext2fs_read_inode2()
842 ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) iptr, in ext2fs_read_inode2()
849 fs->icache->cache_last = cache_slot; in ext2fs_read_inode2()
850 fs->icache->cache[cache_slot].ino = ino; in ext2fs_read_inode2()
854 if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) && in ext2fs_read_inode2()
861 errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, in ext2fs_read_inode_full() argument
864 return ext2fs_read_inode2(fs, ino, inode, bufsize, 0); in ext2fs_read_inode_full()
867 errcode_t ext2fs_read_inode(ext2_filsys fs, ext2_ino_t ino, in ext2fs_read_inode() argument
870 return ext2fs_read_inode2(fs, ino, inode, in ext2fs_read_inode()
874 errcode_t ext2fs_write_inode2(ext2_filsys fs, ext2_ino_t ino, in ext2fs_write_inode2() argument
886 int length = EXT2_INODE_SIZE(fs->super); in ext2fs_write_inode2()
888 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_write_inode2()
891 if (fs->write_inode) { in ext2fs_write_inode2()
892 retval = (fs->write_inode)(fs, ino, inode); in ext2fs_write_inode2()
897 if ((ino == 0) || (ino > fs->super->s_inodes_count)) in ext2fs_write_inode2()
906 retval = ext2fs_read_inode2(fs, ino, in ext2fs_write_inode2()
914 if (fs->icache) { in ext2fs_write_inode2()
915 for (i=0; i < fs->icache->cache_size; i++) { in ext2fs_write_inode2()
916 if (fs->icache->cache[i].ino == ino) { in ext2fs_write_inode2()
917 memcpy(fs->icache->cache[i].inode, inode, in ext2fs_write_inode2()
923 retval = ext2fs_create_inode_cache(fs, 4); in ext2fs_write_inode2()
929 if (!(fs->flags & EXT2_FLAG_RW)) { in ext2fs_write_inode2()
935 ext2fs_swap_inode_full(fs, w_inode, w_inode, 1, length); in ext2fs_write_inode2()
939 retval = ext2fs_inode_csum_set(fs, ino, w_inode); in ext2fs_write_inode2()
944 group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); in ext2fs_write_inode2()
945 offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * in ext2fs_write_inode2()
946 EXT2_INODE_SIZE(fs->super); in ext2fs_write_inode2()
947 block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); in ext2fs_write_inode2()
948 block_nr = ext2fs_inode_table_loc(fs, (unsigned) group); in ext2fs_write_inode2()
953 if ((block_nr < fs->super->s_first_data_block) || in ext2fs_write_inode2()
954 (block_nr + fs->inode_blocks_per_group - 1 >= in ext2fs_write_inode2()
955 ext2fs_blocks_count(fs->super))) { in ext2fs_write_inode2()
961 offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); in ext2fs_write_inode2()
967 if ((offset + length) > fs->blocksize) in ext2fs_write_inode2()
968 clen = fs->blocksize - offset; in ext2fs_write_inode2()
970 if (fs->icache->buffer_blk != block_nr) { in ext2fs_write_inode2()
971 retval = io_channel_read_blk64(fs->io, block_nr, 1, in ext2fs_write_inode2()
972 fs->icache->buffer); in ext2fs_write_inode2()
975 fs->icache->buffer_blk = block_nr; in ext2fs_write_inode2()
979 memcpy((char *) fs->icache->buffer + (unsigned) offset, in ext2fs_write_inode2()
982 retval = io_channel_write_blk64(fs->io, block_nr, 1, in ext2fs_write_inode2()
983 fs->icache->buffer); in ext2fs_write_inode2()
993 fs->flags |= EXT2_FLAG_CHANGED; in ext2fs_write_inode2()
999 errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, in ext2fs_write_inode_full() argument
1002 return ext2fs_write_inode2(fs, ino, inode, bufsize, 0); in ext2fs_write_inode_full()
1005 errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, in ext2fs_write_inode() argument
1008 return ext2fs_write_inode2(fs, ino, inode, in ext2fs_write_inode()
1016 errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, in ext2fs_write_new_inode() argument
1020 int size = EXT2_INODE_SIZE(fs->super); in ext2fs_write_new_inode()
1023 __u32 t = fs->now ? fs->now : time(NULL); in ext2fs_write_new_inode()
1033 return ext2fs_write_inode_full(fs, ino, inode, in ext2fs_write_new_inode()
1049 retval = ext2fs_write_inode_full(fs, ino, buf, size); in ext2fs_write_new_inode()
1055 errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks) in ext2fs_get_blocks() argument
1061 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_get_blocks()
1063 if (ino > fs->super->s_inodes_count) in ext2fs_get_blocks()
1066 if (fs->get_blocks) { in ext2fs_get_blocks()
1067 if (!(*fs->get_blocks)(fs, ino, blocks)) in ext2fs_get_blocks()
1070 retval = ext2fs_read_inode(fs, ino, &inode); in ext2fs_get_blocks()
1078 errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino) in ext2fs_check_directory() argument
1083 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_check_directory()
1085 if (ino > fs->super->s_inodes_count) in ext2fs_check_directory()
1088 if (fs->check_directory) { in ext2fs_check_directory()
1089 retval = (fs->check_directory)(fs, ino); in ext2fs_check_directory()
1093 retval = ext2fs_read_inode(fs, ino, &inode); in ext2fs_check_directory()