Changeset 152610a8 in mainline
- Timestamp:
- 2011-03-29T18:03:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba5beaf
- Parents:
- 1f1cc9d
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
r1f1cc9d r152610a8 57 57 58 58 GLOBAL fs_reg_t mfs_reg; 59 60 typedef uint32_t bitchunk_t; 59 61 60 62 typedef enum { -
uspace/srv/fs/minixfs/mfs_ops.c
r1f1cc9d r152610a8 438 438 if (!d_info) { 439 439 /*Reached the end of the dentries list*/ 440 goto out;440 break; 441 441 } 442 442 -
uspace/srv/fs/minixfs/mfs_read.c
r1f1cc9d r152610a8 74 74 int r, nr_direct; 75 75 int ptrs_per_block; 76 uint32_t *bi1 = NULL;77 uint32_t *bi2 = NULL;76 block_t *bi1; 77 block_t *bi2; 78 78 79 79 assert(mnode); … … 83 83 assert(mnode->instance); 84 84 85 const struct mfs_sb_info *sbi = mnode->instance->sbi; 85 const struct mfs_instance *inst = mnode->instance; 86 const struct mfs_sb_info *sbi = inst->sbi; 86 87 assert(sbi); 87 88 … … 111 112 } 112 113 113 bi1 = (uint32_t *) malloc(sbi->block_size); 114 r = read_ind_block(bi1, mnode->instance, ino_i->i_izone[0], 115 fs_version); 114 r = block_get(&bi1, inst->handle, ino_i->i_izone[0], 115 BLOCK_FLAGS_NONE); 116 if (r != EOK) 117 goto out; 116 118 117 if (fs_version == MFS_VERSION_V1) 118 *b = ((uint16_t *) bi1)[rblock]; 119 else 120 *b = bi1[rblock]; 119 if (fs_version == MFS_VERSION_V1) { 120 uint16_t tmp = ((uint16_t *) bi1->data)[rblock]; 121 *b = conv16(sbi->native, tmp); 122 } else { 123 uint32_t tmp = ((uint32_t *) bi1->data)[rblock]; 124 *b = conv32(sbi->native, tmp); 125 } 121 126 122 goto out ;127 goto out_put_1; 123 128 } 124 129 … … 133 138 } 134 139 135 bi1 = (uint32_t *) malloc(sbi->block_size); 136 bi2 = (uint32_t *) malloc(sbi->block_size); 137 138 r = read_ind_block(bi1, mnode->instance, ino_i->i_izone[1], 139 fs_version); 140 r = block_get(&bi1, inst->handle, ino_i->i_izone[1], 141 BLOCK_FLAGS_NONE); 140 142 141 143 if (r != EOK) … … 150 152 /*read the second indirect zone of the chain*/ 151 153 if (fs_version == MFS_VERSION_V1) { 152 r = read_ind_block(bi2, mnode->instance, 153 ((uint16_t *) bi1)[di_block], fs_version); 154 uint16_t *pt16 = bi1->data; 155 uint16_t blk = conv16(sbi->native, pt16[di_block]); 156 r = block_get(&bi2, inst->handle, blk, BLOCK_FLAGS_NONE); 154 157 155 158 if (r != EOK) 156 goto out ;159 goto out_put_1; 157 160 158 *b = ((uint16_t *) bi2)[rblock % ptrs_per_block]; 161 pt16 = bi2->data; 162 blk = conv16(sbi->native, pt16[di_block % ptrs_per_block]); 163 *b = blk; 159 164 } else { 160 r = read_ind_block(bi2, mnode->instance, 161 ((uint32_t *) bi1)[di_block], fs_version); 165 uint32_t *pt32 = bi1->data; 166 uint32_t blk = conv32(sbi->native, pt32[di_block]); 167 r = block_get(&bi2, inst->handle, blk, BLOCK_FLAGS_NONE); 162 168 163 169 if (r != EOK) 164 goto out ;170 goto out_put_1; 165 171 166 *b = bi2[rblock % ptrs_per_block]; 172 pt32 = bi2->data; 173 blk = conv32(sbi->native, pt32[di_block % ptrs_per_block]); 174 *b = blk; 167 175 } 168 176 r = EOK; 169 177 178 block_put(bi2); 179 out_put_1: 180 block_put(bi1); 170 181 out: 171 if (bi1)172 free(bi1);173 if (bi2)174 free(bi2);175 182 return r; 176 183 } -
uspace/srv/fs/minixfs/mfs_utils.c
r1f1cc9d r152610a8 61 61 } 62 62 63 /*64 *Read an indirect block from disk and convert its65 *content to the native endian format.66 */67 int68 read_ind_block(void *data, struct mfs_instance *inst,69 uint32_t block, mfs_version_t version)70 {71 int rc;72 unsigned i;73 block_t *b;74 uint32_t *ptr32;75 uint16_t *ptr16;76 77 assert(inst);78 devmap_handle_t handle = inst->handle;79 struct mfs_sb_info *sbi = inst->sbi;80 81 assert(sbi);82 83 rc = block_get(&b, handle, block, BLOCK_FLAGS_NONE);84 85 if (rc != EOK)86 goto out;87 88 if (version == MFS_VERSION_V1) {89 uint16_t *p = b->data;90 ptr16 = data;91 for (i = 0; i < sbi->block_size / sizeof(uint16_t); ++i)92 ptr16[i] = conv16(sbi->native, p[i]);93 } else {94 uint32_t *p = b->data;95 ptr32 = data;96 for (i = 0; i < sbi->block_size / sizeof(uint32_t); ++i)97 ptr32[i] = conv32(sbi->native, p[i]);98 99 }100 101 rc = EOK;102 103 out:104 block_put(b);105 return rc;106 }107 108 63 /** 109 64 * @} -
uspace/srv/fs/minixfs/mfs_utils.h
r1f1cc9d r152610a8 47 47 conv64(bool native, uint64_t n); 48 48 49 extern int50 read_ind_block(void *data, struct mfs_instance *inst,51 uint32_t block, mfs_version_t version);52 53 49 #endif 54 50
Note:
See TracChangeset
for help on using the changeset viewer.