Changeset b82985e in mainline
- 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
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vol/vol.c
r6d00aff rb82985e 47 47 vcmd_eject, 48 48 vcmd_insert, 49 vcmd_insert_by_path, 49 50 vcmd_help, 50 51 vcmd_list, … … 155 156 156 157 rc = vol_part_insert(vol, svc_id); 158 if (rc != EOK) { 159 printf("Error inserting volume.\n"); 160 goto out; 161 } 162 163 rc = EOK; 164 out: 165 vol_destroy(vol); 166 return rc; 167 } 168 169 static errno_t vol_cmd_insert_by_path(const char *volspec) 170 { 171 vol_t *vol = NULL; 172 errno_t rc; 173 174 rc = vol_create(&vol); 175 if (rc != EOK) { 176 printf("Error contacting volume service.\n"); 177 goto out; 178 } 179 180 rc = vol_part_insert_by_path(vol, volspec); 157 181 if (rc != EOK) { 158 182 printf("Error inserting volume.\n"); … … 304 328 printf(" %s eject <mp> Eject volume mounted in a directory\n", NAME); 305 329 printf(" %s insert <svc> Insert volume based on service identifier\n", NAME); 330 printf(" %s insert -p <mp> Insert volume based on filesystem path\n", NAME); 306 331 } 307 332 … … 332 357 volspec = argv[i++]; 333 358 } else if (str_cmp(cmd, "insert") == 0) { 334 vcmd = vcmd_insert; 359 if (str_cmp(argv[i], "-p") == 0) { 360 vcmd = vcmd_insert_by_path; 361 ++i; 362 } else { 363 vcmd = vcmd_insert; 364 } 365 335 366 if (argc <= i) { 336 367 printf("Parameter missing.\n"); … … 356 387 rc = vol_cmd_insert(volspec); 357 388 break; 389 case vcmd_insert_by_path: 390 rc = vol_cmd_insert_by_path(volspec); 391 break; 358 392 case vcmd_help: 359 393 print_syntax(); -
uspace/lib/c/generic/vol.c
r6d00aff rb82985e 312 312 } 313 313 314 /** Insert volume by path. 315 * 316 * @param vol Volume service 317 * @param path Filesystem path 318 * 319 * @return EOK on success or an error code 320 */ 321 errno_t vol_part_insert_by_path(vol_t *vol, const char *path) 322 { 323 async_exch_t *exch; 324 ipc_call_t answer; 325 errno_t retval; 326 327 exch = async_exchange_begin(vol->sess); 328 aid_t req = async_send_0(exch, VOL_PART_INSERT_BY_PATH, &answer); 329 330 retval = async_data_write_start(exch, path, str_size(path)); 331 if (retval != EOK) { 332 async_exchange_end(exch); 333 async_forget(req); 334 return retval; 335 } 336 337 async_exchange_end(exch); 338 async_wait_for(req, &retval); 339 340 if (retval != EOK) 341 return retval; 342 343 return EOK; 344 } 345 314 346 /** Get volume label support. 315 347 * -
uspace/lib/c/include/ipc/vol.h
r6d00aff rb82985e 46 46 VOL_PART_EMPTY, 47 47 VOL_PART_INSERT, 48 VOL_PART_INSERT_BY_PATH, 48 49 VOL_PART_LSUPP, 49 50 VOL_PART_MKFS, -
uspace/lib/c/include/vol.h
r6d00aff rb82985e 51 51 extern errno_t vol_part_empty(vol_t *, service_id_t); 52 52 extern errno_t vol_part_insert(vol_t *, service_id_t); 53 extern errno_t vol_part_insert_by_path(vol_t *, const char *); 53 54 extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *); 54 55 extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *, -
uspace/lib/sif/include/sif.h
r6d00aff rb82985e 35 35 */ 36 36 37 #ifndef SIF_H_38 #define SIF_H_37 #ifndef LIBSIF_SIF_H_ 38 #define LIBSIF_SIF_H_ 39 39 40 40 #include <errno.h> -
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 { -
uspace/srv/volsrv/part.h
r6d00aff rb82985e 52 52 extern errno_t vol_part_find_by_id_ref(vol_parts_t *, service_id_t, 53 53 vol_part_t **); 54 extern errno_t vol_part_find_by_path_ref(vol_parts_t *, const char *, 55 vol_part_t **); 54 56 extern void vol_part_del_ref(vol_part_t *); 55 57 extern errno_t vol_part_eject_part(vol_part_t *); -
uspace/srv/volsrv/volsrv.c
r6d00aff rb82985e 250 250 } 251 251 252 static void vol_part_insert_by_path_srv(vol_parts_t *parts, ipc_call_t *icall) 253 { 254 vol_part_t *part; 255 char *path = NULL; 256 errno_t rc; 257 258 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_insert_by_path_srv()"); 259 260 rc = async_data_write_accept((void **)&path, true, 0, VOL_MOUNTP_MAXLEN, 261 0, NULL); 262 if (rc != EOK) { 263 async_answer_0(icall, rc); 264 goto error; 265 } 266 267 rc = vol_part_find_by_path_ref(parts, path, &part); 268 if (rc != EOK) { 269 async_answer_0(icall, ENOENT); 270 goto error; 271 } 272 273 rc = vol_part_insert_part(part); 274 if (rc != EOK) { 275 async_answer_0(icall, rc); 276 vol_part_del_ref(part); 277 goto error; 278 } 279 280 free(path); 281 vol_part_del_ref(part); 282 async_answer_0(icall, EOK); 283 284 return; 285 error: 286 if (path != NULL) 287 free(path); 288 } 289 290 252 291 static void vol_part_empty_srv(vol_parts_t *parts, ipc_call_t *icall) 253 292 { … … 545 584 vol_part_insert_srv(parts, &call); 546 585 break; 586 case VOL_PART_INSERT_BY_PATH: 587 vol_part_insert_by_path_srv(parts, &call); 588 break; 547 589 case VOL_PART_LSUPP: 548 590 vol_part_get_lsupp_srv(parts, &call);
Note:
See TracChangeset
for help on using the changeset viewer.