Changeset f0f8787 in mainline
- Timestamp:
- 2018-10-04T14:53:29Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c5429fe
- Parents:
- 1bb43d5
- git-author:
- Jiri Svoboda <jiri@…> (2018-10-03 21:51:40)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-10-04 14:53:29)
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vol/vol.c
r1bb43d5 rf0f8787 44 44 #define NAME "vol" 45 45 46 static char *volspec;47 48 46 typedef enum { 49 47 vcmd_eject, 48 vcmd_insert, 50 49 vcmd_help, 51 50 vcmd_list, … … 127 126 if (rc != EOK) { 128 127 printf("Error ejecting volume.\n"); 128 goto out; 129 } 130 131 rc = EOK; 132 out: 133 vol_destroy(vol); 134 return rc; 135 } 136 137 static errno_t vol_cmd_insert(const char *volspec) 138 { 139 vol_t *vol = NULL; 140 service_id_t svc_id; 141 errno_t rc; 142 143 rc = loc_service_get_id(volspec, &svc_id, 0); 144 if (rc != EOK) { 145 printf("Error looking up service '%s'.\n", volspec); 146 goto out; 147 } 148 149 rc = vol_create(&vol); 150 if (rc != EOK) { 151 printf("Error contacting volume service.\n"); 152 goto out; 153 } 154 155 rc = vol_part_insert(vol, svc_id); 156 if (rc != EOK) { 157 printf("Error inserting volume.\n"); 129 158 goto out; 130 159 } … … 215 244 printf(" %s List volumes\n", NAME); 216 245 printf(" %s -h Print help\n", NAME); 217 printf(" %s eject <volume> Eject volume\n", NAME); 246 printf(" %s eject <mp> Eject volume mounted in a directory\n", NAME); 247 printf(" %s insert <svc> Insert volume based on service identifier\n", NAME); 218 248 } 219 249 … … 221 251 { 222 252 char *cmd; 253 char *volspec; 223 254 vol_cmd_t vcmd; 224 255 int i; … … 240 271 } 241 272 volspec = argv[i++]; 273 } else if (str_cmp(cmd, "insert") == 0) { 274 vcmd = vcmd_insert; 275 if (argc <= i) { 276 printf("Parameter missing.\n"); 277 goto syntax_error; 278 } 279 volspec = argv[i++]; 242 280 } else { 243 281 printf("Invalid sub-command '%s'.\n", cmd); … … 254 292 case vcmd_eject: 255 293 rc = vol_cmd_eject(volspec); 294 break; 295 case vcmd_insert: 296 rc = vol_cmd_insert(volspec); 256 297 break; 257 298 case vcmd_help: -
uspace/lib/c/generic/vol.c
r1bb43d5 rf0f8787 196 196 * the dummy partition is created), it can take some (unknown) time 197 197 * until it is discovered. 198 * 199 * @param vol Volume service 200 * @param sid Service ID of the partition 201 * @return EOK on success or an error code 198 202 */ 199 203 errno_t vol_part_add(vol_t *vol, service_id_t sid) … … 212 216 } 213 217 214 /** Get partition information. */ 218 /** Get partition information. 219 * 220 * @param vol Volume service 221 * @param sid Service ID of the partition 222 * @param vinfo Place to sore partition information 223 * @return EOK on success or an error code 224 */ 215 225 errno_t vol_part_info(vol_t *vol, service_id_t sid, vol_part_info_t *vinfo) 216 226 { … … 236 246 } 237 247 238 /** Unmount partition (and possibly eject the media). */ 248 /** Unmount partition (and possibly eject the media). 249 * 250 * @param vol Volume service 251 * @param sid Service ID of the partition 252 * @return EOK on success or an error code 253 */ 239 254 errno_t vol_part_eject(vol_t *vol, service_id_t sid) 240 255 { … … 254 269 /** Erase partition (to the extent where we will consider it not containing 255 270 * a file system. 271 * 272 * @param vol Volume service 273 * @param sid Service ID of the partition 274 * @return EOK on success or an error code 256 275 */ 257 276 errno_t vol_part_empty(vol_t *vol, service_id_t sid) … … 270 289 } 271 290 272 /** Get volume label support. */ 291 /** Insert volume. 292 * 293 * This will re-mount the volume if it has been ejected previously. 294 * 295 * @param vol Volume service 296 * @param sid Service ID of the partition 297 * @return EOK on success or an error code 298 */ 299 errno_t vol_part_insert(vol_t *vol, service_id_t sid) 300 { 301 async_exch_t *exch; 302 errno_t retval; 303 304 exch = async_exchange_begin(vol->sess); 305 retval = async_req_1_0(exch, VOL_PART_INSERT, sid); 306 async_exchange_end(exch); 307 308 if (retval != EOK) 309 return retval; 310 311 return EOK; 312 } 313 314 /** Get volume label support. 315 * 316 * @param vol Volume service 317 * @param fstype File system type 318 * @param vlsupp Place to store volume label support information 319 * @return EOK on success or an error code 320 */ 273 321 errno_t vol_part_get_lsupp(vol_t *vol, vol_fstype_t fstype, 274 322 vol_label_supp_t *vlsupp) -
uspace/lib/c/include/ipc/vol.h
r1bb43d5 rf0f8787 45 45 VOL_PART_EJECT, 46 46 VOL_PART_EMPTY, 47 VOL_PART_INSERT, 47 48 VOL_PART_LSUPP, 48 49 VOL_PART_MKFS, -
uspace/lib/c/include/vol.h
r1bb43d5 rf0f8787 50 50 extern errno_t vol_part_eject(vol_t *, service_id_t); 51 51 extern errno_t vol_part_empty(vol_t *, service_id_t); 52 extern errno_t vol_part_insert(vol_t *, service_id_t); 52 53 extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *); 53 54 extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *, -
uspace/srv/volsrv/part.c
r1bb43d5 rf0f8787 602 602 } 603 603 604 /** Insert volume. 605 * 606 * Re-mount the volume in the partition, if applicable. 607 * 608 * @param part Partition 609 */ 610 errno_t vol_part_insert_part(vol_part_t *part) 611 { 612 int rc; 613 614 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_insert_part()"); 615 616 fibril_mutex_lock(&part->parts->lock); 617 618 if (part->cur_mp != NULL) { 619 fibril_mutex_unlock(&part->parts->lock); 620 return EOK; 621 } 622 623 rc = vol_part_probe(part); 624 if (rc != EOK) 625 goto error; 626 627 rc = vol_part_mount(part); 628 if (rc != EOK) 629 goto error; 630 631 fibril_mutex_unlock(&part->parts->lock); 632 633 return EOK; 634 error: 635 return rc; 636 } 637 604 638 /** Set mount point. 605 639 * -
uspace/srv/volsrv/part.h
r1bb43d5 rf0f8787 55 55 extern errno_t vol_part_eject_part(vol_part_t *); 56 56 extern errno_t vol_part_empty_part(vol_part_t *); 57 extern errno_t vol_part_insert_part(vol_part_t *); 57 58 extern errno_t vol_part_mkfs_part(vol_part_t *, vol_fstype_t, const char *, 58 59 const char *); -
uspace/srv/volsrv/volsrv.c
r1bb43d5 rf0f8787 210 210 if (rc != EOK) { 211 211 async_answer_0(icall, ENOENT); 212 goto error;212 return; 213 213 } 214 214 215 215 rc = vol_part_eject_part(part); 216 if (rc != EOK) { 217 async_answer_0(icall, EIO); 218 goto error; 219 } 220 221 async_answer_0(icall, EOK); 222 error: 223 vol_part_del_ref(part); 224 } 225 226 static void vol_part_insert_srv(vol_parts_t *parts, ipc_call_t *icall) 227 { 228 service_id_t sid; 229 vol_part_t *part; 230 errno_t rc; 231 232 sid = IPC_GET_ARG1(*icall); 233 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_insert_srv(%zu)", sid); 234 235 rc = vol_part_find_by_id_ref(parts, sid, &part); 236 if (rc != EOK) { 237 async_answer_0(icall, ENOENT); 238 return; 239 } 240 241 rc = vol_part_insert_part(part); 216 242 if (rc != EOK) { 217 243 async_answer_0(icall, EIO); … … 429 455 vol_part_empty_srv(parts, &call); 430 456 break; 457 case VOL_PART_INSERT: 458 vol_part_insert_srv(parts, &call); 459 break; 431 460 case VOL_PART_LSUPP: 432 461 vol_part_get_lsupp_srv(parts, &call);
Note:
See TracChangeset
for help on using the changeset viewer.