Changeset 10eb754 in mainline for uspace/srv/fs/minixfs/mfs_inode.c
- Timestamp:
- 2011-04-02T09:14:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f3e2663
- Parents:
- 9cd199c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs_inode.c
r9cd199c r10eb754 38 38 #include "mfs_utils.h" 39 39 40 struct mfs_ino_info *mfs_read_inode_raw(const struct mfs_instance *instance, 41 uint16_t inum) 40 static int 41 mfs_write_inode_raw(struct mfs_node *mnode); 42 43 struct mfs_ino_info * 44 mfs_read_inode_raw(const struct mfs_instance *instance, uint16_t inum) 42 45 { 43 46 struct mfs_inode *ino = NULL; … … 46 49 block_t *b; 47 50 int i; 51 52 sbi = instance->sbi; 53 assert(sbi); 48 54 49 const int ino_off = inum % V1_INODES_PER_BLOCK;55 const int ino_off = inum % sbi->ino_per_block; 50 56 const size_t ino_size = sizeof(struct mfs_inode); 51 57 … … 56 62 goto out_err; 57 63 58 sbi = instance->sbi; 59 assert(sbi); 60 61 const int itable_off = 2 + sbi->ibmap_blocks + sbi->zbmap_blocks; 64 const int itable_off = sbi->itable_off; 62 65 63 66 if (block_get(&b, instance->handle, 64 itable_off + inum / V1_INODES_PER_BLOCK,67 itable_off + inum / sbi->ino_per_block, 65 68 BLOCK_FLAGS_NONE) != EOK) 66 69 goto out_err; … … 94 97 } 95 98 96 struct mfs_ino_info * mfs2_read_inode_raw(const struct mfs_instance *instance,97 99 struct mfs_ino_info * 100 mfs2_read_inode_raw(const struct mfs_instance *instance, uint32_t inum) 98 101 { 99 102 struct mfs2_inode *ino = NULL; … … 114 117 assert(sbi); 115 118 116 const int itable_off = 2 + sbi->ibmap_blocks + sbi->zbmap_blocks;117 const int ino_off = inum % V3_INODES_PER_BLOCK(sbi->block_size);119 const int itable_off = sbi->itable_off; 120 const int ino_off = inum % sbi->ino_per_block; 118 121 119 122 if (block_get(&b, instance->handle, 120 itable_off + inum / V3_INODES_PER_BLOCK(sbi->block_size),123 itable_off + inum / sbi->ino_per_block, 121 124 BLOCK_FLAGS_NONE) != EOK) 122 125 goto out_err; … … 153 156 } 154 157 158 int 159 put_inode(struct mfs_node *mnode) 160 { 161 int rc = EOK; 162 163 assert(mnode); 164 assert(mnode->ino_i); 165 166 if (!mnode->ino_i->dirty) 167 goto out; 168 169 struct mfs_instance *inst = mnode->instance; 170 assert(inst); 171 struct mfs_sb_info *sbi = inst->sbi; 172 assert(sbi); 173 174 if (sbi->fs_version == MFS_VERSION_V1) 175 rc = mfs_write_inode_raw(mnode); 176 else { 177 /*rc = mfs2_write_inode_raw(mnode);*/ 178 } 179 180 out: 181 return rc; 182 } 183 184 static int 185 mfs_write_inode_raw(struct mfs_node *mnode) 186 { 187 int i, r; 188 block_t *b; 189 struct mfs_ino_info *ino_i = mnode->ino_i; 190 struct mfs_sb_info *sbi = mnode->instance->sbi; 191 192 const int itable_off = sbi->itable_off; 193 const int ino_off = ino_i->index % sbi->ino_per_block; 194 const bool native = sbi->native; 195 196 r = block_get(&b, mnode->instance->handle, 197 itable_off + ino_i->index / sbi->ino_per_block, 198 BLOCK_FLAGS_NONE); 199 200 if (r != EOK) 201 goto out; 202 203 struct mfs_inode *ino = b->data; 204 ino += ino_off; 205 206 ino->i_mode = conv16(native, ino_i->i_mode); 207 ino->i_uid = conv16(native, ino_i->i_uid); 208 ino->i_gid = ino_i->i_gid; 209 ino->i_nlinks = ino_i->i_nlinks; 210 ino->i_size = conv32(native, ino_i->i_size); 211 ino->i_mtime = conv32(native, ino_i->i_mtime); 212 213 for (i = 0; i < V1_NR_DIRECT_ZONES; ++i) 214 ino->i_dzone[i] = conv16(native, ino_i->i_dzone[i]); 215 for (i = 0; i < V1_NR_INDIRECT_ZONES; ++i) 216 ino->i_izone[i] = conv16(native, ino_i->i_izone[i]); 217 218 b->dirty = true; 219 block_put(b); 220 221 ino_i->dirty = false; 222 out: 223 return r; 224 } 225 155 226 /** 156 227 * @}
Note:
See TracChangeset
for help on using the changeset viewer.