Changeset fde8a27 in mainline
- Timestamp:
- 2011-03-28T19:17:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f1cc9d
- Parents:
- ef76d72
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
ref76d72 rfde8a27 57 57 58 58 GLOBAL fs_reg_t mfs_reg; 59 60 typedef enum { 61 BMAP_ZONE, 62 BMAP_INODE 63 } bmap_id_t; 59 64 60 65 typedef enum { -
uspace/srv/fs/minixfs/mfs_read.c
ref76d72 rfde8a27 72 72 static int read_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock) 73 73 { 74 block_t *bi1, *bi2;75 74 int r, nr_direct; 76 75 int ptrs_per_block; 76 uint32_t *bi1 = NULL; 77 uint32_t *bi2 = NULL; 77 78 78 79 assert(mnode); … … 110 111 } 111 112 112 r = read_ind_block(bi2, mnode->instance, ino_i->i_izone[0]); 113 bi1 = (uint32_t *) malloc(sbi->block_size); 114 r = read_ind_block(bi1, mnode->instance, ino_i->i_izone[0], 115 fs_version); 113 116 114 if (r != EOK) 115 goto out; 117 if (fs_version == MFS_VERSION_V1) 118 *b = ((uint16_t *) bi1)[rblock]; 119 else 120 *b = bi1[rblock]; 116 121 117 *b = fs_version == MFS_VERSION_V1 ? 118 ((uint16_t *) bi1->data)[rblock] : 119 ((uint32_t *) bi1->data)[rblock]; 120 goto out_block; 122 goto out; 121 123 } 122 124 … … 130 132 goto out; 131 133 } 132 r = read_ind_block(bi1, mnode->instance, ino_i->i_izone[1]); 134 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); 133 140 134 141 if (r != EOK) … … 144 151 if (fs_version == MFS_VERSION_V1) { 145 152 r = read_ind_block(bi2, mnode->instance, 146 ((uint16_t *) bi1 ->data)[di_block]);153 ((uint16_t *) bi1)[di_block], fs_version); 147 154 148 155 if (r != EOK) 149 goto out _block;156 goto out; 150 157 151 *b = ((uint16_t *) bi2 ->data)[rblock % ptrs_per_block];158 *b = ((uint16_t *) bi2)[rblock % ptrs_per_block]; 152 159 } else { 153 160 r = read_ind_block(bi2, mnode->instance, 154 ((uint32_t *) bi1 ->data)[di_block]);161 ((uint32_t *) bi1)[di_block], fs_version); 155 162 156 163 if (r != EOK) 157 goto out _block;164 goto out; 158 165 159 *b = ((uint32_t *) bi2->data)[rblock % ptrs_per_block];166 *b = bi2[rblock % ptrs_per_block]; 160 167 } 161 168 r = EOK; 162 block_put(bi2);163 169 164 out_block:165 block_put(bi1);166 170 out: 171 if (bi1) 172 free(bi1); 173 if (bi2) 174 free(bi2); 167 175 return r; 168 176 } -
uspace/srv/fs/minixfs/mfs_utils.c
ref76d72 rfde8a27 65 65 *content to the native endian format. 66 66 */ 67 int read_ind_block(block_t *b, struct mfs_instance *inst, uint32_t block) 67 int 68 read_ind_block(void *data, struct mfs_instance *inst, 69 uint32_t block, mfs_version_t version) 68 70 { 69 71 int rc; 70 72 unsigned i; 73 block_t *b; 74 uint32_t *ptr32; 75 uint16_t *ptr16; 71 76 72 77 assert(inst); … … 79 84 80 85 if (rc != EOK) 81 return rc;86 goto out; 82 87 83 if (sbi->fs_version == MFS_VERSION_V1) { 84 uint16_t *pt16 = b->data; 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]); 85 98 86 for (i = 0; i < MFS_BLOCKSIZE / sizeof(uint16_t); ++i)87 pt16[i] = conv16(sbi->native, pt16[i]);88 } else {89 uint32_t *pt32 = b->data;90 91 for (i = 0; i < sbi->block_size / sizeof(uint32_t); ++i)92 pt32[i] = conv32(sbi->native, pt32[i]);93 99 } 94 100 95 return EOK; 101 rc = EOK; 102 103 out: 104 block_put(b); 105 return rc; 96 106 } 97 107 -
uspace/srv/fs/minixfs/mfs_utils.h
ref76d72 rfde8a27 36 36 #include <sys/types.h> 37 37 #include <bool.h> 38 #include "mfs.h" 38 39 39 uint16_t conv16(bool native, uint16_t n); 40 uint32_t conv32(bool native, uint32_t n); 41 uint64_t conv64(bool native, uint64_t n); 42 int read_ind_block(block_t *b, struct mfs_instance *inst, uint32_t block); 40 extern uint16_t 41 conv16(bool native, uint16_t n); 42 43 extern uint32_t 44 conv32(bool native, uint32_t n); 45 46 extern uint64_t 47 conv64(bool native, uint64_t n); 48 49 extern int 50 read_ind_block(void *data, struct mfs_instance *inst, 51 uint32_t block, mfs_version_t version); 43 52 44 53 #endif
Note:
See TracChangeset
for help on using the changeset viewer.