Changeset 5f36841 in mainline


Ignore:
Timestamp:
2018-06-28T23:03:50Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
db9c889
Parents:
70fae4e
git-author:
Jiri Svoboda <jiri@…> (2018-06-28 22:27:12)
git-committer:
Jiri Svoboda <jiri@…> (2018-06-28 23:03:50)
Message:

Basic automatic volume mounting.

Location:
uspace
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sysinst/sysinst.c

    r70fae4e r5f36841  
    6969#define MOUNT_POINT "/inst"
    7070
    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"
     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
    7976#define BOOT_BLOCK_IDX 0 /* MBR */
    8077
     
    196193static errno_t sysinst_copy_boot_files(void)
    197194{
    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;
     195        errno_t rc;
    227196
    228197        printf("sysinst_copy_boot_files(): copy bootloader files\n");
  • uspace/srv/volsrv/part.c

    r70fae4e r5f36841  
    6868};
    6969
     70static const char *fstype_str(vol_fstype_t fstype)
     71{
     72        struct fsname_type *fst;
     73
     74        fst = &fstab[0];
     75        while (fst->name != NULL) {
     76                if (fst->fstype == fstype)
     77                        return fst->name;
     78                ++fst;
     79        }
     80
     81        assert(false);
     82        return NULL;
     83}
     84
    7085/** Check for new partitions */
    7186static errno_t vol_part_check_new(void)
     
    204219}
    205220
     221static int vol_part_mount(vol_part_t *part)
     222{
     223        char *mp;
     224        int rc;
     225
     226        if (str_size(part->label) < 1) {
     227                /* Don't mount nameless volumes */
     228                log_msg(LOG_DEFAULT, LVL_NOTE, "Not mounting nameless partition.");
     229                return EOK;
     230        }
     231
     232        log_msg(LOG_DEFAULT, LVL_NOTE, "Determine MP label='%s'", part->label);
     233        rc = asprintf(&mp, "/vol/%s", part->label);
     234        if (rc < 0) {
     235                log_msg(LOG_DEFAULT, LVL_NOTE, "rc -> %d", rc);
     236                return ENOMEM;
     237        }
     238
     239        log_msg(LOG_DEFAULT, LVL_NOTE, "Create mount point '%s'", mp);
     240        rc = vfs_link_path(mp, KIND_DIRECTORY, NULL);
     241        if (rc != EOK) {
     242                log_msg(LOG_DEFAULT, LVL_ERROR, "Error creating mount point '%s'",
     243                    mp);
     244                free(mp);
     245                return EIO;
     246        }
     247
     248        log_msg(LOG_DEFAULT, LVL_NOTE, "Call vfs_mount_path mp='%s' fstype='%s' svc_name='%s'",
     249            mp, fstype_str(part->fstype), part->svc_name);
     250        rc = vfs_mount_path(mp, fstype_str(part->fstype),
     251            part->svc_name, "", 0, 0);
     252        if (rc != EOK) {
     253                log_msg(LOG_DEFAULT, LVL_NOTE, "Failed mounting to %s", mp);
     254        }
     255        log_msg(LOG_DEFAULT, LVL_NOTE, "Mount to %s -> %d\n", mp, rc);
     256
     257        free(mp);
     258        return rc;
     259}
     260
     261
    206262static errno_t vol_part_add_locked(service_id_t sid)
    207263{
     
    210266
    211267        assert(fibril_mutex_is_locked(&vol_parts_lock));
     268        log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_add_locked(%zu)", sid);
    212269
    213270        /* Check for duplicates */
     
    216273                return EEXIST;
    217274
    218         log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_add_locked()");
     275        log_msg(LOG_DEFAULT, LVL_NOTE, "partition %zu is new", sid);
     276
    219277        part = vol_part_new();
    220278        if (part == NULL)
     
    230288
    231289        rc = vol_part_probe(part);
     290        if (rc != EOK)
     291                goto error;
     292
     293        rc = vol_part_mount(part);
    232294        if (rc != EOK)
    233295                goto error;
     
    366428        }
    367429
     430        rc = vol_part_mount(part);
     431        if (rc != EOK) {
     432                fibril_mutex_unlock(&vol_parts_lock);
     433                return rc;
     434        }
     435
    368436        fibril_mutex_unlock(&vol_parts_lock);
    369437        return EOK;
  • uspace/srv/volsrv/volsrv.c

    r70fae4e r5f36841  
    251251        errno_t rc;
    252252
     253        log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv()");
     254
    253255        sid = IPC_GET_ARG1(*icall);
    254256        fstype = IPC_GET_ARG2(*icall);
     
    261263        }
    262264
    263         printf("vol_part_mkfs_srv: label=%p\n", label);
    264         if (label != NULL)
    265                 printf("vol_part_mkfs_srv: label='%s'\n", label);
     265        if (label != NULL) {
     266                log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv: label='%s'",
     267                    label);
     268        }
    266269
    267270        rc = vol_part_find_by_id(sid, &part);
Note: See TracChangeset for help on using the changeset viewer.