Changeset 2bbbfd3 in mainline
- Timestamp:
- 2011-04-05T19:28:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7bd68e6
- Parents:
- af8ce880
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
raf8ce880 r2bbbfd3 163 163 put_inode(struct mfs_node *mnode); 164 164 165 /*mfs_read.c*/ 166 int read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos); 165 /*mfs_rw.c*/ 166 extern int 167 read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos); 168 169 extern int 170 write_map(struct mfs_node *mnode, uint32_t pos, uint32_t new_zone, 171 uint32_t *old_zone); 172 173 extern int 174 free_zone(struct mfs_node *mnode, const uint32_t zone); 167 175 168 176 /*mfs_dentry.c*/ -
uspace/srv/fs/minixfs/mfs_rw.c
raf8ce880 r2bbbfd3 1 1 /* 2 g 2 3 * Copyright (c) 2011 Maurizio Lombardi 3 4 * All rights reserved. … … 52 53 *Returns zero if the block does not exist. 53 54 */ 54 int read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos) 55 int 56 read_map(uint32_t *b, const struct mfs_node *mnode, uint32_t pos) 55 57 { 56 58 int r; 57 58 assert(mnode);59 assert(mnode->instance);60 61 59 const struct mfs_sb_info *sbi = mnode->instance->sbi; 62 assert(sbi);63 64 60 const int block_size = sbi->block_size; 65 61 … … 79 75 } 80 76 77 int 78 write_map(struct mfs_node *mnode, const uint32_t pos, uint32_t new_zone, 79 uint32_t *old_zone) 80 { 81 const struct mfs_sb_info *sbi = mnode->instance->sbi; 82 const int block_size = sbi->block_size; 83 84 /*Compute the relative block number in file*/ 85 int rblock = pos / block_size; 86 87 return rw_map_ondisk(old_zone, mnode, rblock, true, new_zone); 88 } 89 90 int 91 free_zone(struct mfs_node *mnode, const uint32_t zone) 92 { 93 int r; 94 uint32_t old_zone; 95 96 r = rw_map_ondisk(&old_zone, mnode, zone, true, 0); 97 if (r != EOK) 98 return r; 99 100 if (old_zone > 0) 101 mfs_free_bit(mnode->instance, old_zone, BMAP_ZONE); 102 103 return EOK; 104 } 105 81 106 static int 82 107 rw_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock, … … 98 123 assert(sbi); 99 124 100 const int fs_version = sbi->fs_version;125 const mfs_version_t fs_version = sbi->fs_version; 101 126 102 127 if (fs_version == MFS_VERSION_V1) { … … 115 140 ino_i->dirty = true; 116 141 } 117 r = EOK; 118 goto out; 142 return EOK; 119 143 } 120 144 rblock -= nr_direct - 1; … … 127 151 r = alloc_zone_and_clear(inst, &block); 128 152 if (r != EOK) 129 goto out;153 return r; 130 154 131 155 ino_i->i_izone[0] = block; 132 156 ino_i->dirty = true; 133 } else { 134 r = -1; 135 goto out; 136 } 157 } else 158 return -1; 137 159 } 138 160 … … 140 162 BLOCK_FLAGS_NONE); 141 163 if (r != EOK) 142 goto out;164 return r; 143 165 144 166 if (fs_version == MFS_VERSION_V1) { … … 171 193 r = alloc_zone_and_clear(inst, &block); 172 194 if (r != EOK) 173 goto out;195 return r; 174 196 175 197 ino_i->i_izone[1] = block; 176 198 ino_i->dirty = true; 177 } else { 178 r = -1; 179 goto out; 180 } 199 } else 200 return -1; 181 201 } 182 202 183 203 r = block_get(&bi1, inst->handle, ino_i->i_izone[1], 184 204 BLOCK_FLAGS_NONE); 185 186 205 if (r != EOK) 187 goto out;206 return r; 188 207 189 208 /* … … 203 222 r = alloc_zone_and_clear(inst, &block); 204 223 if (r != EOK) 205 goto out;224 return r; 206 225 207 226 blk = block; 208 227 pt16[ind2_block] = conv16(sbi->native, blk); 209 228 bi1->dirty = true; 210 } else { 211 r = -1; 212 goto out; 213 } 229 } else 230 return -1; 214 231 } 215 232 … … 235 252 r = alloc_zone_and_clear(inst, &block); 236 253 if (r != EOK) 237 goto out;254 return r; 238 255 239 256 blk = block; 240 257 pt32[ind2_block] = conv32(sbi->native, blk); 241 258 bi1->dirty = true; 242 } else { 243 r = -1; 244 goto out; 245 } 259 } else 260 return -1; 246 261 } 247 262 … … 264 279 out_put_1: 265 280 block_put(bi1); 266 out:267 281 return r; 268 282 }
Note:
See TracChangeset
for help on using the changeset viewer.