Changeset 2d7c77a in mainline
- Timestamp:
- 2011-04-03T17:41:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 18346ec
- Parents:
- c4eeb2f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs_read.c
rc4eeb2f r2d7c77a 36 36 #include "mfs_utils.h" 37 37 38 static int read_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock); 39 40 /*Given the position in the file expressed in 38 static int 39 rw_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock, 40 bool write_mode, uint32_t w_block); 41 42 /**Given the position in the file expressed in 41 43 *bytes, this function returns the on-disk block 42 44 *relative to that position. … … 65 67 } 66 68 67 r = r ead_map_ondisk(b, mnode, rblock);69 r = rw_map_ondisk(b, mnode, rblock, false, 0); 68 70 out: 69 71 return r; 70 72 } 71 73 72 static int read_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock) 74 static int 75 rw_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock, 76 bool write_mode, uint32_t w_block) 73 77 { 74 78 int r, nr_direct; … … 78 82 79 83 assert(mnode); 80 conststruct mfs_ino_info *ino_i = mnode->ino_i;84 struct mfs_ino_info *ino_i = mnode->ino_i; 81 85 82 86 assert(ino_i); … … 100 104 if (rblock < nr_direct) { 101 105 *b = ino_i->i_dzone[rblock]; 106 if (write_mode) { 107 ino_i->i_dzone[rblock] = w_block; 108 ino_i->dirty = true; 109 } 102 110 r = EOK; 103 111 goto out; … … 118 126 119 127 if (fs_version == MFS_VERSION_V1) { 120 uint16_t tmp = ((uint16_t *) bi1->data)[rblock]; 121 *b = conv16(sbi->native, tmp); 128 uint16_t *tmp = &(((uint16_t *) bi1->data)[rblock]); 129 *b = conv16(sbi->native, *tmp); 130 if (write_mode) { 131 *tmp = conv16(sbi->native, w_block); 132 bi1->dirty = true; 133 } 122 134 } else { 123 uint32_t tmp = ((uint32_t *) bi1->data)[rblock]; 124 *b = conv32(sbi->native, tmp); 135 uint32_t *tmp = &(((uint32_t *) bi1->data)[rblock]); 136 *b = conv32(sbi->native, *tmp); 137 if (write_mode) { 138 *tmp = conv32(sbi->native, w_block); 139 bi1->dirty = true; 140 } 125 141 } 126 142 … … 154 170 uint16_t *pt16 = bi1->data; 155 171 uint16_t blk = conv16(sbi->native, pt16[di_block]); 172 156 173 r = block_get(&bi2, inst->handle, blk, BLOCK_FLAGS_NONE); 157 174 … … 160 177 161 178 pt16 = bi2->data; 162 blk = conv16(sbi->native, pt16[di_block % ptrs_per_block]); 163 *b = blk; 179 pt16 += di_block % ptrs_per_block; 180 *b = conv16(sbi->native, *pt16); 181 if (write_mode) { 182 *pt16 = conv16(sbi->native, w_block); 183 bi2->dirty = false; 184 } 164 185 } else { 165 186 uint32_t *pt32 = bi1->data; 166 187 uint32_t blk = conv32(sbi->native, pt32[di_block]); 188 167 189 r = block_get(&bi2, inst->handle, blk, BLOCK_FLAGS_NONE); 168 190 … … 171 193 172 194 pt32 = bi2->data; 173 blk = conv32(sbi->native, pt32[di_block % ptrs_per_block]); 174 *b = blk; 195 pt32 += di_block % ptrs_per_block; 196 *b = conv32(sbi->native, *pt32); 197 if (write_mode) { 198 *pt32 = conv32(sbi->native, w_block); 199 bi2->dirty = false; 200 } 175 201 } 176 202 r = EOK;
Note:
See TracChangeset
for help on using the changeset viewer.