Changeset 10eb754 in mainline
- 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
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
r9cd199c r10eb754 91 91 int ino_per_block; 92 92 int dirsize; 93 int itable_off; 93 94 unsigned max_name_len; 94 95 bool long_names; … … 155 156 mfs2_read_inode_raw(const struct mfs_instance *instance, uint32_t inum); 156 157 158 extern int 159 put_inode(struct mfs_node *mnode); 160 157 161 /*mfs_read.c*/ 158 162 int read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos); -
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 * @} -
uspace/srv/fs/minixfs/mfs_ops.c
r9cd199c r10eb754 56 56 static aoff64_t mfs_size_get(fs_node_t *node); 57 57 static int mfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component); 58 static int mfs_create_node(fs_node_t **rfn, devmap_handle_t handle, int flags); 58 59 59 60 static … … 76 77 .index_get = mfs_index_get, 77 78 .match = mfs_match, 79 .create = mfs_create_node, 78 80 .plb_get_char = mfs_plb_get_char, 79 81 .has_children = mfs_has_children, … … 191 193 sbi->nzones = conv32(native, sb3->s_nzones); 192 194 sbi->block_size = conv16(native, sb3->s_block_size); 195 sbi->ino_per_block = V3_INODES_PER_BLOCK(sbi->block_size); 193 196 sbi->dirsize = MFS3_DIRSIZE; 194 197 sbi->max_name_len = MFS3_MAX_NAME_LEN; … … 202 205 sbi->nzones = conv16(native, sb->s_nzones); 203 206 sbi->block_size = MFS_BLOCKSIZE; 207 sbi->ino_per_block = V1_INODES_PER_BLOCK; 204 208 if (version == MFS_VERSION_V2) 205 209 sbi->nzones = conv32(native, sb->s_nzones2); … … 208 212 MFS_MAX_NAME_LEN; 209 213 } 214 sbi->itable_off = 2 + sbi->ibmap_blocks + sbi->zbmap_blocks; 210 215 211 216 free(sb); … … 243 248 struct mfs_node *node = fsnode->data; 244 249 return node->instance->handle; 250 } 251 252 static int mfs_create_node(fs_node_t **rfn, devmap_handle_t handle, int flags) 253 { 254 mfsdebug("create_node()\n"); 255 return ENOTSUP; 245 256 } 246 257
Note:
See TracChangeset
for help on using the changeset viewer.