Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/volsrv/part.c

    r9c2c7d2 r9c96634  
    143143}
    144144
    145 static int vol_part_probe(vol_part_t *part)
    146 {
     145static int vol_part_add_locked(service_id_t sid)
     146{
     147        vol_part_t *part;
    147148        bool empty;
    148149        vfs_fs_probe_info_t info;
    149150        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;
    208151        int rc;
    209152
     
    228171        }
    229172
    230         rc = vol_part_probe(part);
    231         if (rc != EOK)
    232                 goto error;
     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        } else {
     189                log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain "
     190                    "a recognized file system.");
     191
     192                rc = volsrv_part_is_empty(sid, &empty);
     193                if (rc != EOK) {
     194                        log_msg(LOG_DEFAULT, LVL_ERROR, "Failed determining if "
     195                            "partition is empty.");
     196                        goto error;
     197                }
     198
     199                part->pcnt = empty ? vpc_empty : vpc_unknown;
     200        }
    233201
    234202        list_append(&part->lparts, &vol_parts);
     
    337305}
    338306
    339 int vol_part_mkfs_part(vol_part_t *part, vol_fstype_t fstype,
    340     const char *label)
     307int vol_part_mkfs_part(vol_part_t *part, vol_fstype_t fstype)
    341308{
    342309        int rc;
     
    344311        log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_mkfs_part()");
    345312
    346         fibril_mutex_lock(&vol_parts_lock);
    347 
    348         rc = volsrv_part_mkfs(part->svc_id, fstype, label);
     313        rc = volsrv_part_mkfs(part->svc_id, fstype);
    349314        if (rc != EOK) {
    350315                log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_mkfs_part() - failed %d",
    351316                    rc);
    352                 fibril_mutex_unlock(&vol_parts_lock);
    353317                return rc;
    354318        }
    355319
    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);
     320        part->pcnt = vpc_fs;
     321        part->fstype = fstype;
    368322        return EOK;
    369323}
     
    373327        pinfo->pcnt = part->pcnt;
    374328        pinfo->fstype = part->fstype;
    375         str_cpy(pinfo->label, sizeof(pinfo->label), part->label);
    376329        return EOK;
    377330}
Note: See TracChangeset for help on using the changeset viewer.