Changeset 1db44ea7 in mainline for uspace/srv


Ignore:
Timestamp:
2011-09-25T18:46:45Z (14 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

Location:
uspace/srv
Files:
18 edited

Legend:

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

    rdcc44ca1 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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 r1db44ea7  
    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.