kml_setup.c 1.44 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <asm/uaccess.h>

7 8 9 10
#include "intermezzo_fs.h"
#include "intermezzo_upcall.h"
#include "intermezzo_psdev.h"
#include "intermezzo_kml.h"
Linus Torvalds's avatar
Linus Torvalds committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

int kml_init (struct presto_file_set *fset)
{
        struct kml_fsdata *data;

        ENTRY;
        PRESTO_ALLOC (data, struct kml_fsdata *, sizeof (struct kml_fsdata));
        if (data == NULL) {
                EXIT;
                return -ENOMEM;
        }
        INIT_LIST_HEAD (&data->kml_reint_cache);
        INIT_LIST_HEAD (&data->kml_kop_cache);

        PRESTO_ALLOC (data->kml_buf, char *, KML_REINT_MAXBUF);
        if (data->kml_buf == NULL) {
                PRESTO_FREE (data, sizeof (struct kml_fsdata));
                EXIT;
                return -ENOMEM;
        }

        data->kml_maxsize = KML_REINT_MAXBUF;
        data->kml_len = 0;
        data->kml_reintpos = 0;
        data->kml_count = 0;
        fset->fset_kmldata = data;
        EXIT;
        return 0;
}

int kml_cleanup (struct presto_file_set *fset)
{
        struct kml_fsdata *data = fset->fset_kmldata;

        if (data == NULL)
                return 0;

        fset->fset_kmldata = NULL;
#if 0
        kml_sop_cleanup (&data->kml_reint_cache);
        kml_kop_cleanup (&data->kml_kop_cache);
#endif
        PRESTO_FREE (data->kml_buf, KML_REINT_MAXBUF);
        PRESTO_FREE (data, sizeof (struct kml_fsdata));
        return 0;
}