Changes in / [d3b2ffa:1e472ee] in mainline


Ignore:
Files:
5 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    rd3b2ffa r1e472ee  
     1*.disasm
     2*.deflate
    13*.a
    2 *.check.c
    3 *.d
    4 *.deflate
    5 *.disasm
     4*.o
    65*.la
    76*.lo
    87*.map
    9 *.o
    108*.prev
     9*.so.*
     10*.d
    1111*.pyc
    12 *.so.*
     12*.check.c
     13tag
     14tags
     15common.h.new
     16deps.mk
     17/Makefile.config
    1318/Makefile.common
    14 /Makefile.config
     19autotool/
     20boot/distroot/
     21boot/initrd.img
    1522/common.h
    1623/config.h
    1724/cscope.out
     25doxygen/doxygen.cfg
     26doxygen/doxygen.cfg.gen
     27doxygen/html/
     28doxygen/latex/
    1829/hdisk.img
    19 /image.boot
    2030/image.iso
    2131/uImage.bin
    22 autotool/
     32/image.boot
    2333boot/arch/arm32/_link.ld
    2434boot/arch/ia64/_link.ld
     
    3040boot/components.zip
    3141boot/components_desc.c
    32 boot/distroot/
    3342boot/image.bin
    3443boot/image.boot
    3544boot/image.raw
    36 boot/initrd.img
    37 common.h.new
    38 deps.mk
    39 doxygen/doxygen.cfg
    40 doxygen/doxygen.cfg.gen
    41 doxygen/html/
    42 doxygen/latex/
    43 kernel/arch/abs32le/_link.ld
    4445kernel/arch/amd64/_link.ld
    4546kernel/arch/arm32/_link.ld
     
    4950kernel/arch/ppc32/_link.ld
    5051kernel/arch/sparc64/_link.ld
     52kernel/arch/abs32le/_link.ld
    5153kernel/generic/src/debug/real_map.bin
    5254kernel/kernel.bin
    5355kernel/kernel.dump
    5456kernel/kernel.raw
    55 tag
    56 tags
    57 tools/amd64-unknown-elf
    58 tools/arm-linux-gnueabi
    59 tools/binutils-*.tar.bz2
    60 tools/downloads/
    61 tools/gcc-*.tar.bz2
    62 tools/gdb-*.tar.gz
    63 tools/i686-pc-linux-gnu
    64 tools/ia64-pc-linux-gnu
    65 tools/mips-linux-gnu
    66 tools/mips64el-linux-gnu
    67 tools/mipsel-linux-gnu
    68 tools/ppc-linux-gnu
    69 tools/ppc64-linux-gnu
    70 tools/riscv64-unknown-linux-gnu
    71 tools/sparc64-linux-gnu
    72 tools/sycek/
    7357uspace/app/barber/barber
    7458uspace/app/barber/images.c
     
    146130uspace/app/vlaunch/images_desc.c
    147131uspace/app/vlaunch/vlaunch
    148 uspace/app/vol/vol
    149132uspace/app/vterm/vterm
    150133uspace/app/vuhid/vuh
     
    152135uspace/app/websrv/websrv
    153136uspace/app/wifi_supplicant/wifi_supplicant
    154 uspace/dist/app/
    155137uspace/dist/app/barber
    156138uspace/dist/app/bdsh
     
    224206uspace/dist/demo.wav
    225207uspace/dist/demo.xm
    226 uspace/dist/drv/
    227208uspace/dist/drv/ahci/
    228209uspace/dist/drv/apic/
     
    236217uspace/dist/drv/i8042/
    237218uspace/dist/drv/i8259/
     219uspace/dist/drv/icp/
    238220uspace/dist/drv/icp-ic/
    239 uspace/dist/drv/icp/
    240221uspace/dist/drv/isa/
    241222uspace/dist/drv/kfb/
     
    267248uspace/dist/drv/vhc/
    268249uspace/dist/drv/virt/
     250uspace/dist/drv/xtkbd/
    269251uspace/dist/drv/xhci/
    270 uspace/dist/drv/xtkbd/
    271 uspace/dist/inc/
    272252uspace/dist/inc/_link.ld
    273253uspace/dist/inc/c/
    274254uspace/dist/logo.tga
     255uspace/dist/app/
     256uspace/dist/drv/
     257uspace/dist/inc/
    275258uspace/dist/srv/
    276259uspace/dist/test/
     
    292275uspace/drv/bus/usb/usbmid/usbmid
    293276uspace/drv/bus/usb/vhc/vhc
     277uspace/drv/bus/usb/xhci/xhci
    294278uspace/drv/bus/usb/xhci/test-xhci
    295 uspace/drv/bus/usb/xhci/xhci
    296279uspace/drv/char/i8042/i8042
    297280uspace/drv/char/msim-con/msim-con
     
    306289uspace/drv/hid/adb-mouse/adb-mouse
    307290uspace/drv/hid/atkbd/atkbd
     291uspace/drv/hid/xtkbd/xtkbd
    308292uspace/drv/hid/ps2mouse/ps2mouse
    309293uspace/drv/hid/usbhid/usbhid
    310 uspace/drv/hid/xtkbd/xtkbd
    311294uspace/drv/intctl/apic/apic
    312295uspace/drv/intctl/i8259/i8259
     
    334317uspace/drv/test/test3/test3
    335318uspace/drv/time/cmos-rtc/cmos-rtc
    336 uspace/lib/c/arch/abs32le/_link-dlexe.ld
    337 uspace/lib/c/arch/abs32le/_link-loader.ld
    338 uspace/lib/c/arch/abs32le/_link-shlib.ld
    339 uspace/lib/c/arch/abs32le/_link.ld
    340319uspace/lib/c/arch/amd64/_link-dlexe.ld
    341320uspace/lib/c/arch/amd64/_link-loader.ld
     
    370349uspace/lib/c/arch/sparc64/_link-shlib.ld
    371350uspace/lib/c/arch/sparc64/_link.ld
     351uspace/lib/c/arch/abs32le/_link-dlexe.ld
     352uspace/lib/c/arch/abs32le/_link-loader.ld
     353uspace/lib/c/arch/abs32le/_link-shlib.ld
     354uspace/lib/c/arch/abs32le/_link.ld
    372355uspace/lib/c/test-libc
    373356uspace/lib/label/test-liblabel
     
    426409uspace/srv/vfs/vfs
    427410uspace/srv/volsrv/volsrv
     411tools/amd64-unknown-elf
     412tools/arm-linux-gnueabi
     413tools/i686-pc-linux-gnu
     414tools/ia64-pc-linux-gnu
     415tools/mips-linux-gnu
     416tools/mips64el-linux-gnu
     417tools/mipsel-linux-gnu
     418tools/ppc-linux-gnu
     419tools/ppc64-linux-gnu
     420tools/riscv64-unknown-linux-gnu
     421tools/sparc64-linux-gnu
     422tools/binutils-*.tar.bz2
     423tools/gcc-*.tar.bz2
     424tools/gdb-*.tar.gz
     425tools/sycek/
     426tools/downloads/
  • boot/Makefile.common

    rd3b2ffa r1e472ee  
    217217        $(USPACE_PATH)/app/untar/untar \
    218218        $(USPACE_PATH)/app/usbinfo/usbinfo \
    219         $(USPACE_PATH)/app/vol/vol \
    220219        $(USPACE_PATH)/app/vuhid/vuh \
    221220        $(USPACE_PATH)/app/mkbd/mkbd \
  • uspace/Makefile

    rd3b2ffa r1e472ee  
    7979        app/untar \
    8080        app/usbinfo \
    81         app/vol \
    8281        app/vuhid \
    8382        app/nic \
  • uspace/app/fdisk/fdisk.c

    rd3b2ffa r1e472ee  
    3737#include <cap.h>
    3838#include <errno.h>
    39 #include <fdisk.h>
    40 #include <io/label.h>
    4139#include <nchoice.h>
    4240#include <stdbool.h>
    4341#include <stdio.h>
    4442#include <stdlib.h>
     43#include <fdisk.h>
    4544#include <str.h>
    46 #include <vol.h>
    4745
    4846#define NO_LABEL_CAPTION "(No name)"
     
    7169} devac_t;
    7270
     71static 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
    7399/** Confirm user selection. */
    74100static errno_t fdsk_confirm(const char *msg, bool *rconfirm)
     
    279305
    280306        for (i = LT_FIRST; i < LT_LIMIT; i++) {
    281                 rc = label_type_format(i, &sltype);
     307                rc = fdisk_ltype_format(i, &sltype);
    282308                if (rc != EOK)
    283309                        goto error;
     
    387413
    388414        for (i = 0; i < VOL_FSTYPE_LIMIT; i++) {
    389                 rc = vol_fstype_format(i, &sfstype);
     415                rc = fdisk_fstype_format(i, &sfstype);
    390416                if (rc != EOK)
    391417                        goto error;
     
    572598                }
    573599
    574                 rc = label_pkind_format(pinfo.pkind, &spkind);
     600                rc = fdisk_pkind_format(pinfo.pkind, &spkind);
    575601                if (rc != EOK) {
    576602                        printf("\nOut of memory.\n");
     
    579605
    580606                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);
    582608                        if (rc != EOK) {
    583609                                printf("Out of memory.\n");
     
    747773                break;
    748774        default:
    749                 rc = label_type_format(linfo.ltype, &sltype);
     775                rc = fdisk_ltype_format(linfo.ltype, &sltype);
    750776                if (rc != EOK) {
    751777                        assert(rc == ENOMEM);
     
    778804                }
    779805
    780                 rc = vol_pcnt_fs_format(pinfo.pcnt, pinfo.fstype, &sfstype);
     806                rc = fdsk_pcnt_fs_format(pinfo.pcnt, pinfo.fstype, &sfstype);
    781807                if (rc != EOK) {
    782808                        printf("Out of memory.\n");
     
    795821
    796822                if ((linfo.flags & lf_ext_supp) != 0) {
    797                         rc = label_pkind_format(pinfo.pkind, &spkind);
     823                        rc = fdisk_pkind_format(pinfo.pkind, &spkind);
    798824                        if (rc != EOK) {
    799825                                printf("\nOut of memory.\n");
  • uspace/app/sysinst/sysinst.c

    rd3b2ffa r1e472ee  
    6969#define MOUNT_POINT "/inst"
    7070
    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"
    7679#define BOOT_BLOCK_IDX 0 /* MBR */
    7780
     
    193196static errno_t sysinst_copy_boot_files(void)
    194197{
    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;
    196227
    197228        printf("sysinst_copy_boot_files(): copy bootloader files\n");
  • uspace/lib/c/Makefile

    rd3b2ffa r1e472ee  
    112112        generic/io/log.c \
    113113        generic/io/logctl.c \
    114         generic/io/label.c \
    115114        generic/io/kio.c \
    116115        generic/io/klog.c \
  • uspace/lib/c/generic/vol.c

    rd3b2ffa r1e472ee  
    235235}
    236236
    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 
    253237/** Erase partition (to the extent where we will consider it not containing
    254238 * a file system.
     
    320304}
    321305
    322 /** Format file system type as string.
    323  *
    324  * @param fstype File system type
    325  * @param rstr Place to store pointer to newly allocated string
    326  * @return EOK on success, ENOMEM if out of memory
    327  */
    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 content
    363  * @param fstype File system type
    364  * @param rstr Place to store pointer to newly allocated string
    365  * @return EOK on success, ENOMEM if out of memory
    366  */
    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 
    396306/** @}
    397307 */
  • uspace/lib/c/include/ipc/vol.h

    rd3b2ffa r1e472ee  
    4242        VOL_PART_ADD,
    4343        VOL_PART_INFO,
    44         VOL_PART_EJECT,
    4544        VOL_PART_EMPTY,
    4645        VOL_PART_LSUPP,
    47         VOL_PART_MKFS
     46        VOL_PART_MKFS,
    4847} vol_request_t;
    4948
  • uspace/lib/c/include/types/vol.h

    rd3b2ffa r1e472ee  
    3737
    3838#include <async.h>
    39 #include <ipc/vfs.h>
    4039#include <ipc/vol.h>
    4140#include <stdbool.h>
     
    7675        /** Volume label */
    7776        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;
    8277} vol_part_info_t;
    8378
  • uspace/lib/c/include/vol.h

    rd3b2ffa r1e472ee  
    3737
    3838#include <async.h>
    39 #include <errno.h>
    4039#include <loc.h>
    4140#include <stdint.h>
     
    4847extern errno_t vol_part_add(vol_t *, service_id_t);
    4948extern 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);
    5149extern errno_t vol_part_empty(vol_t *, service_id_t);
    5250extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *);
    5351extern 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 **);
    5752
    5853#endif
  • uspace/lib/fdisk/include/fdisk.h

    rd3b2ffa r1e472ee  
    3737#define LIBFDISK_FDISK_H_
    3838
    39 #include <errno.h>
    4039#include <loc.h>
    4140#include <types/fdisk.h>
     
    7372extern void fdisk_pspec_init(fdisk_part_spec_t *);
    7473
     74extern errno_t fdisk_ltype_format(label_type_t, char **);
     75extern errno_t fdisk_fstype_format(vol_fstype_t, char **);
     76extern errno_t fdisk_pkind_format(label_pkind_t, char **);
     77
    7578extern errno_t fdisk_get_vollabel_support(fdisk_dev_t *, vol_fstype_t,
    7679    vol_label_supp_t *);
  • uspace/lib/fdisk/src/fdisk.c

    rd3b2ffa r1e472ee  
    813813}
    814814
     815errno_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
     841errno_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
     873errno_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
    815899/** Get free partition index. */
    816900static errno_t fdisk_part_get_free_idx(fdisk_dev_t *dev, int *rindex)
  • uspace/srv/volsrv/part.c

    rd3b2ffa r1e472ee  
    5151
    5252static 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 
    5653static LIST_INITIALIZE(vol_parts); /* of vol_part_t */
    5754static FIBRIL_MUTEX_INITIALIZE(vol_parts_lock);
     
    7168};
    7269
    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 */
    8971static errno_t vol_part_check_new(void)
    9072{
    9173        bool already_known;
    92         bool still_exists;
    9374        category_id_t part_cat;
    9475        service_id_t *svcs;
    9576        size_t count, i;
    96         link_t *cur, *next;
    97         vol_part_t *part;
    9877        errno_t rc;
    9978
     
    11594        }
    11695
    117         /* Check for new partitions */
    11896        for (i = 0; i < count; i++) {
    11997                already_known = false;
    12098
    121                 // XXX Make this faster
    12299                list_foreach(vol_parts, lparts, vol_part_t, part) {
    123100                        if (part->svc_id == svcs[i]) {
     
    138115        }
    139116
    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 faster
    148                 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 
    166117        fibril_mutex_unlock(&vol_parts_lock);
    167118        return EOK;
     
    178129        }
    179130
    180         atomic_set(&part->refcnt, 1);
    181131        link_initialize(&part->lparts);
    182132        part->pcnt = vpc_empty;
     
    187137static void vol_part_delete(vol_part_t *part)
    188138{
    189         log_msg(LOG_DEFAULT, LVL_ERROR, "Freeing partition %p", part);
    190139        if (part == NULL)
    191140                return;
    192141
    193         free(part->cur_mp);
    194142        free(part->svc_name);
    195143        free(part);
     
    256204}
    257205
    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 
    301206static errno_t vol_part_add_locked(service_id_t sid)
    302207{
     
    305210
    306211        assert(fibril_mutex_is_locked(&vol_parts_lock));
    307         log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_add_locked(%zu)", sid);
    308212
    309213        /* 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)
    313216                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()");
    318219        part = vol_part_new();
    319220        if (part == NULL)
     
    332233                goto error;
    333234
    334         rc = vol_part_mount(part);
    335         if (rc != EOK)
    336                 goto error;
    337 
    338235        list_append(&part->lparts, &vol_parts);
    339236
     
    345242        vol_part_delete(part);
    346243        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);
    358244}
    359245
     
    422308}
    423309
    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 
     310errno_t vol_part_find_by_id(service_id_t sid, vol_part_t **rpart)
     311{
    429312        list_foreach(vol_parts, lparts, vol_part_t, part) {
    430313                if (part->svc_id == sid) {
    431                         /* Add reference */
    432                         atomic_inc(&part->refcnt);
    433314                        *rpart = part;
     315                        /* XXX Add reference */
    434316                        return EOK;
    435317                }
     
    437319
    438320        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;
    490321}
    491322
     
    535366        }
    536367
    537         rc = vol_part_mount(part);
    538         if (rc != EOK) {
    539                 fibril_mutex_unlock(&vol_parts_lock);
    540                 return rc;
    541         }
    542 
    543368        fibril_mutex_unlock(&vol_parts_lock);
    544369        return EOK;
     
    547372errno_t vol_part_get_info(vol_part_t *part, vol_part_info_t *pinfo)
    548373{
    549         memset(pinfo, 0, sizeof(*pinfo));
    550 
    551374        pinfo->pcnt = part->pcnt;
    552375        pinfo->fstype = part->fstype;
    553376        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;
    557377        return EOK;
    558378}
  • uspace/srv/volsrv/part.h

    rd3b2ffa r1e472ee  
    4747extern errno_t vol_part_add(service_id_t);
    4848extern 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 *);
     49extern errno_t vol_part_find_by_id(service_id_t, vol_part_t **);
    5250extern errno_t vol_part_empty_part(vol_part_t *);
    5351extern errno_t vol_part_mkfs_part(vol_part_t *, vol_fstype_t, const char *);
  • uspace/srv/volsrv/types/part.h

    rd3b2ffa r1e472ee  
    3939
    4040#include <adt/list.h>
    41 #include <atomic.h>
    42 #include <stdbool.h>
    4341#include <types/label.h>
    4442
     
    4745        /** Link to vol_parts */
    4846        link_t lparts;
    49         /** Reference count */
    50         atomic_t refcnt;
    5147        /** Service ID */
    5248        service_id_t svc_id;
     
    5955        /** Volume label */
    6056        char *label;
    61         /** Where volume is currently mounted */
    62         char *cur_mp;
    63         /** Mounted at automatic mount point */
    64         bool cur_mp_auto;
    6557} vol_part_t;
    6658
  • uspace/srv/volsrv/volsrv.c

    rd3b2ffa r1e472ee  
    144144        log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_info_srv(%zu)",
    145145            sid);
    146         rc = vol_part_find_by_id_ref(sid, &part);
     146        rc = vol_part_find_by_id(sid, &part);
    147147        if (rc != EOK) {
    148148                async_answer_0(icall_handle, ENOENT);
     
    153153        if (rc != EOK) {
    154154                async_answer_0(icall_handle, EIO);
    155                 goto error;
     155                return;
    156156        }
    157157
     
    161161                async_answer_0(chandle, EREFUSED);
    162162                async_answer_0(icall_handle, EREFUSED);
    163                 goto error;
     163                return;
    164164        }
    165165
     
    167167                async_answer_0(chandle, EINVAL);
    168168                async_answer_0(icall_handle, EINVAL);
    169                 goto error;
     169                return;
    170170        }
    171171
     
    175175                async_answer_0(chandle, rc);
    176176                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);
    209181}
    210182
     
    218190        log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_empty_srv(%zu)", sid);
    219191
    220         rc = vol_part_find_by_id_ref(sid, &part);
     192        rc = vol_part_find_by_id(sid, &part);
    221193        if (rc != EOK) {
    222194                async_answer_0(icall_handle, ENOENT);
     
    227199        if (rc != EOK) {
    228200                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);
    235205}
    236206
     
    281251        errno_t rc;
    282252
    283         log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv()");
    284 
    285253        sid = IPC_GET_ARG1(*icall);
    286254        fstype = IPC_GET_ARG2(*icall);
     
    293261        }
    294262
    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);
    301268        if (rc != EOK) {
    302269                free(label);
     
    309276                free(label);
    310277                async_answer_0(icall_handle, rc);
    311                 vol_part_del_ref(part);
    312278                return;
    313279        }
     
    345311                        vol_part_info_srv(chandle, &call);
    346312                        break;
    347                 case VOL_PART_EJECT:
    348                         vol_part_eject_srv(chandle, &call);
    349                         break;
    350313                case VOL_PART_EMPTY:
    351314                        vol_part_empty_srv(chandle, &call);
Note: See TracChangeset for help on using the changeset viewer.