Changeset 63a3276 in mainline for uspace/srv/vfs/vfs_register.c


Ignore:
Timestamp:
2019-08-06T19:20:35Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
3f05ef7
Parents:
72c8f77
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-06-17 23:02:03)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-06 19:20:35)
Message:

sysman: Instrumented locsrv for autostart

  • also refactored unit name derivation in other brokers
  • exposee creation is not used in unit's lifecycle (failed assertion)

Conflicts:

uspace/lib/c/generic/loc.c
uspace/srv/devman/driver.c
uspace/srv/devman/drv_conn.c
uspace/srv/hid/compositor/compositor.c
uspace/srv/locsrv/locsrv.c
uspace/srv/vfs/vfs.h
uspace/srv/vfs/vfs_ops.c
uspace/srv/vfs/vfs_register.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_register.c

    r72c8f77 r63a3276  
    3636 */
    3737
    38 #include <ipc/services.h>
     38#include <adt/list.h>
     39#include <as.h>
     40#include <assert.h>
    3941#include <async.h>
     42#include <atomic.h>
     43#include <ctype.h>
     44#include <errno.h>
    4045#include <fibril.h>
    4146#include <fibril_synch.h>
    42 #include <errno.h>
     47#include <ipc/services.h>
     48#include <stdbool.h>
    4349#include <stdio.h>
    4450#include <stdlib.h>
    4551#include <str.h>
    46 #include <ctype.h>
    47 #include <stdbool.h>
    48 #include <adt/list.h>
    49 #include <as.h>
    50 #include <assert.h>
    51 #include <stdatomic.h>
    52 #include <vfs/vfs.h>
     52#include <sysman/broker.h>
    5353#include "vfs.h"
    5454
     
    149149         * Check for duplicit registrations.
    150150         */
    151         if (fs_name_to_handle(fs_info->vfs_info.instance,
    152             fs_info->vfs_info.name, false)) {
     151        if (fs_name_to_handle(fs_info->vfs_info.name,
     152            fs_info->vfs_info.instance, false)) {
    153153                /*
    154154                 * We already register a fs like this.
     
    161161        }
    162162
     163        /* Notify sysman about started FS server */
     164        char *unit_name = NULL;
     165        rc = fs_unit_name(fs_info->vfs_info.name, fs_info->vfs_info.instance,
     166            &unit_name);
     167        if (rc != EOK) {
     168                dprintf("Unknow unit name for FS server.\n");
     169                fibril_mutex_unlock(&fs_list_lock);
     170                free(fs_info);
     171                async_answer_0(rid, rc);
     172                return;
     173        }
     174        sysman_main_exposee_added(unit_name, request->in_task_id);
     175        free(unit_name);
     176       
    163177        /*
    164178         * Add fs_info to the list of registered FS's.
     
    288302 *
    289303 * @param name File system name.
     304 * @param instance
    290305 * @param lock If true, the function will lock and unlock the
    291306 *             fs_list_lock.
     
    294309 *
    295310 */
    296 fs_handle_t fs_name_to_handle(unsigned int instance, const char *name, bool lock)
     311fs_handle_t fs_name_to_handle(const char *name, unsigned int instance, bool lock)
    297312{
    298313        int handle = 0;
     
    393408}
    394409
     410/** Get name of unit that represents the filesystem server
     411 *
     412 * Unit name is made simply by considering service of the same name as
     413 * given FS name.
     414 * TODO instance identifier is not implemented.
     415 *
     416 * @param[in]  fs_name
     417 * @param[in]  instance
     418 * @param[out] unit_name_ptr  should be free'd after use, not touched on fail
     419 *
     420 * @return     EOK on success
     421 * @return     ENOMEM
     422 */
     423errno_t fs_unit_name(const char *fs_name, unsigned int instance,
     424    char **unit_name_ptr)
     425{
     426        assert(instance == 0);
     427
     428        char *unit_name = NULL;
     429        asprintf(&unit_name, "%s%c%s", fs_name, UNIT_NAME_SEPARATOR,
     430            UNIT_SVC_TYPE_NAME);
     431
     432        if (unit_name == NULL) {
     433                return ENOMEM;
     434        } else {
     435                *unit_name_ptr = unit_name;
     436                return EOK;
     437        }
     438}
     439
    395440/**
    396441 * @}
Note: See TracChangeset for help on using the changeset viewer.