Changeset efd4a72 in mainline


Ignore:
Timestamp:
2007-12-16T16:25:26Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c82d28
Parents:
74303b6
Message:

VFS work.
Move FS registration code to libfs.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libfs/libfs.c

    r74303b6 refd4a72  
    3636
    3737#include "libfs.h"
     38#include "../../srv/vfs/vfs.h"
     39#include <errno.h>
     40#include <async.h>
     41#include <ipc/ipc.h>
     42#include <as.h>
     43
     44/** Register file system server.
     45 *
     46 * This function abstracts away the tedious registration protocol from
     47 * file system implementations and lets them to reuse this registration glue
     48 * code.
     49 *
     50 * @param vfs_phone     Open phone for communication with VFS.
     51 * @param reg           File system registration structure. It will be
     52 *                      initialized by this function.
     53 * @param info          VFS info structure supplied by the file system
     54 *                      implementation.
     55 * @param conn          Connection fibril for handling all calls originating in
     56 *                      VFS.
     57 *
     58 * @return              EOK on success or a non-zero error code on errror.
     59 */
     60int fs_register(int vfs_phone, fs_reg_t *reg, vfs_info_t *info,
     61    async_client_conn_t conn)
     62{
     63        /*
     64         * Tell VFS that we are here and want to get registered.
     65         * We use the async framework because VFS will answer the request
     66         * out-of-order, when it knows that the operation succeeded or failed.
     67         */
     68        ipc_call_t answer;
     69        aid_t req = async_send_0(vfs_phone, VFS_REGISTER, &answer);
     70
     71        /*
     72         * Send our VFS info structure to VFS.
     73         */
     74        int rc = ipc_data_send(vfs_phone, info, sizeof(*info));
     75        if (rc != EOK) {
     76                async_wait_for(req, NULL);
     77                return rc;
     78        }
     79
     80        /*
     81         * Ask VFS for callback connection.
     82         */
     83        ipc_connect_to_me(vfs_phone, 0, 0, 0, &reg->vfs_phonehash);
     84
     85        /*
     86         * Allocate piece of address space for PLB.
     87         */
     88        reg->plb_ro = as_get_mappable_page(PLB_SIZE);
     89        if (!reg->plb_ro) {
     90                async_wait_for(req, NULL);
     91                return ENOMEM;
     92        }
     93
     94        /*
     95         * Request sharing the Path Lookup Buffer with VFS.
     96         */
     97        rc = ipc_call_sync_2_0(vfs_phone, IPC_M_AS_AREA_RECV,
     98            (ipcarg_t) reg->plb_ro, PLB_SIZE);
     99        if (rc) {
     100                async_wait_for(req, NULL);
     101                return rc;
     102        }
     103         
     104        /*
     105         * Pick up the answer for the request to the VFS_REQUEST call.
     106         */
     107        async_wait_for(req, NULL);
     108        reg->fs_handle = (int) IPC_GET_ARG1(answer);
     109       
     110        /*
     111         * Create a connection fibril to handle the callback connection.
     112         */
     113        async_new_connection(reg->vfs_phonehash, 0, NULL, conn);
     114       
     115        /*
     116         * Tell the async framework that other connections are to be handled by
     117         * the same connection fibril as well.
     118         */
     119        async_set_client_connection(conn);
     120
     121        return IPC_GET_RETVAL(answer);
     122}
    38123
    39124/** @}
  • uspace/lib/libfs/libfs.h

    r74303b6 refd4a72  
    3737#define LIBFS_LIBFS_H_
    3838
     39#include "../../srv/vfs/vfs.h"
     40#include <stdint.h>
     41#include <ipc/ipc.h>
     42#include <async.h>
     43
     44typedef struct {
     45        int fs_handle;          /**< File system handle. */
     46        ipcarg_t vfs_phonehash; /**< Initial VFS phonehash. */
     47        uint8_t *plb_ro;        /**< Read-only PLB view. */
     48} fs_reg_t;
     49
     50extern int fs_register(int, fs_reg_t *, vfs_info_t *, async_client_conn_t);
     51
    3952#endif
    4053
  • uspace/srv/fs/fat/Makefile

    r74303b6 refd4a72  
    3131
    3232LIBC_PREFIX = ../../../lib/libc
     33LIBFS_PREFIX = ../../../lib/libfs
    3334SOFTINT_PREFIX = ../../../lib/softint
    3435include $(LIBC_PREFIX)/Makefile.toolchain
    3536
    36 LIBS = $(LIBC_PREFIX)/libc.a
     37CFLAGS += -I $(LIBFS_PREFIX)
     38
     39LIBS = $(LIBC_PREFIX)/libc.a $(LIBFS_PREFIX)/libfs.a
    3740
    3841## Sources
  • uspace/srv/fs/fat/fat.c

    r74303b6 refd4a72  
    4444#include <unistd.h>
    4545#include <stdio.h>
    46 #include <as.h>
     46#include <libfs.h>
    4747#include "../../vfs/vfs.h"
    4848
     
    6464};
    6565
    66 uint8_t *plb_ro = NULL;
    67 
    68 int fs_handle = 0;
     66fs_reg_t fat_reg;
    6967
    7068/**
     
    133131        }
    134132       
    135         /*
    136          * Tell VFS that we are here and want to get registered.
    137          * We use the async framework because VFS will answer the request
    138          * out-of-order, when it knows that the operation succeeded or failed.
    139          */
    140         ipc_call_t answer;
    141         aid_t req = async_send_2(vfs_phone, VFS_REGISTER, 0, 0, &answer);
    142 
    143         /*
    144          * Send our VFS info structure to VFS.
    145          */
    146         int rc = ipc_data_send(vfs_phone, &fat_vfs_info, sizeof(fat_vfs_info));
     133        int rc;
     134        rc = fs_register(vfs_phone, &fat_reg, &fat_vfs_info, fat_connection);
    147135        if (rc != EOK) {
    148                 async_wait_for(req, NULL);
     136                printf("Failed to register the FAT file system (%d)\n", rc);
    149137                return rc;
    150138        }
    151 
    152         /*
    153          * Ask VFS for callback connection.
    154          */
    155         ipcarg_t phonehash;
    156         ipc_connect_to_me(vfs_phone, 0, 0, 0, &phonehash);
    157 
    158         /*
    159          * Allocate piece of address space for PLB.
    160          */
    161         plb_ro = as_get_mappable_page(PLB_SIZE);
    162         if (!plb_ro) {
    163                 async_wait_for(req, NULL);
    164                 return ENOMEM;
    165         }
    166 
    167         /*
    168          * Request sharing the Path Lookup Buffer with VFS.
    169          */
    170         rc = ipc_call_sync_2_0(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro,
    171             PLB_SIZE);
    172         if (rc) {
    173                 async_wait_for(req, NULL);
    174                 return rc;
    175         }
    176          
    177         /*
    178          * Pick up the answer for the request to the VFS_REQUEST call.
    179          */
    180         async_wait_for(req, NULL);
    181         fs_handle = (int) IPC_GET_ARG1(answer);
    182         dprintf("FAT filesystem registered, fs_handle=%d.\n", fs_handle);
    183 
    184         /*
    185          * Create a connection fibril to handle the callback connection.
    186          */
    187         async_new_connection(phonehash, 0, NULL, fat_connection);
    188139       
    189         /*
    190          * Tell the async framework that other connections are to be handled by
    191          * the same connection fibril as well.
    192          */
    193         async_set_client_connection(fat_connection);
     140        dprintf("FAT filesystem registered, fs_handle=%d.\n", fat_reg.fs_handle);
    194141
    195142        async_manager();
  • uspace/srv/fs/fat/fat.h

    r74303b6 refd4a72  
    3535
    3636#include <ipc/ipc.h>
     37#include <libfs.h>
    3738#include <atomic.h>
    3839#include <sys/types.h>
     
    134135} __attribute__ ((packed)) fat_dentry_t;
    135136
    136 extern uint8_t *plb_ro;
     137extern fs_reg_t fat_reg;
    137138
    138139extern void fat_lookup(ipc_callid_t, ipc_call_t *);
  • uspace/srv/fs/fat/fat_ops.c

    r74303b6 refd4a72  
    4242#include <errno.h>
    4343
    44 #define PLB_GET_CHAR(i)         (plb_ro[(i) % PLB_SIZE])
     44#define PLB_GET_CHAR(i)         (fat_reg.plb_ro[(i) % PLB_SIZE])
    4545
    4646#define FAT_NAME_LEN            8
Note: See TracChangeset for help on using the changeset viewer.