Subversion Repositories HelenOS

Rev

Rev 3519 | Rev 3526 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3519 Rev 3521
Line 38... Line 38...
38
#include "fat.h"
38
#include "fat.h"
39
#include "fat_dentry.h"
39
#include "fat_dentry.h"
40
#include "fat_fat.h"
40
#include "fat_fat.h"
41
#include "../../vfs/vfs.h"
41
#include "../../vfs/vfs.h"
42
#include <libfs.h>
42
#include <libfs.h>
-
 
43
#include <libblock.h>
43
#include <ipc/ipc.h>
44
#include <ipc/ipc.h>
44
#include <ipc/services.h>
45
#include <ipc/services.h>
45
#include <ipc/devmap.h>
46
#include <ipc/devmap.h>
46
#include <async.h>
47
#include <async.h>
47
#include <errno.h>
48
#include <errno.h>
Line 58... Line 59...
58
static futex_t ffn_futex = FUTEX_INITIALIZER;
59
static futex_t ffn_futex = FUTEX_INITIALIZER;
59
 
60
 
60
/** List of cached free FAT nodes. */
61
/** List of cached free FAT nodes. */
61
static LIST_INITIALIZE(ffn_head);
62
static LIST_INITIALIZE(ffn_head);
62
 
63
 
63
static int dev_phone = -1;      /* FIXME */
-
 
64
static void *dev_buffer = NULL;     /* FIXME */
-
 
65
 
-
 
66
block_t *block_get(dev_handle_t dev_handle, off_t offset, size_t bs)
-
 
67
{
-
 
68
    /* FIXME */
-
 
69
    block_t *b;
-
 
70
    off_t bufpos = 0;
-
 
71
    size_t buflen = 0;
-
 
72
    off_t pos = offset * bs;
-
 
73
 
-
 
74
    assert(dev_phone != -1);
-
 
75
    assert(dev_buffer);
-
 
76
 
-
 
77
    b = malloc(sizeof(block_t));
-
 
78
    if (!b)
-
 
79
        return NULL;
-
 
80
   
-
 
81
    b->data = malloc(bs);
-
 
82
    if (!b->data) {
-
 
83
        free(b);
-
 
84
        return NULL;
-
 
85
    }
-
 
86
    b->size = bs;
-
 
87
 
-
 
88
    if (!libfs_blockread(dev_phone, dev_buffer, &bufpos, &buflen, &pos,
-
 
89
        b->data, bs, bs)) {
-
 
90
        free(b->data);
-
 
91
        free(b);
-
 
92
        return NULL;
-
 
93
    }
-
 
94
 
-
 
95
    return b;
-
 
96
}
-
 
97
 
-
 
98
void block_put(block_t *block)
-
 
99
{
-
 
100
    /* FIXME */
-
 
101
    free(block->data);
-
 
102
    free(block);
-
 
103
}
-
 
104
 
-
 
105
static void fat_node_initialize(fat_node_t *node)
64
static void fat_node_initialize(fat_node_t *node)
106
{
65
{
107
    futex_initialize(&node->lock, 1);
66
    futex_initialize(&node->lock, 1);
108
    node->idx = NULL;
67
    node->idx = NULL;
109
    node->type = 0;
68
    node->type = 0;