Ignore:
File:
1 edited

Legend:

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

    r9e45a41 r4285f384  
    11/*
    2  * Copyright (c) 2015 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636
    3737#include <adt/list.h>
     38#include <bd.h>
    3839#include <errno.h>
    3940#include <fibril_synch.h>
     
    5253#include "types/part.h"
    5354#include "volume.h"
     55#include "volsrv.h"
    5456
    5557static errno_t vol_part_add_locked(vol_parts_t *, service_id_t);
     
    403405        part->cur_mp_auto = mp_auto;
    404406
     407        if (str_cmp(mp, "/w") == 0) {
     408                log_msg(LOG_DEFAULT, LVL_NOTE, "Mounted system volume - "
     409                    "loading additional configuration.");
     410                rc = vol_volumes_merge_to(part->parts->volumes,
     411                    vol_cfg_file);
     412                if (rc != EOK) {
     413                        log_msg(LOG_DEFAULT, LVL_ERROR, "Error loading "
     414                            "additional configuration.");
     415                        return rc;
     416                }
     417        }
     418
    405419        return rc;
    406420}
     
    629643}
    630644
    631 errno_t vol_part_eject_part(vol_part_t *part)
     645static errno_t vol_part_eject_device(service_id_t svcid)
     646{
     647        async_sess_t *sess;
     648        errno_t rc;
     649        bd_t *bd;
     650
     651        log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_eject_device(%zu)",
     652            (size_t)svcid);
     653
     654        sess = loc_service_connect(svcid, INTERFACE_BLOCK, 0);
     655        if (sess == NULL)
     656                return EIO;
     657
     658        rc = bd_open(sess, &bd);
     659        if (rc != EOK) {
     660                async_hangup(sess);
     661                return EIO;
     662        }
     663
     664        rc = bd_eject(bd);
     665        if (rc != EOK) {
     666                log_msg(LOG_DEFAULT, LVL_WARN, "vol_part_eject_device(): "
     667                    "eject fail");
     668                bd_close(bd);
     669                async_hangup(sess);
     670                return EIO;
     671        }
     672
     673        bd_close(bd);
     674        async_hangup(sess);
     675        return EOK;
     676}
     677
     678errno_t vol_part_eject_part(vol_part_t *part, vol_eject_flags_t flags)
    632679{
    633680        int rc;
     
    636683
    637684        if (part->cur_mp == NULL) {
    638                 log_msg(LOG_DEFAULT, LVL_DEBUG, "Attempt to mount unmounted "
    639                     "partition.");
    640                 return EINVAL;
     685                /* Partition is not mounted, nothing to do. */
     686                log_msg(LOG_DEFAULT, LVL_DEBUG, "Partition not mounted, "
     687                    "nothing to do.");
     688                goto done;
    641689        }
    642690
     
    656704        }
    657705
     706        if ((flags & vef_physical) != 0) {
     707                rc = vol_part_eject_device(part->svc_id);
     708                if (rc != EOK) {
     709                        log_msg(LOG_DEFAULT, LVL_ERROR, "Failed physically "
     710                            "ejecting device %s.", part->svc_name);
     711                }
     712        }
     713
    658714        free(part->cur_mp);
    659715        part->cur_mp = NULL;
    660716        part->cur_mp_auto = false;
    661 
     717done:
    662718        return EOK;
    663719}
     
    805861
    806862        if (part->cur_mp != NULL) {
    807                 rc = vol_part_eject_part(part);
     863                rc = vol_part_eject_part(part, vef_none);
    808864                if (rc != EOK)
    809865                        return rc;
Note: See TracChangeset for help on using the changeset viewer.