Changeset b82985e in mainline for uspace/srv/volsrv/part.c
- Timestamp:
- 2018-10-12T13:16:04Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d09eeb2
- Parents:
- 6d00aff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/volsrv/part.c
r6d00aff rb82985e 297 297 } 298 298 299 /** Mountpartition.299 /** Determine actual mount path to be used for a partition. 300 300 * 301 301 * @param part Partition 302 */ 303 static errno_t vol_part_mount(vol_part_t *part) 302 * @param rpath Place to store pointer to newly allocated string or @c NULL 303 * if volume should not be mounted 304 * @param rauto Place to store boolean flag whether mount point is automatic 305 * 306 * @return EOK on success, ENOMEM if out of memory 307 */ 308 static errno_t vol_part_determine_mount_path(vol_part_t *part, char **rpath, 309 bool *rauto) 304 310 { 305 311 const char *cfg_mp; 306 312 char *mp; 313 bool mp_auto; 307 314 int err; 308 bool mp_auto;309 errno_t rc;310 315 311 316 /* Get configured mount point */ … … 324 329 if (str_size(part->label) < 1) { 325 330 /* Don't mount nameless volumes */ 326 log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting nameless volume."); 331 *rpath = NULL; 332 *rauto = false; 327 333 return EOK; 328 334 } … … 335 341 } 336 342 343 mp_auto = true; 344 } else if (str_cmp(cfg_mp, "None") == 0 || str_cmp(cfg_mp, "none") == 0) { 345 mp = NULL; 346 mp_auto = false; 347 } else { 348 mp = str_dup(cfg_mp); 349 mp_auto = false; 350 } 351 352 *rpath = mp; 353 *rauto = mp_auto; 354 return EOK; 355 } 356 357 /** Mount partition. 358 * 359 * @param part Partition 360 */ 361 static errno_t vol_part_mount(vol_part_t *part) 362 { 363 char *mp; 364 bool mp_auto; 365 errno_t rc; 366 367 rc = vol_part_determine_mount_path(part, &mp, &mp_auto); 368 if (rc != EOK) { 369 log_msg(LOG_DEFAULT, LVL_ERROR, "Error determining mount point.\n"); 370 return rc; 371 } 372 373 if (mp == NULL) { 374 log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting volume."); 375 return EOK; 376 } 377 378 if (mp_auto) { 379 /* Create directory for automatic mount point */ 337 380 log_msg(LOG_DEFAULT, LVL_NOTE, "Create mount point '%s'", mp); 338 381 rc = vfs_link_path(mp, KIND_DIRECTORY, NULL); … … 343 386 return EIO; 344 387 } 345 346 mp_auto = true;347 } else if (str_cmp(cfg_mp, "None") == 0 || str_cmp(cfg_mp, "none") == 0) {348 log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting volume.");349 return EOK;350 } else {351 mp = str_dup(cfg_mp);352 mp_auto = false;353 388 } 354 389 … … 545 580 } 546 581 582 /** Find partition by filesystem path. 583 * 584 * @param parts Partitions 585 * @param path Filesystem path 586 * @param rpart Place to store pointer to partition 587 * @return EOK on success, ENOENT if not found, ENOMEM if out of memory 588 */ 589 errno_t vol_part_find_by_path_ref(vol_parts_t *parts, const char *path, 590 vol_part_t **rpart) 591 { 592 errno_t rc; 593 char *mpath; 594 bool mauto; 595 596 fibril_mutex_lock(&parts->lock); 597 598 list_foreach(parts->parts, lparts, vol_part_t, part) { 599 rc = vol_part_determine_mount_path(part, &mpath, &mauto); 600 if (rc != EOK) { 601 fibril_mutex_unlock(&parts->lock); 602 return ENOMEM; 603 } 604 605 if (mpath != NULL && str_cmp(mpath, path) == 0) { 606 /* Add reference */ 607 refcount_up(&part->refcnt); 608 fibril_mutex_unlock(&parts->lock); 609 free(mpath); 610 *rpart = part; 611 return EOK; 612 } 613 614 if (mpath != NULL) 615 free(mpath); 616 } 617 618 fibril_mutex_unlock(&parts->lock); 619 return ENOENT; 620 } 621 547 622 void vol_part_del_ref(vol_part_t *part) 548 623 {
Note:
See TracChangeset
for help on using the changeset viewer.