Changeset 9c2c7d2 in mainline
- Timestamp:
- 2017-07-06T15:52:15Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5cd1eb9a
- Parents:
- d858a660
- Location:
- uspace
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fdisk/fdisk.c
rd858a660 r9c2c7d2 42 42 #include <fdisk.h> 43 43 44 #define NO_LABEL_CAPTION "(No name)" 45 44 46 static bool quit = false; 45 47 static fdisk_t *fdisk; … … 445 447 fdisk_cap_t cap; 446 448 fdisk_cap_t mcap; 449 vol_label_supp_t vlsupp; 447 450 vol_fstype_t fstype = 0; 448 451 tinput_t *tinput = NULL; … … 450 453 char *scap; 451 454 char *smcap = NULL; 455 char *label = NULL; 452 456 453 457 if (pkind == lpk_logical) … … 502 506 } 503 507 508 fdisk_get_vollabel_support(dev, fstype, &vlsupp); 509 if (vlsupp.supported) { 510 tinput = tinput_new(); 511 if (tinput == NULL) { 512 rc = ENOMEM; 513 goto error; 514 } 515 516 rc = tinput_set_prompt(tinput, "?> "); 517 if (rc != EOK) 518 goto error; 519 520 /* Ask for volume label */ 521 printf("Enter volume label for new partition.\n"); 522 rc = tinput_read_i(tinput, "No name", &label); 523 if (rc != EOK) 524 goto error; 525 526 tinput_destroy(tinput); 527 tinput = NULL; 528 } 529 504 530 fdisk_pspec_init(&pspec); 505 531 pspec.capacity = cap; 506 532 pspec.pkind = pkind; 507 533 pspec.fstype = fstype; 534 pspec.label = label; 508 535 509 536 rc = fdisk_part_create(dev, &pspec, NULL); … … 513 540 } 514 541 542 free(label); 515 543 return EOK; 516 544 error: 517 545 free(smcap); 546 free(label); 518 547 if (tinput != NULL) 519 548 tinput_destroy(tinput); … … 530 559 char *sfstype = NULL; 531 560 char *sdesc = NULL; 561 const char *label; 532 562 bool confirm; 533 563 void *sel; … … 577 607 } 578 608 579 rc = asprintf(&sdesc, "%s, %s, %s", scap, spkind, sfstype); 609 if (str_size(pinfo.label) > 0) 610 label = pinfo.label; 611 else 612 label = "(No name)"; 613 614 rc = asprintf(&sdesc, "%s %s, %s, %s", label, 615 scap, spkind, sfstype); 580 616 if (rc < 0) { 581 617 rc = ENOMEM; … … 773 809 label = pinfo.label; 774 810 else 775 label = "(No label)";811 label = "(No name)"; 776 812 777 813 if (linfo.ltype == lt_none) -
uspace/app/init/init.c
rd858a660 r9c2c7d2 328 328 srv_start("/srv/klog"); 329 329 srv_start("/srv/locfs"); 330 srv_start("/srv/taskmon");330 // srv_start("/srv/taskmon"); 331 331 332 332 if (!mount_locfs()) { -
uspace/lib/c/generic/vol.c
rd858a660 r9c2c7d2 39 39 #include <loc.h> 40 40 #include <stdlib.h> 41 #include <str.h> 41 42 #include <vol.h> 42 43 … … 251 252 } 252 253 254 /** Get volume label support. */ 255 int vol_part_get_lsupp(vol_t *vol, vol_fstype_t fstype, 256 vol_label_supp_t *vlsupp) 257 { 258 async_exch_t *exch; 259 sysarg_t retval; 260 ipc_call_t answer; 261 262 exch = async_exchange_begin(vol->sess); 263 aid_t req = async_send_1(exch, VOL_PART_LSUPP, fstype, &answer); 264 int rc = async_data_read_start(exch, vlsupp, sizeof(vol_label_supp_t)); 265 async_exchange_end(exch); 266 267 if (rc != EOK) { 268 async_forget(req); 269 return EIO; 270 } 271 272 async_wait_for(req, &retval); 273 if (retval != EOK) 274 return EIO; 275 276 return EOK; 277 } 278 253 279 /** Create file system. */ 254 int vol_part_mkfs(vol_t *vol, service_id_t sid, vol_fstype_t fstype) 255 { 256 async_exch_t *exch; 257 int retval; 258 259 exch = async_exchange_begin(vol->sess); 260 retval = async_req_2_0(exch, VOL_PART_MKFS, sid, fstype); 261 async_exchange_end(exch); 280 int vol_part_mkfs(vol_t *vol, service_id_t sid, vol_fstype_t fstype, 281 const char *label) 282 { 283 async_exch_t *exch; 284 ipc_call_t answer; 285 sysarg_t retval; 286 287 exch = async_exchange_begin(vol->sess); 288 aid_t req = async_send_2(exch, VOL_PART_MKFS, sid, fstype, &answer); 289 retval = async_data_write_start(exch, label, str_size(label)); 290 async_exchange_end(exch); 291 292 if (retval != EOK) { 293 async_forget(req); 294 return retval; 295 } 296 297 async_wait_for(req, &retval); 262 298 263 299 if (retval != EOK) -
uspace/lib/c/include/ipc/vol.h
rd858a660 r9c2c7d2 43 43 VOL_PART_INFO, 44 44 VOL_PART_EMPTY, 45 VOL_PART_MKFS 45 VOL_PART_LSUPP, 46 VOL_PART_MKFS, 46 47 } vol_request_t; 47 48 -
uspace/lib/c/include/types/vol.h
rd858a660 r9c2c7d2 38 38 #include <async.h> 39 39 #include <ipc/vol.h> 40 #include <stdbool.h> 40 41 41 42 typedef enum { … … 76 77 } vol_part_info_t; 77 78 79 /** Volume label support */ 80 typedef struct { 81 /** Volume labels are supported */ 82 bool supported; 83 } vol_label_supp_t; 84 78 85 #endif 79 86 -
uspace/lib/c/include/vol.h
rd858a660 r9c2c7d2 48 48 extern int vol_part_info(vol_t *, service_id_t, vol_part_info_t *); 49 49 extern int vol_part_empty(vol_t *, service_id_t); 50 extern int vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t); 50 extern int vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *); 51 extern int vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *); 51 52 52 53 #endif -
uspace/lib/fdisk/include/fdisk.h
rd858a660 r9c2c7d2 39 39 #include <loc.h> 40 40 #include <types/fdisk.h> 41 #include <types/vol.h> 41 42 42 43 extern int fdisk_create(fdisk_t **); … … 81 82 extern int fdisk_pkind_format(label_pkind_t, char **); 82 83 84 extern int fdisk_get_vollabel_support(fdisk_dev_t *, vol_fstype_t, 85 vol_label_supp_t *); 86 83 87 #endif 84 88 -
uspace/lib/fdisk/include/types/fdisk.h
rd858a660 r9c2c7d2 43 43 #include <types/vol.h> 44 44 #include <vbd.h> 45 #include <vol.h>46 45 47 46 /** Capacity unit */ … … 199 198 /** File system type */ 200 199 vol_fstype_t fstype; 200 /** Volume label */ 201 char *label; 201 202 } fdisk_part_spec_t; 202 203 -
uspace/lib/fdisk/src/fdisk.c
rd858a660 r9c2c7d2 731 731 fdisk_part_t **rpart) 732 732 { 733 fdisk_part_t *part ;733 fdisk_part_t *part = NULL; 734 734 vbd_part_spec_t vpspec; 735 vbd_part_id_t partid; 736 int rc; 735 vbd_part_id_t partid = 0; 736 vol_part_info_t vpinfo; 737 char *label; 738 int rc; 739 740 label = str_dup(pspec->label); 741 if (label == NULL) 742 return ENOMEM; 737 743 738 744 rc = fdisk_part_spec_prepare(dev, pspec, &vpspec); 739 if (rc != EOK) 740 return EIO; 745 if (rc != EOK) { 746 rc = EIO; 747 goto error; 748 } 741 749 742 750 rc = vbd_part_create(dev->fdisk->vbd, dev->sid, &vpspec, &partid); 743 if (rc != EOK) 744 return EIO; 751 if (rc != EOK) { 752 rc = EIO; 753 goto error; 754 } 745 755 746 756 rc = fdisk_part_add(dev, partid, &part); 747 757 if (rc != EOK) { 748 /* Try rolling back */ 749 (void) vbd_part_delete(dev->fdisk->vbd, partid); 750 return EIO; 758 rc = EIO; 759 goto error; 751 760 } 752 761 753 762 if (part->svc_id != 0) { 754 rc = vol_part_mkfs(dev->fdisk->vol, part->svc_id, pspec->fstype); 763 rc = vol_part_mkfs(dev->fdisk->vol, part->svc_id, pspec->fstype, 764 pspec->label); 755 765 if (rc != EOK && rc != ENOTSUP) { 756 fdisk_part_remove(part); 757 (void) vbd_part_delete(dev->fdisk->vbd, partid); 758 return EIO; 759 } 760 761 part->pcnt = vpc_fs; 762 part->fstype = pspec->fstype; 766 rc = EIO; 767 goto error; 768 } 769 770 /* Get the real label value */ 771 rc = vol_part_info(dev->fdisk->vol, part->svc_id, &vpinfo); 772 if (rc != EOK) { 773 rc = EIO; 774 goto error; 775 } 776 777 part->pcnt = vpinfo.pcnt; 778 part->fstype = vpinfo.fstype; 779 part->label = str_dup(vpinfo.label); 780 781 if (part->label == NULL) { 782 rc = EIO; 783 goto error; 784 } 763 785 } 764 786 … … 766 788 *rpart = part; 767 789 return EOK; 790 error: 791 /* Try rolling back */ 792 if (part != NULL) 793 fdisk_part_remove(part); 794 if (partid != 0) 795 (void) vbd_part_delete(dev->fdisk->vbd, partid); 796 return rc; 768 797 } 769 798 … … 1194 1223 } 1195 1224 1225 /** Get volume label support. */ 1226 int fdisk_get_vollabel_support(fdisk_dev_t *dev, vol_fstype_t fstype, 1227 vol_label_supp_t *vlsupp) 1228 { 1229 return vol_part_get_lsupp(dev->fdisk->vol, fstype, vlsupp); 1230 } 1231 1196 1232 /** @} 1197 1233 */ -
uspace/srv/volsrv/mkfs.c
rd858a660 r9c2c7d2 40 40 #include <stdarg.h> 41 41 #include <stdlib.h> 42 #include <str.h> 42 43 #include <str_error.h> 43 44 #include <task.h> … … 101 102 102 103 103 int volsrv_part_mkfs(service_id_t sid, vol_fstype_t fstype )104 int volsrv_part_mkfs(service_id_t sid, vol_fstype_t fstype, const char *label) 104 105 { 105 106 const char *cmd; … … 131 132 return rc; 132 133 133 rc = cmd_runl(cmd, cmd, svc_name, NULL); 134 if (str_size(label) > 0) 135 rc = cmd_runl(cmd, cmd, "--label", label, svc_name, NULL); 136 else 137 rc = cmd_runl(cmd, cmd, svc_name, NULL); 138 134 139 free(svc_name); 135 140 return rc; 136 141 } 137 142 143 void volsrv_part_get_lsupp(vol_fstype_t fstype, vol_label_supp_t *vlsupp) 144 { 145 vlsupp->supported = false; 146 147 switch (fstype) { 148 case fs_fat: 149 vlsupp->supported = true; 150 break; 151 case fs_exfat: 152 case fs_minix: 153 case fs_ext4: 154 case fs_cdfs: 155 break; 156 } 157 } 158 138 159 /** @} 139 160 */ -
uspace/srv/volsrv/mkfs.h
rd858a660 r9c2c7d2 41 41 #include <types/vol.h> 42 42 43 extern int volsrv_part_mkfs(service_id_t, vol_fstype_t); 43 extern int volsrv_part_mkfs(service_id_t, vol_fstype_t, const char *); 44 extern void volsrv_part_get_lsupp(vol_fstype_t, vol_label_supp_t *); 44 45 45 46 #endif -
uspace/srv/volsrv/part.c
rd858a660 r9c2c7d2 143 143 } 144 144 145 static int vol_part_add_locked(service_id_t sid) 146 { 147 vol_part_t *part; 145 static int vol_part_probe(vol_part_t *part) 146 { 148 147 bool empty; 149 148 vfs_fs_probe_info_t info; 150 149 struct fsname_type *fst; 150 char *label; 151 int rc; 152 153 log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name); 154 155 assert(fibril_mutex_is_locked(&vol_parts_lock)); 156 157 fst = &fstab[0]; 158 while (fst->name != NULL) { 159 rc = vfs_fsprobe(fst->name, part->svc_id, &info); 160 if (rc == EOK) 161 break; 162 ++fst; 163 } 164 165 if (fst->name != NULL) { 166 log_msg(LOG_DEFAULT, LVL_NOTE, "Found %s, label '%s'", 167 fst->name, info.label); 168 label = str_dup(info.label); 169 if (label == NULL) { 170 rc = ENOMEM; 171 goto error; 172 } 173 174 part->pcnt = vpc_fs; 175 part->fstype = fst->fstype; 176 part->label = label; 177 } else { 178 log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain " 179 "a recognized file system."); 180 181 rc = volsrv_part_is_empty(part->svc_id, &empty); 182 if (rc != EOK) { 183 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed determining if " 184 "partition is empty."); 185 rc = EIO; 186 goto error; 187 } 188 189 label = str_dup(""); 190 if (label == NULL) { 191 rc = ENOMEM; 192 goto error; 193 } 194 195 part->pcnt = empty ? vpc_empty : vpc_unknown; 196 part->label = label; 197 } 198 199 return EOK; 200 201 error: 202 return rc; 203 } 204 205 static int vol_part_add_locked(service_id_t sid) 206 { 207 vol_part_t *part; 151 208 int rc; 152 209 … … 171 228 } 172 229 173 log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name); 174 175 fst = &fstab[0]; 176 while (fst->name != NULL) { 177 rc = vfs_fsprobe(fst->name, sid, &info); 178 if (rc == EOK) 179 break; 180 ++fst; 181 } 182 183 if (fst->name != NULL) { 184 log_msg(LOG_DEFAULT, LVL_NOTE, "Found %s, label '%s'", 185 fst->name, info.label); 186 part->pcnt = vpc_fs; 187 part->fstype = fst->fstype; 188 part->label = str_dup(info.label); 189 if (part->label == NULL) 190 goto error; 191 } else { 192 log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain " 193 "a recognized file system."); 194 195 rc = volsrv_part_is_empty(sid, &empty); 196 if (rc != EOK) { 197 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed determining if " 198 "partition is empty."); 199 goto error; 200 } 201 202 part->pcnt = empty ? vpc_empty : vpc_unknown; 203 part->label = str_dup(""); 204 if (part->label == NULL) 205 goto error; 206 } 230 rc = vol_part_probe(part); 231 if (rc != EOK) 232 goto error; 207 233 208 234 list_append(&part->lparts, &vol_parts); … … 311 337 } 312 338 313 int vol_part_mkfs_part(vol_part_t *part, vol_fstype_t fstype) 339 int vol_part_mkfs_part(vol_part_t *part, vol_fstype_t fstype, 340 const char *label) 314 341 { 315 342 int rc; … … 317 344 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_mkfs_part()"); 318 345 319 rc = volsrv_part_mkfs(part->svc_id, fstype); 346 fibril_mutex_lock(&vol_parts_lock); 347 348 rc = volsrv_part_mkfs(part->svc_id, fstype, label); 320 349 if (rc != EOK) { 321 350 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_mkfs_part() - failed %d", 322 351 rc); 352 fibril_mutex_unlock(&vol_parts_lock); 323 353 return rc; 324 354 } 325 355 326 part->pcnt = vpc_fs; 327 part->fstype = fstype; 356 /* 357 * Re-probe the partition to update information. This is needed since 358 * the FS can make conversions of the volume label (e.g. make it 359 * uppercase). 360 */ 361 rc = vol_part_probe(part); 362 if (rc != EOK) { 363 fibril_mutex_unlock(&vol_parts_lock); 364 return rc; 365 } 366 367 fibril_mutex_unlock(&vol_parts_lock); 328 368 return EOK; 329 369 } -
uspace/srv/volsrv/part.h
rd858a660 r9c2c7d2 49 49 extern int vol_part_find_by_id(service_id_t, vol_part_t **); 50 50 extern int vol_part_empty_part(vol_part_t *); 51 extern int vol_part_mkfs_part(vol_part_t *, vol_fstype_t );51 extern int vol_part_mkfs_part(vol_part_t *, vol_fstype_t, const char *); 52 52 extern int vol_part_get_info(vol_part_t *, vol_part_info_t *); 53 53 -
uspace/srv/volsrv/volsrv.c
rd858a660 r9c2c7d2 46 46 #include <types/vol.h> 47 47 48 #include "mkfs.h" 48 49 #include "part.h" 49 50 … … 131 132 async_answer_0(iid, EOK); 132 133 } 133 134 134 135 135 static void vol_part_info_srv(ipc_callid_t iid, ipc_call_t *icall) … … 204 204 } 205 205 206 static void vol_part_get_lsupp_srv(ipc_callid_t iid, ipc_call_t *icall) 207 { 208 vol_fstype_t fstype; 209 vol_label_supp_t vlsupp; 210 int rc; 211 212 fstype = IPC_GET_ARG1(*icall); 213 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_get_lsupp_srv(%u)", 214 fstype); 215 216 volsrv_part_get_lsupp(fstype, &vlsupp); 217 218 ipc_callid_t callid; 219 size_t size; 220 if (!async_data_read_receive(&callid, &size)) { 221 async_answer_0(callid, EREFUSED); 222 async_answer_0(iid, EREFUSED); 223 return; 224 } 225 226 if (size != sizeof(vol_label_supp_t)) { 227 async_answer_0(callid, EINVAL); 228 async_answer_0(iid, EINVAL); 229 return; 230 } 231 232 rc = async_data_read_finalize(callid, &vlsupp, 233 min(size, sizeof(vlsupp))); 234 if (rc != EOK) { 235 async_answer_0(callid, rc); 236 async_answer_0(iid, rc); 237 return; 238 } 239 240 async_answer_0(iid, EOK); 241 } 242 243 206 244 static void vol_part_mkfs_srv(ipc_callid_t iid, ipc_call_t *icall) 207 245 { … … 209 247 vol_part_t *part; 210 248 vol_fstype_t fstype; 249 char *label; 211 250 int rc; 212 251 … … 214 253 fstype = IPC_GET_ARG2(*icall); 215 254 255 rc = async_data_write_accept((void **)&label, true, 0, VOL_LABEL_MAXLEN, 256 0, NULL); 257 if (rc != EOK) { 258 async_answer_0(iid, rc); 259 return; 260 } 261 262 printf("vol_part_mkfs_srv: label=%p\n", label); 263 if (label!=NULL) printf("vol_part_mkfs_srv: label='%s'\n", label); 264 216 265 rc = vol_part_find_by_id(sid, &part); 217 266 if (rc != EOK) { 267 free(label); 218 268 async_answer_0(iid, ENOENT); 219 269 return; 220 270 } 221 271 222 rc = vol_part_mkfs_part(part, fstype); 223 if (rc != EOK) { 224 async_answer_0(iid, rc); 225 return; 226 } 227 228 part->pcnt = vpc_fs; 229 part->fstype = fstype; 230 272 rc = vol_part_mkfs_part(part, fstype, label); 273 if (rc != EOK) { 274 free(label); 275 async_answer_0(iid, rc); 276 return; 277 } 278 279 free(label); 231 280 async_answer_0(iid, EOK); 232 281 } … … 263 312 vol_part_empty_srv(callid, &call); 264 313 break; 314 case VOL_PART_LSUPP: 315 vol_part_get_lsupp_srv(callid, &call); 316 break; 265 317 case VOL_PART_MKFS: 266 318 vol_part_mkfs_srv(callid, &call);
Note:
See TracChangeset
for help on using the changeset viewer.