Changeset 629b480 in mainline for uspace/lib
- Timestamp:
- 2025-04-25T20:48:07Z (9 months ago)
- Branches:
- master
- Children:
- 21cd0c8, 32cb7cd, a4f8c3f, cbaf408
- Parents:
- 4b9213d
- Location:
- uspace/lib
- Files:
-
- 3 edited
-
device/include/vol.h (modified) (1 diff)
-
device/src/vol.c (modified) (1 diff)
-
futil/src/futil.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/device/include/vol.h
r4b9213d r629b480 61 61 extern errno_t vol_pcnt_fs_format(vol_part_cnt_t, vol_fstype_t, char **); 62 62 extern errno_t vol_mountp_validate(const char *); 63 extern errno_t vol_part_by_mp(vol_t *, const char *, service_id_t *); 63 64 64 65 #endif -
uspace/lib/device/src/vol.c
r4b9213d r629b480 608 608 } 609 609 610 /** Find volume by current mount point. 611 * 612 * @param vol Volume service 613 * @param mp Mount point 614 * @param rid Place to store partition service ID 615 * @return EOK on success or an error code 616 */ 617 errno_t vol_part_by_mp(vol_t *vol, const char *mp, service_id_t *rid) 618 { 619 vol_part_info_t vinfo; 620 service_id_t *part_ids = NULL; 621 char *canon_mp_buf = NULL; 622 char *canon_mp; 623 size_t nparts; 624 size_t i; 625 errno_t rc; 626 627 canon_mp_buf = str_dup(mp); 628 if (canon_mp_buf == NULL) { 629 rc = ENOMEM; 630 goto out; 631 } 632 633 canon_mp = vfs_absolutize(canon_mp_buf, NULL); 634 if (canon_mp == NULL) { 635 rc = EINVAL; 636 goto out; 637 } 638 639 rc = vol_get_parts(vol, &part_ids, &nparts); 640 if (rc != EOK) 641 goto out; 642 643 for (i = 0; i < nparts; i++) { 644 rc = vol_part_info(vol, part_ids[i], &vinfo); 645 if (rc != EOK) { 646 rc = EIO; 647 goto out; 648 } 649 650 if (str_cmp(vinfo.cur_mp, canon_mp) == 0) { 651 *rid = part_ids[i]; 652 rc = EOK; 653 goto out; 654 } 655 } 656 657 rc = ENOENT; 658 out: 659 free(part_ids); 660 free(canon_mp_buf); 661 return rc; 662 } 663 610 664 /** @} 611 665 */ -
uspace/lib/futil/src/futil.c
r4b9213d r629b480 99 99 return EIO; 100 100 101 rc = vfs_lookup_open(destp, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE, &df); 102 if (rc != EOK) 103 return EIO; 101 rc = vfs_lookup_open(destp, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE, 102 &df); 103 if (rc != EOK) { 104 vfs_put(sf); 105 return EIO; 106 } 104 107 105 108 do { … … 152 155 de = readdir(dir); 153 156 while (de != NULL) { 154 if (asprintf(&srcp, "%s/%s", srcdir, de->d_name) < 0) 155 return ENOMEM; 156 if (asprintf(&destp, "%s/%s", destdir, de->d_name) < 0) 157 return ENOMEM; 157 if (asprintf(&srcp, "%s/%s", srcdir, de->d_name) < 0) { 158 rc = ENOMEM; 159 goto error; 160 } 161 162 if (asprintf(&destp, "%s/%s", destdir, de->d_name) < 0) { 163 rc = ENOMEM; 164 goto error; 165 } 158 166 159 167 rc = vfs_stat_path(srcp, &s); 160 168 if (rc != EOK) 161 return EIO;169 goto error; 162 170 163 171 if (s.is_file) { 164 172 rc = futil_copy_file(futil, srcp, destp); 165 if (rc != EOK) 166 return EIO; 173 if (rc != EOK) { 174 rc = EIO; 175 goto error; 176 } 167 177 } else if (s.is_directory) { 168 178 if (futil->cb != NULL && futil->cb->create_dir != NULL) … … 170 180 rc = vfs_link_path(destp, KIND_DIRECTORY, NULL); 171 181 if (rc != EOK) 172 return EIO;182 goto error; 173 183 rc = futil_rcopy_contents(futil, srcp, destp); 174 184 if (rc != EOK) 175 return EIO;185 goto error; 176 186 } else { 177 return EIO; 187 rc = EIO; 188 goto error; 178 189 } 179 190 … … 181 192 } 182 193 183 return EOK; 194 closedir(dir); 195 return EOK; 196 error: 197 closedir(dir); 198 return rc; 184 199 } 185 200
Note:
See TracChangeset
for help on using the changeset viewer.
