Changeset bee37cf in mainline for uspace/srv/fs


Ignore:
Timestamp:
2011-07-05T21:21:36Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5e2aa83, eb66f236
Parents:
3714e79 (diff), f7a55f9 (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/fs
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/devfs/devfs.c

    r3714e79 rbee37cf  
    4141#include <stdio.h>
    4242#include <ipc/services.h>
    43 #include <ipc/ns.h>
     43#include <ns.h>
    4444#include <async.h>
    4545#include <errno.h>
     
    5959fs_reg_t devfs_reg;
    6060
    61 static void devfs_connection(ipc_callid_t iid, ipc_call_t *icall)
     61static void devfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    6262{
    6363        if (iid)
     
    6868                ipc_callid_t callid = async_get_call(&call);
    6969               
    70                 switch  (IPC_GET_IMETHOD(call)) {
    71                 case IPC_M_PHONE_HUNGUP:
     70                if (!IPC_GET_IMETHOD(call))
    7271                        return;
     72               
     73                switch (IPC_GET_IMETHOD(call)) {
    7374                case VFS_OUT_MOUNTED:
    7475                        devfs_mounted(callid, &call);
     
    119120int main(int argc, char *argv[])
    120121{
    121         printf(NAME ": HelenOS Device Filesystem\n");
     122        printf("%s: HelenOS Device Filesystem\n", NAME);
    122123       
    123124        if (!devfs_init()) {
    124                 printf(NAME ": failed to initialize devfs\n");
     125                printf("%s: failed to initialize devfs\n", NAME);
    125126                return -1;
    126127        }
    127128       
    128         int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
    129         if (vfs_phone < EOK) {
    130                 printf(NAME ": Unable to connect to VFS\n");
     129        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     130            SERVICE_VFS, 0, 0);
     131        if (!vfs_sess) {
     132                printf("%s: Unable to connect to VFS\n", NAME);
    131133                return -1;
    132134        }
    133135       
    134         int rc = fs_register(vfs_phone, &devfs_reg, &devfs_vfs_info,
     136        int rc = fs_register(vfs_sess, &devfs_reg, &devfs_vfs_info,
    135137            devfs_connection);
    136138        if (rc != EOK) {
    137                 printf(NAME ": Failed to register file system (%d)\n", rc);
     139                printf("%s: Failed to register file system (%d)\n", NAME, rc);
    138140                return rc;
    139141        }
    140142       
    141         printf(NAME ": Accepting connections\n");
     143        printf("%s: Accepting connections\n", NAME);
    142144        task_retval(0);
    143145        async_manager();
  • uspace/srv/fs/devfs/devfs_ops.c

    r3714e79 rbee37cf  
    5959typedef struct {
    6060        devmap_handle_t handle;
    61         int phone;              /**< When < 0, the structure is incomplete. */
     61        async_sess_t *sess;       /**< If NULL, the structure is incomplete. */
    6262        size_t refcount;
    6363        link_t link;
    64         fibril_condvar_t cv;    /**< Broadcast when completed. */
     64        fibril_condvar_t cv;      /**< Broadcast when completed. */
    6565} device_t;
    6666
     
    232232                };
    233233                link_t *lnk;
    234 
     234               
    235235                fibril_mutex_lock(&devices_mutex);
    236236restart:
     
    244244                       
    245245                        dev->handle = node->handle;
    246                         dev->phone = -1;        /* mark as incomplete */
     246                       
     247                        /* Mark as incomplete */
     248                        dev->sess = NULL;
    247249                        dev->refcount = 1;
    248250                        fibril_condvar_initialize(&dev->cv);
    249 
     251                       
    250252                        /*
    251253                         * Insert the incomplete device structure so that other
     
    254256                         */
    255257                        hash_table_insert(&devices, key, &dev->link);
    256 
     258                       
    257259                        /*
    258260                         * Drop the mutex to allow recursive devfs requests.
    259261                         */
    260262                        fibril_mutex_unlock(&devices_mutex);
    261 
    262                         int phone = devmap_device_connect(node->handle, 0);
    263 
     263                       
     264                        async_sess_t *sess = devmap_device_connect(EXCHANGE_SERIALIZE,
     265                            node->handle, 0);
     266                       
    264267                        fibril_mutex_lock(&devices_mutex);
    265 
     268                       
    266269                        /*
    267270                         * Notify possible waiters about this device structure
     
    269272                         */
    270273                        fibril_condvar_broadcast(&dev->cv);
    271 
    272                         if (phone < 0) {
     274                       
     275                        if (!sess) {
    273276                                /*
    274277                                 * Connecting failed, need to remove the
     
    277280                                hash_table_remove(&devices, key, DEVICES_KEYS);
    278281                                fibril_mutex_unlock(&devices_mutex);
    279 
     282                               
    280283                                return ENOENT;
    281284                        }
    282285                       
    283                         /* Set the correct phone. */
    284                         dev->phone = phone;
     286                        /* Set the correct session. */
     287                        dev->sess = sess;
    285288                } else {
    286289                        device_t *dev = hash_table_get_instance(lnk, device_t, link);
    287 
    288                         if (dev->phone < 0) {
     290                       
     291                        if (!dev->sess) {
    289292                                /*
    290293                                 * Wait until the device structure is completed
     
    608611               
    609612                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    610                 assert(dev->phone >= 0);
     613                assert(dev->sess);
    611614               
    612615                ipc_callid_t callid;
     
    619622               
    620623                /* Make a request at the driver */
     624                async_exch_t *exch = async_exchange_begin(dev->sess);
     625               
    621626                ipc_call_t answer;
    622                 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
     627                aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
    623628                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
    624629                    IPC_GET_ARG3(*request), &answer);
    625630               
    626631                /* Forward the IPC_M_DATA_READ request to the driver */
    627                 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     632                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     633               
     634                async_exchange_end(exch);
     635               
    628636                fibril_mutex_unlock(&devices_mutex);
    629637               
     
    672680               
    673681                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    674                 assert(dev->phone >= 0);
     682                assert(dev->sess);
    675683               
    676684                ipc_callid_t callid;
     
    683691               
    684692                /* Make a request at the driver */
     693                async_exch_t *exch = async_exchange_begin(dev->sess);
     694               
    685695                ipc_call_t answer;
    686                 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
     696                aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
    687697                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
    688698                    IPC_GET_ARG3(*request), &answer);
    689699               
    690700                /* Forward the IPC_M_DATA_WRITE request to the driver */
    691                 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     701                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     702               
     703                async_exchange_end(exch);
    692704               
    693705                fibril_mutex_unlock(&devices_mutex);
     
    742754               
    743755                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    744                 assert(dev->phone >= 0);
     756                assert(dev->sess);
    745757                dev->refcount--;
    746758               
    747759                if (dev->refcount == 0) {
    748                         async_hangup(dev->phone);
     760                        async_hangup(dev->sess);
    749761                        hash_table_remove(&devices, key, DEVICES_KEYS);
    750762                }
     
    790802               
    791803                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    792                 assert(dev->phone >= 0);
     804                assert(dev->sess);
    793805               
    794806                /* Make a request at the driver */
     807                async_exch_t *exch = async_exchange_begin(dev->sess);
     808               
    795809                ipc_call_t answer;
    796                 aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request),
     810                aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request),
    797811                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
     812               
     813                async_exchange_end(exch);
    798814               
    799815                fibril_mutex_unlock(&devices_mutex);
  • uspace/srv/fs/ext2fs/ext2fs.c

    r3714e79 rbee37cf  
    4040#include "ext2fs.h"
    4141#include <ipc/services.h>
    42 #include <ipc/ns.h>
     42#include <ns.h>
    4343#include <async.h>
    4444#include <errno.h>
     
    7575 * request has been completed.
    7676 */
    77 static void ext2fs_connection(ipc_callid_t iid, ipc_call_t *icall)
     77static void ext2fs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    7878{
    7979        if (iid) {
     
    8787       
    8888        dprintf(NAME ": connection opened\n");
    89         while (1) {
    90                 ipc_callid_t callid;
     89        while (true) {
    9190                ipc_call_t call;
    92        
    93                 callid = async_get_call(&call);
    94                 switch  (IPC_GET_IMETHOD(call)) {
    95                 case IPC_M_PHONE_HUNGUP:
     91                ipc_callid_t callid = async_get_call(&call);
     92               
     93                if (!IPC_GET_IMETHOD(call))
    9694                        return;
     95               
     96                switch (IPC_GET_IMETHOD(call)) {
    9797                case VFS_OUT_MOUNTED:
    9898                        ext2fs_mounted(callid, &call);
     
    143143int main(int argc, char **argv)
    144144{
    145         int vfs_phone;
    146         int rc;
    147 
    148145        printf(NAME ": HelenOS EXT2 file system server\n");
    149 
    150         vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
    151         if (vfs_phone < EOK) {
     146       
     147        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     148            SERVICE_VFS, 0, 0);
     149        if (!vfs_sess) {
    152150                printf(NAME ": failed to connect to VFS\n");
    153151                return -1;
    154152        }
    155153
    156         rc = ext2fs_global_init();
     154        int rc = ext2fs_global_init();
    157155        if (rc != EOK) {
    158156                printf(NAME ": Failed global initialization\n");
     
    160158        }       
    161159               
    162         rc = fs_register(vfs_phone, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection);
     160        rc = fs_register(vfs_sess, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection);
    163161        if (rc != EOK) {
    164162                fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc);
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    r3714e79 rbee37cf  
    187187{
    188188        EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
    189         link_t *link;
    190189        ext2fs_instance_t *tmp;
    191190       
     
    198197        }
    199198
    200         for (link = instance_list.next; link != &instance_list; link = link->next) {
     199        list_foreach(instance_list, link) {
    201200                tmp = list_get_instance(link, ext2fs_instance_t, link);
    202201               
     
    241240        }
    242241       
    243         rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref);
     242        rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0);
    244243        if (rc != EOK) {
    245244                return rc;
     
    479478        }
    480479       
    481         rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref);
     480        rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0);
    482481        if (rc != EOK) {
    483482                EXT2FS_DBG("error %u", rc);
     
    819818{
    820819        ext2_directory_iterator_t it;
    821         aoff64_t cur;
     820        aoff64_t next;
    822821        uint8_t *buf;
    823822        size_t name_size;
     
    825824        bool found = false;
    826825       
    827         rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref);
     826        rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos);
    828827        if (rc != EOK) {
    829828                async_answer_0(callid, rc);
     
    832831        }
    833832       
    834         /* Find the index we want to read
    835          * Note that we need to iterate and count as
    836          * the underlying structure is a linked list
    837          * Moreover, we want to skip . and .. entries
     833        /* Find next interesting directory entry.
     834         * We want to skip . and .. entries
    838835         * as these are not used in HelenOS
    839836         */
    840         cur = 0;
    841837        while (it.current != NULL) {
    842838                if (it.current->inode == 0) {
     
    852848                }
    853849               
    854                 /* Is this the dir entry we want to read? */
    855                 if (cur == pos) {
    856                         /* The on-disk entry does not contain \0 at the end
    857                          * end of entry name, so we copy it to new buffer
    858                          * and add the \0 at the end
    859                          */
    860                         buf = malloc(name_size+1);
    861                         if (buf == NULL) {
    862                                 ext2_directory_iterator_fini(&it);
    863                                 async_answer_0(callid, ENOMEM);
    864                                 async_answer_0(rid, ENOMEM);
    865                                 return;
    866                         }
    867                         memcpy(buf, &it.current->name, name_size);
    868                         *(buf+name_size) = 0;
    869                         found = true;
    870                         (void) async_data_read_finalize(callid, buf, name_size+1);
    871                         free(buf);
    872                         break;
    873                 }
    874                 cur++;
     850                /* The on-disk entry does not contain \0 at the end
     851                        * end of entry name, so we copy it to new buffer
     852                        * and add the \0 at the end
     853                        */
     854                buf = malloc(name_size+1);
     855                if (buf == NULL) {
     856                        ext2_directory_iterator_fini(&it);
     857                        async_answer_0(callid, ENOMEM);
     858                        async_answer_0(rid, ENOMEM);
     859                        return;
     860                }
     861                memcpy(buf, &it.current->name, name_size);
     862                *(buf+name_size) = 0;
     863                found = true;
     864                (void) async_data_read_finalize(callid, buf, name_size+1);
     865                free(buf);
     866                break;
    875867               
    876868skip:
     
    884876        }
    885877       
     878        if (found) {
     879                rc = ext2_directory_iterator_next(&it);
     880                if (rc != EOK) {
     881                        async_answer_0(rid, rc);
     882                        return;
     883                }
     884                next = it.current_offset;
     885        }
     886       
    886887        rc = ext2_directory_iterator_fini(&it);
    887888        if (rc != EOK) {
     
    891892       
    892893        if (found) {
    893                 async_answer_1(rid, EOK, 1);
     894                async_answer_1(rid, EOK, next-pos);
    894895        }
    895896        else {
  • uspace/srv/fs/fat/fat.c

    r3714e79 rbee37cf  
    3939#include "fat.h"
    4040#include <ipc/services.h>
    41 #include <ipc/ns.h>
     41#include <ns.h>
    4242#include <async.h>
    4343#include <errno.h>
     
    7676 * request has been completed.
    7777 */
    78 static void fat_connection(ipc_callid_t iid, ipc_call_t *icall)
     78static void fat_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    7979{
    8080        if (iid) {
     
    8888       
    8989        dprintf(NAME ": connection opened\n");
    90         while (1) {
    91                 ipc_callid_t callid;
     90       
     91        while (true) {
    9292                ipc_call_t call;
    93        
    94                 callid = async_get_call(&call);
    95                 switch  (IPC_GET_IMETHOD(call)) {
    96                 case IPC_M_PHONE_HUNGUP:
     93                ipc_callid_t callid = async_get_call(&call);
     94               
     95                if (!IPC_GET_IMETHOD(call))
    9796                        return;
     97               
     98                switch (IPC_GET_IMETHOD(call)) {
    9899                case VFS_OUT_MOUNTED:
    99100                        fat_mounted(callid, &call);
     
    144145int main(int argc, char **argv)
    145146{
    146         int vfs_phone;
    147         int rc;
    148 
    149147        printf(NAME ": HelenOS FAT file system server\n");
    150 
    151         rc = fat_idx_init();
     148       
     149        int rc = fat_idx_init();
    152150        if (rc != EOK)
    153151                goto err;
    154 
    155         vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
    156         if (vfs_phone < EOK) {
     152       
     153        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     154            SERVICE_VFS, 0, 0);
     155        if (!vfs_sess) {
    157156                printf(NAME ": failed to connect to VFS\n");
    158157                return -1;
    159158        }
    160159       
    161         rc = fs_register(vfs_phone, &fat_reg, &fat_vfs_info, fat_connection);
     160        rc = fs_register(vfs_sess, &fat_reg, &fat_vfs_info, fat_connection);
    162161        if (rc != EOK) {
    163162                fat_idx_fini();
     
    168167        task_retval(0);
    169168        async_manager();
    170         /* not reached */
     169       
     170        /* Not reached */
    171171        return 0;
    172 
     172       
    173173err:
    174174        printf(NAME ": Failed to register file system (%d)\n", rc);
     
    178178/**
    179179 * @}
    180  */ 
     180 */
  • uspace/srv/fs/fat/fat_idx.c

    r3714e79 rbee37cf  
    5959typedef struct {
    6060        link_t          link;
    61         devmap_handle_t devmap_handle;
     61        devmap_handle_t devmap_handle;
    6262
    6363        /** Next unassigned index. */
    64         fs_index_t      next;
     64        fs_index_t next;
    6565        /** Number of remaining unassigned indices. */
    66         uint64_t        remaining;
     66        uint64_t remaining;
    6767
    6868        /** Sorted list of intervals of freed indices. */
    69         link_t          freed_head;
     69        list_t freed_list;
    7070} unused_t;
    7171
     
    7474
    7575/** List of unused structures. */
    76 static LIST_INITIALIZE(unused_head);
     76static LIST_INITIALIZE(unused_list);
    7777
    7878static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
     
    8282        u->next = 0;
    8383        u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
    84         list_initialize(&u->freed_head);
     84        list_initialize(&u->freed_list);
    8585}
    8686
     
    8888{
    8989        unused_t *u;
    90         link_t *l;
    9190
    9291        if (lock)
    9392                fibril_mutex_lock(&unused_lock);
    94         for (l = unused_head.next; l != &unused_head; l = l->next) {
     93
     94        list_foreach(unused_list, l) {
    9595                u = list_get_instance(l, unused_t, link);
    9696                if (u->devmap_handle == devmap_handle)
    9797                        return u;
    9898        }
     99       
    99100        if (lock)
    100101                fibril_mutex_unlock(&unused_lock);
     
    249250                return false;   
    250251
    251         if (list_empty(&u->freed_head)) {
     252        if (list_empty(&u->freed_list)) {
    252253                if (u->remaining) {
    253254                        /*
     
    262263        } else {
    263264                /* There are some freed indices which we can reuse. */
    264                 freed_t *f = list_get_instance(u->freed_head.next, freed_t,
    265                     link);
     265                freed_t *f = list_get_instance(list_first(&u->freed_list),
     266                    freed_t, link);
    266267                *index = f->first;
    267268                if (f->first++ == f->last) {
     
    320321                link_t *lnk;
    321322                freed_t *n;
    322                 for (lnk = u->freed_head.next; lnk != &u->freed_head;
     323                for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head;
    323324                    lnk = lnk->next) {
    324325                        freed_t *f = list_get_instance(lnk, freed_t, link);
    325326                        if (f->first == index + 1) {
    326327                                f->first--;
    327                                 if (lnk->prev != &u->freed_head)
     328                                if (lnk->prev != &u->freed_list.head)
    328329                                        try_coalesce_intervals(lnk->prev, lnk,
    329330                                            lnk);
     
    333334                        if (f->last == index - 1) {
    334335                                f->last++;
    335                                 if (lnk->next != &u->freed_head)
     336                                if (lnk->next != &u->freed_list.head)
    336337                                        try_coalesce_intervals(lnk, lnk->next,
    337338                                            lnk);
     
    359360                n->first = index;
    360361                n->last = index;
    361                 list_append(&n->link, &u->freed_head);
     362                list_append(&n->link, &u->freed_list);
    362363        }
    363364        fibril_mutex_unlock(&unused_lock);
     
    558559        fibril_mutex_lock(&unused_lock);
    559560        if (!unused_find(devmap_handle, false)) {
    560                 list_append(&u->link, &unused_head);
     561                list_append(&u->link, &unused_list);
    561562        } else {
    562563                free(u);
     
    594595        fibril_mutex_unlock(&unused_lock);
    595596
    596         while (!list_empty(&u->freed_head)) {
     597        while (!list_empty(&u->freed_list)) {
    597598                freed_t *f;
    598                 f = list_get_instance(u->freed_head.next, freed_t, link);
     599                f = list_get_instance(list_first(&u->freed_list), freed_t, link);
    599600                list_remove(&f->link);
    600601                free(f);
  • uspace/srv/fs/fat/fat_ops.c

    r3714e79 rbee37cf  
    6767
    6868/** List of cached free FAT nodes. */
    69 static LIST_INITIALIZE(ffn_head);
     69static LIST_INITIALIZE(ffn_list);
    7070
    7171/*
     
    147147static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
    148148{
    149         link_t *lnk;
    150149        fat_node_t *nodep;
    151150        int rc;
     
    159158restart:
    160159        fibril_mutex_lock(&ffn_mutex);
    161         for (lnk = ffn_head.next; lnk != &ffn_head; lnk = lnk->next) {
     160        list_foreach(ffn_list, lnk) {
    162161                nodep = list_get_instance(lnk, fat_node_t, ffn_link);
    163162                if (!fibril_mutex_trylock(&nodep->lock)) {
     
    196195                free(nodep);
    197196
    198                 /* Need to restart because we changed the ffn_head list. */
     197                /* Need to restart because we changed ffn_list. */
    199198                goto restart;
    200199        }
     
    211210
    212211        fibril_mutex_lock(&ffn_mutex);
    213         if (!list_empty(&ffn_head)) {
     212        if (!list_empty(&ffn_list)) {
    214213                /* Try to use a cached free node structure. */
    215214                fat_idx_t *idxp_tmp;
    216                 nodep = list_get_instance(ffn_head.next, fat_node_t, ffn_link);
     215                nodep = list_get_instance(list_first(&ffn_list), fat_node_t,
     216                    ffn_link);
    217217                if (!fibril_mutex_trylock(&nodep->lock))
    218218                        goto skip_cache;
     
    473473                if (nodep->idx) {
    474474                        fibril_mutex_lock(&ffn_mutex);
    475                         list_append(&nodep->ffn_link, &ffn_head);
     475                        list_append(&nodep->ffn_link, &ffn_list);
    476476                        fibril_mutex_unlock(&ffn_mutex);
    477477                } else {
     
    970970
    971971        /* initialize libblock */
    972         rc = block_init(devmap_handle, BS_SIZE);
     972        rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, BS_SIZE);
    973973        if (rc != EOK) {
    974974                async_answer_0(rid, rc);
  • uspace/srv/fs/tmpfs/tmpfs.c

    r3714e79 rbee37cf  
    3030/** @addtogroup fs
    3131 * @{
    32  */ 
     32 */
    3333
    3434/**
     
    4343#include "tmpfs.h"
    4444#include <ipc/services.h>
    45 #include <ipc/ns.h>
     45#include <ns.h>
    4646#include <async.h>
    4747#include <errno.h>
     
    8282 * request has been completed.
    8383 */
    84 static void tmpfs_connection(ipc_callid_t iid, ipc_call_t *icall)
     84static void tmpfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    8585{
    8686        if (iid) {
     
    9494       
    9595        dprintf(NAME ": connection opened\n");
    96         while (1) {
    97                 ipc_callid_t callid;
     96       
     97        while (true) {
    9898                ipc_call_t call;
    99        
    100                 callid = async_get_call(&call);
    101                 switch  (IPC_GET_IMETHOD(call)) {
    102                 case IPC_M_PHONE_HUNGUP:
     99                ipc_callid_t callid = async_get_call(&call);
     100               
     101                if (!IPC_GET_IMETHOD(call))
    103102                        return;
     103               
     104                switch (IPC_GET_IMETHOD(call)) {
    104105                case VFS_OUT_MOUNTED:
    105106                        tmpfs_mounted(callid, &call);
     
    151152{
    152153        printf(NAME ": HelenOS TMPFS file system server\n");
    153 
     154       
    154155        if (!tmpfs_init()) {
    155156                printf(NAME ": failed to initialize TMPFS\n");
    156157                return -1;
    157158        }
    158 
    159         int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
    160         if (vfs_phone < EOK) {
     159       
     160        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     161            SERVICE_VFS, 0, 0);
     162        if (!vfs_sess) {
    161163                printf(NAME ": Unable to connect to VFS\n");
    162164                return -1;
    163165        }
    164 
    165         int rc = fs_register(vfs_phone, &tmpfs_reg, &tmpfs_vfs_info,
     166       
     167        int rc = fs_register(vfs_sess, &tmpfs_reg, &tmpfs_vfs_info,
    166168            tmpfs_connection);
    167169        if (rc != EOK) {
     
    169171                return rc;
    170172        }
    171 
     173       
    172174        printf(NAME ": Accepting connections\n");
    173175        task_retval(0);
    174176        async_manager();
    175         /* not reached */
     177       
     178        /* Not reached */
    176179        return 0;
    177180}
     
    179182/**
    180183 * @}
    181  */ 
     184 */
  • uspace/srv/fs/tmpfs/tmpfs.h

    r3714e79 rbee37cf  
    6767        size_t size;            /**< File size if type is TMPFS_FILE. */
    6868        void *data;             /**< File content's if type is TMPFS_FILE. */
    69         link_t cs_head;         /**< Head of child's siblings list. */
     69        list_t cs_list;         /**< Child's siblings list. */
    7070} tmpfs_node_t;
    7171
  • uspace/srv/fs/tmpfs/tmpfs_dump.c

    r3714e79 rbee37cf  
    167167        int rc;
    168168
    169         rc = block_init(dev, TMPFS_COMM_SIZE);
     169        rc = block_init(EXCHANGE_SERIALIZE, dev, TMPFS_COMM_SIZE);
    170170        if (rc != EOK)
    171171                return false;
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r3714e79 rbee37cf  
    8585static int tmpfs_has_children(bool *has_children, fs_node_t *fn)
    8686{
    87         *has_children = !list_empty(&TMPFS_NODE(fn)->cs_head);
     87        *has_children = !list_empty(&TMPFS_NODE(fn)->cs_list);
    8888        return EOK;
    8989}
     
    180180            nh_link);
    181181
    182         while (!list_empty(&nodep->cs_head)) {
    183                 tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,
    184                     tmpfs_dentry_t, link);
     182        while (!list_empty(&nodep->cs_list)) {
     183                tmpfs_dentry_t *dentryp = list_get_instance(
     184                    list_first(&nodep->cs_list), tmpfs_dentry_t, link);
    185185
    186186                assert(nodep->type == TMPFS_DIRECTORY);
     
    214214        nodep->data = NULL;
    215215        link_initialize(&nodep->nh_link);
    216         list_initialize(&nodep->cs_head);
     216        list_initialize(&nodep->cs_list);
    217217}
    218218
     
    262262{
    263263        tmpfs_node_t *parentp = TMPFS_NODE(pfn);
    264         link_t *lnk;
    265 
    266         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    267             lnk = lnk->next) {
     264
     265        list_foreach(parentp->cs_list, lnk) {
    268266                tmpfs_dentry_t *dentryp;
    269267                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
     
    353351       
    354352        assert(!nodep->lnkcnt);
    355         assert(list_empty(&nodep->cs_head));
     353        assert(list_empty(&nodep->cs_list));
    356354
    357355        unsigned long key[] = {
     
    373371        tmpfs_node_t *childp = TMPFS_NODE(cfn);
    374372        tmpfs_dentry_t *dentryp;
    375         link_t *lnk;
    376373
    377374        assert(parentp->type == TMPFS_DIRECTORY);
    378375
    379376        /* Check for duplicit entries. */
    380         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    381             lnk = lnk->next) {
     377        list_foreach(parentp->cs_list, lnk) {
    382378                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    383379                if (!str_cmp(dentryp->name, nm))
     
    401397        dentryp->node = childp;
    402398        childp->lnkcnt++;
    403         list_append(&dentryp->link, &parentp->cs_head);
     399        list_append(&dentryp->link, &parentp->cs_list);
    404400
    405401        return EOK;
     
    411407        tmpfs_node_t *childp = NULL;
    412408        tmpfs_dentry_t *dentryp;
    413         link_t *lnk;
    414409
    415410        if (!parentp)
    416411                return EBUSY;
    417412       
    418         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    419             lnk = lnk->next) {
     413        list_foreach(parentp->cs_list, lnk) {
    420414                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    421415                if (!str_cmp(dentryp->name, nm)) {
     
    423417                        assert(FS_NODE(childp) == cfn);
    424418                        break;
    425                 }       
     419                }
    426420        }
    427421
     
    429423                return ENOENT;
    430424               
    431         if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_head))
     425        if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_list))
    432426                return ENOTEMPTY;
    433427
     
    550544                tmpfs_dentry_t *dentryp;
    551545                link_t *lnk;
    552                 aoff64_t i;
    553546               
    554547                assert(nodep->type == TMPFS_DIRECTORY);
     
    559552                 * hash table.
    560553                 */
    561                 for (i = 0, lnk = nodep->cs_head.next;
    562                     (i < pos) && (lnk != &nodep->cs_head);
    563                     i++, lnk = lnk->next)
    564                         ;
    565 
    566                 if (lnk == &nodep->cs_head) {
     554                lnk = list_nth(&nodep->cs_list, pos);
     555               
     556                if (lnk == NULL) {
    567557                        async_answer_0(callid, ENOENT);
    568558                        async_answer_1(rid, ENOENT, 0);
Note: See TracChangeset for help on using the changeset viewer.