Changes in uspace/app/vol/vol.c [b82985e:629b480] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vol/vol.c
rb82985e r629b480 1 1 /* 2 * Copyright (c) 20 17Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #include <io/table.h> 37 37 #include <loc.h> 38 #include <stdbool.h> 38 39 #include <stdio.h> 39 40 #include <stdlib.h> … … 53 54 } vol_cmd_t; 54 55 55 /** Find volume by current mount point. */ 56 static errno_t vol_cmd_part_by_mp(vol_t *vol, const char *mp, 57 service_id_t *rid) 58 { 59 vol_part_info_t vinfo; 60 service_id_t *part_ids = NULL; 61 char *canon_mp_buf = NULL; 62 char *canon_mp; 63 size_t nparts; 64 size_t i; 65 errno_t rc; 66 67 canon_mp_buf = str_dup(mp); 68 if (canon_mp_buf == NULL) { 69 printf("Out of memory.\n"); 70 rc = ENOMEM; 71 goto out; 72 } 73 74 canon_mp = vfs_absolutize(canon_mp_buf, NULL); 75 if (canon_mp == NULL) { 76 printf("Invalid volume path '%s'.\n", mp); 77 rc = EINVAL; 78 goto out; 79 } 80 81 rc = vol_get_parts(vol, &part_ids, &nparts); 82 if (rc != EOK) { 83 printf("Error getting list of volumes.\n"); 84 goto out; 85 } 86 87 for (i = 0; i < nparts; i++) { 88 rc = vol_part_info(vol, part_ids[i], &vinfo); 89 if (rc != EOK) { 90 printf("Error getting volume information.\n"); 91 rc = EIO; 92 goto out; 93 } 94 95 if (str_cmp(vinfo.cur_mp, canon_mp) == 0) { 96 *rid = part_ids[i]; 97 rc = EOK; 98 goto out; 99 } 100 } 101 102 rc = ENOENT; 103 out: 104 free(part_ids); 105 free(canon_mp_buf); 106 return rc; 107 } 108 109 static errno_t vol_cmd_eject(const char *volspec) 56 static errno_t vol_cmd_eject(const char *volspec, bool physical) 110 57 { 111 58 vol_t *vol = NULL; … … 119 66 } 120 67 121 rc = vol_ cmd_part_by_mp(vol, volspec, &part_id);68 rc = vol_part_by_mp(vol, volspec, &part_id); 122 69 if (rc != EOK) { 123 70 printf("Error looking up volume '%s'.\n", volspec); … … 125 72 } 126 73 127 rc = vol_part_eject(vol, part_id); 74 rc = vol_part_eject(vol, part_id, physical ? vef_physical : 75 vef_none); 128 76 if (rc != EOK) { 129 77 printf("Error ejecting volume.\n"); … … 323 271 { 324 272 printf("Syntax:\n"); 325 printf(" %s List present volumes\n", NAME); 326 printf(" %s -c List volume configuration entries\n", NAME); 327 printf(" %s -h Print help\n", NAME); 328 printf(" %s eject <mp> Eject volume mounted in a directory\n", NAME); 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); 273 printf(" %s List present volumes\n", NAME); 274 printf(" %s -c List volume configuration entries\n", NAME); 275 printf(" %s -h Print help\n", NAME); 276 printf(" %s eject [-s] <mp> Eject volume mounted in a directory\n", NAME); 277 printf(" -s to eject physically\n"); 278 printf(" %s insert <svc> Insert volume based on service identifier\n", NAME); 279 printf(" %s insert -p <mp> Insert volume based on filesystem path\n", NAME); 331 280 } 332 281 … … 336 285 char *volspec; 337 286 vol_cmd_t vcmd; 287 bool physical = false; 338 288 int i; 339 289 errno_t rc = EINVAL; … … 351 301 } else if (str_cmp(cmd, "eject") == 0) { 352 302 vcmd = vcmd_eject; 303 if (str_cmp(argv[i], "-s") == 0) { 304 physical = true; 305 ++i; 306 } 307 353 308 if (argc <= i) { 354 309 printf("Parameter missing.\n"); … … 382 337 switch (vcmd) { 383 338 case vcmd_eject: 384 rc = vol_cmd_eject(volspec );339 rc = vol_cmd_eject(volspec, physical); 385 340 break; 386 341 case vcmd_insert:
Note:
See TracChangeset
for help on using the changeset viewer.