Changeset 72c72d4 in mainline
- Timestamp:
- 2018-06-29T13:41:13Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1a9174e
- Parents:
- db9c889
- git-author:
- Jiri Svoboda <jiri@…> (2018-06-28 17:40:58)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-06-29 13:41:13)
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vol/vol.c
rdb9c889 r72c72d4 52 52 } vol_cmd_t; 53 53 54 static int vol_cmd_list(void) 54 /** Find volume by current mount point. */ 55 static errno_t vol_cmd_part_by_mp(vol_t *vol, const char *mp, 56 service_id_t *rid) 57 { 58 vol_part_info_t vinfo; 59 service_id_t *part_ids = NULL; 60 char *canon_mp_buf = NULL; 61 char *canon_mp; 62 size_t nparts; 63 size_t i; 64 errno_t rc; 65 66 canon_mp_buf = str_dup(mp); 67 if (canon_mp_buf == NULL) { 68 printf("Out of memory.\n"); 69 rc = ENOMEM; 70 goto out; 71 } 72 73 canon_mp = vfs_absolutize(canon_mp_buf, NULL); 74 if (canon_mp == NULL) { 75 printf("Invalid volume path '%s'.\n", mp); 76 rc = EINVAL; 77 goto out; 78 } 79 80 rc = vol_get_parts(vol, &part_ids, &nparts); 81 if (rc != EOK) { 82 printf("Error getting list of volumes.\n"); 83 goto out; 84 } 85 86 for (i = 0; i < nparts; i++) { 87 rc = vol_part_info(vol, part_ids[i], &vinfo); 88 if (rc != EOK) { 89 printf("Error getting volume information.\n"); 90 rc = EIO; 91 goto out; 92 } 93 94 if (str_cmp(vinfo.cur_mp, canon_mp) == 0) { 95 *rid = part_ids[i]; 96 rc = EOK; 97 goto out; 98 } 99 } 100 101 rc = ENOENT; 102 out: 103 free(part_ids); 104 free(canon_mp_buf); 105 return rc; 106 } 107 108 static errno_t vol_cmd_eject(const char *volspec) 109 { 110 vol_t *vol = NULL; 111 service_id_t part_id; 112 errno_t rc; 113 114 rc = vol_create(&vol); 115 if (rc != EOK) { 116 printf("Error contacting volume service.\n"); 117 goto out; 118 } 119 120 rc = vol_cmd_part_by_mp(vol, volspec, &part_id); 121 if (rc != EOK) { 122 printf("Error looking up volume '%s'.\n", volspec); 123 goto out; 124 } 125 126 rc = vol_part_eject(vol, part_id); 127 if (rc != EOK) { 128 printf("Error ejecting volume.\n"); 129 goto out; 130 } 131 132 rc = EOK; 133 out: 134 vol_destroy(vol); 135 return rc; 136 } 137 138 static errno_t vol_cmd_list(void) 55 139 { 56 140 vol_t *vol = NULL; … … 62 146 size_t i; 63 147 table_t *table = NULL; 64 int rc;148 errno_t rc; 65 149 66 150 rc = vol_create(&vol); … … 139 223 vol_cmd_t vcmd; 140 224 int i; 141 int rc;225 errno_t rc; 142 226 143 227 if (argc < 2) { … … 169 253 switch (vcmd) { 170 254 case vcmd_eject: 171 rc = EOK;255 rc = vol_cmd_eject(volspec); 172 256 break; 173 257 case vcmd_help: -
uspace/lib/c/generic/vol.c
rdb9c889 r72c72d4 235 235 } 236 236 237 /** Unmount partition (and possibly eject the media). */ 238 errno_t vol_part_eject(vol_t *vol, service_id_t sid) 239 { 240 async_exch_t *exch; 241 errno_t retval; 242 243 exch = async_exchange_begin(vol->sess); 244 retval = async_req_1_0(exch, VOL_PART_EJECT, sid); 245 async_exchange_end(exch); 246 247 if (retval != EOK) 248 return retval; 249 250 return EOK; 251 } 252 237 253 /** Erase partition (to the extent where we will consider it not containing 238 254 * a file system. -
uspace/lib/c/include/ipc/vol.h
rdb9c889 r72c72d4 42 42 VOL_PART_ADD, 43 43 VOL_PART_INFO, 44 VOL_PART_EJECT, 44 45 VOL_PART_EMPTY, 45 46 VOL_PART_LSUPP, 46 VOL_PART_MKFS ,47 VOL_PART_MKFS 47 48 } vol_request_t; 48 49 -
uspace/srv/volsrv/part.c
rdb9c889 r72c72d4 478 478 errno_t vol_part_get_info(vol_part_t *part, vol_part_info_t *pinfo) 479 479 { 480 memset(pinfo, 0, sizeof(*pinfo)); 481 480 482 pinfo->pcnt = part->pcnt; 481 483 pinfo->fstype = part->fstype; 482 484 str_cpy(pinfo->label, sizeof(pinfo->label), part->label); 483 str_cpy(pinfo->cur_mp, sizeof(pinfo->cur_mp), part->cur_mp); 485 if (part->cur_mp != NULL) 486 str_cpy(pinfo->cur_mp, sizeof(pinfo->cur_mp), part->cur_mp); 484 487 pinfo->cur_mp_auto = part->cur_mp_auto; 485 488 return EOK; -
uspace/srv/volsrv/volsrv.c
rdb9c889 r72c72d4 181 181 } 182 182 183 static void vol_part_eject_srv(cap_call_handle_t icall_handle, ipc_call_t *icall) 184 { 185 service_id_t sid; 186 vol_part_t *part; 187 errno_t rc; 188 189 sid = IPC_GET_ARG1(*icall); 190 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_eject_srv(%zu)", sid); 191 192 rc = vol_part_find_by_id(sid, &part); 193 if (rc != EOK) { 194 async_answer_0(icall_handle, ENOENT); 195 return; 196 } 197 198 rc = vol_part_eject_part(part); 199 if (rc != EOK) { 200 async_answer_0(icall_handle, EIO); 201 return; 202 } 203 204 async_answer_0(icall_handle, EOK); 205 } 206 183 207 static void vol_part_empty_srv(cap_call_handle_t icall_handle, ipc_call_t *icall) 184 208 { … … 314 338 vol_part_info_srv(chandle, &call); 315 339 break; 340 case VOL_PART_EJECT: 341 vol_part_eject_srv(chandle, &call); 342 break; 316 343 case VOL_PART_EMPTY: 317 344 vol_part_empty_srv(chandle, &call);
Note:
See TracChangeset
for help on using the changeset viewer.