Changes in / [d3b2ffa:1e472ee] in mainline
- Files:
-
- 5 deleted
- 16 edited
-
.gitignore (modified) (13 diffs)
-
boot/Makefile.common (modified) (1 diff)
-
uspace/Makefile (modified) (1 diff)
-
uspace/app/fdisk/fdisk.c (modified) (9 diffs)
-
uspace/app/sysinst/sysinst.c (modified) (2 diffs)
-
uspace/app/vol/Makefile (deleted)
-
uspace/app/vol/vol.c (deleted)
-
uspace/dist/vol/.keep (deleted)
-
uspace/lib/c/Makefile (modified) (1 diff)
-
uspace/lib/c/generic/io/label.c (deleted)
-
uspace/lib/c/generic/vol.c (modified) (2 diffs)
-
uspace/lib/c/include/io/label.h (deleted)
-
uspace/lib/c/include/ipc/vol.h (modified) (1 diff)
-
uspace/lib/c/include/types/vol.h (modified) (2 diffs)
-
uspace/lib/c/include/vol.h (modified) (2 diffs)
-
uspace/lib/fdisk/include/fdisk.h (modified) (2 diffs)
-
uspace/lib/fdisk/src/fdisk.c (modified) (1 diff)
-
uspace/srv/volsrv/part.c (modified) (14 diffs)
-
uspace/srv/volsrv/part.h (modified) (1 diff)
-
uspace/srv/volsrv/types/part.h (modified) (3 diffs)
-
uspace/srv/volsrv/volsrv.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
rd3b2ffa r1e472ee 1 *.disasm 2 *.deflate 1 3 *.a 2 *.check.c 3 *.d 4 *.deflate 5 *.disasm 4 *.o 6 5 *.la 7 6 *.lo 8 7 *.map 9 *.o10 8 *.prev 9 *.so.* 10 *.d 11 11 *.pyc 12 *.so.* 12 *.check.c 13 tag 14 tags 15 common.h.new 16 deps.mk 17 /Makefile.config 13 18 /Makefile.common 14 /Makefile.config 19 autotool/ 20 boot/distroot/ 21 boot/initrd.img 15 22 /common.h 16 23 /config.h 17 24 /cscope.out 25 doxygen/doxygen.cfg 26 doxygen/doxygen.cfg.gen 27 doxygen/html/ 28 doxygen/latex/ 18 29 /hdisk.img 19 /image.boot20 30 /image.iso 21 31 /uImage.bin 22 autotool/ 32 /image.boot 23 33 boot/arch/arm32/_link.ld 24 34 boot/arch/ia64/_link.ld … … 30 40 boot/components.zip 31 41 boot/components_desc.c 32 boot/distroot/33 42 boot/image.bin 34 43 boot/image.boot 35 44 boot/image.raw 36 boot/initrd.img37 common.h.new38 deps.mk39 doxygen/doxygen.cfg40 doxygen/doxygen.cfg.gen41 doxygen/html/42 doxygen/latex/43 kernel/arch/abs32le/_link.ld44 45 kernel/arch/amd64/_link.ld 45 46 kernel/arch/arm32/_link.ld … … 49 50 kernel/arch/ppc32/_link.ld 50 51 kernel/arch/sparc64/_link.ld 52 kernel/arch/abs32le/_link.ld 51 53 kernel/generic/src/debug/real_map.bin 52 54 kernel/kernel.bin 53 55 kernel/kernel.dump 54 56 kernel/kernel.raw 55 tag56 tags57 tools/amd64-unknown-elf58 tools/arm-linux-gnueabi59 tools/binutils-*.tar.bz260 tools/downloads/61 tools/gcc-*.tar.bz262 tools/gdb-*.tar.gz63 tools/i686-pc-linux-gnu64 tools/ia64-pc-linux-gnu65 tools/mips-linux-gnu66 tools/mips64el-linux-gnu67 tools/mipsel-linux-gnu68 tools/ppc-linux-gnu69 tools/ppc64-linux-gnu70 tools/riscv64-unknown-linux-gnu71 tools/sparc64-linux-gnu72 tools/sycek/73 57 uspace/app/barber/barber 74 58 uspace/app/barber/images.c … … 146 130 uspace/app/vlaunch/images_desc.c 147 131 uspace/app/vlaunch/vlaunch 148 uspace/app/vol/vol149 132 uspace/app/vterm/vterm 150 133 uspace/app/vuhid/vuh … … 152 135 uspace/app/websrv/websrv 153 136 uspace/app/wifi_supplicant/wifi_supplicant 154 uspace/dist/app/155 137 uspace/dist/app/barber 156 138 uspace/dist/app/bdsh … … 224 206 uspace/dist/demo.wav 225 207 uspace/dist/demo.xm 226 uspace/dist/drv/227 208 uspace/dist/drv/ahci/ 228 209 uspace/dist/drv/apic/ … … 236 217 uspace/dist/drv/i8042/ 237 218 uspace/dist/drv/i8259/ 219 uspace/dist/drv/icp/ 238 220 uspace/dist/drv/icp-ic/ 239 uspace/dist/drv/icp/240 221 uspace/dist/drv/isa/ 241 222 uspace/dist/drv/kfb/ … … 267 248 uspace/dist/drv/vhc/ 268 249 uspace/dist/drv/virt/ 250 uspace/dist/drv/xtkbd/ 269 251 uspace/dist/drv/xhci/ 270 uspace/dist/drv/xtkbd/271 uspace/dist/inc/272 252 uspace/dist/inc/_link.ld 273 253 uspace/dist/inc/c/ 274 254 uspace/dist/logo.tga 255 uspace/dist/app/ 256 uspace/dist/drv/ 257 uspace/dist/inc/ 275 258 uspace/dist/srv/ 276 259 uspace/dist/test/ … … 292 275 uspace/drv/bus/usb/usbmid/usbmid 293 276 uspace/drv/bus/usb/vhc/vhc 277 uspace/drv/bus/usb/xhci/xhci 294 278 uspace/drv/bus/usb/xhci/test-xhci 295 uspace/drv/bus/usb/xhci/xhci296 279 uspace/drv/char/i8042/i8042 297 280 uspace/drv/char/msim-con/msim-con … … 306 289 uspace/drv/hid/adb-mouse/adb-mouse 307 290 uspace/drv/hid/atkbd/atkbd 291 uspace/drv/hid/xtkbd/xtkbd 308 292 uspace/drv/hid/ps2mouse/ps2mouse 309 293 uspace/drv/hid/usbhid/usbhid 310 uspace/drv/hid/xtkbd/xtkbd311 294 uspace/drv/intctl/apic/apic 312 295 uspace/drv/intctl/i8259/i8259 … … 334 317 uspace/drv/test/test3/test3 335 318 uspace/drv/time/cmos-rtc/cmos-rtc 336 uspace/lib/c/arch/abs32le/_link-dlexe.ld337 uspace/lib/c/arch/abs32le/_link-loader.ld338 uspace/lib/c/arch/abs32le/_link-shlib.ld339 uspace/lib/c/arch/abs32le/_link.ld340 319 uspace/lib/c/arch/amd64/_link-dlexe.ld 341 320 uspace/lib/c/arch/amd64/_link-loader.ld … … 370 349 uspace/lib/c/arch/sparc64/_link-shlib.ld 371 350 uspace/lib/c/arch/sparc64/_link.ld 351 uspace/lib/c/arch/abs32le/_link-dlexe.ld 352 uspace/lib/c/arch/abs32le/_link-loader.ld 353 uspace/lib/c/arch/abs32le/_link-shlib.ld 354 uspace/lib/c/arch/abs32le/_link.ld 372 355 uspace/lib/c/test-libc 373 356 uspace/lib/label/test-liblabel … … 426 409 uspace/srv/vfs/vfs 427 410 uspace/srv/volsrv/volsrv 411 tools/amd64-unknown-elf 412 tools/arm-linux-gnueabi 413 tools/i686-pc-linux-gnu 414 tools/ia64-pc-linux-gnu 415 tools/mips-linux-gnu 416 tools/mips64el-linux-gnu 417 tools/mipsel-linux-gnu 418 tools/ppc-linux-gnu 419 tools/ppc64-linux-gnu 420 tools/riscv64-unknown-linux-gnu 421 tools/sparc64-linux-gnu 422 tools/binutils-*.tar.bz2 423 tools/gcc-*.tar.bz2 424 tools/gdb-*.tar.gz 425 tools/sycek/ 426 tools/downloads/ -
boot/Makefile.common
rd3b2ffa r1e472ee 217 217 $(USPACE_PATH)/app/untar/untar \ 218 218 $(USPACE_PATH)/app/usbinfo/usbinfo \ 219 $(USPACE_PATH)/app/vol/vol \220 219 $(USPACE_PATH)/app/vuhid/vuh \ 221 220 $(USPACE_PATH)/app/mkbd/mkbd \ -
uspace/Makefile
rd3b2ffa r1e472ee 79 79 app/untar \ 80 80 app/usbinfo \ 81 app/vol \82 81 app/vuhid \ 83 82 app/nic \ -
uspace/app/fdisk/fdisk.c
rd3b2ffa r1e472ee 37 37 #include <cap.h> 38 38 #include <errno.h> 39 #include <fdisk.h>40 #include <io/label.h>41 39 #include <nchoice.h> 42 40 #include <stdbool.h> 43 41 #include <stdio.h> 44 42 #include <stdlib.h> 43 #include <fdisk.h> 45 44 #include <str.h> 46 #include <vol.h>47 45 48 46 #define NO_LABEL_CAPTION "(No name)" … … 71 69 } devac_t; 72 70 71 static errno_t fdsk_pcnt_fs_format(vol_part_cnt_t pcnt, vol_fstype_t fstype, 72 char **rstr) 73 { 74 errno_t rc; 75 char *s; 76 77 switch (pcnt) { 78 case vpc_empty: 79 s = str_dup("Empty"); 80 if (s == NULL) 81 return ENOMEM; 82 break; 83 case vpc_fs: 84 rc = fdisk_fstype_format(fstype, &s); 85 if (rc != EOK) 86 return ENOMEM; 87 break; 88 case vpc_unknown: 89 s = str_dup("Unknown"); 90 if (s == NULL) 91 return ENOMEM; 92 break; 93 } 94 95 *rstr = s; 96 return EOK; 97 } 98 73 99 /** Confirm user selection. */ 74 100 static errno_t fdsk_confirm(const char *msg, bool *rconfirm) … … 279 305 280 306 for (i = LT_FIRST; i < LT_LIMIT; i++) { 281 rc = label_type_format(i, &sltype);307 rc = fdisk_ltype_format(i, &sltype); 282 308 if (rc != EOK) 283 309 goto error; … … 387 413 388 414 for (i = 0; i < VOL_FSTYPE_LIMIT; i++) { 389 rc = vol_fstype_format(i, &sfstype);415 rc = fdisk_fstype_format(i, &sfstype); 390 416 if (rc != EOK) 391 417 goto error; … … 572 598 } 573 599 574 rc = label_pkind_format(pinfo.pkind, &spkind);600 rc = fdisk_pkind_format(pinfo.pkind, &spkind); 575 601 if (rc != EOK) { 576 602 printf("\nOut of memory.\n"); … … 579 605 580 606 if (pinfo.pkind != lpk_extended) { 581 rc = vol_pcnt_fs_format(pinfo.pcnt, pinfo.fstype, &sfstype);607 rc = fdsk_pcnt_fs_format(pinfo.pcnt, pinfo.fstype, &sfstype); 582 608 if (rc != EOK) { 583 609 printf("Out of memory.\n"); … … 747 773 break; 748 774 default: 749 rc = label_type_format(linfo.ltype, &sltype);775 rc = fdisk_ltype_format(linfo.ltype, &sltype); 750 776 if (rc != EOK) { 751 777 assert(rc == ENOMEM); … … 778 804 } 779 805 780 rc = vol_pcnt_fs_format(pinfo.pcnt, pinfo.fstype, &sfstype);806 rc = fdsk_pcnt_fs_format(pinfo.pcnt, pinfo.fstype, &sfstype); 781 807 if (rc != EOK) { 782 808 printf("Out of memory.\n"); … … 795 821 796 822 if ((linfo.flags & lf_ext_supp) != 0) { 797 rc = label_pkind_format(pinfo.pkind, &spkind);823 rc = fdisk_pkind_format(pinfo.pkind, &spkind); 798 824 if (rc != EOK) { 799 825 printf("\nOut of memory.\n"); -
uspace/app/sysinst/sysinst.c
rd3b2ffa r1e472ee 69 69 #define MOUNT_POINT "/inst" 70 70 71 /** HelenOS live CD volume label */ 72 #define CD_VOL_LABEL "HelenOS-CD" 73 #define CD_MOUNT_POINT "/vol/" CD_VOL_LABEL 74 75 #define BOOT_FILES_SRC CD_MOUNT_POINT 71 /** Device containing HelenOS live CD */ 72 #define CD_DEV "devices/\\hw\\pci0\\00:01.0\\ata-c2\\d0" 73 74 #define CD_FS_TYPE "cdfs" 75 #define CD_FS_SRV "/srv/cdfs" 76 #define CD_MOUNT_POINT "/cdrom" 77 78 #define BOOT_FILES_SRC "/cdrom" 76 79 #define BOOT_BLOCK_IDX 0 /* MBR */ 77 80 … … 193 196 static errno_t sysinst_copy_boot_files(void) 194 197 { 195 errno_t rc; 198 task_wait_t twait; 199 task_exit_t texit; 200 errno_t rc; 201 int trc; 202 203 printf("sysinst_copy_boot_files(): start filesystem server\n"); 204 rc = task_spawnl(NULL, &twait, CD_FS_SRV, CD_FS_SRV, NULL); 205 if (rc != EOK) 206 return rc; 207 208 printf("sysinst_copy_boot_files(): wait for filesystem server\n"); 209 rc = task_wait(&twait, &texit, &trc); 210 if (rc != EOK) 211 return rc; 212 213 printf("sysinst_copy_boot_files(): verify filesystem server result\n"); 214 if (texit != TASK_EXIT_NORMAL || trc != 0) { 215 printf("sysinst_fs_mount(): not successful, but could be already loaded.\n"); 216 } 217 218 printf("sysinst_copy_boot_files(): create CD mount point\n"); 219 rc = vfs_link_path(CD_MOUNT_POINT, KIND_DIRECTORY, NULL); 220 if (rc != EOK) 221 return rc; 222 223 printf("sysinst_copy_boot_files(): mount CD filesystem\n"); 224 rc = vfs_mount_path(CD_MOUNT_POINT, CD_FS_TYPE, CD_DEV, "", 0, 0); 225 if (rc != EOK) 226 return rc; 196 227 197 228 printf("sysinst_copy_boot_files(): copy bootloader files\n"); -
uspace/lib/c/Makefile
rd3b2ffa r1e472ee 112 112 generic/io/log.c \ 113 113 generic/io/logctl.c \ 114 generic/io/label.c \115 114 generic/io/kio.c \ 116 115 generic/io/klog.c \ -
uspace/lib/c/generic/vol.c
rd3b2ffa r1e472ee 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 253 237 /** Erase partition (to the extent where we will consider it not containing 254 238 * a file system. … … 320 304 } 321 305 322 /** Format file system type as string.323 *324 * @param fstype File system type325 * @param rstr Place to store pointer to newly allocated string326 * @return EOK on success, ENOMEM if out of memory327 */328 errno_t vol_fstype_format(vol_fstype_t fstype, char **rstr)329 {330 const char *sfstype;331 char *s;332 333 sfstype = NULL;334 switch (fstype) {335 case fs_exfat:336 sfstype = "ExFAT";337 break;338 case fs_fat:339 sfstype = "FAT";340 break;341 case fs_minix:342 sfstype = "MINIX";343 break;344 case fs_ext4:345 sfstype = "Ext4";346 break;347 case fs_cdfs:348 sfstype = "ISO 9660";349 break;350 }351 352 s = str_dup(sfstype);353 if (s == NULL)354 return ENOMEM;355 356 *rstr = s;357 return EOK;358 }359 360 /** Format partition content / file system type as string.361 *362 * @param pcnt Partition content363 * @param fstype File system type364 * @param rstr Place to store pointer to newly allocated string365 * @return EOK on success, ENOMEM if out of memory366 */367 errno_t vol_pcnt_fs_format(vol_part_cnt_t pcnt, vol_fstype_t fstype,368 char **rstr)369 {370 int rc;371 char *s = NULL;372 373 switch (pcnt) {374 case vpc_empty:375 s = str_dup("Empty");376 if (s == NULL)377 return ENOMEM;378 break;379 case vpc_fs:380 rc = vol_fstype_format(fstype, &s);381 if (rc != EOK)382 return ENOMEM;383 break;384 case vpc_unknown:385 s = str_dup("Unknown");386 if (s == NULL)387 return ENOMEM;388 break;389 }390 391 assert(s != NULL);392 *rstr = s;393 return EOK;394 }395 396 306 /** @} 397 307 */ -
uspace/lib/c/include/ipc/vol.h
rd3b2ffa r1e472ee 42 42 VOL_PART_ADD, 43 43 VOL_PART_INFO, 44 VOL_PART_EJECT,45 44 VOL_PART_EMPTY, 46 45 VOL_PART_LSUPP, 47 VOL_PART_MKFS 46 VOL_PART_MKFS, 48 47 } vol_request_t; 49 48 -
uspace/lib/c/include/types/vol.h
rd3b2ffa r1e472ee 37 37 38 38 #include <async.h> 39 #include <ipc/vfs.h>40 39 #include <ipc/vol.h> 41 40 #include <stdbool.h> … … 76 75 /** Volume label */ 77 76 char label[VOL_LABEL_MAXLEN + 1]; 78 /** Current mount point */79 char cur_mp[MAX_PATH_LEN + 1]; /* XXX too big */80 /** Current mount point is automatic */81 bool cur_mp_auto;82 77 } vol_part_info_t; 83 78 -
uspace/lib/c/include/vol.h
rd3b2ffa r1e472ee 37 37 38 38 #include <async.h> 39 #include <errno.h>40 39 #include <loc.h> 41 40 #include <stdint.h> … … 48 47 extern errno_t vol_part_add(vol_t *, service_id_t); 49 48 extern errno_t vol_part_info(vol_t *, service_id_t, vol_part_info_t *); 50 extern errno_t vol_part_eject(vol_t *, service_id_t);51 49 extern errno_t vol_part_empty(vol_t *, service_id_t); 52 50 extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *); 53 51 extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *); 54 55 extern errno_t vol_fstype_format(vol_fstype_t, char **);56 extern errno_t vol_pcnt_fs_format(vol_part_cnt_t, vol_fstype_t, char **);57 52 58 53 #endif -
uspace/lib/fdisk/include/fdisk.h
rd3b2ffa r1e472ee 37 37 #define LIBFDISK_FDISK_H_ 38 38 39 #include <errno.h>40 39 #include <loc.h> 41 40 #include <types/fdisk.h> … … 73 72 extern void fdisk_pspec_init(fdisk_part_spec_t *); 74 73 74 extern errno_t fdisk_ltype_format(label_type_t, char **); 75 extern errno_t fdisk_fstype_format(vol_fstype_t, char **); 76 extern errno_t fdisk_pkind_format(label_pkind_t, char **); 77 75 78 extern errno_t fdisk_get_vollabel_support(fdisk_dev_t *, vol_fstype_t, 76 79 vol_label_supp_t *); -
uspace/lib/fdisk/src/fdisk.c
rd3b2ffa r1e472ee 813 813 } 814 814 815 errno_t fdisk_ltype_format(label_type_t ltype, char **rstr) 816 { 817 const char *sltype; 818 char *s; 819 820 sltype = NULL; 821 switch (ltype) { 822 case lt_none: 823 sltype = "None"; 824 break; 825 case lt_mbr: 826 sltype = "MBR"; 827 break; 828 case lt_gpt: 829 sltype = "GPT"; 830 break; 831 } 832 833 s = str_dup(sltype); 834 if (s == NULL) 835 return ENOMEM; 836 837 *rstr = s; 838 return EOK; 839 } 840 841 errno_t fdisk_fstype_format(vol_fstype_t fstype, char **rstr) 842 { 843 const char *sfstype; 844 char *s; 845 846 sfstype = NULL; 847 switch (fstype) { 848 case fs_exfat: 849 sfstype = "ExFAT"; 850 break; 851 case fs_fat: 852 sfstype = "FAT"; 853 break; 854 case fs_minix: 855 sfstype = "MINIX"; 856 break; 857 case fs_ext4: 858 sfstype = "Ext4"; 859 break; 860 case fs_cdfs: 861 sfstype = "ISO 9660"; 862 break; 863 } 864 865 s = str_dup(sfstype); 866 if (s == NULL) 867 return ENOMEM; 868 869 *rstr = s; 870 return EOK; 871 } 872 873 errno_t fdisk_pkind_format(label_pkind_t pkind, char **rstr) 874 { 875 const char *spkind; 876 char *s; 877 878 spkind = NULL; 879 switch (pkind) { 880 case lpk_primary: 881 spkind = "Primary"; 882 break; 883 case lpk_extended: 884 spkind = "Extended"; 885 break; 886 case lpk_logical: 887 spkind = "Logical"; 888 break; 889 } 890 891 s = str_dup(spkind); 892 if (s == NULL) 893 return ENOMEM; 894 895 *rstr = s; 896 return EOK; 897 } 898 815 899 /** Get free partition index. */ 816 900 static errno_t fdisk_part_get_free_idx(fdisk_dev_t *dev, int *rindex) -
uspace/srv/volsrv/part.c
rd3b2ffa r1e472ee 51 51 52 52 static errno_t vol_part_add_locked(service_id_t); 53 static void vol_part_remove_locked(vol_part_t *);54 static errno_t vol_part_find_by_id_ref_locked(service_id_t, vol_part_t **);55 56 53 static LIST_INITIALIZE(vol_parts); /* of vol_part_t */ 57 54 static FIBRIL_MUTEX_INITIALIZE(vol_parts_lock); … … 71 68 }; 72 69 73 static const char *fstype_str(vol_fstype_t fstype) 74 { 75 struct fsname_type *fst; 76 77 fst = &fstab[0]; 78 while (fst->name != NULL) { 79 if (fst->fstype == fstype) 80 return fst->name; 81 ++fst; 82 } 83 84 assert(false); 85 return NULL; 86 } 87 88 /** Check for new and removed partitions */ 70 /** Check for new partitions */ 89 71 static errno_t vol_part_check_new(void) 90 72 { 91 73 bool already_known; 92 bool still_exists;93 74 category_id_t part_cat; 94 75 service_id_t *svcs; 95 76 size_t count, i; 96 link_t *cur, *next;97 vol_part_t *part;98 77 errno_t rc; 99 78 … … 115 94 } 116 95 117 /* Check for new partitions */118 96 for (i = 0; i < count; i++) { 119 97 already_known = false; 120 98 121 // XXX Make this faster122 99 list_foreach(vol_parts, lparts, vol_part_t, part) { 123 100 if (part->svc_id == svcs[i]) { … … 138 115 } 139 116 140 /* Check for removed partitions */141 cur = list_first(&vol_parts);142 while (cur != NULL) {143 next = list_next(cur, &vol_parts);144 part = list_get_instance(cur, vol_part_t, lparts);145 146 still_exists = false;147 // XXX Make this faster148 for (i = 0; i < count; i++) {149 if (part->svc_id == svcs[i]) {150 still_exists = true;151 break;152 }153 }154 155 if (!still_exists) {156 log_msg(LOG_DEFAULT, LVL_NOTE, "Partition '%zu' is gone",157 part->svc_id);158 vol_part_remove_locked(part);159 }160 161 cur = next;162 }163 164 free(svcs);165 166 117 fibril_mutex_unlock(&vol_parts_lock); 167 118 return EOK; … … 178 129 } 179 130 180 atomic_set(&part->refcnt, 1);181 131 link_initialize(&part->lparts); 182 132 part->pcnt = vpc_empty; … … 187 137 static void vol_part_delete(vol_part_t *part) 188 138 { 189 log_msg(LOG_DEFAULT, LVL_ERROR, "Freeing partition %p", part);190 139 if (part == NULL) 191 140 return; 192 141 193 free(part->cur_mp);194 142 free(part->svc_name); 195 143 free(part); … … 256 204 } 257 205 258 static errno_t vol_part_mount(vol_part_t *part)259 {260 char *mp;261 int err;262 errno_t rc;263 264 if (str_size(part->label) < 1) {265 /* Don't mount nameless volumes */266 log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting nameless partition.");267 return EOK;268 }269 270 log_msg(LOG_DEFAULT, LVL_NOTE, "Determine MP label='%s'", part->label);271 err = asprintf(&mp, "/vol/%s", part->label);272 if (err < 0) {273 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory");274 return ENOMEM;275 }276 277 log_msg(LOG_DEFAULT, LVL_NOTE, "Create mount point '%s'", mp);278 rc = vfs_link_path(mp, KIND_DIRECTORY, NULL);279 if (rc != EOK) {280 log_msg(LOG_DEFAULT, LVL_ERROR, "Error creating mount point '%s'",281 mp);282 free(mp);283 return EIO;284 }285 286 log_msg(LOG_DEFAULT, LVL_NOTE, "Call vfs_mount_path mp='%s' fstype='%s' svc_name='%s'",287 mp, fstype_str(part->fstype), part->svc_name);288 rc = vfs_mount_path(mp, fstype_str(part->fstype),289 part->svc_name, "", 0, 0);290 if (rc != EOK) {291 log_msg(LOG_DEFAULT, LVL_NOTE, "Failed mounting to %s", mp);292 }293 log_msg(LOG_DEFAULT, LVL_NOTE, "Mount to %s -> %d\n", mp, rc);294 295 part->cur_mp = mp;296 part->cur_mp_auto = true;297 298 return rc;299 }300 301 206 static errno_t vol_part_add_locked(service_id_t sid) 302 207 { … … 305 210 306 211 assert(fibril_mutex_is_locked(&vol_parts_lock)); 307 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_add_locked(%zu)", sid);308 212 309 213 /* Check for duplicates */ 310 rc = vol_part_find_by_id_ref_locked(sid, &part); 311 if (rc == EOK) { 312 vol_part_del_ref(part); 214 rc = vol_part_find_by_id(sid, &part); 215 if (rc == EOK) 313 216 return EEXIST; 314 } 315 316 log_msg(LOG_DEFAULT, LVL_NOTE, "partition %zu is new", sid); 317 217 218 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_add_locked()"); 318 219 part = vol_part_new(); 319 220 if (part == NULL) … … 332 233 goto error; 333 234 334 rc = vol_part_mount(part);335 if (rc != EOK)336 goto error;337 338 235 list_append(&part->lparts, &vol_parts); 339 236 … … 345 242 vol_part_delete(part); 346 243 return rc; 347 }348 349 static void vol_part_remove_locked(vol_part_t *part)350 {351 assert(fibril_mutex_is_locked(&vol_parts_lock));352 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_remove_locked(%zu)", part->svc_id);353 354 list_remove(&part->lparts);355 356 log_msg(LOG_DEFAULT, LVL_NOTE, "Removed partition.");357 vol_part_del_ref(part);358 244 } 359 245 … … 422 308 } 423 309 424 static errno_t vol_part_find_by_id_ref_locked(service_id_t sid, 425 vol_part_t **rpart) 426 { 427 assert(fibril_mutex_is_locked(&vol_parts_lock)); 428 310 errno_t vol_part_find_by_id(service_id_t sid, vol_part_t **rpart) 311 { 429 312 list_foreach(vol_parts, lparts, vol_part_t, part) { 430 313 if (part->svc_id == sid) { 431 /* Add reference */432 atomic_inc(&part->refcnt);433 314 *rpart = part; 315 /* XXX Add reference */ 434 316 return EOK; 435 317 } … … 437 319 438 320 return ENOENT; 439 }440 441 errno_t vol_part_find_by_id_ref(service_id_t sid, vol_part_t **rpart)442 {443 errno_t rc;444 445 fibril_mutex_lock(&vol_parts_lock);446 rc = vol_part_find_by_id_ref_locked(sid, rpart);447 fibril_mutex_unlock(&vol_parts_lock);448 449 return rc;450 }451 452 void vol_part_del_ref(vol_part_t *part)453 {454 if (atomic_predec(&part->refcnt) == 0)455 vol_part_delete(part);456 }457 458 errno_t vol_part_eject_part(vol_part_t *part)459 {460 int rc;461 462 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_eject_part()");463 464 if (part->cur_mp == NULL) {465 log_msg(LOG_DEFAULT, LVL_DEBUG, "Attempt to mount unmounted "466 "partition.");467 return EINVAL;468 }469 470 rc = vfs_unmount_path(part->cur_mp);471 if (rc != EOK) {472 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed unmounting partition "473 "from %s", part->cur_mp);474 return rc;475 }476 477 if (part->cur_mp_auto) {478 rc = vfs_unlink_path(part->cur_mp);479 if (rc != EOK) {480 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed deleting "481 "mount directory %s.", part->cur_mp);482 }483 }484 485 free(part->cur_mp);486 part->cur_mp = NULL;487 part->cur_mp_auto = false;488 489 return EOK;490 321 } 491 322 … … 535 366 } 536 367 537 rc = vol_part_mount(part);538 if (rc != EOK) {539 fibril_mutex_unlock(&vol_parts_lock);540 return rc;541 }542 543 368 fibril_mutex_unlock(&vol_parts_lock); 544 369 return EOK; … … 547 372 errno_t vol_part_get_info(vol_part_t *part, vol_part_info_t *pinfo) 548 373 { 549 memset(pinfo, 0, sizeof(*pinfo));550 551 374 pinfo->pcnt = part->pcnt; 552 375 pinfo->fstype = part->fstype; 553 376 str_cpy(pinfo->label, sizeof(pinfo->label), part->label); 554 if (part->cur_mp != NULL)555 str_cpy(pinfo->cur_mp, sizeof(pinfo->cur_mp), part->cur_mp);556 pinfo->cur_mp_auto = part->cur_mp_auto;557 377 return EOK; 558 378 } -
uspace/srv/volsrv/part.h
rd3b2ffa r1e472ee 47 47 extern errno_t vol_part_add(service_id_t); 48 48 extern errno_t vol_part_get_ids(service_id_t *, size_t, size_t *); 49 extern errno_t vol_part_find_by_id_ref(service_id_t, vol_part_t **); 50 extern void vol_part_del_ref(vol_part_t *); 51 extern errno_t vol_part_eject_part(vol_part_t *); 49 extern errno_t vol_part_find_by_id(service_id_t, vol_part_t **); 52 50 extern errno_t vol_part_empty_part(vol_part_t *); 53 51 extern errno_t vol_part_mkfs_part(vol_part_t *, vol_fstype_t, const char *); -
uspace/srv/volsrv/types/part.h
rd3b2ffa r1e472ee 39 39 40 40 #include <adt/list.h> 41 #include <atomic.h>42 #include <stdbool.h>43 41 #include <types/label.h> 44 42 … … 47 45 /** Link to vol_parts */ 48 46 link_t lparts; 49 /** Reference count */50 atomic_t refcnt;51 47 /** Service ID */ 52 48 service_id_t svc_id; … … 59 55 /** Volume label */ 60 56 char *label; 61 /** Where volume is currently mounted */62 char *cur_mp;63 /** Mounted at automatic mount point */64 bool cur_mp_auto;65 57 } vol_part_t; 66 58 -
uspace/srv/volsrv/volsrv.c
rd3b2ffa r1e472ee 144 144 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_info_srv(%zu)", 145 145 sid); 146 rc = vol_part_find_by_id _ref(sid, &part);146 rc = vol_part_find_by_id(sid, &part); 147 147 if (rc != EOK) { 148 148 async_answer_0(icall_handle, ENOENT); … … 153 153 if (rc != EOK) { 154 154 async_answer_0(icall_handle, EIO); 155 goto error;155 return; 156 156 } 157 157 … … 161 161 async_answer_0(chandle, EREFUSED); 162 162 async_answer_0(icall_handle, EREFUSED); 163 goto error;163 return; 164 164 } 165 165 … … 167 167 async_answer_0(chandle, EINVAL); 168 168 async_answer_0(icall_handle, EINVAL); 169 goto error;169 return; 170 170 } 171 171 … … 175 175 async_answer_0(chandle, rc); 176 176 async_answer_0(icall_handle, rc); 177 goto error; 178 } 179 180 async_answer_0(icall_handle, EOK); 181 error: 182 vol_part_del_ref(part); 183 } 184 185 static void vol_part_eject_srv(cap_call_handle_t icall_handle, ipc_call_t *icall) 186 { 187 service_id_t sid; 188 vol_part_t *part; 189 errno_t rc; 190 191 sid = IPC_GET_ARG1(*icall); 192 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_eject_srv(%zu)", sid); 193 194 rc = vol_part_find_by_id_ref(sid, &part); 195 if (rc != EOK) { 196 async_answer_0(icall_handle, ENOENT); 197 goto error; 198 } 199 200 rc = vol_part_eject_part(part); 201 if (rc != EOK) { 202 async_answer_0(icall_handle, EIO); 203 goto error; 204 } 205 206 async_answer_0(icall_handle, EOK); 207 error: 208 vol_part_del_ref(part); 177 return; 178 } 179 180 async_answer_0(icall_handle, EOK); 209 181 } 210 182 … … 218 190 log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_empty_srv(%zu)", sid); 219 191 220 rc = vol_part_find_by_id _ref(sid, &part);192 rc = vol_part_find_by_id(sid, &part); 221 193 if (rc != EOK) { 222 194 async_answer_0(icall_handle, ENOENT); … … 227 199 if (rc != EOK) { 228 200 async_answer_0(icall_handle, EIO); 229 goto error; 230 } 231 232 async_answer_0(icall_handle, EOK); 233 error: 234 vol_part_del_ref(part); 201 return; 202 } 203 204 async_answer_0(icall_handle, EOK); 235 205 } 236 206 … … 281 251 errno_t rc; 282 252 283 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv()");284 285 253 sid = IPC_GET_ARG1(*icall); 286 254 fstype = IPC_GET_ARG2(*icall); … … 293 261 } 294 262 295 if (label != NULL) { 296 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv: label='%s'", 297 label); 298 } 299 300 rc = vol_part_find_by_id_ref(sid, &part); 263 printf("vol_part_mkfs_srv: label=%p\n", label); 264 if (label != NULL) 265 printf("vol_part_mkfs_srv: label='%s'\n", label); 266 267 rc = vol_part_find_by_id(sid, &part); 301 268 if (rc != EOK) { 302 269 free(label); … … 309 276 free(label); 310 277 async_answer_0(icall_handle, rc); 311 vol_part_del_ref(part);312 278 return; 313 279 } … … 345 311 vol_part_info_srv(chandle, &call); 346 312 break; 347 case VOL_PART_EJECT:348 vol_part_eject_srv(chandle, &call);349 break;350 313 case VOL_PART_EMPTY: 351 314 vol_part_empty_srv(chandle, &call);
Note:
See TracChangeset
for help on using the changeset viewer.
