Changeset 488f7ed in mainline
- Timestamp:
- 2011-04-16T11:47:52Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6fc5262
- Parents:
- afd9c3b
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
rafd9c3b r488f7ed 181 181 182 182 /*mfs_dentry.c*/ 183 extern struct mfs_dentry_info * 184 read_directory_entry(struct mfs_node *mnode, unsigned index); 183 extern int 184 read_directory_entry(struct mfs_node *mnode, 185 struct mfs_dentry_info **d_info, unsigned index); 185 186 186 187 extern int -
uspace/srv/fs/minixfs/mfs_dentry.c
rafd9c3b r488f7ed 36 36 #include "mfs_utils.h" 37 37 38 struct mfs_dentry_info * 39 read_directory_entry(struct mfs_node *mnode, unsigned index) 38 int 39 read_directory_entry(struct mfs_node *mnode, 40 struct mfs_dentry_info **d_info, unsigned index) 40 41 { 41 42 const struct mfs_instance *inst = mnode->instance; … … 47 48 mfsdebug("read_directory(%u)\n", index); 48 49 49 struct mfs_dentry_info *d_info = malloc(sizeof(*d_info));50 if (! d_info)51 return NULL;50 *d_info = malloc(sizeof(**d_info)); 51 if (!*d_info) 52 return ENOMEM; 52 53 53 54 int r = read_map(&block, mnode, index * sbi->dirsize); 54 if (r != EOK || block == 0)55 if (r != EOK) 55 56 goto out_err; 57 58 if (block == 0) { 59 r = EIO; 60 goto out_err; 61 } 56 62 57 63 r = block_get(&b, inst->handle, block, BLOCK_FLAGS_NONE); … … 67 73 d3 = b->data + (dentry_off * MFS3_DIRSIZE); 68 74 69 d_info->d_inum = conv32(sbi->native, d3->d_inum);70 memcpy( d_info->d_name, d3->d_name, MFS3_MAX_NAME_LEN);75 (*d_info)->d_inum = conv32(sbi->native, d3->d_inum); 76 memcpy((*d_info)->d_name, d3->d_name, MFS3_MAX_NAME_LEN); 71 77 } else { 72 78 const int namelen = longnames ? MFS_L_MAX_NAME_LEN : … … 77 83 d = b->data + dentry_off * (longnames ? MFSL_DIRSIZE : 78 84 MFS_DIRSIZE); 79 d_info->d_inum = conv16(sbi->native, d->d_inum);80 memcpy( d_info->d_name, d->d_name, namelen);85 (*d_info)->d_inum = conv16(sbi->native, d->d_inum); 86 memcpy((*d_info)->d_name, d->d_name, namelen); 81 87 } 82 88 83 89 block_put(b); 84 90 85 d_info->index = index;86 d_info->node = mnode;87 return d_info;91 (*d_info)->index = index; 92 (*d_info)->node = mnode; 93 return EOK; 88 94 89 95 out_err: 90 free(d_info); 91 return NULL; 96 free(*d_info); 97 *d_info = NULL; 98 return r; 92 99 } 93 100 … … 151 158 152 159 for (i = 2; ; ++i) { 153 d_info = read_directory_entry(mnode, i); 160 r = read_directory_entry(mnode, &d_info, i); 161 if (r != EOK) 162 return r; 154 163 155 164 if (!d_info) { … … 171 180 return r; 172 181 173 d_info = read_directory_entry(mnode, i);174 if ( !d_info)175 return EIO;182 r = read_directory_entry(mnode, &d_info, i); 183 if (r != EOK) 184 return r; 176 185 } 177 186 -
uspace/srv/fs/minixfs/mfs_ops.c
rafd9c3b r488f7ed 336 336 struct mfs_ino_info *ino_i = mnode->ino_i; 337 337 struct mfs_dentry_info *d_info; 338 int r; 338 339 339 340 mfsdebug("mfs_match()\n"); … … 347 348 int i = 2; 348 349 while (1) { 349 d_info = read_directory_entry(mnode, i++); 350 r = read_directory_entry(mnode, &d_info, i++); 351 if (r != EOK) 352 return r; 353 350 354 if (!d_info) { 351 355 /*Reached the end of the directory entry list*/ … … 535 539 { 536 540 struct mfs_node *mnode = fsnode->data; 541 int r; 537 542 538 543 *has_children = false; … … 546 551 int i = 2; 547 552 while (1) { 548 d_info = read_directory_entry(mnode, i++); 553 r = read_directory_entry(mnode, &d_info, i++); 554 if (r != EOK) 555 return r; 549 556 550 557 if (!d_info) { … … 612 619 613 620 while (1) { 614 d_info = read_directory_entry(mnode, pos); 621 rc = read_directory_entry(mnode, &d_info, pos); 622 if (rc != EOK) 623 goto out_error; 624 615 625 if (!d_info) { 616 626 /*Reached the end of the dentries list*/
Note:
See TracChangeset
for help on using the changeset viewer.