Changeset 47a776f9 in mainline


Ignore:
Timestamp:
2007-09-19T18:56:02Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d2d0baf
Parents:
26f2af0
Message:

VFS work.

The VFS_REGISTER is now fully implemented by both vfs and fat servers. Thanks to
the debugging dprintf()'s, I was able to fix little errors here and there to
make them actually work.

Modified vfs and fat service makefiles so that the two are not built as drivers
and can therefore print to standard output. Added many debugging dprintf()'s.

Change the amd64 boot configuration to load vfs and fat.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/amd64/Makefile.inc

    r26f2af0 r47a776f9  
    3232        $(USPACEDIR)/srv/fb/fb \
    3333        $(USPACEDIR)/srv/kbd/kbd \
     34        $(USPACEDIR)/srv/vfs/vfs \
     35        $(USPACEDIR)/srv/fs/fat/fat \
    3436        $(USPACEDIR)/srv/console/console \
    3537        $(USPACEDIR)/app/init/init \
  • boot/arch/amd64/grub/menu.lst

    r26f2af0 r47a776f9  
    1414module /boot/tester
    1515module /boot/klog
     16module /boot/fat
     17module /boot/vfs
  • uspace/srv/fs/fat/Makefile

    r26f2af0 r47a776f9  
    5858
    5959$(OUTPUT): $(OBJECTS) $(LIBS)
    60         $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     60        $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    6161
    6262disasm:
  • uspace/srv/fs/fat/fat.c

    r26f2af0 r47a776f9  
    4242#include <errno.h>
    4343#include <unistd.h>
     44#include <stdio.h>>
    4445#include "../../vfs/vfs.h"
     46
     47#define dprintf(...)    printf(__VA_ARGS__)
    4548
    4649vfs_info_t fat_vfs_info = {
     
    6568void fat_connection(ipc_callid_t iid, ipc_call_t *icall)
    6669{
     70        dprintf("Callback connection established.\n");
    6771        while (1) {
    6872                ipc_callid_t callid;
     
    7680int main(int argc, char **argv)
    7781{
    78         ipcarg_t vfs_phone;
     82        int vfs_phone;
     83
     84        printf("FAT: HelenOS FAT file system server.\n");
    7985
    8086        vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0);
    81         while (vfs_phone != EOK) {
     87        while (vfs_phone < EOK) {
    8288                usleep(10000);
    8389                vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0);
     
    108114
    109115        async_new_connection(phonehash, 0, NULL, fat_connection);
     116
     117        /*
     118         * Pick up the answer for the request to the VFS_REQUEST call.
     119         */
     120        async_wait_for(req, NULL);
     121        dprintf("FAT filesystem registered.\n");
     122        async_manager();
    110123        return 0;
    111124}
  • uspace/srv/vfs/Makefile

    r26f2af0 r47a776f9  
    5959
    6060$(OUTPUT): $(OBJECTS) $(LIBS)
    61         $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     61        $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    6262
    6363disasm:
  • uspace/srv/vfs/vfs.c

    r26f2af0 r47a776f9  
    4040#include <async.h>
    4141#include <errno.h>
     42#include <stdio.h>
    4243#include <stdlib.h>
    4344#include <string.h>
     
    4849#include "vfs.h"
    4950
     51
     52#define dprintf(...)    printf(__VA_ARGS__)
     53
    5054atomic_t fs_head_futex = FUTEX_INITIALIZER;
    5155link_t fs_head;
     
    6569         * characters [a-z]+[a-z0-9_-]*.
    6670         */
    67         if (!islower(info->name[0]))
    68                 return false;
     71        if (!islower(info->name[0])) {
     72                dprintf("The name doesn't start with a lowercase character.\n");
     73                return false;
     74        }
    6975        for (i = 1; i < FS_NAME_MAXLEN; i++) {
    7076                if (!(islower(info->name[i]) || isdigit(info->name[i])) &&
    7177                    (info->name[i] != '-') && (info->name[i] != '_')) {
    72                         if (info->name[i] == '\0')
     78                        if (info->name[i] == '\0') {
    7379                                break;
    74                         else
     80                        } else {
     81                                dprintf("The name contains illegal "
     82                                    "characters.\n");
    7583                                return false;
     84                        }
    7685                }
    7786        }
     
    8190         * Check if the FS implements mandatory VFS operations.
    8291         */
    83         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_REGISTER)] != VFS_OP_DEFINED)
    84                 return false;
    85         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] != VFS_OP_DEFINED)
    86                 return false;
    87         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] != VFS_OP_DEFINED)
    88                 return false;
    89         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] != VFS_OP_DEFINED)
    90                 return false;
    91         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_OPEN)] != VFS_OP_DEFINED)
    92                 return false;
    93         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] != VFS_OP_DEFINED)
    94                 return false;
    95         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_READ)] != VFS_OP_DEFINED)
    96                 return false;
     92        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_REGISTER)] != VFS_OP_DEFINED) {
     93                dprintf("Operation VFS_REGISTER not defined by the client.\n");
     94                return false;
     95        }
     96        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] != VFS_OP_DEFINED) {
     97                dprintf("Operation VFS_MOUNT not defined by the client.\n");
     98                return false;
     99        }
     100        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] != VFS_OP_DEFINED) {
     101                dprintf("Operation VFS_UNMOUNT not defined by the client.\n");
     102                return false;
     103        }
     104        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] != VFS_OP_DEFINED) {
     105                dprintf("Operation VFS_LOOKUP not defined by the client.\n");
     106                return false;
     107        }
     108        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_OPEN)] != VFS_OP_DEFINED) {
     109                dprintf("Operation VFS_OPEN not defined by the client.\n");
     110                return false;
     111        }
     112        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] != VFS_OP_DEFINED) {
     113                dprintf("Operation VFS_CLOSE not defined by the client.\n");
     114                return false;
     115        }
     116        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_READ)] != VFS_OP_DEFINED) {
     117                dprintf("Operation VFS_READ not defined by the client.\n");
     118                return false;
     119        }
    97120       
    98121        /*
     
    100123         */
    101124        for (i = VFS_FIRST; i < VFS_LAST; i++) {
    102                 if ((IPC_METHOD_TO_VFS_OP(i) != VFS_OP_NULL) &&
    103                     (IPC_METHOD_TO_VFS_OP(i) != VFS_OP_DEFAULT) &&
    104                     (IPC_METHOD_TO_VFS_OP(i) != VFS_OP_DEFINED))
    105                         return false;   
     125                if ((info->ops[IPC_METHOD_TO_VFS_OP(i)] != VFS_OP_NULL) &&
     126                    (info->ops[IPC_METHOD_TO_VFS_OP(i)] != VFS_OP_DEFAULT) &&
     127                    (info->ops[IPC_METHOD_TO_VFS_OP(i)] != VFS_OP_DEFINED)) {
     128                        dprintf("Operation info not understood.\n");
     129                        return false;
     130                }
    106131        }
    107132        return true;
     
    120145        size_t size;
    121146
     147        dprintf("Processing VFS_REGISTER request received from %p.\n",
     148                request->in_phone_hash);
     149
    122150        /*
    123151         * The first call has to be IPC_M_DATA_SEND in which we receive the
     
    127155                /*
    128156                 * The client doesn't obey the same protocol as we do.
    129                  */
     157                 */
     158                dprintf("Receiving of VFS info failed.\n");
    130159                ipc_answer_fast(callid, EINVAL, 0, 0);
    131160                ipc_answer_fast(rid, EINVAL, 0, 0);
    132161                return;
    133162        }
     163       
     164        dprintf("VFS info received, size = %d\n", size);
    134165       
    135166        /*
     
    142173                 * the info structure.
    143174                 */
     175                dprintf("Received VFS info has bad size.\n");
    144176                ipc_answer_fast(callid, EINVAL, 0, 0);
    145177                ipc_answer_fast(rid, EINVAL, 0, 0);
     
    153185        fs_info = (fs_info_t *) malloc(sizeof(fs_info_t));
    154186        if (!fs_info) {
     187                dprintf("Could not allocate memory for FS info.\n");
    155188                ipc_answer_fast(callid, ENOMEM, 0, 0);
    156189                ipc_answer_fast(rid, ENOMEM, 0, 0);
     
    160193               
    161194        rc = ipc_data_deliver(callid, &call, &fs_info->vfs_info, size);
    162         if (!rc) {
     195        if (rc != EOK) {
     196                dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n",
     197                    rc);
    163198                free(fs_info);
    164199                ipc_answer_fast(callid, rc, 0, 0);
     
    166201                return;
    167202        }
     203
     204        dprintf("VFS info delivered.\n");
    168205               
    169206        if (!vfs_info_sane(&fs_info->vfs_info)) {
     
    188225                         * We already register a fs like this.
    189226                         */
     227                        dprintf("FS is already registered.\n");
    190228                        futex_up(&fs_head_futex);
    191229                        free(fs_info);
     
    199237         * Add fs_info to the list of registered FS's.
    200238         */
     239        dprintf("Adding FS into the registered list.\n");
    201240        list_append(&fs_info->fs_link, &fs_head);
    202241
     
    213252        callid = async_get_call(&call);
    214253        if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
     254                dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
    215255                list_remove(&fs_info->fs_link);
    216256                futex_up(&fs_head_futex);
     
    223263        ipc_answer_fast(callid, EOK, 0, 0);
    224264
     265        dprintf("Callback connection to FS created.\n");
     266
    225267        futex_up(&fs_head_futex);
    226268
     
    229271         */
    230272        ipc_answer_fast(rid, EOK, 0, 0);
     273        dprintf("\"%s\" filesystem successfully registered.\n",
     274            fs_info->vfs_info.name);
    231275}
    232276
     
    234278{
    235279        bool keep_on_going = 1;
     280
     281        printf("Connection opened from %p\n", icall->in_phone_hash);
    236282
    237283        /*
     
    256302
    257303                callid = async_get_call(&call);
     304
     305                printf("Received call, method=%d\n", IPC_GET_METHOD(call));
    258306               
    259307                switch (IPC_GET_METHOD(call)) {
     
    287335        ipcarg_t phonead;
    288336
     337        printf("VFS: HelenOS VFS server\n");
     338
    289339        list_initialize(&fs_head);
    290340        async_set_client_connection(vfs_connection);
Note: See TracChangeset for help on using the changeset viewer.