Changeset 4bf0052a in mainline
- Timestamp:
- 2011-07-27T11:23:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ee257b2
- Parents:
- dd9af5d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs_inode.c
rdd9af5d r4bf0052a 40 40 mfs2_write_inode_raw(struct mfs_node *mnode); 41 41 42 static struct mfs_ino_info * 43 mfs_read_inode_raw(const struct mfs_instance *instance, uint16_t inum); 44 45 static struct mfs_ino_info * 46 mfs2_read_inode_raw(const struct mfs_instance *instance, uint32_t inum); 42 static int 43 mfs_read_inode_raw(const struct mfs_instance *instance, 44 struct mfs_ino_info **ino_ptr, uint16_t inum); 45 46 static int 47 mfs2_read_inode_raw(const struct mfs_instance *instance, 48 struct mfs_ino_info **ino_ptr, uint32_t inum); 47 49 48 50 … … 52 54 { 53 55 struct mfs_sb_info *sbi = inst->sbi; 56 int r; 54 57 55 58 if (sbi->fs_version == MFS_VERSION_V1) { 56 59 /*Read a MFS V1 inode*/ 57 *ino_i = mfs_read_inode_raw(inst, index);60 r = mfs_read_inode_raw(inst, ino_i, index); 58 61 } else { 59 62 /*Read a MFS V2/V3 inode*/ 60 *ino_i = mfs2_read_inode_raw(inst, index); 61 } 62 63 if (*ino_i == NULL) 64 return -1; 65 66 return EOK; 67 } 68 69 static struct mfs_ino_info * 70 mfs_read_inode_raw(const struct mfs_instance *instance, uint16_t inum) { 71 struct mfs_inode *ino = NULL; 63 r = mfs2_read_inode_raw(inst, ino_i, index); 64 } 65 66 return r; 67 } 68 69 static int 70 mfs_read_inode_raw(const struct mfs_instance *instance, 71 struct mfs_ino_info **ino_ptr, uint16_t inum) { 72 struct mfs_inode *ino; 72 73 struct mfs_ino_info *ino_i = NULL; 73 74 struct mfs_sb_info *sbi; 74 75 block_t *b; 75 int i ;76 int i, r; 76 77 77 78 sbi = instance->sbi; … … 82 83 83 84 const int ino_off = inum % sbi->ino_per_block; 84 const size_t ino_size = sizeof(struct mfs_inode);85 85 86 86 ino_i = malloc(sizeof(*ino_i)); 87 ino = malloc(ino_size); 88 89 if (!ino || !ino_i)87 88 if (!ino_i) { 89 r = ENOMEM; 90 90 goto out_err; 91 } 91 92 92 93 const int itable_off = sbi->itable_off; 93 94 94 if (block_get(&b, instance->handle,95 r = block_get(&b, instance->handle, 95 96 itable_off + inum / sbi->ino_per_block, 96 BLOCK_FLAGS_NONE) != EOK)97 goto out_err;98 99 memcpy(ino, ((uint8_t *) b->data) + ino_off * ino_size, ino_size);97 BLOCK_FLAGS_NONE); 98 on_error(r, goto out_err); 99 100 ino = b->data + ino_off * sizeof(struct mfs_inode); 100 101 101 102 ino_i->i_mode = conv16(sbi->native, ino->i_mode); … … 111 112 ino_i->i_izone[i] = conv16(sbi->native, ino->i_izone[i]); 112 113 113 block_put(b); 114 free(ino); 114 r = block_put(b); 115 115 ino_i->dirty = false; 116 117 return ino_i; 116 *ino_ptr = ino_i; 117 118 return r; 118 119 119 120 out_err: 120 if (ino)121 free(ino);122 121 if (ino_i) 123 122 free(ino_i); 124 return NULL; 125 } 126 127 static struct mfs_ino_info * 128 mfs2_read_inode_raw(const struct mfs_instance *instance, uint32_t inum) { 129 struct mfs2_inode *ino = NULL; 123 return EOK; 124 } 125 126 static int 127 mfs2_read_inode_raw(const struct mfs_instance *instance, 128 struct mfs_ino_info **ino_ptr, uint32_t inum) { 129 struct mfs2_inode *ino; 130 130 struct mfs_ino_info *ino_i = NULL; 131 131 struct mfs_sb_info *sbi; 132 132 block_t *b; 133 int i; 134 135 const size_t ino_size = sizeof(struct mfs2_inode); 136 137 ino = malloc(ino_size); 133 int i, r; 134 138 135 ino_i = malloc(sizeof(*ino_i)); 139 136 140 if (!ino || !ino_i) 137 if (!ino_i) { 138 r = ENOMEM; 141 139 goto out_err; 140 } 142 141 143 142 sbi = instance->sbi; … … 150 149 const int ino_off = inum % sbi->ino_per_block; 151 150 152 if (block_get(&b, instance->handle,151 r = block_get(&b, instance->handle, 153 152 itable_off + inum / sbi->ino_per_block, 154 BLOCK_FLAGS_NONE) != EOK)155 goto out_err;156 157 memcpy(ino, b->data + ino_off * ino_size, ino_size);153 BLOCK_FLAGS_NONE); 154 on_error(r, goto out_err); 155 156 ino = b->data + ino_off * sizeof(struct mfs2_inode); 158 157 159 158 ino_i->i_mode = conv16(sbi->native, ino->i_mode); … … 172 171 ino_i->i_izone[i] = conv32(sbi->native, ino->i_izone[i]); 173 172 174 block_put(b); 175 free(ino); 173 r = block_put(b); 176 174 ino_i->dirty = false; 177 178 return ino_i; 175 *ino_ptr = ino_i; 176 177 return r; 179 178 180 179 out_err: 181 if (ino)182 free(ino);183 180 if (ino_i) 184 181 free(ino_i); 185 return NULL;182 return EOK; 186 183 } 187 184
Note:
See TracChangeset
for help on using the changeset viewer.