Changeset 1db44ea in mainline


Ignore:
Timestamp:
2011-09-25T18:46:45Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
36cb22f
Parents:
dcc44ca1 (diff), f9d8c3a (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

Files:
2 added
43 edited

Legend:

Unmodified
Added
Removed
  • contrib/arch/uspace/srv/vfs/vfs.adl

    rdcc44ca1 r1db44ea  
    44               
    55                /* Mount filesystem */
    6                 sysarg_t mount(in sysarg_t device, in sysarg_t flags, in_copy string point, in_copy string opts, in_copy string fs);
     6                sysarg_t mount(in sysarg_t device, in sysarg_t flags, in sysarg_t instance, in_copy string point, in_copy string opts, in_copy string fs);
    77               
    88                /* Open file */
     
    5656               
    5757                /* Mount filesystem */
    58                 sysarg_t mount(in sysarg_t device, in sysarg_t flags, in_copy string point, in_copy string opts, ...);
     58                sysarg_t mount(in sysarg_t device, in sysarg_t flags, in sysarg_t instance, in_copy string point, in_copy string opts, ...);
    5959               
    6060                /* Open file by node */
  • kernel/arch/ia64/include/asm.h

    rdcc44ca1 r1db44ea  
    4444#define IA64_IOSPACE_ADDRESS  0xE001000000000000ULL
    4545
     46#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
     47
    4648NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
    4749{
    48         uintptr_t prt = (uintptr_t) port;
    49        
    50         *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
    51             ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     50        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     51                uintptr_t prt = (uintptr_t) port;
     52       
     53                *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
     54                    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     55        } else {
     56                *port = v;
     57        }
    5258       
    5359        asm volatile (
     
    5965NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
    6066{
    61         uintptr_t prt = (uintptr_t) port;
    62        
    63         *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
    64             ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     67        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     68                uintptr_t prt = (uintptr_t) port;
     69       
     70                *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
     71                    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     72        } else {
     73                *port = v;
     74        }
    6575       
    6676        asm volatile (
     
    7282NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
    7383{
    74         uintptr_t prt = (uintptr_t) port;
    75        
    76         *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
    77             ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     84        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
     85                uintptr_t prt = (uintptr_t) port;
     86       
     87                *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
     88                    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     89        } else {
     90                *port = v;
     91        }
    7892       
    7993        asm volatile (
     
    8599NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
    86100{
    87         uintptr_t prt = (uintptr_t) port;
    88        
    89         asm volatile (
    90                 "mf\n"
    91                 ::: "memory"
    92         );
    93        
    94         return *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
    95             ((prt & 0xfff) | ((prt >> 2) << 12))));
     101        uint8_t v;
     102
     103        asm volatile (
     104                "mf\n"
     105                ::: "memory"
     106        );
     107
     108        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     109                uintptr_t prt = (uintptr_t) port;
     110
     111                v = *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
     112                    ((prt & 0xfff) | ((prt >> 2) << 12))));
     113        } else {
     114                v = *port;
     115        }
     116       
     117        return v;
    96118}
    97119
    98120NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
    99121{
    100         uintptr_t prt = (uintptr_t) port;
    101        
    102         asm volatile (
    103                 "mf\n"
    104                 ::: "memory"
    105         );
    106        
    107         return *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
    108             ((prt & 0xfff) | ((prt >> 2) << 12))));
     122        uint16_t v;
     123
     124        asm volatile (
     125                "mf\n"
     126                ::: "memory"
     127        );
     128
     129        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     130                uintptr_t prt = (uintptr_t) port;
     131
     132                v = *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
     133                    ((prt & 0xfff) | ((prt >> 2) << 12))));
     134        } else {
     135                v = *port;
     136        }
     137       
     138        return v;
    109139}
    110140
    111141NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
    112142{
    113         uintptr_t prt = (uintptr_t) port;
    114        
    115         asm volatile (
    116                 "mf\n"
    117                 ::: "memory"
    118         );
    119        
    120         return *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
    121             ((prt & 0xfff) | ((prt >> 2) << 12))));
     143        uint32_t v;
     144       
     145        asm volatile (
     146                "mf\n"
     147                ::: "memory"
     148        );
     149       
     150        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
     151                uintptr_t prt = (uintptr_t) port;
     152               
     153                v = *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
     154                    ((prt & 0xfff) | ((prt >> 2) << 12))));
     155        } else {
     156                v = *port;
     157        }
     158
     159        return v;
    122160}
    123161
  • kernel/generic/src/adt/btree.c

    rdcc44ca1 r1db44ea  
    3838 *
    3939 * The B+tree has the following properties:
    40  * @li it is a ballanced 3-4-5 tree (i.e. BTREE_M = 5)
     40 * @li it is a balanced 3-4-5 tree (i.e. BTREE_M = 5)
    4141 * @li values (i.e. pointers to values) are stored only in leaves
    4242 * @li leaves are linked in a list
    4343 *
    44  * Be carefull when using these trees. They need to allocate
     44 * Be careful when using these trees. They need to allocate
    4545 * and deallocate memory for their index nodes and as such
    4646 * can sleep.
     
    146146 * also makes use of this feature.
    147147 *
    148  * @param node     B-tree node into wich the new key is to be inserted.
     148 * @param node     B-tree node into which the new key is to be inserted.
    149149 * @param key      The key to be inserted.
    150150 * @param value    Pointer to value to be inserted.
     
    270270 * This feature is used during insert by right rotation.
    271271 *
    272  * @param node     B-tree node into wich the new key is to be inserted.
     272 * @param node     B-tree node into which the new key is to be inserted.
    273273 * @param key      The key to be inserted.
    274274 * @param value    Pointer to value to be inserted.
     
    463463        if (rnode->keys < BTREE_MAX_KEYS) {
    464464                /*
    465                  * The rotaion can be done. The right sibling has free space.
     465                 * The rotation can be done. The right sibling has free space.
    466466                 */
    467467                node_insert_key_and_rsubtree(node, inskey, insvalue, rsubtree);
     
    484484 * the median will be copied there.
    485485 *
    486  * @param node     B-tree node wich is going to be split.
     486 * @param node     B-tree node which is going to be split.
    487487 * @param key      The key to be inserted.
    488488 * @param value    Pointer to the value to be inserted.
     
    562562        if (node->keys < BTREE_MAX_KEYS) {
    563563                /*
    564                  * Node conatins enough space, the key can be stored immediately.
     564                 * Node contains enough space, the key can be stored immediately.
    565565                 */
    566566                node_insert_key_and_rsubtree(node, key, value, rsubtree);
     
    806806               
    807807                /*
    808                  * The key can be immediatelly removed.
     808                 * The key can be immediately removed.
    809809                 *
    810810                 * Note that the right subtree is removed because when
  • kernel/generic/src/adt/list.c

    rdcc44ca1 r1db44ea  
    3333/**
    3434 * @file
    35  * @brief       Functions completing doubly linked circular list implementaion.
     35 * @brief       Functions completing doubly linked circular list implementation.
    3636 *
    3737 * This file contains some of the functions implementing doubly linked circular lists.
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    rdcc44ca1 r1db44ea  
    5454static struct option const long_options[] = {
    5555        {"size", required_argument, 0, 's'},
     56        {"sparse", no_argument, 0, 'p'},
    5657        {"help", no_argument, 0, 'h'},
    5758        {0, 0, 0, 0}
     
    6970                "  -h, --help       A short option summary\n"
    7071                "  -s, --size sz    Size of the file\n"
     72                "  -p, --sparse     Create a sparse file\n"
    7173                "\n"
    7274                "Size is a number followed by 'k', 'm' or 'g' for kB, MB, GB.\n"
     
    115117        ssize_t file_size;
    116118        ssize_t total_written;
    117         ssize_t to_write, rc;
     119        ssize_t to_write, rc, rc2 = 0;
    118120        char *file_name;
    119121        void *buffer;
     122        bool create_sparse = false;
    120123
    121124        file_size = 0;
     
    124127
    125128        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    126                 c = getopt_long(argc, argv, "s:h", long_options, &opt_ind);
     129                c = getopt_long(argc, argv, "ps:h", long_options, &opt_ind);
    127130                switch (c) {
    128131                case 'h':
    129132                        help_cmd_mkfile(HELP_LONG);
    130133                        return CMD_SUCCESS;
     134                case 'p':
     135                        create_sparse = true;
     136                        break;
    131137                case 's':
    132138                        file_size = read_size(optarg);
     
    154160                printf("%s: failed to create file %s.\n", cmdname, file_name);
    155161                return CMD_FAILURE;
     162        }
     163
     164        if (create_sparse && file_size > 0) {
     165                const char byte = 0x00;
     166
     167                if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0)
     168                        goto exit;
     169
     170                rc2 = write(fd, &byte, sizeof(char));
     171                goto exit;
    156172        }
    157173
     
    174190        }
    175191
     192        free(buffer);
     193exit:
    176194        rc = close(fd);
    177         if (rc != 0) {
     195
     196        if (rc != 0 || rc2 < 0) {
    178197                printf("%s: Error writing file (%zd).\n", cmdname, rc);
    179198                return CMD_FAILURE;
    180199        }
    181 
    182         free(buffer);
    183200
    184201        return CMD_SUCCESS;
  • uspace/app/bdsh/cmds/modules/mount/mount.c

    rdcc44ca1 r1db44ea  
    4343static struct option const long_options[] = {
    4444        { "help", no_argument, 0, 'h' },
     45        { "instance", required_argument, 0, 'i' },
    4546        { 0, 0, 0, 0 }
    4647};
     
    6869        const char *dev = "";
    6970        int rc, c, opt_ind;
     71        unsigned int instance = 0;
     72        bool instance_set = false;
     73        char **t_argv;
    7074
    7175        argc = cli_count_args(argv);
    7276
    7377        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    74                 c = getopt_long(argc, argv, "h", long_options, &opt_ind);
     78                c = getopt_long(argc, argv, "i:h", long_options, &opt_ind);
    7579                switch (c) {
    7680                case 'h':
    7781                        help_cmd_mount(HELP_LONG);
    7882                        return CMD_SUCCESS;
     83                case 'i':
     84                        instance = (unsigned int) strtol(optarg, NULL, 10);
     85                        instance_set = true;
     86                        break;
    7987                }
    8088        }
     89
     90        if (instance_set) {
     91                argc -= 2;
     92                t_argv = &argv[2];
     93        } else
     94                t_argv = &argv[0];
    8195
    8296        if ((argc < 3) || (argc > 5)) {
     
    86100        }
    87101        if (argc > 3)
    88                 dev = argv[3];
     102                dev = t_argv[3];
    89103        if (argc == 5)
    90                 mopts = argv[4];
     104                mopts = t_argv[4];
    91105
    92         rc = mount(argv[1], argv[2], dev, mopts, 0);
     106        rc = mount(t_argv[1], t_argv[2], dev, mopts, 0, instance);
    93107        if (rc != EOK) {
    94108                printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n",
    95                     argv[1], argv[2], argv[3], rc);
     109                    t_argv[1], t_argv[2], t_argv[3], rc);
    96110                return CMD_FAILURE;
    97111        }
  • uspace/app/init/init.c

    rdcc44ca1 r1db44ea  
    121121       
    122122        int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,
    123             IPC_FLAG_BLOCKING);
     123            IPC_FLAG_BLOCKING, 0);
    124124        return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype,
    125125            ROOT_DEVICE, rc);
     
    138138{
    139139        int rc = mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",
    140             IPC_FLAG_BLOCKING);
     140            IPC_FLAG_BLOCKING, 0);
    141141        return mount_report("Location service filesystem", LOCFS_MOUNT_POINT,
    142142            LOCFS_FS_TYPE, NULL, rc);
     
    261261static bool mount_tmpfs(void)
    262262{
    263         int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0);
     263        int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0);
    264264        return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT,
    265265            TMPFS_FS_TYPE, NULL, rc);
     
    268268static bool mount_data(void)
    269269{
    270         int rc = mount(DATA_FS_TYPE, DATA_MOUNT_POINT, DATA_DEVICE, "wtcache", 0);
     270        int rc = mount(DATA_FS_TYPE, DATA_MOUNT_POINT, DATA_DEVICE, "wtcache", 0, 0);
    271271        return mount_report("Data filesystem", DATA_MOUNT_POINT, DATA_FS_TYPE,
    272272            DATA_DEVICE, rc);
  • uspace/app/vuhid/Makefile

    rdcc44ca1 r1db44ea  
    4747
    4848SOURCES_INTERFACES = \
    49         hids/bootkbd.c
     49        hids/bootkbd.c \
     50        hids/logitech_wireless.c
    5051
    5152SOURCES = \
     
    5354        device.c \
    5455        ifaces.c \
     56        life.c \
    5557        stdreq.c \
    5658        $(SOURCES_INTERFACES)
  • uspace/app/vuhid/hids/bootkbd.c

    rdcc44ca1 r1db44ea  
    9393             0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    9494};
    95 static size_t in_data_count = sizeof(in_data)/INPUT_SIZE;
    96 // FIXME - locking
    97 static size_t in_data_position = 0;
    98 
    99 static int on_data_in(vuhid_interface_t *iface,
    100     void *buffer, size_t buffer_size, size_t *act_buffer_size)
    101 {
    102         static size_t last_pos = (size_t) -1;
    103         size_t pos = in_data_position;
    104         if (pos >= in_data_count) {
    105                 return EBADCHECKSUM;
    106         }
    107 
    108         if (last_pos == pos) {
    109                 return ENAK;
    110         }
    111 
    112         if (buffer_size > INPUT_SIZE) {
    113                 buffer_size = INPUT_SIZE;
    114         }
    115 
    116         if (act_buffer_size != NULL) {
    117                 *act_buffer_size = buffer_size;
    118         }
    119 
    120         memcpy(buffer, in_data + pos * INPUT_SIZE, buffer_size);
    121         last_pos = pos;
    122 
    123         return EOK;
    124 }
     95static vuhid_interface_life_t boot_life = {
     96        .data_in = in_data,
     97        .data_in_count = sizeof(in_data)/INPUT_SIZE,
     98        .data_in_pos_change_delay = 500,
     99        .msg_born = "Boot keyboard comes to life...",
     100        .msg_die = "Boot keyboard died."
     101};
    125102
    126103static int on_data_out(vuhid_interface_t *iface,
     
    141118}
    142119
    143 
    144 static void live(vuhid_interface_t *iface)
    145 {
    146         async_usleep(1000 * 1000 * 5);
    147         usb_log_debug("Boot keyboard comes to life...\n");
    148         while (in_data_position < in_data_count) {
    149                 async_usleep(1000 * 500);
    150                 in_data_position++;
    151         }
    152         usb_log_debug("Boot keyboard died.\n");
    153 }
    154 
    155 
    156120vuhid_interface_t vuhid_interface_bootkbd = {
    157121        .id = "boot",
     
    164128
    165129        .in_data_size = INPUT_SIZE,
    166         .on_data_in = on_data_in,
     130        .on_data_in = interface_live_on_data_in,
    167131
    168132        .out_data_size = 1,
    169133        .on_data_out = on_data_out,
    170134
    171         .live = live,
     135        .live = interface_life_live,
    172136
     137        .interface_data = &boot_life,
    173138        .vuhid_data = NULL
    174139};
  • uspace/app/vuhid/ifaces.c

    rdcc44ca1 r1db44ea  
    3838
    3939extern vuhid_interface_t vuhid_interface_bootkbd;
     40extern vuhid_interface_t vuhid_interface_logitech_wireless_1;
    4041
    4142vuhid_interface_t *available_hid_interfaces[] = {
    4243        &vuhid_interface_bootkbd,
     44        &vuhid_interface_logitech_wireless_1,
    4345        NULL
    4446};
  • uspace/app/vuhid/virthid.h

    rdcc44ca1 r1db44ea  
    8282
    8383typedef struct {
     84        /** Buffer with data from device to the host. */
     85        uint8_t *data_in;
     86        /** Number of items in @c data_in.
     87         * The total size of @c data_in buffer shall be
     88         * <code>data_in_count * vuhid_interface_t.in_data_size</code>.
     89         */
     90        size_t data_in_count;
     91
     92        /** Current position in the data buffer. */
     93        size_t data_in_pos;
     94        /** Previous position. */
     95        size_t data_in_last_pos;
     96
     97        /** Delay between transition to "next" input buffer (in ms). */
     98        size_t data_in_pos_change_delay;
     99
     100        /** Message to print when interface becomes alive. */
     101        const char *msg_born;
     102        /** Message to print when interface dies. */
     103        const char *msg_die;
     104} vuhid_interface_life_t;
     105
     106typedef struct {
    84107        uint8_t length;
    85108        uint8_t type;
     
    94117void wait_for_interfaces_death(usbvirt_device_t *);
    95118
     119void interface_life_live(vuhid_interface_t *);
     120int interface_live_on_data_in(vuhid_interface_t *, void *, size_t, size_t *);
     121
     122
    96123#endif
    97124/**
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    rdcc44ca1 r1db44ea  
    7575/** Default idle rate for mouses. */
    7676static const uint8_t IDLE_RATE = 0;
    77 static const size_t USB_MOUSE_BUTTON_COUNT = 3;
    7877
    7978/*----------------------------------------------------------------------------*/
     
    397396/*----------------------------------------------------------------------------*/
    398397
     398/** Get highest index of a button mentioned in given report.
     399 *
     400 * @param report HID report.
     401 * @param report_id Report id we are interested in.
     402 * @return Highest button mentioned in the report.
     403 * @retval 1 No button was mentioned.
     404 *
     405 */
     406static size_t usb_mouse_get_highest_button(usb_hid_report_t *report, uint8_t report_id)
     407{
     408        size_t highest_button = 0;
     409
     410        usb_hid_report_path_t *path = usb_hid_report_path();
     411        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0);
     412        usb_hid_report_path_set_report_id(path, report_id);
     413
     414        usb_hid_report_field_t *field = NULL;
     415
     416        /* Break from within. */
     417        while (1) {
     418                field = usb_hid_report_get_sibling(
     419                    report, field, path,
     420                    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     421                    USB_HID_REPORT_TYPE_INPUT);
     422                /* No more buttons? */
     423                if (field == NULL) {
     424                        break;
     425                }
     426
     427                size_t current_button = field->usage - field->usage_minimum;
     428                if (current_button > highest_button) {
     429                        highest_button = current_button;
     430                }
     431        }
     432
     433        usb_hid_report_path_free(path);
     434
     435        return highest_button;
     436}
     437
     438/*----------------------------------------------------------------------------*/
     439
    399440int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
    400441{
     
    414455        }
    415456       
    416         mouse_dev->buttons = (int32_t *)calloc(USB_MOUSE_BUTTON_COUNT,
    417             sizeof(int32_t));
     457        // FIXME: This may not be optimal since stupid hardware vendor may
     458        // use buttons 1, 2, 3 and 6000 and we would allocate array of
     459        // 6001*4B and use only 4 items in it.
     460        // Since I doubt that hardware producers would do that, I think
     461        // that the current solution is good enough.
     462        /* Adding 1 because we will be accessing buttons[highest]. */
     463        mouse_dev->buttons_count = usb_mouse_get_highest_button(hid_dev->report,
     464            hid_dev->report_id) + 1;
     465        mouse_dev->buttons = calloc(mouse_dev->buttons_count, sizeof(int32_t));
    418466       
    419467        if (mouse_dev->buttons == NULL) {
    420                 usb_log_fatal("No memory!\n");
     468                usb_log_error(NAME ": out of memory, giving up on device!\n");
    421469                free(mouse_dev);
    422470                return ENOMEM;
    423471        }
    424        
     472
     473
    425474        // save the Mouse device structure into the HID device structure
    426475        *data = mouse_dev;
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    rdcc44ca1 r1db44ea  
    5050        async_sess_t *wheel_sess;
    5151       
     52        /* Mouse buttons statuses. */
    5253        int32_t *buttons;
     54        size_t buttons_count;
    5355       
    5456        ddf_dev_ops_t ops;
  • uspace/drv/bus/usb/usbhub/usbhub.c

    rdcc44ca1 r1db44ea  
    130130
    131131        opResult = ddf_fun_bind(hub_fun);
    132         assert(opResult == EOK);
    133         opResult = ddf_fun_add_to_category(hub_fun, "hub");
    134132        assert(opResult == EOK);
    135133
  • uspace/drv/bus/usb/vhc/connhost.c

    rdcc44ca1 r1db44ea  
    440440        int rc = vhc_virtdev_add_transfer(vhc, transfer);
    441441        if (rc != EOK) {
    442                 free(transfer->setup_buffer);
     442                if (transfer->setup_buffer != NULL) {
     443                        free(transfer->setup_buffer);
     444                }
    443445                free(transfer);
    444446                return rc;
  • uspace/lib/c/arch/ia64/include/ddi.h

    rdcc44ca1 r1db44ea  
    5252static inline void pio_write_8(ioport8_t *port, uint8_t v)
    5353{
    54         uintptr_t prt = (uintptr_t) port;
     54        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     55                uintptr_t prt = (uintptr_t) port;
    5556
    56         *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
    57             ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     57                *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
     58                    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     59        } else {
     60                *port = v;
     61        }
    5862
    5963        asm volatile ("mf\n" ::: "memory");
     
    6266static inline void pio_write_16(ioport16_t *port, uint16_t v)
    6367{
    64         uintptr_t prt = (uintptr_t) port;
     68        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     69                uintptr_t prt = (uintptr_t) port;
    6570
    66         *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
    67             ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     71                *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
     72                    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     73        } else {
     74                *port = v;
     75        }
    6876
    6977        asm volatile ("mf\n" ::: "memory");
     
    7280static inline void pio_write_32(ioport32_t *port, uint32_t v)
    7381{
    74         uintptr_t prt = (uintptr_t) port;
     82        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
     83                uintptr_t prt = (uintptr_t) port;
    7584
    76         *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
    77             ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     85                *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
     86                    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
     87        } else {
     88                *port = v;
     89        }
    7890
    7991        asm volatile ("mf\n" ::: "memory");
     
    8294static inline uint8_t pio_read_8(ioport8_t *port)
    8395{
    84         uintptr_t prt = (uintptr_t) port;
     96        uint8_t v;
    8597
    8698        asm volatile ("mf\n" ::: "memory");
    8799
    88         return *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
    89             ((prt & 0xfff) | ((prt >> 2) << 12))));
     100        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     101                uintptr_t prt = (uintptr_t) port;
     102
     103                v = *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
     104                    ((prt & 0xfff) | ((prt >> 2) << 12))));
     105        } else {
     106                v = *port;
     107        }
     108
     109        return v;
    90110}
    91111
    92112static inline uint16_t pio_read_16(ioport16_t *port)
    93113{
    94         uintptr_t prt = (uintptr_t) port;
     114        uint16_t v;
    95115
    96116        asm volatile ("mf\n" ::: "memory");
    97117
    98         return *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
    99             ((prt & 0xfff) | ((prt >> 2) << 12))));
     118        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     119                uintptr_t prt = (uintptr_t) port;
     120
     121                v = *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
     122                    ((prt & 0xfff) | ((prt >> 2) << 12))));
     123        } else {
     124                v = *port;
     125        }
     126
     127        return v;
    100128}
    101129
    102130static inline uint32_t pio_read_32(ioport32_t *port)
    103131{
    104         uintptr_t prt = (uintptr_t) port;
     132        uint32_t v;
    105133
    106134        asm volatile ("mf\n" ::: "memory");
    107135
    108         return *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
    109             ((prt & 0xfff) | ((prt >> 2) << 12))));
     136        if (port < (ioport32_t *) port) {
     137                uintptr_t prt = (uintptr_t) port;
     138
     139                v = *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
     140                    ((prt & 0xfff) | ((prt >> 2) << 12))));
     141        } else {
     142                v = *port;
     143        }
     144
     145        return v;
    110146}
    111147
  • uspace/lib/c/generic/adt/hash_table.c

    rdcc44ca1 r1db44ea  
    190190}
    191191
    192 /** Apply fucntion to all items in hash table.
     192/** Apply function to all items in hash table.
    193193 *
    194194 * @param h   Hash table.
  • uspace/lib/c/generic/adt/list.c

    rdcc44ca1 r1db44ea  
    3333/**
    3434 * @file
    35  * @brief       Functions completing doubly linked circular list implementaion.
     35 * @brief       Functions completing doubly linked circular list implementation.
    3636 *
    3737 * This file contains some of the functions implementing doubly linked circular lists.
  • uspace/lib/c/generic/malloc.c

    rdcc44ca1 r1db44ea  
    873873void free(const void *addr)
    874874{
     875        if (addr == NULL)
     876                return;
     877
    875878        futex_down(&malloc_futex);
    876879       
  • uspace/lib/c/generic/vfs/vfs.c

    rdcc44ca1 r1db44ea  
    143143
    144144int mount(const char *fs_name, const char *mp, const char *fqsn,
    145     const char *opts, unsigned int flags)
     145    const char *opts, unsigned int flags, unsigned int instance)
    146146{
    147147        int null_id = -1;
     
    181181
    182182        sysarg_t rc_orig;
    183         aid_t req = async_send_2(exch, VFS_IN_MOUNT, service_id, flags, NULL);
     183        aid_t req = async_send_3(exch, VFS_IN_MOUNT, service_id, flags,
     184            instance, NULL);
    184185        sysarg_t rc = async_data_write_start(exch, (void *) mpa, mpa_size);
    185186        if (rc != EOK) {
  • uspace/lib/c/include/ipc/vfs.h

    rdcc44ca1 r1db44ea  
    5656        /** Unique identifier of the fs. */
    5757        char name[FS_NAME_MAXLEN + 1];
     58        unsigned int instance;
    5859        bool concurrent_read_write;
    5960        bool write_retains_size;
  • uspace/lib/c/include/vfs/vfs.h

    rdcc44ca1 r1db44ea  
    4949
    5050extern int mount(const char *, const char *, const char *, const char *,
    51     unsigned int);
     51    unsigned int, unsigned int);
    5252extern int unmount(const char *);
    5353
  • uspace/lib/fs/libfs.c

    rdcc44ca1 r1db44ea  
    877877}
    878878
     879static FIBRIL_MUTEX_INITIALIZE(instances_mutex);
     880static LIST_INITIALIZE(instances_list);
     881
     882typedef struct {
     883        service_id_t service_id;
     884        link_t link;
     885        void *data;
     886} fs_instance_t;
     887
     888int fs_instance_create(service_id_t service_id, void *data)
     889{
     890        fs_instance_t *inst = malloc(sizeof(fs_instance_t));
     891        if (!inst)
     892                return ENOMEM;
     893
     894        link_initialize(&inst->link);
     895        inst->service_id = service_id;
     896        inst->data = data;
     897
     898        fibril_mutex_lock(&instances_mutex);
     899        list_foreach(instances_list, link) {
     900                fs_instance_t *cur = list_get_instance(link, fs_instance_t,
     901                    link);
     902
     903                if (cur->service_id == service_id) {
     904                        fibril_mutex_unlock(&instances_mutex);
     905                        free(inst);
     906                        return EEXIST;
     907                }
     908
     909                /* keep the list sorted */
     910                if (cur->service_id < service_id) {
     911                        list_insert_before(&inst->link, &cur->link);
     912                        fibril_mutex_unlock(&instances_mutex);
     913                        return EOK;
     914                }
     915        }
     916        list_append(&inst->link, &instances_list);
     917        fibril_mutex_unlock(&instances_mutex);
     918
     919        return EOK;
     920}
     921
     922int fs_instance_get(service_id_t service_id, void **idp)
     923{
     924        fibril_mutex_lock(&instances_mutex);
     925        list_foreach(instances_list, link) {
     926                fs_instance_t *inst = list_get_instance(link, fs_instance_t,
     927                    link);
     928
     929                if (inst->service_id == service_id) {
     930                        *idp = inst->data;
     931                        fibril_mutex_unlock(&instances_mutex);
     932                        return EOK;
     933                }
     934        }
     935        fibril_mutex_unlock(&instances_mutex);
     936        return ENOENT;
     937}
     938
     939int fs_instance_destroy(service_id_t service_id)
     940{
     941        fibril_mutex_lock(&instances_mutex);
     942        list_foreach(instances_list, link) {
     943                fs_instance_t *inst = list_get_instance(link, fs_instance_t,
     944                    link);
     945
     946                if (inst->service_id == service_id) {
     947                        list_remove(&inst->link);
     948                        fibril_mutex_unlock(&instances_mutex);
     949                        free(inst);
     950                        return EOK;
     951                }
     952        }
     953        fibril_mutex_unlock(&instances_mutex);
     954        return ENOENT;
     955}
     956
    879957/** @}
    880958 */
  • uspace/lib/fs/libfs.h

    rdcc44ca1 r1db44ea  
    105105extern void fs_node_initialize(fs_node_t *);
    106106
     107extern int fs_instance_create(service_id_t, void *);
     108extern int fs_instance_get(service_id_t, void **);
     109extern int fs_instance_destroy(service_id_t);
     110
    107111#endif
    108112
  • uspace/lib/usbhid/src/hidpath.c

    rdcc44ca1 r1db44ea  
    7676                                    int32_t usage_page, int32_t usage)
    7777{       
    78         usb_hid_report_usage_path_t *item;
    79 
    80         if(!(item=malloc(sizeof(usb_hid_report_usage_path_t)))) {
     78        usb_hid_report_usage_path_t *item
     79                = malloc(sizeof(usb_hid_report_usage_path_t));
     80
     81        if (item == NULL) {
    8182                return ENOMEM;
    8283        }
  • uspace/srv/devman/main.c

    rdcc44ca1 r1db44ea  
    490490        if (rc == EOK) {
    491491                loc_service_add_to_cat(fun->service_id, cat_id);
     492                log_msg(LVL_NOTE, "Function `%s' added to category `%s'.",
     493                    fun->pathname, cat_name);
    492494        } else {
    493495                log_msg(LVL_ERROR, "Failed adding function `%s' to category "
     
    495497        }
    496498       
    497         log_msg(LVL_NOTE, "Function `%s' added to category `%s'.",
    498             fun->pathname, cat_name);
    499 
    500499        fibril_rwlock_read_unlock(&device_tree.rwlock);
    501500        fun_del_ref(fun);
    502 
    503         async_answer_0(callid, EOK);
     501       
     502        async_answer_0(callid, rc);
    504503}
    505504
  • uspace/srv/fs/cdfs/cdfs.c

    rdcc44ca1 r1db44ea  
    5252        .concurrent_read_write = false,
    5353        .write_retains_size = false,
     54        .instance = 0,
    5455};
    5556
     
    5859        printf("%s: HelenOS cdfs file system server\n", NAME);
    5960       
     61        if (argc == 3) {
     62                if (!str_cmp(argv[1], "--instance"))
     63                        cdfs_vfs_info.instance = strtol(argv[2], NULL, 10);
     64                else {
     65                        printf(NAME " Unrecognized parameters");
     66                        return -1;
     67                }
     68        }
     69
    6070        if (!cdfs_init()) {
    6171                printf("%s: failed to initialize cdfs\n", NAME);
  • uspace/srv/fs/exfat/exfat.c

    rdcc44ca1 r1db44ea  
    5454        .name = NAME,
    5555        .concurrent_read_write = false,
    56         .write_retains_size = false,   
     56        .write_retains_size = false,
     57        .instance = 0,
    5758};
    5859
     
    6061{
    6162        printf(NAME ": HelenOS exFAT file system server\n");
     63
     64        if (argc == 3) {
     65                if (!str_cmp(argv[1], "--instance"))
     66                        exfat_vfs_info.instance = strtol(argv[2], NULL, 10);
     67                else {
     68                        printf(NAME " Unrecognized parameters");
     69                        return -1;
     70                }
     71        }
    6272
    6373        int rc = exfat_idx_init();
  • uspace/srv/fs/ext2fs/ext2fs.c

    rdcc44ca1 r1db44ea  
    5252vfs_info_t ext2fs_vfs_info = {
    5353        .name = NAME,
     54        .instance = 0,
    5455};
    5556
     
    5758{
    5859        printf(NAME ": HelenOS EXT2 file system server\n");
     60
     61        if (argc == 3) {
     62                if (!str_cmp(argv[1], "--instance"))
     63                        ext2fs_vfs_info.instance = strtol(argv[2], NULL, 10);
     64                else {
     65                        printf(NAME " Unrecognized parameters");
     66                        return -1;
     67                }
     68        }
    5969       
    6070        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
  • uspace/srv/fs/fat/fat.c

    rdcc44ca1 r1db44ea  
    5454        .name = NAME,
    5555        .concurrent_read_write = false,
    56         .write_retains_size = false,   
     56        .write_retains_size = false,
     57        .instance = 0,
    5758};
    5859
     
    6162        printf(NAME ": HelenOS FAT file system server\n");
    6263       
     64        if (argc == 3) {
     65                if (!str_cmp(argv[1], "--instance"))
     66                        fat_vfs_info.instance = strtol(argv[2], NULL, 10);
     67                else {
     68                        printf(NAME " Unrecognized parameters");
     69                        return -1;
     70                }
     71        }
     72
    6373        int rc = fat_idx_init();
    6474        if (rc != EOK)
  • uspace/srv/fs/fat/fat.h

    rdcc44ca1 r1db44ea  
    230230} fat_node_t;
    231231
     232typedef struct {
     233        bool lfn_enabled;
     234} fat_instance_t;
     235
    232236extern vfs_out_ops_t fat_ops;
    233237extern libfs_ops_t fat_libfs_ops;
  • uspace/srv/fs/fat/fat_directory.c

    rdcc44ca1 r1db44ea  
    262262{
    263263        int rc;
    264         bool enable_lfn = true; /* TODO: make this a mount option */
     264        void *data;
     265        fat_instance_t *instance;
     266
     267        rc = fs_instance_get(di->nodep->idx->service_id, &data);
     268        assert(rc == EOK);
     269        instance = (fat_instance_t *) data;
    265270       
    266271        if (fat_valid_short_name(name)) {
     
    277282                rc = fat_directory_write_dentry(di, de);
    278283                return rc;
    279         } else if (enable_lfn && fat_valid_name(name)) {
     284        } else if (instance->lfn_enabled && fat_valid_name(name)) {
    280285                /* We should create long entries to store name */
    281286                int long_entry_count;
     
    292297                if (lfn_size % FAT_LFN_ENTRY_SIZE)
    293298                        long_entry_count++;
    294                 rc = fat_directory_lookup_free(di, long_entry_count+1);
     299                rc = fat_directory_lookup_free(di, long_entry_count + 1);
    295300                if (rc != EOK)
    296301                        return rc;
     
    328333                FAT_LFN_ORDER(d) |= FAT_LFN_LAST;
    329334
    330                 rc = fat_directory_seek(di, start_pos+long_entry_count);
     335                rc = fat_directory_seek(di, start_pos + long_entry_count);
    331336                return rc;
    332337        }
  • uspace/srv/fs/fat/fat_ops.c

    rdcc44ca1 r1db44ea  
    871871    aoff64_t *size, unsigned *linkcnt)
    872872{
    873         enum cache_mode cmode;
     873        enum cache_mode cmode = CACHE_MODE_WB;
    874874        fat_bs_t *bs;
    875         int rc;
    876 
    877         /* Check for option enabling write through. */
    878         if (str_cmp(opts, "wtcache") == 0)
    879                 cmode = CACHE_MODE_WT;
    880         else
    881                 cmode = CACHE_MODE_WB;
     875        fat_instance_t *instance;
     876        int rc;
     877
     878        instance = malloc(sizeof(fat_instance_t));
     879        if (!instance)
     880                return ENOMEM;
     881        instance->lfn_enabled = true;
     882
     883        /* Parse mount options. */
     884        char *mntopts = (char *) opts;
     885        char *saveptr;
     886        char *opt;
     887        while ((opt = strtok_r(mntopts, " ,", &saveptr)) != NULL) {
     888                if (str_cmp(opt, "wtcache") == 0)
     889                        cmode = CACHE_MODE_WT;
     890                else if (str_cmp(opt, "nolfn") == 0)
     891                        instance->lfn_enabled = false;
     892                mntopts = NULL;
     893        }
    882894
    883895        /* initialize libblock */
    884896        rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE);
    885         if (rc != EOK)
    886                 return rc;
     897        if (rc != EOK) {
     898                free(instance);
     899                return rc;
     900        }
    887901
    888902        /* prepare the boot block */
    889903        rc = block_bb_read(service_id, BS_BLOCK);
    890904        if (rc != EOK) {
     905                free(instance);
    891906                block_fini(service_id);
    892907                return rc;
     
    897912       
    898913        if (BPS(bs) != BS_SIZE) {
     914                free(instance);
    899915                block_fini(service_id);
    900916                return ENOTSUP;
     
    904920        rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode);
    905921        if (rc != EOK) {
     922                free(instance);
    906923                block_fini(service_id);
    907924                return rc;
     
    911928        rc = fat_sanity_check(bs, service_id);
    912929        if (rc != EOK) {
     930                free(instance);
    913931                (void) block_cache_fini(service_id);
    914932                block_fini(service_id);
     
    918936        rc = fat_idx_init_by_service_id(service_id);
    919937        if (rc != EOK) {
     938                free(instance);
    920939                (void) block_cache_fini(service_id);
    921940                block_fini(service_id);
     
    926945        fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t));
    927946        if (!rfn) {
     947                free(instance);
    928948                (void) block_cache_fini(service_id);
    929949                block_fini(service_id);
     
    935955        fat_node_t *rootp = (fat_node_t *)malloc(sizeof(fat_node_t));
    936956        if (!rootp) {
     957                free(instance);
    937958                free(rfn);
    938959                (void) block_cache_fini(service_id);
     
    945966        fat_idx_t *ridxp = fat_idx_get_by_pos(service_id, FAT_CLST_ROOTPAR, 0);
    946967        if (!ridxp) {
     968                free(instance);
    947969                free(rfn);
    948970                free(rootp);
     
    964986                rc = fat_clusters_get(&clusters, bs, service_id, rootp->firstc);
    965987                if (rc != EOK) {
     988                        fibril_mutex_unlock(&ridxp->lock);
     989                        free(instance);
    966990                        free(rfn);
    967991                        free(rootp);
     
    974998        } else
    975999                rootp->size = RDE(bs) * sizeof(fat_dentry_t);
     1000
     1001        rc = fs_instance_create(service_id, instance);
     1002        if (rc != EOK) {
     1003                fibril_mutex_unlock(&ridxp->lock);
     1004                free(instance);
     1005                free(rfn);
     1006                free(rootp);
     1007                (void) block_cache_fini(service_id);
     1008                block_fini(service_id);
     1009                fat_idx_fini_by_service_id(service_id);
     1010                return rc;
     1011        }
    9761012
    9771013        rootp->idx = ridxp;
     
    10241060        (void) block_cache_fini(service_id);
    10251061        block_fini(service_id);
     1062
     1063        void *data;
     1064        if (fs_instance_get(service_id, &data) == EOK) {
     1065                fs_instance_destroy(service_id);
     1066                free(data);
     1067        }
    10261068
    10271069        return EOK;
  • uspace/srv/fs/locfs/locfs.c

    rdcc44ca1 r1db44ea  
    5555        .concurrent_read_write = false,
    5656        .write_retains_size = false,
     57        .instance = 0,
    5758};
    5859
     
    6162        printf("%s: HelenOS Device Filesystem\n", NAME);
    6263       
     64        if (argc == 3) {
     65                if (!str_cmp(argv[1], "--instance"))
     66                        locfs_vfs_info.instance = strtol(argv[2], NULL, 10);
     67                else {
     68                        printf(NAME " Unrecognized parameters");
     69                        return -1;
     70                }
     71        }
     72
     73
    6374        if (!locfs_init()) {
    6475                printf("%s: failed to initialize locfs\n", NAME);
  • uspace/srv/fs/locfs/locfs_ops.c

    rdcc44ca1 r1db44ea  
    593593                sysarg_t rc;
    594594                async_wait_for(msg, &rc);
     595
     596                /* Do not propagate EHANGUP back to VFS. */
     597                if ((int) rc == EHANGUP)
     598                        rc = ENOTSUP;
    595599               
    596600                *rbytes = IPC_GET_ARG1(answer);
     
    655659                sysarg_t rc;
    656660                async_wait_for(msg, &rc);
     661
     662                /* Do not propagate EHANGUP back to VFS. */
     663                if ((int) rc == EHANGUP)
     664                        rc = ENOTSUP;
    657665               
    658666                *wbytes = IPC_GET_ARG1(answer);
  • uspace/srv/fs/mfs/mfs.c

    rdcc44ca1 r1db44ea  
    3939
    4040#include <ipc/services.h>
     41#include <stdlib.h>
     42#include <str.h>
    4143#include <ns.h>
    4244#include <async.h>
     
    5254        .concurrent_read_write = false,
    5355        .write_retains_size = false,
     56        .instance = 0,
    5457};
    5558
     
    5962
    6063        printf(NAME ": HelenOS Minix file system server\n");
     64
     65        if (argc == 3) {
     66                if (!str_cmp(argv[1], "--instance"))
     67                        mfs_vfs_info.instance = strtol(argv[2], NULL, 10);
     68                else {
     69                        printf(NAME " Unrecognized parameters");
     70                        rc = -1;
     71                        goto err;
     72                }
     73        }
    6174
    6275        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
  • uspace/srv/fs/mfs/mfs.h

    rdcc44ca1 r1db44ea  
    131131
    132132struct mfs_instance {
    133         link_t link;
    134133        service_id_t service_id;
    135134        struct mfs_sb_info *sbi;
  • uspace/srv/fs/mfs/mfs_ops.c

    rdcc44ca1 r1db44ea  
    7373
    7474
    75 static LIST_INITIALIZE(inst_list);
    76 static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex);
    7775static hash_table_t open_nodes;
    7876static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock);
     
    178176                goto out_error;
    179177        }
    180 
    181         instance->open_nodes_cnt = 0;
    182178
    183179        sb = malloc(MFS_SUPERBLOCK_SIZE);
     
    271267        }
    272268
    273         /*Initialize the instance structure and add it to the list*/
    274         link_initialize(&instance->link);
     269        /*Initialize the instance structure and remember it*/
    275270        instance->service_id = service_id;
    276271        instance->sbi = sbi;
    277 
    278         fibril_mutex_lock(&inst_list_mutex);
    279         list_append(&instance->link, &inst_list);
    280         fibril_mutex_unlock(&inst_list_mutex);
     272        instance->open_nodes_cnt = 0;
     273        rc = fs_instance_create(service_id, instance);
     274        if (rc != EOK) {
     275                free(instance);
     276                free(sbi);
     277                block_cache_fini(service_id);
     278                block_fini(service_id);
     279                mfsdebug("fs instance creation failed\n");
     280                return rc;
     281        }
    281282
    282283        mfsdebug("mount successful\n");
     
    323324        block_fini(service_id);
    324325
    325         /* Remove the instance from the list */
    326         fibril_mutex_lock(&inst_list_mutex);
    327         list_remove(&inst->link);
    328         fibril_mutex_unlock(&inst_list_mutex);
    329 
     326        /* Remove and destroy the instance */
     327        (void) fs_instance_destroy(service_id);
    330328        free(inst->sbi);
    331329        free(inst);
     
    10201018mfs_instance_get(service_id_t service_id, struct mfs_instance **instance)
    10211019{
    1022         struct mfs_instance *instance_ptr;
    1023 
    1024         fibril_mutex_lock(&inst_list_mutex);
    1025 
    1026         if (list_empty(&inst_list)) {
    1027                 fibril_mutex_unlock(&inst_list_mutex);
    1028                 return EINVAL;
    1029         }
    1030 
    1031         list_foreach(inst_list, link) {
    1032                 instance_ptr = list_get_instance(link, struct mfs_instance,
    1033                                                  link);
    1034 
    1035                 if (instance_ptr->service_id == service_id) {
    1036                         *instance = instance_ptr;
    1037                         fibril_mutex_unlock(&inst_list_mutex);
    1038                         return EOK;
    1039                 }
    1040         }
    1041 
    1042         mfsdebug("Instance not found\n");
    1043 
    1044         fibril_mutex_unlock(&inst_list_mutex);
    1045         return EINVAL;
     1020        void *data;
     1021        int rc;
     1022
     1023        rc = fs_instance_get(service_id, &data);
     1024        if (rc == EOK) {
     1025                *instance = (struct mfs_instance *) data;
     1026        } else {
     1027                mfsdebug("instance not found\n");
     1028        }
     1029
     1030        return rc;
    10461031}
    10471032
  • uspace/srv/fs/tmpfs/tmpfs.c

    rdcc44ca1 r1db44ea  
    5959        .concurrent_read_write = false,
    6060        .write_retains_size = false,
     61        .instance = 0,
    6162};
    6263
     
    6465{
    6566        printf(NAME ": HelenOS TMPFS file system server\n");
     67
     68        if (argc == 3) {
     69                if (!str_cmp(argv[1], "--instance"))
     70                        tmpfs_vfs_info.instance = strtol(argv[2], NULL, 10);
     71                else {
     72                        printf(NAME " Unrecognized parameters");
     73                        return -1;
     74                }
     75        }
    6676       
    6777        if (!tmpfs_init()) {
  • uspace/srv/hid/console/console.c

    rdcc44ca1 r1db44ea  
    344344}
    345345
     346static console_t *cons_get_active_uspace(void)
     347{
     348        fibril_mutex_lock(&switch_mtx);
     349
     350        console_t *active_uspace = active_console;
     351        if (active_uspace == kernel_console) {
     352                active_uspace = prev_console;
     353        }
     354        assert(active_uspace != kernel_console);
     355
     356        fibril_mutex_unlock(&switch_mtx);
     357
     358        return active_uspace;
     359}
     360
    346361static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi)
    347362{
     
    466481                                event->c = c;
    467482                               
    468                                 prodcons_produce(&active_console->input_pc, &event->link);
     483                                /* Kernel console does not read events
     484                                 * from us, so we will redirect them
     485                                 * to the (last) active userspace console
     486                                 * if necessary.
     487                                 */
     488                                console_t *target_console = cons_get_active_uspace();
     489
     490                                prodcons_produce(&target_console->input_pc,
     491                                    &event->link);
    469492                        }
    470493                       
     
    904927                atomic_set(&consoles[i].refcnt, 0);
    905928                fibril_mutex_initialize(&consoles[i].mtx);
     929                prodcons_initialize(&consoles[i].input_pc);
    906930               
    907931                if (graphics_state == GRAPHICS_FULL) {
     
    942966                }
    943967               
    944                 prodcons_initialize(&consoles[i].input_pc);
    945968                cons_redraw_state(&consoles[i]);
    946969               
  • uspace/srv/vfs/vfs.h

    rdcc44ca1 r1db44ea  
    171171extern void vfs_exchange_release(async_exch_t *);
    172172
    173 extern fs_handle_t fs_name_to_handle(char *, bool);
     173extern fs_handle_t fs_name_to_handle(unsigned int instance, char *, bool);
    174174extern vfs_info_t *fs_handle_to_info(fs_handle_t);
    175175
  • uspace/srv/vfs/vfs_ops.c

    rdcc44ca1 r1db44ea  
    146146
    147147                        rindex = (fs_index_t) IPC_GET_ARG1(answer);
    148                         rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), IPC_GET_ARG3(answer));
     148                        rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer),
     149                            IPC_GET_ARG3(answer));
    149150                        rlnkcnt = (unsigned) IPC_GET_ARG4(answer);
    150151                       
     
    276277       
    277278        /*
    278          * For now, don't make use of ARG3, but it can be used to
    279          * carry mount options in the future.
    280          */
    281        
     279         * Instance number is passed as ARG3.
     280         */
     281        unsigned int instance = IPC_GET_ARG3(*request);
     282
    282283        /* We want the client to send us the mount point. */
    283284        char *mp;
     
    335336        fs_handle_t fs_handle;
    336337recheck:
    337         fs_handle = fs_name_to_handle(fs_name, false);
     338        fs_handle = fs_name_to_handle(instance, fs_name, false);
    338339        if (!fs_handle) {
    339340                if (flags & IPC_FLAG_BLOCKING) {
  • uspace/srv/vfs/vfs_register.c

    rdcc44ca1 r1db44ea  
    154154         * Check for duplicit registrations.
    155155         */
    156         if (fs_name_to_handle(fs_info->vfs_info.name, false)) {
     156        if (fs_name_to_handle(fs_info->vfs_info.instance,
     157            fs_info->vfs_info.name, false)) {
    157158                /*
    158159                 * We already register a fs like this.
     
    297298 *
    298299 */
    299 fs_handle_t fs_name_to_handle(char *name, bool lock)
     300fs_handle_t fs_name_to_handle(unsigned int instance, char *name, bool lock)
    300301{
    301302        int handle = 0;
     
    306307        list_foreach(fs_list, cur) {
    307308                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    308                 if (str_cmp(fs->vfs_info.name, name) == 0) {
     309                if (str_cmp(fs->vfs_info.name, name) == 0 &&
     310                    instance == fs->vfs_info.instance) {
    309311                        handle = fs->fs_handle;
    310312                        break;
Note: See TracChangeset for help on using the changeset viewer.