Changes in / [2cc7f16:5608deba] in mainline


Ignore:
Files:
4 added
6 deleted
37 edited

Legend:

Unmodified
Added
Removed
  • abi/include/syscall.h

    r2cc7f16 r5608deba  
    9292        SYS_IRQ_UNREGISTER,
    9393       
     94        SYS_SYSINFO_GET_KEYS_SIZE,
     95        SYS_SYSINFO_GET_KEYS,
    9496        SYS_SYSINFO_GET_VAL_TYPE,
    9597        SYS_SYSINFO_GET_VALUE,
  • boot/Makefile.common

    r2cc7f16 r5608deba  
    165165        $(USPACE_PATH)/app/locinfo/locinfo \
    166166        $(USPACE_PATH)/app/mkfat/mkfat \
     167        $(USPACE_PATH)/app/mkexfat/mkexfat \
    167168        $(USPACE_PATH)/app/mkmfs/mkmfs \
    168169        $(USPACE_PATH)/app/lsusb/lsusb \
  • boot/arch/ia64/src/pal_asm.S

    r2cc7f16 r5608deba  
    3232
    3333pal_static_call:
    34         alloc loc0 = ar.pfs, 7, 5, 0, 0
     34        alloc loc0 = ar.pfs, 7, 6, 0, 0
     35
     36        mov loc1 = psr ;;
     37        mov psr.l = r0 ;;
     38        srlz.i
     39        srlz.d
    3540       
    36         mov loc1 = gp
    37         mov loc2 = rp
     41        mov loc2 = gp
     42        mov loc3 = rp
    3843       
    39         addl loc3 = @gprel(pal_proc), gp
    40        
     44        addl loc4 = @gprel(pal_proc), gp
     45
    4146        mov r28 = in0
    4247        mov r29 = in1
     
    4449        mov r31 = in3 ;;
    4550       
    46         ld8 loc3 = [loc3]
    47         movl loc4 = 0f ;;
     51        ld8 loc4 = [loc4]
     52        movl loc5 = 0f ;;
    4853
    49         mov b6 = loc3
    50         mov rp = loc4 ;;
     54        mov b6 = loc4
     55        mov rp = loc5 ;;
    5156        br.cond.sptk.many b6
    5257
    53580:
     59        mov psr.l = loc1 ;;
     60        srlz.i
     61        srlz.d
     62
    5463        cmp.ne p7,p0 = 0, in4
    5564        cmp.ne p8,p0 = 0, in5
     
    6069(p9)    st8 [in6] = r11
    6170       
    62         mov gp = loc1
    63         mov rp = loc2 ;;
     71        mov gp = loc2
     72        mov rp = loc3 ;;
    6473       
    6574        mov ar.pfs = loc0
  • boot/arch/ia64/src/sal_asm.S

    r2cc7f16 r5608deba  
    2929.explicit
    3030
     31#define STACK_SCRATCH_AREA      16
     32#define STACK_IN8               (0 + STACK_SCRATCH_AREA)
     33#define STACK_IN9               (8 + STACK_SCRATCH_AREA)
     34#define STACK_IN10              (16 + STACK_SCRATCH_AREA)
     35
    3136.global sal_call
    3237
     
    3944#
    4045sal_call:
    41         alloc loc0 = ar.pfs, 11, 5, 8, 0
     46        alloc loc0 = ar.pfs, 8, 8, 8, 0
    4247       
     48        adds sp = -STACK_SCRATCH_AREA, sp
     49
    4350        mov loc1 = gp
    4451        mov loc2 = rp
     
    5764       
    5865        ld8 loc3 = [loc3]
    59         ld8 gp = [loc4] ;;
     66        ld8 gp = [loc4]
     67
     68        adds r14 = STACK_IN8 + STACK_SCRATCH_AREA, sp
     69        adds r15 = STACK_IN9 + STACK_SCRATCH_AREA, sp
     70        adds r16 = STACK_IN10 + STACK_SCRATCH_AREA, sp ;;
     71
     72        ld8 loc5 = [r14]
     73        ld8 loc6 = [r15]
     74        ld8 loc7 = [r16]
    6075       
    6176        mov b6 = loc3 ;;
    6277        br.call.sptk.many rp = b6
    6378       
    64         cmp.ne p7,p0 = 0, in8
    65         cmp.ne p8,p0 = 0, in9
    66         cmp.ne p9,p0 = 0, in10 ;;
     79        cmp.ne p7,p0 = 0, loc5
     80        cmp.ne p8,p0 = 0, loc6
     81        cmp.ne p9,p0 = 0, loc7 ;;
    6782       
    68 (p7)    st8 [in8] = r9
    69 (p8)    st8 [in9] = r10
    70 (p9)    st8 [in10] = r11
     83(p7)    st8 [loc5] = r9
     84(p8)    st8 [loc6] = r10
     85(p9)    st8 [loc7] = r11
    7186       
    7287        mov gp = loc1
    73         mov rp = loc2 ;;
     88        mov rp = loc2
     89
     90        adds sp = STACK_SCRATCH_AREA, sp ;;
    7491       
    7592        mov ar.pfs = loc0
    7693        br.ret.sptk.many rp
     94
  • kernel/arch/ia64/include/asm.h

    r2cc7f16 r5608deba  
    6161        asm volatile (
    6262                "mf\n"
     63                "mf.a\n"
    6364                ::: "memory"
    6465        );
     
    7475        asm volatile (
    7576                "mf\n"
     77                "mf.a\n"
    7678                ::: "memory"
    7779        );
     
    8789        asm volatile (
    8890                "mf\n"
     91                "mf.a\n"
    8992                ::: "memory"
    9093        );
     
    104107        else
    105108                v = *port;
     109
     110        asm volatile (
     111                "mf.a\n"
     112                ::: "memory"
     113        );
    106114       
    107115        return v;
     
    121129        else
    122130                v = *port;
     131
     132        asm volatile (
     133                "mf.a\n"
     134                ::: "memory"
     135        );
    123136       
    124137        return v;
     
    138151        else
    139152                v = *port;
     153
     154        asm volatile (
     155                "mf.a\n"
     156                ::: "memory"
     157        );
    140158
    141159        return v;
  • kernel/arch/ia64/src/ia64.c

    r2cc7f16 r5608deba  
    144144#endif
    145145#ifdef MACHINE_i460GX
    146         platform = "i460GX";
     146        platform = "pc";
    147147#endif
    148148        sysinfo_set_item_data("platform", NULL, (void *) platform,
  • kernel/arch/ppc32/src/ppc32.c

    r2cc7f16 r5608deba  
    173173                ofw_tree_walk_by_device_type("display", display_register, NULL);
    174174#endif
     175                /* Map OFW information into sysinfo */
     176                ofw_sysinfo_map();
    175177               
    176178                /* Initialize IRQ routing */
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    r2cc7f16 r5608deba  
    9494{
    9595        if (config.cpu_active == 1) {
     96                /* Map OFW information into sysinfo */
     97                ofw_sysinfo_map();
     98               
    9699                /*
    97100                 * We have 2^11 different interrupt vectors.
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    r2cc7f16 r5608deba  
    9292{
    9393        if (config.cpu_active == 1) {
     94                /* Map OFW information into sysinfo */
     95                ofw_sysinfo_map();
     96               
    9497                /*
    9598                 * We have 2^11 different interrupt vectors.
  • kernel/genarch/include/ofw/ofw_tree.h

    r2cc7f16 r5608deba  
    6767
    6868extern void ofw_tree_init(ofw_tree_node_t *);
    69 extern void ofw_tree_print(void);
     69extern void ofw_sysinfo_map(void);
    7070
    7171extern const char *ofw_tree_node_name(const ofw_tree_node_t *);
  • kernel/genarch/src/ofw/ofw_tree.c

    r2cc7f16 r5608deba  
    3838#include <genarch/ofw/ofw_tree.h>
    3939#include <mm/slab.h>
     40#include <sysinfo/sysinfo.h>
    4041#include <memstr.h>
    4142#include <str.h>
     
    6566    const char *name)
    6667{
    67         size_t i;
    68        
    69         for (i = 0; i < node->properties; i++) {
     68        for (size_t i = 0; i < node->properties; i++) {
    7069                if (str_cmp(node->property[i].name, name) == 0)
    7170                        return &node->property[i];
     
    104103    const char *name)
    105104{
    106         ofw_tree_node_t *cur;
    107        
    108105        /*
    109106         * Try to find the disambigued name.
    110107         */
    111         for (cur = node->child; cur; cur = cur->peer) {
     108        for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
    112109                if (str_cmp(cur->da_name, name) == 0)
    113110                        return cur;
     
    121118         * are not always fully-qualified.
    122119         */
    123         for (cur = node->child; cur; cur = cur->peer) {
     120        for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
    124121                if (str_cmp(ofw_tree_node_name(cur), name) == 0)
    125122                        return cur;
     
    141138    const char *dtype)
    142139{
    143         ofw_tree_node_t *cur;
    144        
    145         for (cur = node->child; cur; cur = cur->peer) {
     140        for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
    146141                ofw_tree_property_t *prop =
    147142                    ofw_tree_getprop(cur, "device_type");
     
    172167    phandle handle)
    173168{
    174         ofw_tree_node_t *cur;
    175        
    176         for (cur = root; cur; cur = cur->peer) {
     169        for (ofw_tree_node_t *cur = root; cur; cur = cur->peer) {
    177170                if (cur->node_handle == handle)
    178171                        return cur;
    179172               
    180173                if (cur->child) {
    181                         ofw_tree_node_t *node
    182                             = ofw_tree_find_node_by_handle(cur->child, handle);
     174                        ofw_tree_node_t *node =
     175                            ofw_tree_find_node_by_handle(cur->child, handle);
    183176                        if (node)
    184177                                return node;
     
    201194    const char *dtype)
    202195{
    203         ofw_tree_node_t *cur;
    204        
    205         for (cur = node->peer; cur; cur = cur->peer) {
     196        for (ofw_tree_node_t *cur = node->peer; cur; cur = cur->peer) {
    206197                ofw_tree_property_t *prop =
    207198                    ofw_tree_getprop(cur, "device_type");
     
    229220    const char *name)
    230221{
    231         ofw_tree_node_t *cur;
    232        
    233         for (cur = node->peer; cur; cur = cur->peer) {
    234                 ofw_tree_property_t *prop
    235                     = ofw_tree_getprop(cur, "name");
     222        for (ofw_tree_node_t *cur = node->peer; cur; cur = cur->peer) {
     223                ofw_tree_property_t *prop =
     224                    ofw_tree_getprop(cur, "name");
    236225               
    237226                if ((!prop) || (!prop->value))
     
    259248       
    260249        ofw_tree_node_t *node = ofw_root;
    261         size_t i;
    262250        size_t j;
    263251       
    264         for (i = 1; (i < str_size(path)) && (node); i = j + 1) {
     252        for (size_t i = 1; (i < str_size(path)) && (node); i = j + 1) {
    265253                for (j = i; (j < str_size(path)) && (path[j] != '/'); j++);
    266254               
     
    294282    const char *dtype, ofw_tree_walker_t walker, void *arg)
    295283{
    296         ofw_tree_node_t *cur;
    297        
    298         for (cur = node; cur; cur = cur->peer) {
     284        for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
    299285                ofw_tree_property_t *prop =
    300286                    ofw_tree_getprop(cur, "device_type");
     
    334320}
    335321
    336 /** Print OpenFirmware device subtree rooted in a node.
     322/** Get OpenFirmware node properties.
     323 *
     324 * @param item    Sysinfo item (unused).
     325 * @param size    Size of the returned data.
     326 * @param dry_run Do not get the data, just calculate the size.
     327 * @param data    OpenFirmware node.
     328 *
     329 * @return Data containing a serialized dump of all node
     330 *         properties. If the return value is not NULL, it
     331 *         should be freed in the context of the sysinfo request.
     332 *
     333 */
     334static void *ofw_sysinfo_properties(struct sysinfo_item *item, size_t *size,
     335    bool dry_run, void *data)
     336{
     337        ofw_tree_node_t *node = (ofw_tree_node_t *) data;
     338       
     339        /* Compute serialized data size */
     340        *size = 0;
     341        for (size_t i = 0; i < node->properties; i++)
     342                *size += str_size(node->property[i].name) + 1 +
     343                    sizeof(node->property[i].size) + node->property[i].size;
     344       
     345        if (dry_run)
     346                return NULL;
     347       
     348        void *dump = malloc(*size, FRAME_ATOMIC);
     349        if (dump == NULL) {
     350                *size = 0;
     351                return NULL;
     352        }
     353       
     354        /* Serialize the data */
     355        size_t pos = 0;
     356        for (size_t i = 0; i < node->properties; i++) {
     357                /* Property name */
     358                str_cpy(dump + pos, *size - pos, node->property[i].name);
     359                pos += str_size(node->property[i].name) + 1;
     360               
     361                /* Value size */
     362                memcpy(dump + pos, &node->property[i].size,
     363                    sizeof(node->property[i].size));
     364                pos += sizeof(node->property[i].size);
     365               
     366                /* Value */
     367                memcpy(dump + pos, node->property[i].value,
     368                    node->property[i].size);
     369                pos += node->property[i].size;
     370        }
     371       
     372        return ((void *) dump);
     373}
     374
     375/** Map OpenFirmware device subtree rooted in a node into sysinfo.
    337376 *
    338377 * Child nodes are processed recursively and peer nodes are processed
     
    343382 *
    344383 */
    345 static void ofw_tree_node_print(ofw_tree_node_t *node, const char *path)
     384static void ofw_tree_node_sysinfo(ofw_tree_node_t *node, const char *path)
    346385{
    347386        char *cur_path = (char *) malloc(PATH_MAX_LEN, 0);
    348         ofw_tree_node_t *cur;
    349        
    350         for (cur = node; cur; cur = cur->peer) {
    351                 if ((cur->parent) && (path)) {
    352                         snprintf(cur_path, PATH_MAX_LEN, "%s/%s", path, cur->da_name);
    353                         printf("%s\n", cur_path);
    354                 } else {
    355                         snprintf(cur_path, PATH_MAX_LEN, "%s", cur->da_name);
    356                         printf("/\n");
    357                 }
     387       
     388        for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
     389                if ((cur->parent) && (path))
     390                        snprintf(cur_path, PATH_MAX_LEN, "%s.%s", path, cur->da_name);
     391                else
     392                        snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name);
     393               
     394                sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties,
     395                    (void *) cur);
    358396               
    359397                if (cur->child)
    360                         ofw_tree_node_print(cur->child, cur_path);
     398                        ofw_tree_node_sysinfo(cur->child, cur_path);
    361399        }
    362400       
     
    364402}
    365403
    366 /** Print the structure of the OpenFirmware device tree. */
    367 void ofw_tree_print(void)
    368 {
    369         ofw_tree_node_print(ofw_root, NULL);
     404/** Map the OpenFirmware device tree into sysinfo. */
     405void ofw_sysinfo_map(void)
     406{
     407        ofw_tree_node_sysinfo(ofw_root, NULL);
    370408}
    371409
  • kernel/generic/include/sysinfo/sysinfo.h

    r2cc7f16 r5608deba  
    11/*
    22 * Copyright (c) 2006 Jakub Vana
     3 * Copyright (c) 2012 Martin Decky
    34 * All rights reserved.
    45 *
     
    5455struct sysinfo_item;
    5556
    56 /** Gerated numeric value function */
    57 typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
     57/** Generated numeric value function */
     58typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *, void *);
     59
     60/** Sysinfo generated numberic value data
     61 *
     62 */
     63typedef struct {
     64        sysinfo_fn_val_t fn;  /**< Generated value function */
     65        void *data;           /**< Private data */
     66} sysinfo_gen_val_data_t;
    5867
    5968/** Generated binary data function */
    60 typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool);
     69typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool,
     70    void *);
     71
     72/** Sysinfo generated binary data data
     73 *
     74 */
     75typedef struct {
     76        sysinfo_fn_data_t fn;  /**< Generated binary data function */
     77        void *data;            /**< Private data */
     78} sysinfo_gen_data_data_t;
    6179
    6280/** Sysinfo item binary data
     
    7290 */
    7391typedef union {
    74         sysarg_t val;               /**< Constant numberic value */
    75         sysinfo_fn_val_t fn_val;    /**< Generated numeric value function */
    76         sysinfo_fn_data_t fn_data;  /**< Generated binary data function */
    77         sysinfo_data_t data;        /**< Constant binary data */
     92        sysarg_t val;                      /**< Constant numberic value */
     93        sysinfo_data_t data;               /**< Constant binary data */
     94        sysinfo_gen_val_data_t gen_val;    /**< Generated numeric value function */
     95        sysinfo_gen_data_data_t gen_data;  /**< Generated binary data function */
    7896} sysinfo_item_val_t;
    7997
     
    95113
    96114/** Generated subtree function */
    97 typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool);
     115typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool, void *);
     116
     117/** Sysinfo generated subtree data
     118 *
     119 */
     120typedef struct {
     121        sysinfo_fn_subtree_t fn;  /**< Generated subtree function */
     122        void *data;               /**< Private data */
     123} sysinfo_gen_subtree_data_t;
    98124
    99125/** Sysinfo subtree (union)
     
    101127 */
    102128typedef union {
    103         struct sysinfo_item *table;     /**< Fixed subtree (list of subitems) */
    104         sysinfo_fn_subtree_t get_data;  /**< Generated subtree function */
     129        struct sysinfo_item *table;            /**< Fixed subtree (list of subitems) */
     130        sysinfo_gen_subtree_data_t generator;  /**< Generated subtree */
    105131} sysinfo_subtree_t;
    106132
     
    123149extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
    124150    size_t);
    125 extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **,
    126     sysinfo_fn_val_t);
    127 extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **,
    128     sysinfo_fn_data_t);
     151extern void sysinfo_set_item_gen_val(const char *, sysinfo_item_t **,
     152    sysinfo_fn_val_t, void *);
     153extern void sysinfo_set_item_gen_data(const char *, sysinfo_item_t **,
     154    sysinfo_fn_data_t, void *);
    129155extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
    130156
    131157extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
    132     sysinfo_fn_subtree_t);
     158    sysinfo_fn_subtree_t, void *);
    133159
    134160extern void sysinfo_init(void);
    135161extern void sysinfo_dump(sysinfo_item_t *);
    136162
     163extern sysarg_t sys_sysinfo_get_keys_size(void *, size_t, void *);
     164extern sysarg_t sys_sysinfo_get_keys(void *, size_t, void *, size_t, size_t *);
    137165extern sysarg_t sys_sysinfo_get_val_type(void *, size_t);
    138166extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
  • kernel/generic/src/ddi/ddi.c

    r2cc7f16 r5608deba  
    166166        }
    167167       
    168         if (zones.info[znum].flags & ZONE_FIRMWARE) {
    169                 /*
    170                  * Frames are part of firmware
     168        if (zones.info[znum].flags & (ZONE_FIRMWARE | ZONE_RESERVED)) {
     169                /*
     170                 * Frames are part of firmware or reserved zone
    171171                 * -> allow mapping for privileged tasks.
    172172                 */
  • kernel/generic/src/lib/func.c

    r2cc7f16 r5608deba  
    5353void halt()
    5454{
    55 #ifdef CONFIG_DEBUG
     55#if (defined(CONFIG_DEBUG)) && (defined(CONFIG_KCONSOLE))
    5656        bool rundebugger = false;
    5757       
  • kernel/generic/src/main/main.c

    r2cc7f16 r5608deba  
    221221        frame_init();
    222222        slab_cache_init();
    223         ra_init();     
     223        ra_init();
    224224        sysinfo_init();
    225225        btree_init();
     
    257257                for (i = 0; i < init.cnt; i++)
    258258                        LOG("init[%zu].addr=%p, init[%zu].size=%zu",
    259                             i, (void *) init.tasks[i].addr, i, init.tasks[i].size);
     259                            i, (void *) init.tasks[i].paddr, i, init.tasks[i].size);
    260260        } else
    261261                printf("No init binaries found.\n");
  • kernel/generic/src/mm/page.c

    r2cc7f16 r5608deba  
    168168int page_find_mapping(uintptr_t virt, void **phys)
    169169{
    170         mutex_lock(&AS->lock);
     170        page_table_lock(AS, true);
    171171       
    172172        pte_t *pte = page_mapping_find(AS, virt, false);
    173173        if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) {
    174                 mutex_unlock(&AS->lock);
     174                page_table_unlock(AS, true);
    175175                return ENOENT;
    176176        }
     
    179179            (virt - ALIGN_DOWN(virt, PAGE_SIZE));
    180180       
    181         mutex_unlock(&AS->lock);
     181        page_table_unlock(AS, true);
    182182       
    183183        return EOK;
  • kernel/generic/src/syscall/syscall.c

    r2cc7f16 r5608deba  
    184184       
    185185        /* Sysinfo syscalls. */
     186        (syshandler_t) sys_sysinfo_get_keys_size,
     187        (syshandler_t) sys_sysinfo_get_keys,
    186188        (syshandler_t) sys_sysinfo_get_val_type,
    187189        (syshandler_t) sys_sysinfo_get_value,
  • kernel/generic/src/sysinfo/stats.c

    r2cc7f16 r5608deba  
    8383 *
    8484 * @param item Sysinfo item (unused).
     85 * @param data Unused.
    8586 *
    8687 * @return System uptime (in secords).
    8788 *
    8889 */
    89 static sysarg_t get_stats_uptime(struct sysinfo_item *item)
     90static sysarg_t get_stats_uptime(struct sysinfo_item *item, void *data)
    9091{
    9192        /* This doesn't have to be very accurate */
     
    9899 * @param size    Size of the returned data.
    99100 * @param dry_run Do not get the data, just calculate the size.
     101 * @param data    Unused.
    100102 *
    101103 * @return Data containing several stats_cpu_t structures.
     
    104106 */
    105107static void *get_stats_cpus(struct sysinfo_item *item, size_t *size,
    106     bool dry_run)
     108    bool dry_run, void *data)
    107109{
    108110        *size = sizeof(stats_cpu_t) * config.cpu_count;
     
    249251        ASSERT(interrupts_disabled());
    250252        ASSERT(irq_spinlock_locked(&task->lock));
    251 
     253       
    252254        stats_task->task_id = task->taskid;
    253255        str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
     
    293295 * @param size    Size of the returned data.
    294296 * @param dry_run Do not get the data, just calculate the size.
     297 * @param data    Unused.
    295298 *
    296299 * @return Data containing several stats_task_t structures.
     
    299302 */
    300303static void *get_stats_tasks(struct sysinfo_item *item, size_t *size,
    301     bool dry_run)
     304    bool dry_run, void *data)
    302305{
    303306        /* Messing with task structures, avoid deadlock */
     
    350353        ASSERT(interrupts_disabled());
    351354        ASSERT(irq_spinlock_locked(&thread->lock));
    352 
     355       
    353356        stats_thread->thread_id = thread->tid;
    354357        stats_thread->task_id = thread->task->taskid;
     
    398401 * @param size    Size of the returned data.
    399402 * @param dry_run Do not get the data, just calculate the size.
     403 * @param data    Unused.
    400404 *
    401405 * @return Data containing several stats_task_t structures.
     
    404408 */
    405409static void *get_stats_threads(struct sysinfo_item *item, size_t *size,
    406     bool dry_run)
     410    bool dry_run, void *data)
    407411{
    408412        /* Messing with threads structures, avoid deadlock */
     
    451455 * @param name    Task ID (string-encoded number).
    452456 * @param dry_run Do not get the data, just calculate the size.
     457 * @param data    Unused.
    453458 *
    454459 * @return Sysinfo return holder. The type of the returned
     
    460465 *
    461466 */
    462 static sysinfo_return_t get_stats_task(const char *name, bool dry_run)
     467static sysinfo_return_t get_stats_task(const char *name, bool dry_run,
     468    void *data)
    463469{
    464470        /* Initially no return value */
     
    520526 * @param name    Thread ID (string-encoded number).
    521527 * @param dry_run Do not get the data, just calculate the size.
     528 * @param data    Unused.
    522529 *
    523530 * @return Sysinfo return holder. The type of the returned
     
    529536 *
    530537 */
    531 static sysinfo_return_t get_stats_thread(const char *name, bool dry_run)
     538static sysinfo_return_t get_stats_thread(const char *name, bool dry_run,
     539    void *data)
    532540{
    533541        /* Initially no return value */
     
    586594 * @param size    Size of the returned data.
    587595 * @param dry_run Do not get the data, just calculate the size.
     596 * @param data    Unused.
    588597 *
    589598 * @return Data containing several stats_exc_t structures.
     
    592601 */
    593602static void *get_stats_exceptions(struct sysinfo_item *item, size_t *size,
    594     bool dry_run)
     603    bool dry_run, void *data)
    595604{
    596605        *size = sizeof(stats_exc_t) * IVT_ITEMS;
     
    634643 * @param name    Exception number (string-encoded number).
    635644 * @param dry_run Do not get the data, just calculate the size.
     645 * @param data    Unused.
    636646 *
    637647 * @return Sysinfo return holder. The type of the returned
     
    643653 *
    644654 */
    645 static sysinfo_return_t get_stats_exception(const char *name, bool dry_run)
     655static sysinfo_return_t get_stats_exception(const char *name, bool dry_run,
     656    void *data)
    646657{
    647658        /* Initially no return value */
     
    705716 * @param size    Size of the returned data.
    706717 * @param dry_run Do not get the data, just calculate the size.
     718 * @param data    Unused.
    707719 *
    708720 * @return Data containing stats_physmem_t.
     
    711723 */
    712724static void *get_stats_physmem(struct sysinfo_item *item, size_t *size,
    713     bool dry_run)
     725    bool dry_run, void *data)
    714726{
    715727        *size = sizeof(stats_physmem_t);
     
    735747 * @param size    Size of the returned data.
    736748 * @param dry_run Do not get the data, just calculate the size.
     749 * @param data    Unused.
    737750 *
    738751 * @return Data several load_t values.
     
    741754 */
    742755static void *get_stats_load(struct sysinfo_item *item, size_t *size,
    743     bool dry_run)
     756    bool dry_run, void *data)
    744757{
    745758        *size = sizeof(load_t) * LOAD_STEPS;
     
    810823        mutex_initialize(&load_lock, MUTEX_PASSIVE);
    811824       
    812         sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime);
    813         sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus);
    814         sysinfo_set_item_fn_data("system.physmem", NULL, get_stats_physmem);
    815         sysinfo_set_item_fn_data("system.load", NULL, get_stats_load);
    816         sysinfo_set_item_fn_data("system.tasks", NULL, get_stats_tasks);
    817         sysinfo_set_item_fn_data("system.threads", NULL, get_stats_threads);
    818         sysinfo_set_item_fn_data("system.exceptions", NULL, get_stats_exceptions);
    819         sysinfo_set_subtree_fn("system.tasks", NULL, get_stats_task);
    820         sysinfo_set_subtree_fn("system.threads", NULL, get_stats_thread);
    821         sysinfo_set_subtree_fn("system.exceptions", NULL, get_stats_exception);
     825        sysinfo_set_item_gen_val("system.uptime", NULL, get_stats_uptime, NULL);
     826        sysinfo_set_item_gen_data("system.cpus", NULL, get_stats_cpus, NULL);
     827        sysinfo_set_item_gen_data("system.physmem", NULL, get_stats_physmem, NULL);
     828        sysinfo_set_item_gen_data("system.load", NULL, get_stats_load, NULL);
     829        sysinfo_set_item_gen_data("system.tasks", NULL, get_stats_tasks, NULL);
     830        sysinfo_set_item_gen_data("system.threads", NULL, get_stats_threads, NULL);
     831        sysinfo_set_item_gen_data("system.exceptions", NULL, get_stats_exceptions, NULL);
     832        sysinfo_set_subtree_fn("system.tasks", NULL, get_stats_task, NULL);
     833        sysinfo_set_subtree_fn("system.threads", NULL, get_stats_thread, NULL);
     834        sysinfo_set_subtree_fn("system.exceptions", NULL, get_stats_exception, NULL);
    822835}
    823836
  • kernel/generic/src/sysinfo/sysinfo.c

    r2cc7f16 r5608deba  
    11/*
    22 * Copyright (c) 2006 Jakub Vana
     3 * Copyright (c) 2012 Martin Decky
    34 * All rights reserved.
    45 *
     
    99100            sizeof(sysinfo_item_t), 0, sysinfo_item_constructor,
    100101            sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED);
    101 
     102       
    102103        mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE);
    103104}
     
    110111 * @param subtree Current sysinfo (sub)tree root item.
    111112 * @param ret     If the return value is NULL, this argument
    112  *                can be either also NULL (i.e. no item was
     113 *                can be set either to NULL (i.e. no item was
    113114 *                found and no data was generated) or the
    114115 *                original pointer is used to store the value
     
    125126{
    126127        ASSERT(subtree != NULL);
    127         ASSERT(ret != NULL);
    128128       
    129129        sysinfo_item_t *cur = subtree;
     
    151151                        case SYSINFO_SUBTREE_FUNCTION:
    152152                                /* Get generated data */
    153                                 **ret = cur->subtree.get_data(name + i + 1, dry_run);
     153                                if (ret != NULL)
     154                                        **ret = cur->subtree.generator.fn(name + i + 1,
     155                                            dry_run, cur->subtree.generator.data);
     156                               
    154157                                return NULL;
    155158                        default:
    156159                                /* Not found, no data generated */
    157                                 *ret = NULL;
     160                                if (ret != NULL)
     161                                        *ret = NULL;
     162                               
    158163                                return NULL;
    159164                        }
     
    164169       
    165170        /* Not found, no data generated */
    166         *ret = NULL;
     171        if (ret != NULL)
     172                *ret = NULL;
     173       
    167174        return NULL;
    168175}
     
    352359 *             a new root item (NULL for global sysinfo root).
    353360 * @param fn   Numeric value generator function.
    354  *
    355  */
    356 void sysinfo_set_item_fn_val(const char *name, sysinfo_item_t **root,
    357     sysinfo_fn_val_t fn)
     361 * @param data Private data.
     362 *
     363 */
     364void sysinfo_set_item_gen_val(const char *name, sysinfo_item_t **root,
     365    sysinfo_fn_val_t fn, void *data)
    358366{
    359367        /* Protect sysinfo tree consistency */
     
    366374        if (item != NULL) {
    367375                item->val_type = SYSINFO_VAL_FUNCTION_VAL;
    368                 item->val.fn_val = fn;
     376                item->val.gen_val.fn = fn;
     377                item->val.gen_val.data = data;
    369378        }
    370379       
     
    383392 *             a new root item (NULL for global sysinfo root).
    384393 * @param fn   Binary data generator function.
    385  *
    386  */
    387 void sysinfo_set_item_fn_data(const char *name, sysinfo_item_t **root,
    388     sysinfo_fn_data_t fn)
     394 * @param data Private data.
     395 *
     396 */
     397void sysinfo_set_item_gen_data(const char *name, sysinfo_item_t **root,
     398    sysinfo_fn_data_t fn, void *data)
    389399{
    390400        /* Protect sysinfo tree consistency */
     
    397407        if (item != NULL) {
    398408                item->val_type = SYSINFO_VAL_FUNCTION_DATA;
    399                 item->val.fn_data = fn;
     409                item->val.gen_data.fn = fn;
     410                item->val.gen_data.data = data;
    400411        }
    401412       
     
    431442 *             a new root item (NULL for global sysinfo root).
    432443 * @param fn   Subtree generator function.
     444 * @param data Private data to be passed to the generator.
    433445 *
    434446 */
    435447void sysinfo_set_subtree_fn(const char *name, sysinfo_item_t **root,
    436     sysinfo_fn_subtree_t fn)
     448    sysinfo_fn_subtree_t fn, void *data)
    437449{
    438450        /* Protect sysinfo tree consistency */
     
    448460        if ((item != NULL) && (item->subtree_type != SYSINFO_SUBTREE_TABLE)) {
    449461                item->subtree_type = SYSINFO_SUBTREE_FUNCTION;
    450                 item->subtree.get_data = fn;
     462                item->subtree.generator.fn = fn;
     463                item->subtree.generator.data = data;
    451464        }
    452465       
     
    456469/** Sysinfo dump indentation helper routine
    457470 *
    458  * @param depth Number of indentation characters to print.
    459  *
    460  */
    461 NO_TRACE static void sysinfo_indent(unsigned int depth)
    462 {
    463         unsigned int i;
    464         for (i = 0; i < depth; i++)
    465                 printf("  ");
     471 * @param depth Number of spaces to print.
     472 *
     473 */
     474NO_TRACE static void sysinfo_indent(size_t spaces)
     475{
     476        for (size_t i = 0; i < spaces; i++)
     477                printf(" ");
    466478}
    467479
     
    470482 * Should be called with sysinfo_lock held.
    471483 *
    472  * @param root  Root item of the current (sub)tree.
    473  * @param depth Current depth in the sysinfo tree.
    474  *
    475  */
    476 NO_TRACE static void sysinfo_dump_internal(sysinfo_item_t *root, unsigned int depth)
    477 {
    478         sysinfo_item_t *cur = root;
    479        
     484 * @param root   Root item of the current (sub)tree.
     485 * @param spaces Current indentation level.
     486 *
     487 */
     488NO_TRACE static void sysinfo_dump_internal(sysinfo_item_t *root, size_t spaces)
     489{
    480490        /* Walk all siblings */
    481         while (cur != NULL) {
    482                 sysinfo_indent(depth);
     491        for (sysinfo_item_t *cur = root; cur; cur = cur->next) {
     492                size_t length;
     493               
     494                if (spaces == 0) {
     495                        printf("%s", cur->name);
     496                        length = str_length(cur->name);
     497                } else {
     498                        sysinfo_indent(spaces);
     499                        printf(".%s", cur->name);
     500                        length = str_length(cur->name) + 1;
     501                }
    483502               
    484503                sysarg_t val;
     
    488507                switch (cur->val_type) {
    489508                case SYSINFO_VAL_UNDEFINED:
    490                         printf("+ %s\n", cur->name);
     509                        printf(" [undefined]\n");
    491510                        break;
    492511                case SYSINFO_VAL_VAL:
    493                         printf("+ %s -> %" PRIun" (%#" PRIxn ")\n", cur->name,
    494                             cur->val.val, cur->val.val);
     512                        printf(" -> %" PRIun" (%#" PRIxn ")\n", cur->val.val,
     513                            cur->val.val);
    495514                        break;
    496515                case SYSINFO_VAL_DATA:
    497                         printf("+ %s (%zu bytes)\n", cur->name,
    498                             cur->val.data.size);
     516                        printf(" (%zu bytes)\n", cur->val.data.size);
    499517                        break;
    500518                case SYSINFO_VAL_FUNCTION_VAL:
    501                         val = cur->val.fn_val(cur);
    502                         printf("+ %s -> %" PRIun" (%#" PRIxn ") [generated]\n",
    503                             cur->name, val, val);
     519                        val = cur->val.gen_val.fn(cur, cur->val.gen_val.data);
     520                        printf(" -> %" PRIun" (%#" PRIxn ") [generated]\n", val,
     521                            val);
    504522                        break;
    505523                case SYSINFO_VAL_FUNCTION_DATA:
    506524                        /* N.B.: No data was actually returned (only a dry run) */
    507                         (void) cur->val.fn_data(cur, &size, true);
    508                         printf("+ %s (%zu bytes) [generated]\n", cur->name,
    509                             size);
     525                        (void) cur->val.gen_data.fn(cur, &size, true,
     526                            cur->val.gen_data.data);
     527                        printf(" (%zu bytes) [generated]\n", size);
    510528                        break;
    511529                default:
     
    518536                        break;
    519537                case SYSINFO_SUBTREE_TABLE:
    520                         sysinfo_dump_internal(cur->subtree.table, depth + 1);
     538                        sysinfo_dump_internal(cur->subtree.table, spaces + length);
    521539                        break;
    522540                case SYSINFO_SUBTREE_FUNCTION:
    523                         sysinfo_indent(depth + 1);
    524                         printf("+ [generated subtree]\n");
     541                        sysinfo_indent(spaces + length);
     542                        printf("<generated subtree>\n");
    525543                        break;
    526544                default:
    527                         sysinfo_indent(depth + 1);
    528                         printf("+ [unknown subtree]\n");
     545                        sysinfo_indent(spaces + length);
     546                        printf("<unknown subtree>\n");
    529547                }
    530                
    531                 cur = cur->next;
    532548        }
    533549}
     
    594610                        break;
    595611                case SYSINFO_VAL_FUNCTION_VAL:
    596                         ret.val = item->val.fn_val(item);
     612                        ret.val = item->val.gen_val.fn(item, item->val.gen_val.data);
    597613                        break;
    598614                case SYSINFO_VAL_FUNCTION_DATA:
    599                         ret.data.data = item->val.fn_data(item, &ret.data.size,
    600                             dry_run);
     615                        ret.data.data = item->val.gen_data.fn(item, &ret.data.size,
     616                            dry_run, item->val.gen_data.data);
    601617                        break;
    602618                }
     
    635651        ASSERT(path);
    636652       
    637         if ((copy_from_uspace(path, ptr, size + 1) == 0)
    638             && (path[size] == 0)) {
     653        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
     654            (path[size] == 0)) {
    639655                /*
    640656                 * Prevent other functions from messing with sysinfo while we
     
    645661                mutex_unlock(&sysinfo_lock);
    646662        }
     663       
    647664        free(path);
    648665        return ret;
     666}
     667
     668/** Return sysinfo keys determined by name
     669 *
     670 * Should be called with sysinfo_lock held.
     671 *
     672 * @param name    Sysinfo path.
     673 * @param root    Root item of the sysinfo (sub)tree.
     674 *                If it is NULL then consider the global
     675 *                sysinfo tree.
     676 * @param dry_run Do not actually get any generated
     677 *                binary data, just calculate the size.
     678 *
     679 * @return Item value (constant or generated).
     680 *
     681 */
     682NO_TRACE static sysinfo_return_t sysinfo_get_keys(const char *name,
     683    sysinfo_item_t **root, bool dry_run)
     684{
     685        if (root == NULL)
     686                root = &global_root;
     687       
     688        sysinfo_item_t *subtree = NULL;
     689       
     690        if (name[0] != 0) {
     691                /* Try to find the item */
     692                sysinfo_item_t *item =
     693                    sysinfo_find_item(name, *root, NULL, dry_run);
     694                if ((item != NULL) &&
     695                    (item->subtree_type == SYSINFO_SUBTREE_TABLE))
     696                        subtree = item->subtree.table;
     697        } else
     698                subtree = *root;
     699       
     700        sysinfo_return_t ret;
     701       
     702        if (subtree != NULL) {
     703                /*
     704                 * Calculate the size of subkeys.
     705                 */
     706                size_t size = 0;
     707                for (sysinfo_item_t *cur = subtree; cur; cur = cur->next)
     708                        size += str_size(cur->name) + 1;
     709               
     710                if (dry_run) {
     711                        ret.tag = SYSINFO_VAL_DATA;
     712                        ret.data.data = NULL;
     713                        ret.data.size = size;
     714                } else {
     715                        /* Allocate buffer for subkeys */
     716                        char *names = (char *) malloc(size, FRAME_ATOMIC);
     717                        if (names == NULL)
     718                                return ret;
     719                       
     720                        size_t pos = 0;
     721                        for (sysinfo_item_t *cur = subtree; cur; cur = cur->next) {
     722                                str_cpy(names + pos, size - pos, cur->name);
     723                                pos += str_size(cur->name) + 1;
     724                        }
     725                       
     726                        /* Correct return value */
     727                        ret.tag = SYSINFO_VAL_DATA;
     728                        ret.data.data = (void *) names;
     729                        ret.data.size = size;
     730                }
     731        } else {
     732                /* No item in the fixed sysinfo tree */
     733                ret.tag = SYSINFO_VAL_UNDEFINED;
     734        }
     735       
     736        return ret;
     737}
     738
     739/** Return sysinfo keys determined by name from user space
     740 *
     741 * The path string passed from the user space has to be properly
     742 * null-terminated (the last passed character must be null).
     743 *
     744 * @param ptr     Sysinfo path in the user address space.
     745 * @param size    Size of the path string.
     746 * @param dry_run Do not actually get any generated
     747 *                binary data, just calculate the size.
     748 *
     749 */
     750NO_TRACE static sysinfo_return_t sysinfo_get_keys_uspace(void *ptr, size_t size,
     751    bool dry_run)
     752{
     753        sysinfo_return_t ret;
     754        ret.tag = SYSINFO_VAL_UNDEFINED;
     755       
     756        if (size > SYSINFO_MAX_PATH)
     757                return ret;
     758       
     759        char *path = (char *) malloc(size + 1, 0);
     760        ASSERT(path);
     761       
     762        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
     763            (path[size] == 0)) {
     764                /*
     765                 * Prevent other functions from messing with sysinfo while we
     766                 * are reading it.
     767                 */
     768                mutex_lock(&sysinfo_lock);
     769                ret = sysinfo_get_keys(path, NULL, dry_run);
     770                mutex_unlock(&sysinfo_lock);
     771        }
     772       
     773        free(path);
     774        return ret;
     775}
     776
     777/** Get the sysinfo keys size (syscall)
     778 *
     779 * The path string passed from the user space has
     780 * to be properly null-terminated (the last passed
     781 * character must be null).
     782 *
     783 * @param path_ptr  Sysinfo path in the user address space.
     784 * @param path_size Size of the path string.
     785 * @param size_ptr  User space pointer where to store the
     786 *                  keys size.
     787 *
     788 * @return Error code (EOK in case of no error).
     789 *
     790 */
     791sysarg_t sys_sysinfo_get_keys_size(void *path_ptr, size_t path_size,
     792    void *size_ptr)
     793{
     794        int rc;
     795       
     796        /*
     797         * Get the keys.
     798         *
     799         * N.B.: There is no need to free any potential keys
     800         * since we request a dry run.
     801         */
     802        sysinfo_return_t ret =
     803            sysinfo_get_keys_uspace(path_ptr, path_size, true);
     804       
     805        /* Check return data tag */
     806        if (ret.tag == SYSINFO_VAL_DATA)
     807                rc = copy_to_uspace(size_ptr, &ret.data.size,
     808                    sizeof(ret.data.size));
     809        else
     810                rc = EINVAL;
     811       
     812        return (sysarg_t) rc;
     813}
     814
     815/** Get the sysinfo keys (syscall)
     816 *
     817 * The path string passed from the user space has
     818 * to be properly null-terminated (the last passed
     819 * character must be null).
     820 *
     821 * If the user space buffer size does not equal
     822 * the actual size of the returned data, the data
     823 * is truncated.
     824 *
     825 * The actual size of data returned is stored to
     826 * size_ptr.
     827 *
     828 * @param path_ptr    Sysinfo path in the user address space.
     829 * @param path_size   Size of the path string.
     830 * @param buffer_ptr  User space pointer to the buffer where
     831 *                    to store the binary data.
     832 * @param buffer_size User space buffer size.
     833 * @param size_ptr    User space pointer where to store the
     834 *                    binary data size.
     835 *
     836 * @return Error code (EOK in case of no error).
     837 *
     838 */
     839sysarg_t sys_sysinfo_get_keys(void *path_ptr, size_t path_size,
     840    void *buffer_ptr, size_t buffer_size, size_t *size_ptr)
     841{
     842        int rc;
     843       
     844        /* Get the keys */
     845        sysinfo_return_t ret = sysinfo_get_keys_uspace(path_ptr, path_size,
     846            false);
     847       
     848        /* Check return data tag */
     849        if (ret.tag == SYSINFO_VAL_DATA) {
     850                size_t size = min(ret.data.size, buffer_size);
     851                rc = copy_to_uspace(buffer_ptr, ret.data.data, size);
     852                if (rc == EOK)
     853                        rc = copy_to_uspace(size_ptr, &size, sizeof(size));
     854               
     855                free(ret.data.data);
     856        } else
     857                rc = EINVAL;
     858       
     859        return (sysarg_t) rc;
    649860}
    650861
     
    672883       
    673884        /*
    674          * Map generated value types to constant types (user space does not care
    675          * whether the value is constant or generated).
     885         * Map generated value types to constant types (user space does
     886         * not care whether the value is constant or generated).
    676887         */
    677888        if (ret.tag == SYSINFO_VAL_FUNCTION_VAL)
     
    701912{
    702913        int rc;
    703 
     914       
    704915        /*
    705916         * Get the item.
    706917         *
    707          * N.B.: There is no need to free any potential generated binary data
    708          * since we request a dry run.
     918         * N.B.: There is no need to free any potential generated binary
     919         * data since we request a dry run.
    709920         */
    710921        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
     
    741952         * Get the item.
    742953         *
    743          * N.B.: There is no need to free any potential generated binary data
    744          * since we request a dry run.
     954         * N.B.: There is no need to free any potential generated binary
     955         * data since we request a dry run.
    745956         */
    746957        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
  • uspace/Makefile

    r2cc7f16 r5608deba  
    4848        app/lsusb \
    4949        app/mkfat \
     50        app/mkexfat \
    5051        app/mkmfs \
    5152        app/redir \
  • uspace/app/sysinfo/sysinfo.c

    r2cc7f16 r5608deba  
    3737#include <stdio.h>
    3838#include <sysinfo.h>
     39#include <malloc.h>
    3940#include <sys/types.h>
    4041
    41 static int print_item_val(char *ipath);
    42 static int print_item_data(char *ipath);
    43 
    44 static void dump_bytes_hex(char *data, size_t size);
    45 static void dump_bytes_text(char *data, size_t size);
    46 
    47 static void print_syntax(void);
    48 
    49 int main(int argc, char *argv[])
    50 {
    51         int rc;
    52         char *ipath;
    53         sysinfo_item_val_type_t tag;
    54 
    55         if (argc != 2) {
    56                 print_syntax();
    57                 return 1;
    58         }
    59 
    60         ipath = argv[1];
    61 
    62         tag = sysinfo_get_val_type(ipath);
    63 
    64         /* Silence warning */
    65         rc = EOK;
    66 
    67         switch (tag) {
    68         case SYSINFO_VAL_UNDEFINED:
    69                 printf("Error: Sysinfo item '%s' not defined.\n", ipath);
    70                 rc = 2;
    71                 break;
    72         case SYSINFO_VAL_VAL:
    73                 rc = print_item_val(ipath);
    74                 break;
    75         case SYSINFO_VAL_DATA:
    76                 rc = print_item_data(ipath);
    77                 break;
    78         default:
    79                 printf("Error: Sysinfo item '%s' with unknown value type.\n",
    80                     ipath);
    81                 rc = 2;
    82                 break;
    83         }
    84 
    85         return rc;
     42static void dump_bytes_hex(char *data, size_t size)
     43{
     44        for (size_t i = 0; i < size; i++) {
     45                if (i > 0)
     46                        putchar(' ');
     47                printf("0x%02x", (uint8_t) data[i]);
     48        }
     49}
     50
     51static void dump_bytes_text(char *data, size_t size)
     52{
     53        size_t offset = 0;
     54       
     55        while (offset < size) {
     56                wchar_t c = str_decode(data, &offset, size);
     57                printf("%lc", (wint_t) c);
     58        }
    8659}
    8760
     
    8962{
    9063        sysarg_t value;
    91         int rc;
    92 
    93         rc = sysinfo_get_value(ipath, &value);
     64        int rc = sysinfo_get_value(ipath, &value);
    9465        if (rc != EOK) {
    9566                printf("Error reading item '%s'.\n", ipath);
    9667                return rc;
    9768        }
    98 
     69       
    9970        printf("%s -> %" PRIu64 " (0x%" PRIx64 ")\n", ipath,
    10071            (uint64_t) value, (uint64_t) value);
    101 
     72       
    10273        return EOK;
    10374}
     
    10576static int print_item_data(char *ipath)
    10677{
    107         void *data;
    10878        size_t size;
    109 
    110         data = sysinfo_get_data(ipath, &size);
     79        void *data = sysinfo_get_data(ipath, &size);
    11180        if (data == NULL) {
    11281                printf("Error reading item '%s'.\n", ipath);
    11382                return -1;
    11483        }
    115 
     84       
    11685        printf("%s -> ", ipath);
    11786        dump_bytes_hex(data, size);
     
    11988        dump_bytes_text(data, size);
    12089        fputs("')\n", stdout);
    121 
     90       
    12291        return EOK;
    12392}
    12493
    125 static void dump_bytes_hex(char *data, size_t size)
    126 {
    127         size_t i;
    128 
    129         for (i = 0; i < size; ++i) {
    130                 if (i > 0) putchar(' ');
    131                 printf("0x%02x", (uint8_t) data[i]);
    132         }
    133 }
    134 
    135 static void dump_bytes_text(char *data, size_t size)
    136 {
    137         wchar_t c;
    138         size_t offset;
    139 
    140         offset = 0;
    141 
    142         while (offset < size) {
    143                 c = str_decode(data, &offset, size);
    144                 printf("%lc", (wint_t) c);
    145         }
    146 }
    147 
    148 
    149 static void print_syntax(void)
    150 {
    151         printf("Syntax: sysinfo <item_path>\n");
     94static int print_item_property(char *ipath, char *iprop)
     95{
     96        size_t size;
     97        void *data = sysinfo_get_property(ipath, iprop, &size);
     98        if (data == NULL) {
     99                printf("Error reading property '%s' of item '%s'.\n", iprop,
     100                    ipath);
     101                return -1;
     102        }
     103       
     104        printf("%s property %s -> ", ipath, iprop);
     105        dump_bytes_hex(data, size);
     106        fputs(" ('", stdout);
     107        dump_bytes_text(data, size);
     108        fputs("')\n", stdout);
     109       
     110        return EOK;
     111}
     112
     113static void print_spaces(size_t spaces)
     114{
     115        for (size_t i = 0; i < spaces; i++)
     116                printf(" ");
     117}
     118
     119static void print_keys(const char *path, size_t spaces)
     120{
     121        size_t size;
     122        char *keys = sysinfo_get_keys(path, &size);
     123        if ((keys == NULL) || (size == 0))
     124                return;
     125       
     126        size_t pos = 0;
     127        while (pos < size) {
     128                /* Process each key with sanity checks */
     129                size_t cur_size = str_nsize(keys + pos, size - pos);
     130                if (keys[pos + cur_size] != 0)
     131                        break;
     132               
     133                size_t path_size = str_size(path) + cur_size + 2;
     134                char *cur_path = (char *) malloc(path_size);
     135                if (cur_path == NULL)
     136                        break;
     137               
     138                size_t length;
     139               
     140                if (path[0] != 0) {
     141                        print_spaces(spaces);
     142                        printf(".%s\n", keys + pos);
     143                        length = str_length(keys + pos) + 1;
     144                       
     145                        snprintf(cur_path, path_size, "%s.%s", path, keys + pos);
     146                } else {
     147                        printf("%s\n", keys + pos);
     148                        length = str_length(keys + pos);
     149                       
     150                        snprintf(cur_path, path_size, "%s", keys + pos);
     151                }
     152               
     153                print_keys(cur_path, spaces + length);
     154               
     155                free(cur_path);
     156                pos += cur_size + 1;
     157        }
     158       
     159        free(keys);
     160}
     161
     162int main(int argc, char *argv[])
     163{
     164        int rc = 0;
     165       
     166        if (argc < 2) {
     167                /* Print keys */
     168                print_keys("", 0);
     169                return rc;
     170        }
     171       
     172        char *ipath = argv[1];
     173       
     174        if (argc < 3) {
     175                sysinfo_item_val_type_t tag = sysinfo_get_val_type(ipath);
     176               
     177                switch (tag) {
     178                case SYSINFO_VAL_UNDEFINED:
     179                        printf("Error: Sysinfo item '%s' not defined.\n", ipath);
     180                        rc = 2;
     181                        break;
     182                case SYSINFO_VAL_VAL:
     183                        rc = print_item_val(ipath);
     184                        break;
     185                case SYSINFO_VAL_DATA:
     186                        rc = print_item_data(ipath);
     187                        break;
     188                default:
     189                        printf("Error: Sysinfo item '%s' with unknown value type.\n",
     190                            ipath);
     191                        rc = 2;
     192                        break;
     193                }
     194               
     195                return rc;
     196        }
     197       
     198        char *iprop = argv[2];
     199        rc = print_item_property(ipath, iprop);
     200        return rc;
    152201}
    153202
  • uspace/drv/bus/usb/uhci/transfer_list.c

    r2cc7f16 r5608deba  
    110110        assert(instance);
    111111        assert(uhci_batch);
    112         usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name,
    113             uhci_batch->usb_batch);
     112        usb_log_debug2("Batch %p adding to queue %s.\n",
     113            uhci_batch->usb_batch, instance->name);
    114114
    115115        fibril_mutex_lock(&instance->guard);
     
    139139        list_append(&uhci_batch->link, &instance->batch_list);
    140140
    141         usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " scheduled in queue %s.\n",
    142             uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch),
    143             instance->name);
     141        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT
     142            " scheduled in queue %s.\n", uhci_batch->usb_batch,
     143            USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch), instance->name);
    144144        fibril_mutex_unlock(&instance->guard);
    145145}
     
    205205        assert(fibril_mutex_is_locked(&instance->guard));
    206206
    207         usb_log_debug2("Queue %s: removing batch(%p).\n",
    208             instance->name, uhci_batch->usb_batch);
     207        usb_log_debug2("Batch %p removing from queue %s.\n",
     208            uhci_batch->usb_batch, instance->name);
    209209
    210210        /* Assume I'm the first */
     
    228228        list_remove(&uhci_batch->link);
    229229        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " removed (%s) "
    230             "from %s, next: %x.\n",
    231             uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch),
     230            "from %s, next: %x.\n", uhci_batch->usb_batch,
     231            USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch),
    232232            qpos, instance->name, uhci_batch->qh->next);
    233233}
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    r2cc7f16 r5608deba  
    174174                        assert(uhci_batch->usb_batch->ep != NULL);
    175175
    176                         usb_log_debug("Batch(%p) found error TD(%zu):%"
     176                        usb_log_debug("Batch %p found error TD(%zu->%p):%"
    177177                            PRIx32 ".\n", uhci_batch->usb_batch, i,
    178                             uhci_batch->tds[i].status);
     178                            &uhci_batch->tds[i], uhci_batch->tds[i].status);
    179179                        td_print_status(&uhci_batch->tds[i]);
    180180
  • uspace/drv/char/ps2mouse/ps2mouse.c

    r2cc7f16 r5608deba  
    8080        } \
    8181        if (data != (value)) { \
    82                 ddf_msg(LVL_ERROR, "Failed testing byte: got %hhx vs. %hhx)", \
     82                ddf_msg(LVL_DEBUG, "Failed testing byte: got %hhx vs. %hhx)", \
    8383                    data, (value)); \
    8484                return EIO; \
  • uspace/drv/infrastructure/root/root.c

    r2cc7f16 r5608deba  
    158158        if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
    159159                ddf_msg(LVL_ERROR, "Memory allocation failed.");
    160                 return ENOMEM;
    161         }
     160                free(platform);
     161                return ENOMEM;
     162        }
     163
     164        free(platform);
    162165
    163166        /* Add function. */
     
    169172        if (fun == NULL) {
    170173                ddf_msg(LVL_ERROR, "Error creating function %s", name);
     174                free(match_id);
    171175                return ENOMEM;
    172176        }
     
    176180                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
    177181                    name);
     182                free(match_id);
    178183                ddf_fun_destroy(fun);
    179184                return rc;
     
    208213         * vital for the system.
    209214         */
    210         add_virtual_root_fun(dev);
     215        (void) add_virtual_root_fun(dev);
    211216
    212217        /* Register root device's children. */
  • uspace/lib/c/arch/ia64/include/ddi.h

    r2cc7f16 r5608deba  
    6262
    6363        asm volatile ("mf\n" ::: "memory");
     64        asm volatile ("mf.a\n" ::: "memory");
    6465}
    6566
     
    7677
    7778        asm volatile ("mf\n" ::: "memory");
     79        asm volatile ("mf.a\n" ::: "memory");
    7880}
    7981
     
    9092
    9193        asm volatile ("mf\n" ::: "memory");
     94        asm volatile ("mf.a\n" ::: "memory");
    9295}
    9396
     
    106109                v = *port;
    107110        }
     111
     112        asm volatile ("mf.a\n" ::: "memory");
    108113
    109114        return v;
     
    125130        }
    126131
     132        asm volatile ("mf.a\n" ::: "memory");
     133
    127134        return v;
    128135}
     
    134141        asm volatile ("mf\n" ::: "memory");
    135142
    136         if (port < (ioport32_t *) port) {
     143        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
    137144                uintptr_t prt = (uintptr_t) port;
    138145
     
    143150        }
    144151
     152        asm volatile ("mf.a\n" ::: "memory");
     153
    145154        return v;
    146155}
  • uspace/lib/c/generic/str.c

    r2cc7f16 r5608deba  
    259259       
    260260        return offset;
     261}
     262
     263/** Get size of string with size limit.
     264 *
     265 * Get the number of bytes which are used by the string @a str
     266 * (excluding the NULL-terminator), but no more than @max_size bytes.
     267 *
     268 * @param str      String to consider.
     269 * @param max_size Maximum number of bytes to measure.
     270 *
     271 * @return Number of bytes used by the string
     272 *
     273 */
     274size_t str_nsize(const char *str, size_t max_size)
     275{
     276        size_t size = 0;
     277       
     278        while ((*str++ != 0) && (size < max_size))
     279                size++;
     280       
     281        return size;
     282}
     283
     284/** Get size of wide string with size limit.
     285 *
     286 * Get the number of bytes which are used by the wide string @a str
     287 * (excluding the NULL-terminator), but no more than @max_size bytes.
     288 *
     289 * @param str      Wide string to consider.
     290 * @param max_size Maximum number of bytes to measure.
     291 *
     292 * @return Number of bytes used by the wide string
     293 *
     294 */
     295size_t wstr_nsize(const wchar_t *str, size_t max_size)
     296{
     297        return (wstr_nlength(str, max_size) * sizeof(wchar_t));
    261298}
    262299
  • uspace/lib/c/generic/sysinfo.c

    r2cc7f16 r5608deba  
    4040#include <bool.h>
    4141
     42/** Get sysinfo keys size
     43 *
     44 * @param path  Sysinfo path.
     45 * @param value Pointer to store the keys size.
     46 *
     47 * @return EOK if the keys were successfully read.
     48 *
     49 */
     50static int sysinfo_get_keys_size(const char *path, size_t *size)
     51{
     52        return (int) __SYSCALL3(SYS_SYSINFO_GET_KEYS_SIZE, (sysarg_t) path,
     53            (sysarg_t) str_size(path), (sysarg_t) size);
     54}
     55
     56/** Get sysinfo keys
     57 *
     58 * @param path  Sysinfo path.
     59 * @param value Pointer to store the keys size.
     60 *
     61 * @return Keys read from sysinfo or NULL if the
     62 *         sysinfo item has no subkeys.
     63 *         The returned non-NULL pointer should be
     64 *         freed by free().
     65 *
     66 */
     67char *sysinfo_get_keys(const char *path, size_t *size)
     68{
     69        /*
     70         * The size of the keys might change during time.
     71         * Unfortunatelly we cannot allocate the buffer
     72         * and transfer the keys as a single atomic operation.
     73         */
     74       
     75        /* Get the keys size */
     76        int ret = sysinfo_get_keys_size(path, size);
     77        if ((ret != EOK) || (size == 0)) {
     78                /*
     79                 * Item with no subkeys.
     80                 */
     81                *size = 0;
     82                return NULL;
     83        }
     84       
     85        char *data = malloc(*size);
     86        if (data == NULL) {
     87                *size = 0;
     88                return NULL;
     89        }
     90       
     91        /* Get the data */
     92        size_t sz;
     93        ret = __SYSCALL5(SYS_SYSINFO_GET_KEYS, (sysarg_t) path,
     94            (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size,
     95            (sysarg_t) &sz);
     96        if (ret == EOK) {
     97                *size = sz;
     98                return data;
     99        }
     100       
     101        free(data);
     102        *size = 0;
     103        return NULL;
     104}
     105
    42106/** Get sysinfo item type
    43107 *
     
    70134/** Get sysinfo binary data size
    71135 *
    72  * @param path  Sysinfo path.
    73  * @param value Pointer to store the binary data size.
     136 * @param path Sysinfo path.
     137 * @param size Pointer to store the binary data size.
    74138 *
    75139 * @return EOK if the value was successfully read and
     
    85149/** Get sysinfo binary data
    86150 *
    87  * @param path  Sysinfo path.
    88  * @param value Pointer to store the binary data size.
     151 * @param path Sysinfo path.
     152 * @param size Pointer to store the binary data size.
    89153 *
    90154 * @return Binary data read from sysinfo or NULL if the
     
    134198}
    135199
     200/** Get sysinfo property
     201 *
     202 * @param path Sysinfo path.
     203 * @param name Property name.
     204 * @param size Pointer to store the binary data size.
     205 *
     206 * @return Property value read from sysinfo or NULL if the
     207 *         sysinfo item value type is not binary data.
     208 *         The returned non-NULL pointer should be
     209 *         freed by free().
     210 *
     211 */
     212void *sysinfo_get_property(const char *path, const char *name, size_t *size)
     213{
     214        size_t total_size;
     215        void *data = sysinfo_get_data(path, &total_size);
     216        if ((data == NULL) || (total_size == 0)) {
     217                *size = 0;
     218                return NULL;
     219        }
     220       
     221        size_t pos = 0;
     222        while (pos < total_size) {
     223                /* Process each property with sanity checks */
     224                size_t cur_size = str_nsize(data + pos, total_size - pos);
     225                if (((char *) data)[pos + cur_size] != 0)
     226                        break;
     227               
     228                bool found = (str_cmp(data + pos, name) == 0);
     229               
     230                pos += cur_size + 1;
     231                if (pos >= total_size)
     232                        break;
     233               
     234                /* Process value size */
     235                size_t value_size;
     236                memcpy(&value_size, data + pos, sizeof(value_size));
     237               
     238                pos += sizeof(value_size);
     239                if ((pos >= total_size) || (pos + value_size > total_size))
     240                        break;
     241               
     242                if (found) {
     243                        void *value = malloc(value_size);
     244                        if (value == NULL)
     245                                break;
     246                       
     247                        memcpy(value, data + pos, value_size);
     248                        free(data);
     249                       
     250                        *size = value_size;
     251                        return value;
     252                }
     253               
     254                pos += value_size;
     255        }
     256       
     257        free(data);
     258       
     259        *size = 0;
     260        return NULL;
     261}
     262
    136263/** @}
    137264 */
  • uspace/lib/c/include/str.h

    r2cc7f16 r5608deba  
    6060extern size_t str_size(const char *str);
    6161extern size_t wstr_size(const wchar_t *str);
     62
     63extern size_t str_nsize(const char *str, size_t max_size);
     64extern size_t wstr_nsize(const wchar_t *str, size_t max_size);
    6265
    6366extern size_t str_lsize(const char *str, size_t max_len);
  • uspace/lib/c/include/sysinfo.h

    r2cc7f16 r5608deba  
    4040#include <abi/sysinfo.h>
    4141
     42extern char *sysinfo_get_keys(const char *, size_t *);
    4243extern sysinfo_item_val_type_t sysinfo_get_val_type(const char *);
    4344extern int sysinfo_get_value(const char *, sysarg_t *);
    4445extern void *sysinfo_get_data(const char *, size_t *);
     46extern void *sysinfo_get_property(const char *, const char *, size_t *);
    4547
    4648#endif
  • uspace/srv/fs/exfat/exfat_bitmap.c

    r2cc7f16 r5608deba  
    4848
    4949
    50 int bitmap_is_free(exfat_bs_t *bs, service_id_t service_id,
     50int exfat_bitmap_is_free(exfat_bs_t *bs, service_id_t service_id,
    5151    exfat_cluster_t clst)
    5252{
     
    8989}
    9090
    91 int bitmap_set_cluster(exfat_bs_t *bs, service_id_t service_id,
     91int exfat_bitmap_set_cluster(exfat_bs_t *bs, service_id_t service_id,
    9292    exfat_cluster_t clst)
    9393{
     
    124124}
    125125
    126 int bitmap_clear_cluster(exfat_bs_t *bs, service_id_t service_id,
     126int exfat_bitmap_clear_cluster(exfat_bs_t *bs, service_id_t service_id,
    127127    exfat_cluster_t clst)
    128128{
     
    160160}
    161161
    162 int bitmap_set_clusters(exfat_bs_t *bs, service_id_t service_id,
     162int exfat_bitmap_set_clusters(exfat_bs_t *bs, service_id_t service_id,
    163163    exfat_cluster_t firstc, exfat_cluster_t count)
    164164{
     
    168168
    169169        while (clst < firstc + count ) {
    170                 rc = bitmap_set_cluster(bs, service_id, clst);
     170                rc = exfat_bitmap_set_cluster(bs, service_id, clst);
    171171                if (rc != EOK) {
    172172                        if (clst - firstc > 0)
    173                                 (void) bitmap_clear_clusters(bs, service_id,
     173                                (void) exfat_bitmap_clear_clusters(bs, service_id,
    174174                                    firstc, clst - firstc);
    175175                        return rc;
     
    180180}
    181181
    182 int bitmap_clear_clusters(exfat_bs_t *bs, service_id_t service_id,
     182int exfat_bitmap_clear_clusters(exfat_bs_t *bs, service_id_t service_id,
    183183    exfat_cluster_t firstc, exfat_cluster_t count)
    184184{
     
    188188
    189189        while (clst < firstc + count) {
    190                 rc = bitmap_clear_cluster(bs, service_id, clst);
     190                rc = exfat_bitmap_clear_cluster(bs, service_id, clst);
    191191                if (rc != EOK)
    192192                        return rc;
     
    196196}
    197197
    198 int bitmap_alloc_clusters(exfat_bs_t *bs, service_id_t service_id,
     198int exfat_bitmap_alloc_clusters(exfat_bs_t *bs, service_id_t service_id,
    199199    exfat_cluster_t *firstc, exfat_cluster_t count)
    200200{
     
    204204        while (startc < DATA_CNT(bs) + 2) {
    205205                endc = startc;
    206                 while (bitmap_is_free(bs, service_id, endc) == EOK) {
     206                while (exfat_bitmap_is_free(bs, service_id, endc) == EOK) {
    207207                        if ((endc - startc) + 1 == count) {
    208208                                *firstc = startc;
    209                                 return bitmap_set_clusters(bs, service_id, startc, count);
     209                                return exfat_bitmap_set_clusters(bs, service_id, startc, count);
    210210                        } else
    211211                                endc++;
     
    217217
    218218
    219 int bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep,
     219int exfat_bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep,
    220220    exfat_cluster_t count)
    221221{
    222222        if (nodep->firstc == 0) {
    223                 return bitmap_alloc_clusters(bs, nodep->idx->service_id,
     223                return exfat_bitmap_alloc_clusters(bs, nodep->idx->service_id,
    224224                    &nodep->firstc, count);
    225225        } else {
     
    228228
    229229                clst = lastc + 1;
    230                 while (bitmap_is_free(bs, nodep->idx->service_id, clst) == EOK) {
     230                while (exfat_bitmap_is_free(bs, nodep->idx->service_id, clst) == EOK) {
    231231                        if (clst - lastc == count){
    232                                 return bitmap_set_clusters(bs, nodep->idx->service_id,
     232                                return exfat_bitmap_set_clusters(bs, nodep->idx->service_id,
    233233                                    lastc + 1, count);
    234234                        } else
     
    240240
    241241
    242 int bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep,
     242int exfat_bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep,
    243243    exfat_cluster_t count)
    244244{
     
    247247        lastc -= count;
    248248
    249         return bitmap_clear_clusters(bs, nodep->idx->service_id, lastc + 1, count);
    250 }
    251 
    252 
    253 int bitmap_replicate_clusters(exfat_bs_t *bs, exfat_node_t *nodep)
     249        return exfat_bitmap_clear_clusters(bs, nodep->idx->service_id, lastc + 1, count);
     250}
     251
     252
     253int exfat_bitmap_replicate_clusters(exfat_bs_t *bs, exfat_node_t *nodep)
    254254{
    255255        int rc;
  • uspace/srv/fs/exfat/exfat_bitmap.h

    r2cc7f16 r5608deba  
    4242struct exfat_bs;
    4343
    44 extern int bitmap_alloc_clusters(struct exfat_bs *, service_id_t,
     44extern int exfat_bitmap_alloc_clusters(struct exfat_bs *, service_id_t,
    4545    exfat_cluster_t *, exfat_cluster_t);
    46 extern int bitmap_append_clusters(struct exfat_bs *, struct exfat_node *,
     46extern int exfat_bitmap_append_clusters(struct exfat_bs *, struct exfat_node *,
    4747    exfat_cluster_t);
    48 extern int bitmap_free_clusters(struct exfat_bs *, struct exfat_node *,
     48extern int exfat_bitmap_free_clusters(struct exfat_bs *, struct exfat_node *,
    4949    exfat_cluster_t);
    50 extern int bitmap_replicate_clusters(struct exfat_bs *, struct exfat_node *);
     50extern int exfat_bitmap_replicate_clusters(struct exfat_bs *, struct exfat_node *);
    5151
    52 extern int bitmap_is_free(struct exfat_bs *, service_id_t, exfat_cluster_t);
    53 extern int bitmap_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t);
    54 extern int bitmap_clear_cluster(struct exfat_bs *, service_id_t,
     52extern int exfat_bitmap_is_free(struct exfat_bs *, service_id_t, exfat_cluster_t);
     53extern int exfat_bitmap_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t);
     54extern int exfat_bitmap_clear_cluster(struct exfat_bs *, service_id_t,
    5555    exfat_cluster_t);
    5656
    57 extern int bitmap_set_clusters(struct exfat_bs *, service_id_t,
     57extern int exfat_bitmap_set_clusters(struct exfat_bs *, service_id_t,
    5858    exfat_cluster_t, exfat_cluster_t);
    59 extern int bitmap_clear_clusters(struct exfat_bs *, service_id_t,
     59extern int exfat_bitmap_clear_clusters(struct exfat_bs *, service_id_t,
    6060    exfat_cluster_t, exfat_cluster_t);
    6161
  • uspace/srv/fs/exfat/exfat_dentry.c

    r2cc7f16 r5608deba  
    130130}
    131131
    132 size_t utf16_length(const uint16_t *wstr)
     132size_t exfat_utf16_length(const uint16_t *wstr)
    133133{
    134134        size_t len = 0;
  • uspace/srv/fs/exfat/exfat_dentry.h

    r2cc7f16 r5608deba  
    160160extern bool exfat_valid_name(const char *);
    161161
    162 extern size_t utf16_length(const uint16_t *);
     162extern size_t exfat_utf16_length(const uint16_t *);
    163163
    164164
  • uspace/srv/fs/exfat/exfat_directory.c

    r2cc7f16 r5608deba  
    371371        ds.stream.valid_data_size = 0;
    372372        ds.stream.data_size = 0;
    373         ds.stream.name_size = utf16_length(wname);
     373        ds.stream.name_size = exfat_utf16_length(wname);
    374374        ds.stream.hash = host2uint16_t_le(exfat_name_hash(wname, uctable,
    375375            uctable_chars));
  • uspace/srv/fs/exfat/exfat_fat.c

    r2cc7f16 r5608deba  
    314314            clst++) {
    315315                /* Need to rewrite because of multiple exfat_bitmap_get calls */
    316                 if (bitmap_is_free(bs, service_id, clst) == EOK) {
     316                if (exfat_bitmap_is_free(bs, service_id, clst) == EOK) {
    317317                        /*
    318318                         * The cluster is free. Put it into our stack
     
    325325                                goto exit_error;
    326326                        found++;
    327                         rc = bitmap_set_cluster(bs, service_id, clst);
     327                        rc = exfat_bitmap_set_cluster(bs, service_id, clst);
    328328                        if (rc != EOK)
    329329                                goto exit_error;
     
    346346        /* If something wrong - free the clusters */
    347347        while (found--) {
    348                 (void) bitmap_clear_cluster(bs, service_id, lifo[found]);
     348                (void) exfat_bitmap_clear_cluster(bs, service_id, lifo[found]);
    349349                (void) exfat_set_cluster(bs, service_id, lifo[found], 0);
    350350        }
     
    378378                if (rc != EOK)
    379379                        return rc;
    380                 rc = bitmap_clear_cluster(bs, service_id, firstc);
     380                rc = exfat_bitmap_clear_cluster(bs, service_id, firstc);
    381381                if (rc != EOK)
    382382                        return rc;
  • uspace/srv/fs/exfat/exfat_ops.c

    r2cc7f16 r5608deba  
    405405
    406406        if (!nodep->fragmented) {
    407                 rc = bitmap_append_clusters(bs, nodep, clusters);
     407                rc = exfat_bitmap_append_clusters(bs, nodep, clusters);
    408408                if (rc != ENOSPC)
    409409                        return rc;
     
    411411                        nodep->fragmented = true;
    412412                        nodep->dirty = true;            /* need to sync node */
    413                         rc = bitmap_replicate_clusters(bs, nodep);
     413                        rc = exfat_bitmap_replicate_clusters(bs, nodep);
    414414                        if (rc != EOK)
    415415                                return rc;
     
    457457
    458458                clsts = prev_clsts - new_clsts;
    459                 rc = bitmap_free_clusters(bs, nodep, clsts);
     459                rc = exfat_bitmap_free_clusters(bs, nodep, clsts);
    460460                if (rc != EOK)
    461461                        return rc;
     
    704704                                nodep->firstc);
    705705                else
    706                         rc = bitmap_free_clusters(bs, nodep,
     706                        rc = exfat_bitmap_free_clusters(bs, nodep,
    707707                            ROUND_UP(nodep->size, BPC(bs)) / BPC(bs));
    708708        }
     
    758758
    759759        fibril_mutex_unlock(&parentp->idx->lock);
    760         if (rc != EOK)
    761                 return rc;
    762 
    763760        fibril_mutex_lock(&childp->idx->lock);
    764 
    765761
    766762        childp->idx->pfc = parentp->firstc;
     
    14631459        }
    14641460
    1465         (void) exfat_node_put(fn);
     1461        int rc2 = exfat_node_put(fn);
     1462        if (rc == EOK && rc2 != EOK)
     1463                rc = rc2;
     1464
    14661465        return rc;
    14671466}
Note: See TracChangeset for help on using the changeset viewer.