Changeset d011038 in mainline for uspace/srv


Ignore:
Timestamp:
2011-03-29T20:12:44Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f17503
Parents:
c4fb95d3 (diff), 93ebe4e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/srv
Files:
1 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    rc4fb95d3 rd011038  
    266266        }
    267267       
    268         if (read(fd, buf, len) <= 0) {
     268        ssize_t read_bytes = safe_read(fd, buf, len);
     269        if (read_bytes <= 0) {
    269270                printf(NAME ": unable to read file '%s'.\n", conf_path);
    270271                goto cleanup;
    271272        }
    272         buf[len] = 0;
     273        buf[read_bytes] = 0;
    273274       
    274275        suc = parse_match_ids(buf, ids);
     
    11231124fun_node_t *find_fun_node_by_path(dev_tree_t *tree, char *path)
    11241125{
     1126        assert(path != NULL);
     1127
     1128        bool is_absolute = path[0] == '/';
     1129        if (!is_absolute) {
     1130                return NULL;
     1131        }
     1132
    11251133        fibril_rwlock_read_lock(&tree->rwlock);
    11261134       
     
    11321140        char *rel_path = path;
    11331141        char *next_path_elem = NULL;
    1134         bool cont = (rel_path[0] == '/');
     1142        bool cont = true;
    11351143       
    11361144        while (cont && fun != NULL) {
  • uspace/srv/devman/main.c

    rc4fb95d3 rd011038  
    477477                dev = fun->dev;
    478478
    479         if (fun == NULL && dev == NULL) {
     479        /*
     480         * For a valid function to connect to we need a device. The root
     481         * function, for example, has no device and cannot be connected to.
     482         * This means @c dev needs to be valid regardless whether we are
     483         * connecting to a device or to a function.
     484         */
     485        if (dev == NULL) {
    480486                printf(NAME ": devman_forward error - no device or function with "
    481487                    "handle %" PRIun " was found.\n", handle);
     
    562568        }
    563569       
    564         async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
     570        async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
    565571            IPC_FF_NONE);
    566572        printf(NAME ": devman_connection_devmapper: forwarded connection to "
  • uspace/srv/devman/util.c

    rc4fb95d3 rd011038  
    111111}
    112112
     113ssize_t safe_read(int fd, void *buffer, size_t size)
     114{
     115        if (size == 0) {
     116                return 0;
     117        }
     118
     119        uint8_t *buf_ptr = (uint8_t *) buffer;
     120
     121        size_t total_read = 0;
     122        while (total_read < size) {
     123                ssize_t bytes_read = read(fd, buf_ptr, size - total_read);
     124                if (bytes_read < 0) {
     125                        /* Error. */
     126                        return bytes_read;
     127                } else if (bytes_read == 0) {
     128                        /* Possibly end of file. */
     129                        break;
     130                } else {
     131                        /* Read at least something. */
     132                        buf_ptr += bytes_read;
     133                        total_read += bytes_read;
     134                }
     135        }
     136
     137        return (ssize_t) total_read;
     138}
     139
    113140/** @}
    114141 */
  • uspace/srv/devman/util.h

    rc4fb95d3 rd011038  
    4747extern void replace_char(char *, char, char);
    4848
     49extern ssize_t safe_read(int, void *, size_t);
     50
    4951#endif
    5052
  • uspace/srv/devmap/devmap.c

    rc4fb95d3 rd011038  
    123123static devmap_handle_t last_handle = 0;
    124124static devmap_device_t *null_devices[NULL_DEVICES];
     125
     126/*
     127 * Dummy list for null devices. This is necessary so that null devices can
     128 * be used just as any other devices, e.g. in devmap_device_unregister_core().
     129 */
     130static LIST_INITIALIZE(dummy_null_driver_devices);
    125131
    126132static devmap_handle_t devmap_create_handle(void)
     
    953959        device->name = dev_name;
    954960       
    955         /* Insert device into list of all devices
    956            and into null devices array */
     961        /*
     962         * Insert device into list of all devices and into null devices array.
     963         * Insert device into a dummy list of null driver's devices so that it
     964         * can be safely removed later.
     965         */
    957966        list_append(&device->devices, &devices_list);
     967        list_append(&device->driver_devices, &dummy_null_driver_devices);
    958968        null_devices[i] = device;
    959969       
  • uspace/srv/fs/fat/fat_ops.c

    rc4fb95d3 rd011038  
    325325                    uint16_t_le2host(d->firstc));
    326326                if (rc != EOK) {
     327                        (void) block_put(b);
    327328                        (void) fat_node_put(FS_NODE(nodep));
    328329                        return rc;
     
    811812        fibril_mutex_unlock(&childp->idx->lock);
    812813        childp->lnkcnt = 0;
     814        childp->refcnt++;       /* keep the node in memory until destroyed */
    813815        childp->dirty = true;
    814816        fibril_mutex_unlock(&childp->lock);
     
    14881490        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    14891491        fs_node_t *fn;
     1492        fat_node_t *nodep;
    14901493        int rc;
    14911494
     
    14991502                return;
    15001503        }
     1504
     1505        nodep = FAT_NODE(fn);
     1506        /*
     1507         * We should have exactly two references. One for the above
     1508         * call to fat_node_get() and one from fat_unlink().
     1509         */
     1510        assert(nodep->refcnt == 2);
    15011511
    15021512        rc = fat_destroy_node(fn);
  • uspace/srv/hid/console/gcons.c

    rc4fb95d3 rd011038  
    285285        ssize_t nx = (ssize_t) mouse_x + dx;
    286286        ssize_t ny = (ssize_t) mouse_y + dy;
    287 
    288         if (!use_gcons)
     287       
     288        /* Until gcons is initalized we don't have the screen resolution */
     289        if (xres == 0 || yres == 0)
    289290                return;
    290291       
  • uspace/srv/hid/kbd/Makefile

    rc4fb95d3 rd011038  
    7878                SOURCES += \
    7979                        port/pl050.c \
    80                         ctl/pl050.c
     80                        ctl/pc.c
    8181        endif
    8282endif
  • uspace/srv/hid/kbd/generic/kbd.c

    rc4fb95d3 rd011038  
    6767static unsigned lock_keys;
    6868
    69 int cir_service = 0;
    70 int cir_phone = -1;
     69bool irc_service = false;
     70int irc_phone = -1;
    7171
    7272#define NUM_LAYOUTS 3
     
    216216        sysarg_t obio;
    217217       
    218         if ((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc))
    219                 cir_service = SERVICE_FHC;
    220         else if ((sysinfo_get_value("kbd.cir.obio", &obio) == EOK) && (obio))
    221                 cir_service = SERVICE_OBIO;
    222        
    223         if (cir_service) {
    224                 while (cir_phone < 0)
    225                         cir_phone = service_connect_blocking(cir_service, 0, 0);
     218        if (((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc))
     219            || ((sysinfo_get_value("kbd.cir.obio", &obio) == EOK) && (obio)))
     220                irc_service = true;
     221       
     222        if (irc_service) {
     223                while (irc_phone < 0)
     224                        irc_phone = service_connect_blocking(SERVICE_IRC, 0, 0);
    226225        }
    227226       
  • uspace/srv/hid/kbd/include/kbd.h

    rc4fb95d3 rd011038  
    3838#define KBD_KBD_H_
    3939
    40 extern int cir_service;
    41 extern int cir_phone;
     40#include <bool.h>
     41
     42extern bool irc_service;
     43extern int irc_phone;
    4244
    4345extern void kbd_push_scancode(int);
  • uspace/srv/hid/kbd/port/ns16550.c

    rc4fb95d3 rd011038  
    120120        kbd_push_scancode(scan_code);
    121121       
    122         if (cir_service)
    123                 async_msg_1(cir_phone, IRC_CLEAR_INTERRUPT,
     122        if (irc_service)
     123                async_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    124124                    IPC_GET_IMETHOD(*call));
    125125}
  • uspace/srv/hid/kbd/port/z8530.c

    rc4fb95d3 rd011038  
    108108        kbd_push_scancode(scan_code);
    109109       
    110         if (cir_service)
    111                 async_msg_1(cir_phone, IRC_CLEAR_INTERRUPT,
     110        if (irc_service)
     111                async_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    112112                    IPC_GET_IMETHOD(*call));
    113113}
  • uspace/srv/hw/irc/apic/apic.c

    rc4fb95d3 rd011038  
    107107       
    108108        async_set_client_connection(apic_connection);
    109         service_register(SERVICE_APIC);
     109        service_register(SERVICE_IRC);
    110110       
    111111        return true;
  • uspace/srv/hw/irc/fhc/fhc.c

    rc4fb95d3 rd011038  
    136136       
    137137        async_set_client_connection(fhc_connection);
    138         service_register(SERVICE_FHC);
     138        service_register(SERVICE_IRC);
    139139       
    140140        return true;
  • uspace/srv/hw/irc/i8259/i8259.c

    rc4fb95d3 rd011038  
    149149       
    150150        async_set_client_connection(i8259_connection);
    151         service_register(SERVICE_I8259);
     151        service_register(SERVICE_IRC);
    152152       
    153153        return true;
  • uspace/srv/hw/irc/obio/obio.c

    rc4fb95d3 rd011038  
    137137       
    138138        async_set_client_connection(obio_connection);
    139         service_register(SERVICE_OBIO);
     139        service_register(SERVICE_IRC);
    140140       
    141141        return true;
  • uspace/srv/hw/netif/ne2000/ne2000.c

    rc4fb95d3 rd011038  
    7575#define IRQ_GET_TSR(call)  ((int) IPC_GET_ARG3(call))
    7676
    77 static int irc_service = 0;
     77static bool irc_service = false;
    7878static int irc_phone = -1;
    7979
     
    383383        sysarg_t i8259;
    384384       
    385         if ((sysinfo_get_value("apic", &apic) == EOK) && (apic))
    386                 irc_service = SERVICE_APIC;
    387         else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))
    388                 irc_service = SERVICE_I8259;
     385        if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))
     386            || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)))
     387                irc_service = true;
    389388       
    390389        if (irc_service) {
    391390                while (irc_phone < 0)
    392                         irc_phone = service_connect_blocking(irc_service, 0, 0);
     391                        irc_phone = service_connect_blocking(SERVICE_IRC, 0, 0);
    393392        }
    394393       
  • uspace/srv/net/il/arp/arp.c

    rc4fb95d3 rd011038  
    157157                       
    158158                        arp_clear_addr(&proto->addresses);
    159                         arp_addr_destroy(&proto->addresses);
    160                 }
    161         }
    162        
    163         arp_protos_clear(&device->protos);
     159                        arp_addr_destroy(&proto->addresses, free);
     160                }
     161        }
     162       
     163        arp_protos_clear(&device->protos, free);
    164164}
    165165
     
    184184        }
    185185       
    186         arp_cache_clear(&arp_globals.cache);
     186        arp_cache_clear(&arp_globals.cache, free);
    187187        fibril_mutex_unlock(&arp_globals.lock);
    188188       
     
    212212                arp_clear_trans(trans);
    213213       
    214         arp_addr_exclude(&proto->addresses, address->value, address->length);
     214        arp_addr_exclude(&proto->addresses, address->value, address->length, free);
    215215       
    216216        fibril_mutex_unlock(&arp_globals.lock);
     
    345345                            header->protocol_length, trans);
    346346                        if (rc != EOK) {
    347                                 /* The generic char map has already freed trans! */
     347                                free(trans);
    348348                                return rc;
    349349                        }
     
    556556                if (index < 0) {
    557557                        fibril_mutex_unlock(&arp_globals.lock);
    558                         arp_protos_destroy(&device->protos);
     558                        arp_protos_destroy(&device->protos, free);
    559559                        free(device);
    560560                        return index;
     
    569569                if (device->phone < 0) {
    570570                        fibril_mutex_unlock(&arp_globals.lock);
    571                         arp_protos_destroy(&device->protos);
     571                        arp_protos_destroy(&device->protos, free);
    572572                        free(device);
    573573                        return EREFUSED;
     
    579579                if (rc != EOK) {
    580580                        fibril_mutex_unlock(&arp_globals.lock);
    581                         arp_protos_destroy(&device->protos);
     581                        arp_protos_destroy(&device->protos, free);
    582582                        free(device);
    583583                        return rc;
     
    589589                if (rc != EOK) {
    590590                        fibril_mutex_unlock(&arp_globals.lock);
    591                         arp_protos_destroy(&device->protos);
     591                        arp_protos_destroy(&device->protos, free);
    592592                        free(device);
    593593                        return rc;
     
    601601                        free(device->addr);
    602602                        free(device->addr_data);
    603                         arp_protos_destroy(&device->protos);
     603                        arp_protos_destroy(&device->protos, free);
    604604                        free(device);
    605605                        return rc;
     
    614614                        free(device->broadcast_addr);
    615615                        free(device->broadcast_data);
    616                         arp_protos_destroy(&device->protos);
     616                        arp_protos_destroy(&device->protos, free);
    617617                        free(device);
    618618                        return rc;
     
    746746                        arp_clear_trans(trans);
    747747                        arp_addr_exclude(&proto->addresses, target->value,
    748                             target->length);
     748                            target->length, free);
    749749                        return EAGAIN;
    750750                }
     
    794794            trans);
    795795        if (rc != EOK) {
    796                 /* The generic char map has already freed trans! */
     796                free(trans);
    797797                return rc;
    798798        }
     
    807807                arp_clear_trans(trans);
    808808                arp_addr_exclude(&proto->addresses, target->value,
    809                     target->length);
     809                    target->length, free);
    810810                return ENOENT;
    811811        }
  • uspace/srv/net/il/ip/ip.c

    rc4fb95d3 rd011038  
    505505        if (rc != EOK) {
    506506                fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
    507                 ip_routes_destroy(&ip_netif->routes);
     507                ip_routes_destroy(&ip_netif->routes, free);
    508508                free(ip_netif);
    509509                return rc;
  • uspace/srv/net/net/net.c

    rc4fb95d3 rd011038  
    289289        if (rc != EOK)
    290290                return rc;
     291       
    291292        rc = add_module(NULL, &net_globals.modules, (uint8_t *) NE2000_NAME,
    292293            (uint8_t *) NE2000_FILENAME, SERVICE_NE2000, 0, connect_to_service);
    293294        if (rc != EOK)
    294295                return rc;
     296       
    295297        rc = add_module(NULL, &net_globals.modules, (uint8_t *) ETHERNET_NAME,
    296298            (uint8_t *) ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service);
    297299        if (rc != EOK)
    298300                return rc;
     301       
    299302        rc = add_module(NULL, &net_globals.modules, (uint8_t *) NILDUMMY_NAME,
    300303            (uint8_t *) NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service);
     
    552555                rc = read_netif_configuration(conf_files[i], netif);
    553556                if (rc != EOK) {
    554                         measured_strings_destroy(&netif->configuration);
     557                        measured_strings_destroy(&netif->configuration, free);
    555558                        free(netif);
    556559                        return rc;
     
    562565                if (!setting) {
    563566                        fprintf(stderr, "%s: Network interface name is missing\n", NAME);
    564                         measured_strings_destroy(&netif->configuration);
     567                        measured_strings_destroy(&netif->configuration, free);
    565568                        free(netif);
    566569                        return EINVAL;
     
    571574                int index = netifs_add(&net_globals.netifs, netif->id, netif);
    572575                if (index < 0) {
    573                         measured_strings_destroy(&netif->configuration);
     576                        measured_strings_destroy(&netif->configuration, free);
    574577                        free(netif);
    575578                        return index;
     
    583586                    index);
    584587                if (rc != EOK) {
    585                         measured_strings_destroy(&netif->configuration);
    586                         netifs_exclude_index(&net_globals.netifs, index);
     588                        measured_strings_destroy(&netif->configuration, free);
     589                        netifs_exclude_index(&net_globals.netifs, index, free);
    587590                        return rc;
    588591                }
     
    590593                rc = start_device(netif);
    591594                if (rc != EOK) {
    592                         printf("%s: Error starting interface %s (%s)\n", NAME,
     595                        printf("%s: Ignoring failed interface %s (%s)\n", NAME,
    593596                            netif->name, str_error(rc));
    594                         measured_strings_destroy(&netif->configuration);
    595                         netifs_exclude_index(&net_globals.netifs, index);
    596                        
    597                         return rc;
     597                        measured_strings_destroy(&netif->configuration, free);
     598                        netifs_exclude_index(&net_globals.netifs, index, free);
     599                        continue;
    598600                }
    599601               
  • uspace/srv/net/nil/eth/eth.c

    rc4fb95d3 rd011038  
    214214        if (rc != EOK) {
    215215                free(eth_globals.broadcast_addr);
    216                 eth_devices_destroy(&eth_globals.devices);
     216                eth_devices_destroy(&eth_globals.devices, free);
    217217        }
    218218out:
  • uspace/srv/net/tl/tcp/tcp.c

    rc4fb95d3 rd011038  
    17071707                if (socket->port > 0) {
    17081708                        socket_ports_exclude(&tcp_globals.sockets,
    1709                             socket->port);
     1709                            socket->port, free);
    17101710                        socket->port = 0;
    17111711                }
     
    24922492        rc = packet_dimensions_initialize(&tcp_globals.dimensions);
    24932493        if (rc != EOK) {
    2494                 socket_ports_destroy(&tcp_globals.sockets);
     2494                socket_ports_destroy(&tcp_globals.sockets, free);
    24952495                goto out;
    24962496        }
  • uspace/srv/net/tl/udp/udp.c

    rc4fb95d3 rd011038  
    417417        rc = packet_dimensions_initialize(&udp_globals.dimensions);
    418418        if (rc != EOK) {
    419                 socket_ports_destroy(&udp_globals.sockets);
     419                socket_ports_destroy(&udp_globals.sockets, free);
    420420                fibril_rwlock_write_unlock(&udp_globals.lock);
    421421                return rc;
     
    434434            &data);
    435435        if (rc != EOK) {
    436                 socket_ports_destroy(&udp_globals.sockets);
     436                socket_ports_destroy(&udp_globals.sockets, free);
    437437                fibril_rwlock_write_unlock(&udp_globals.lock);
    438438                return rc;
     
    740740        int socket_id;
    741741        size_t addrlen;
    742         size_t size;
     742        size_t size = 0;
    743743        ipc_call_t answer;
    744744        size_t answer_count;
  • uspace/srv/vfs/vfs_ops.c

    rc4fb95d3 rd011038  
    12341234        if (!parentc) {
    12351235                fibril_rwlock_write_unlock(&namespace_rwlock);
     1236                vfs_node_put(old_node);
    12361237                async_answer_0(rid, rc);
    12371238                free(old);
     
    12511252        if (rc != EOK) {
    12521253                fibril_rwlock_write_unlock(&namespace_rwlock);
     1254                vfs_node_put(old_node);
    12531255                async_answer_0(rid, rc);
    12541256                free(old);
     
    12611263            (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
    12621264                fibril_rwlock_write_unlock(&namespace_rwlock);
     1265                vfs_node_put(old_node);
    12631266                async_answer_0(rid, EXDEV);     /* different file systems */
    12641267                free(old);
     
    12791282                if (!new_node) {
    12801283                        fibril_rwlock_write_unlock(&namespace_rwlock);
     1284                        vfs_node_put(old_node);
    12811285                        async_answer_0(rid, ENOMEM);
    12821286                        free(old);
     
    12901294        default:
    12911295                fibril_rwlock_write_unlock(&namespace_rwlock);
     1296                vfs_node_put(old_node);
    12921297                async_answer_0(rid, ENOTEMPTY);
    12931298                free(old);
     
    13001305        if (rc != EOK) {
    13011306                fibril_rwlock_write_unlock(&namespace_rwlock);
     1307                vfs_node_put(old_node);
    13021308                if (new_node)
    13031309                        vfs_node_put(new_node);
Note: See TracChangeset for help on using the changeset viewer.