/branches/dynload/uspace/srv/fs/devfs/devfs.c |
---|
File deleted |
/branches/dynload/uspace/srv/fs/devfs/devfs_ops.c |
---|
File deleted |
/branches/dynload/uspace/srv/fs/devfs/devfs.h |
---|
File deleted |
/branches/dynload/uspace/srv/fs/devfs/Makefile |
---|
File deleted |
/branches/dynload/uspace/srv/fs/devfs/devfs_ops.h |
---|
File deleted |
/branches/dynload/uspace/srv/fs/tmpfs/tmpfs.h |
---|
38,7 → 38,7 |
#include <atomic.h> |
#include <sys/types.h> |
#include <bool.h> |
#include <adt/hash_table.h> |
#include <libadt/hash_table.h> |
#ifndef dprintf |
#define dprintf(...) printf(__VA_ARGS__) |
86,11 → 86,7 |
extern void tmpfs_read(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_write(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_truncate(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_stat(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_close(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_destroy(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_open_node(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_sync(ipc_callid_t, ipc_call_t *); |
extern bool tmpfs_restore(dev_handle_t); |
/branches/dynload/uspace/srv/fs/tmpfs/tmpfs_dump.c |
---|
54,8 → 54,8 |
} __attribute__((packed)); |
static bool |
tmpfs_restore_recursion(dev_handle_t dev, off_t *bufpos, size_t *buflen, |
off_t *pos, fs_node_t *pfn) |
tmpfs_restore_recursion(int dev, off_t *bufpos, size_t *buflen, off_t *pos, |
fs_node_t *pfn) |
{ |
struct rdentry entry; |
libfs_ops_t *ops = &tmpfs_libfs_ops; |
67,8 → 67,8 |
tmpfs_node_t *nodep; |
uint32_t size; |
if (block_seqread(dev, bufpos, buflen, pos, &entry, |
sizeof(entry), TMPFS_BLOCK_SIZE) != EOK) |
if (block_read(dev, bufpos, buflen, pos, &entry, sizeof(entry), |
TMPFS_BLOCK_SIZE) != EOK) |
return false; |
entry.len = uint32_t_le2host(entry.len); |
87,7 → 87,7 |
return false; |
} |
if (block_seqread(dev, bufpos, buflen, pos, fname, |
if (block_read(dev, bufpos, buflen, pos, fname, |
entry.len, TMPFS_BLOCK_SIZE) != EOK) { |
ops->destroy(fn); |
free(fname); |
103,7 → 103,7 |
} |
free(fname); |
if (block_seqread(dev, bufpos, buflen, pos, &size, |
if (block_read(dev, bufpos, buflen, pos, &size, |
sizeof(size), TMPFS_BLOCK_SIZE) != EOK) |
return false; |
115,7 → 115,7 |
return false; |
nodep->size = size; |
if (block_seqread(dev, bufpos, buflen, pos, nodep->data, |
if (block_read(dev, bufpos, buflen, pos, nodep->data, |
size, TMPFS_BLOCK_SIZE) != EOK) |
return false; |
131,7 → 131,7 |
return false; |
} |
if (block_seqread(dev, bufpos, buflen, pos, fname, |
if (block_read(dev, bufpos, buflen, pos, fname, |
entry.len, TMPFS_BLOCK_SIZE) != EOK) { |
ops->destroy(fn); |
free(fname); |
174,7 → 174,7 |
off_t pos = 0; |
char tag[6]; |
if (block_seqread(dev, &bufpos, &buflen, &pos, tag, 5, |
if (block_read(dev, &bufpos, &buflen, &pos, tag, 5, |
TMPFS_BLOCK_SIZE) != EOK) |
goto error; |
/branches/dynload/uspace/srv/fs/tmpfs/tmpfs_ops.c |
---|
47,7 → 47,7 |
#include <stdio.h> |
#include <assert.h> |
#include <sys/types.h> |
#include <adt/hash_table.h> |
#include <libadt/hash_table.h> |
#include <as.h> |
#include <libfs.h> |
250,7 → 250,6 |
free(nodep); |
return NULL; |
} |
fs_node_initialize(nodep->bp); |
nodep->bp->data = nodep; /* link the FS and TMPFS nodes */ |
if (!tmpfs_root_get(dev_handle)) |
nodep->index = TMPFS_SOME_ROOT; |
409,7 → 408,12 |
void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_mount(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request); |
dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
fs_index_t mp_index = (fs_index_t) IPC_GET_ARG2(*request); |
fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request); |
dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request); |
ipc_answer_0(rid, ENOTSUP); |
} |
void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request) |
596,11 → 600,6 |
ipc_answer_0(rid, EOK); |
} |
void tmpfs_close(ipc_callid_t rid, ipc_call_t *request) |
{ |
ipc_answer_0(rid, EOK); |
} |
void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request) |
{ |
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
623,22 → 622,6 |
ipc_answer_0(rid, rc); |
} |
void tmpfs_open_node(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_open_node(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request); |
} |
void tmpfs_stat(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_stat(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request); |
} |
void tmpfs_sync(ipc_callid_t rid, ipc_call_t *request) |
{ |
/* Dummy implementation */ |
ipc_answer_0(rid, EOK); |
} |
/** |
* @} |
*/ |
*/ |
/branches/dynload/uspace/srv/fs/tmpfs/tmpfs.c |
---|
96,41 → 96,27 |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
return; |
case VFS_OUT_MOUNTED: |
case VFS_MOUNTED: |
tmpfs_mounted(callid, &call); |
break; |
case VFS_OUT_MOUNT: |
case VFS_MOUNT: |
tmpfs_mount(callid, &call); |
break; |
case VFS_OUT_LOOKUP: |
case VFS_LOOKUP: |
tmpfs_lookup(callid, &call); |
break; |
case VFS_OUT_READ: |
case VFS_READ: |
tmpfs_read(callid, &call); |
break; |
case VFS_OUT_WRITE: |
case VFS_WRITE: |
tmpfs_write(callid, &call); |
break; |
case VFS_OUT_TRUNCATE: |
case VFS_TRUNCATE: |
tmpfs_truncate(callid, &call); |
break; |
case VFS_OUT_CLOSE: |
tmpfs_close(callid, &call); |
break; |
case VFS_OUT_DESTROY: |
case VFS_DESTROY: |
tmpfs_destroy(callid, &call); |
break; |
case VFS_OUT_OPEN_NODE: |
tmpfs_open_node(callid, &call); |
break; |
case VFS_OUT_STAT: |
tmpfs_stat(callid, &call); |
break; |
case VFS_OUT_SYNC: |
tmpfs_sync(callid, &call); |
break; |
default: |
ipc_answer_0(callid, ENOTSUP); |
break; |
152,7 → 138,7 |
printf(NAME ": Unable to connect to VFS\n"); |
return -1; |
} |
int rc = fs_register(vfs_phone, &tmpfs_reg, &tmpfs_vfs_info, |
tmpfs_connection); |
if (rc != EOK) { |
/branches/dynload/uspace/srv/fs/tmpfs/Makefile |
---|
72,7 → 72,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dynload/uspace/srv/fs/fat/fat.h |
---|
35,7 → 35,6 |
#include "fat_fat.h" |
#include <ipc/ipc.h> |
#include <fibril_sync.h> |
#include <libfs.h> |
#include <atomic.h> |
#include <sys/types.h> |
161,7 → 160,7 |
/** Used indices (index) hash table link. */ |
link_t uih_link; |
fibril_mutex_t lock; |
futex_t lock; |
dev_handle_t dev_handle; |
fs_index_t index; |
/** |
182,7 → 181,7 |
/** Back pointer to the FS node. */ |
fs_node_t *bp; |
fibril_mutex_t lock; |
futex_t lock; |
fat_node_type_t type; |
fat_idx_t *idx; |
/** |
207,12 → 206,7 |
extern void fat_read(ipc_callid_t, ipc_call_t *); |
extern void fat_write(ipc_callid_t, ipc_call_t *); |
extern void fat_truncate(ipc_callid_t, ipc_call_t *); |
extern void fat_stat(ipc_callid_t, ipc_call_t *); |
extern void fat_close(ipc_callid_t, ipc_call_t *); |
extern void fat_destroy(ipc_callid_t, ipc_call_t *); |
extern void fat_open_node(ipc_callid_t, ipc_call_t *); |
extern void fat_stat(ipc_callid_t, ipc_call_t *); |
extern void fat_sync(ipc_callid_t, ipc_call_t *); |
extern fat_idx_t *fat_idx_get_new(dev_handle_t); |
extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned); |
/branches/dynload/uspace/srv/fs/fat/fat_ops.c |
---|
48,10 → 48,10 |
#include <errno.h> |
#include <string.h> |
#include <byteorder.h> |
#include <adt/hash_table.h> |
#include <adt/list.h> |
#include <libadt/hash_table.h> |
#include <libadt/list.h> |
#include <assert.h> |
#include <fibril_sync.h> |
#include <futex.h> |
#include <sys/mman.h> |
#include <align.h> |
58,8 → 58,8 |
#define FAT_NODE(node) ((node) ? (fat_node_t *) (node)->data : NULL) |
#define FS_NODE(node) ((node) ? (node)->bp : NULL) |
/** Mutex protecting the list of cached free FAT nodes. */ |
static FIBRIL_MUTEX_INITIALIZE(ffn_mutex); |
/** Futex protecting the list of cached free FAT nodes. */ |
static futex_t ffn_futex = FUTEX_INITIALIZER; |
/** List of cached free FAT nodes. */ |
static LIST_INITIALIZE(ffn_head); |
66,7 → 66,7 |
static void fat_node_initialize(fat_node_t *node) |
{ |
fibril_mutex_initialize(&node->lock); |
futex_initialize(&node->lock, 1); |
node->bp = NULL; |
node->idx = NULL; |
node->type = 0; |
115,30 → 115,30 |
fs_node_t *fn; |
fat_node_t *nodep; |
fibril_mutex_lock(&ffn_mutex); |
futex_down(&ffn_futex); |
if (!list_empty(&ffn_head)) { |
/* Try to use a cached free node structure. */ |
fat_idx_t *idxp_tmp; |
nodep = list_get_instance(ffn_head.next, fat_node_t, ffn_link); |
if (!fibril_mutex_trylock(&nodep->lock)) |
if (futex_trydown(&nodep->lock) == ESYNCH_WOULD_BLOCK) |
goto skip_cache; |
idxp_tmp = nodep->idx; |
if (!fibril_mutex_trylock(&idxp_tmp->lock)) { |
fibril_mutex_unlock(&nodep->lock); |
if (futex_trydown(&idxp_tmp->lock) == ESYNCH_WOULD_BLOCK) { |
futex_up(&nodep->lock); |
goto skip_cache; |
} |
list_remove(&nodep->ffn_link); |
fibril_mutex_unlock(&ffn_mutex); |
futex_up(&ffn_futex); |
if (nodep->dirty) |
fat_node_sync(nodep); |
idxp_tmp->nodep = NULL; |
fibril_mutex_unlock(&nodep->lock); |
fibril_mutex_unlock(&idxp_tmp->lock); |
futex_up(&nodep->lock); |
futex_up(&idxp_tmp->lock); |
fn = FS_NODE(nodep); |
} else { |
skip_cache: |
/* Try to allocate a new node structure. */ |
fibril_mutex_unlock(&ffn_mutex); |
futex_up(&ffn_futex); |
fn = (fs_node_t *)malloc(sizeof(fs_node_t)); |
if (!fn) |
return NULL; |
149,7 → 149,6 |
} |
} |
fat_node_initialize(nodep); |
fs_node_initialize(fn); |
fn->data = nodep; |
nodep->bp = fn; |
175,10 → 174,10 |
* We are lucky. |
* The node is already instantiated in memory. |
*/ |
fibril_mutex_lock(&idxp->nodep->lock); |
futex_down(&idxp->nodep->lock); |
if (!idxp->nodep->refcnt++) |
list_remove(&idxp->nodep->ffn_link); |
fibril_mutex_unlock(&idxp->nodep->lock); |
futex_up(&idxp->nodep->lock); |
return idxp->nodep; |
} |
268,7 → 267,7 |
return NULL; |
/* idxp->lock held */ |
nodep = fat_node_get_core(idxp); |
fibril_mutex_unlock(&idxp->lock); |
futex_up(&idxp->lock); |
return FS_NODE(nodep); |
} |
277,12 → 276,12 |
fat_node_t *nodep = FAT_NODE(fn); |
bool destroy = false; |
fibril_mutex_lock(&nodep->lock); |
futex_down(&nodep->lock); |
if (!--nodep->refcnt) { |
if (nodep->idx) { |
fibril_mutex_lock(&ffn_mutex); |
futex_down(&ffn_futex); |
list_append(&nodep->ffn_link, &ffn_head); |
fibril_mutex_unlock(&ffn_mutex); |
futex_up(&ffn_futex); |
} else { |
/* |
* The node does not have any index structure associated |
293,7 → 292,7 |
destroy = true; |
} |
} |
fibril_mutex_unlock(&nodep->lock); |
futex_up(&nodep->lock); |
if (destroy) { |
free(nodep->bp); |
free(nodep); |
360,7 → 359,7 |
nodep->idx = idxp; |
idxp->nodep = nodep; |
fibril_mutex_unlock(&idxp->lock); |
futex_up(&idxp->lock); |
return FS_NODE(nodep); |
} |
402,7 → 401,7 |
fat_dentry_t *d; |
fat_bs_t *bs; |
block_t *b; |
unsigned i, j; |
int i, j; |
uint16_t bps; |
unsigned dps; |
unsigned blocks; |
409,16 → 408,16 |
fat_cluster_t mcl, lcl; |
int rc; |
fibril_mutex_lock(&childp->lock); |
futex_down(&childp->lock); |
if (childp->lnkcnt == 1) { |
/* |
* On FAT, we don't support multiple hard links. |
*/ |
fibril_mutex_unlock(&childp->lock); |
futex_up(&childp->lock); |
return EMLINK; |
} |
assert(childp->lnkcnt == 0); |
fibril_mutex_unlock(&childp->lock); |
futex_up(&childp->lock); |
if (!fat_dentry_name_verify(name)) { |
/* |
432,7 → 431,7 |
* a new one. |
*/ |
fibril_mutex_lock(&parentp->idx->lock); |
futex_down(&parentp->idx->lock); |
bs = block_bb_get(parentp->idx->dev_handle); |
bps = uint16_t_le2host(bs->bps); |
dps = bps / sizeof(fat_dentry_t); |
463,12 → 462,12 |
*/ |
if (parentp->idx->pfc == FAT_CLST_ROOT) { |
/* Can't grow the root directory. */ |
fibril_mutex_unlock(&parentp->idx->lock); |
futex_up(&parentp->idx->lock); |
return ENOSPC; |
} |
rc = fat_alloc_clusters(bs, parentp->idx->dev_handle, 1, &mcl, &lcl); |
if (rc != EOK) { |
fibril_mutex_unlock(&parentp->idx->lock); |
futex_up(&parentp->idx->lock); |
return rc; |
} |
fat_append_clusters(bs, parentp, mcl); |
491,9 → 490,9 |
fat_dentry_name_set(d, name); |
b->dirty = true; /* need to sync block */ |
block_put(b); |
fibril_mutex_unlock(&parentp->idx->lock); |
futex_up(&parentp->idx->lock); |
fibril_mutex_lock(&childp->idx->lock); |
futex_down(&childp->idx->lock); |
/* |
* If possible, create the Sub-directory Identifier Entry and the |
529,12 → 528,12 |
childp->idx->pfc = parentp->firstc; |
childp->idx->pdi = i * dps + j; |
fibril_mutex_unlock(&childp->idx->lock); |
futex_up(&childp->idx->lock); |
fibril_mutex_lock(&childp->lock); |
futex_down(&childp->lock); |
childp->lnkcnt = 1; |
childp->dirty = true; /* need to sync node */ |
fibril_mutex_unlock(&childp->lock); |
futex_up(&childp->lock); |
/* |
* Hash in the index structure into the position hash. |
559,10 → 558,10 |
if (fat_has_children(cfn)) |
return ENOTEMPTY; |
fibril_mutex_lock(&parentp->lock); |
fibril_mutex_lock(&childp->lock); |
futex_down(&parentp->lock); |
futex_down(&childp->lock); |
assert(childp->lnkcnt == 1); |
fibril_mutex_lock(&childp->idx->lock); |
futex_down(&childp->idx->lock); |
bs = block_bb_get(childp->idx->dev_handle); |
bps = uint16_t_le2host(bs->bps); |
581,11 → 580,11 |
/* clear position information */ |
childp->idx->pfc = FAT_CLST_RES0; |
childp->idx->pdi = 0; |
fibril_mutex_unlock(&childp->idx->lock); |
futex_up(&childp->idx->lock); |
childp->lnkcnt = 0; |
childp->dirty = true; |
fibril_mutex_unlock(&childp->lock); |
fibril_mutex_unlock(&parentp->lock); |
futex_up(&childp->lock); |
futex_up(&parentp->lock); |
return EOK; |
} |
602,7 → 601,7 |
fat_dentry_t *d; |
block_t *b; |
fibril_mutex_lock(&parentp->idx->lock); |
futex_down(&parentp->idx->lock); |
bs = block_bb_get(parentp->idx->dev_handle); |
bps = uint16_t_le2host(bs->bps); |
dps = bps / sizeof(fat_dentry_t); |
617,7 → 616,7 |
continue; |
case FAT_DENTRY_LAST: |
block_put(b); |
fibril_mutex_unlock(&parentp->idx->lock); |
futex_up(&parentp->idx->lock); |
return NULL; |
default: |
case FAT_DENTRY_VALID: |
636,7 → 635,7 |
fat_idx_t *idx = fat_idx_get_by_pos( |
parentp->idx->dev_handle, parentp->firstc, |
i * dps + j); |
fibril_mutex_unlock(&parentp->idx->lock); |
futex_up(&parentp->idx->lock); |
if (!idx) { |
/* |
* Can happen if memory is low or if we |
646,7 → 645,7 |
return NULL; |
} |
nodep = fat_node_get_core(idx); |
fibril_mutex_unlock(&idx->lock); |
futex_up(&idx->lock); |
block_put(b); |
return FS_NODE(nodep); |
} |
654,7 → 653,7 |
block_put(b); |
} |
fibril_mutex_unlock(&parentp->idx->lock); |
futex_up(&parentp->idx->lock); |
return NULL; |
} |
686,7 → 685,7 |
if (nodep->type != FAT_DIRECTORY) |
return false; |
fibril_mutex_lock(&nodep->idx->lock); |
futex_down(&nodep->idx->lock); |
bs = block_bb_get(nodep->idx->dev_handle); |
bps = uint16_t_le2host(bs->bps); |
dps = bps / sizeof(fat_dentry_t); |
705,22 → 704,22 |
continue; |
case FAT_DENTRY_LAST: |
block_put(b); |
fibril_mutex_unlock(&nodep->idx->lock); |
futex_up(&nodep->idx->lock); |
return false; |
default: |
case FAT_DENTRY_VALID: |
block_put(b); |
fibril_mutex_unlock(&nodep->idx->lock); |
futex_up(&nodep->idx->lock); |
return true; |
} |
block_put(b); |
fibril_mutex_unlock(&nodep->idx->lock); |
futex_up(&nodep->idx->lock); |
return true; |
} |
block_put(b); |
} |
fibril_mutex_unlock(&nodep->idx->lock); |
futex_up(&nodep->idx->lock); |
return false; |
} |
770,7 → 769,6 |
void fat_mounted(ipc_callid_t rid, ipc_call_t *request) |
{ |
dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
enum cache_mode cmode; |
fat_bs_t *bs; |
uint16_t bps; |
uint16_t rde; |
798,12 → 796,6 |
} |
opts[size] = '\0'; |
/* Check for option enabling write through. */ |
if (str_cmp(opts, "wtcache") == 0) |
cmode = CACHE_MODE_WT; |
else |
cmode = CACHE_MODE_WB; |
/* initialize libblock */ |
rc = block_init(dev_handle, BS_SIZE); |
if (rc != EOK) { |
833,7 → 825,7 |
} |
/* Initialize the block cache */ |
rc = block_cache_init(dev_handle, bps, 0 /* XXX */, cmode); |
rc = block_cache_init(dev_handle, bps, 0 /* XXX */); |
if (rc != EOK) { |
block_fini(dev_handle); |
ipc_answer_0(rid, rc); |
855,7 → 847,6 |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
fs_node_initialize(rfn); |
fat_node_t *rootp = (fat_node_t *)malloc(sizeof(fat_node_t)); |
if (!rootp) { |
free(rfn); |
888,7 → 879,7 |
rootp->bp = rfn; |
rfn->data = rootp; |
fibril_mutex_unlock(&ridxp->lock); |
futex_up(&ridxp->lock); |
ipc_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt); |
} |
895,7 → 886,7 |
void fat_mount(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_mount(&fat_libfs_ops, fat_reg.fs_handle, rid, request); |
ipc_answer_0(rid, ENOTSUP); |
} |
void fat_lookup(ipc_callid_t rid, ipc_call_t *request) |
1176,11 → 1167,6 |
return; |
} |
void fat_close(ipc_callid_t rid, ipc_call_t *request) |
{ |
ipc_answer_0(rid, EOK); |
} |
void fat_destroy(ipc_callid_t rid, ipc_call_t *request) |
{ |
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
1197,22 → 1183,6 |
ipc_answer_0(rid, rc); |
} |
void fat_open_node(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_open_node(&fat_libfs_ops, fat_reg.fs_handle, rid, request); |
} |
void fat_stat(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_stat(&fat_libfs_ops, fat_reg.fs_handle, rid, request); |
} |
void fat_sync(ipc_callid_t rid, ipc_call_t *request) |
{ |
/* Dummy implementation */ |
ipc_answer_0(rid, EOK); |
} |
/** |
* @} |
*/ |
*/ |
/branches/dynload/uspace/srv/fs/fat/fat.c |
---|
89,41 → 89,27 |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
return; |
case VFS_OUT_MOUNTED: |
case VFS_MOUNTED: |
fat_mounted(callid, &call); |
break; |
case VFS_OUT_MOUNT: |
case VFS_MOUNT: |
fat_mount(callid, &call); |
break; |
case VFS_OUT_LOOKUP: |
case VFS_LOOKUP: |
fat_lookup(callid, &call); |
break; |
case VFS_OUT_READ: |
case VFS_READ: |
fat_read(callid, &call); |
break; |
case VFS_OUT_WRITE: |
case VFS_WRITE: |
fat_write(callid, &call); |
break; |
case VFS_OUT_TRUNCATE: |
case VFS_TRUNCATE: |
fat_truncate(callid, &call); |
break; |
case VFS_OUT_STAT: |
fat_stat(callid, &call); |
break; |
case VFS_OUT_CLOSE: |
fat_close(callid, &call); |
break; |
case VFS_OUT_DESTROY: |
case VFS_DESTROY: |
fat_destroy(callid, &call); |
break; |
case VFS_OUT_OPEN_NODE: |
fat_open_node(callid, &call); |
break; |
case VFS_OUT_SYNC: |
fat_sync(callid, &call); |
break; |
default: |
ipc_answer_0(callid, ENOTSUP); |
break; |
/branches/dynload/uspace/srv/fs/fat/Makefile |
---|
74,7 → 74,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dynload/uspace/srv/fs/fat/fat_idx.c |
---|
39,10 → 39,10 |
#include "../../vfs/vfs.h" |
#include <errno.h> |
#include <string.h> |
#include <adt/hash_table.h> |
#include <adt/list.h> |
#include <libadt/hash_table.h> |
#include <libadt/list.h> |
#include <assert.h> |
#include <fibril_sync.h> |
#include <futex.h> |
/** Each instance of this type describes one interval of freed VFS indices. */ |
typedef struct { |
68,8 → 68,8 |
link_t freed_head; |
} unused_t; |
/** Mutex protecting the list of unused structures. */ |
static FIBRIL_MUTEX_INITIALIZE(unused_lock); |
/** Futex protecting the list of unused structures. */ |
static futex_t unused_futex = FUTEX_INITIALIZER; |
/** List of unused structures. */ |
static LIST_INITIALIZE(unused_head); |
89,7 → 89,7 |
link_t *l; |
if (lock) |
fibril_mutex_lock(&unused_lock); |
futex_down(&unused_futex); |
for (l = unused_head.next; l != &unused_head; l = l->next) { |
u = list_get_instance(l, unused_t, link); |
if (u->dev_handle == dev_handle) |
96,12 → 96,12 |
return u; |
} |
if (lock) |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return NULL; |
} |
/** Mutex protecting the up_hash and ui_hash. */ |
static FIBRIL_MUTEX_INITIALIZE(used_lock); |
/** Futex protecting the up_hash and ui_hash. */ |
static futex_t used_futex = FUTEX_INITIALIZER; |
/** |
* Global hash table of all used fat_idx_t structures. |
231,7 → 231,7 |
*/ |
*index = u->next++; |
--u->remaining; |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return true; |
} |
} else { |
244,7 → 244,7 |
list_remove(&f->link); |
free(f); |
} |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return true; |
} |
/* |
252,7 → 252,7 |
* theoretically still possible (e.g. too many open unlinked nodes or |
* too many zero-sized nodes). |
*/ |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return false; |
} |
302,7 → 302,7 |
if (lnk->prev != &u->freed_head) |
try_coalesce_intervals(lnk->prev, lnk, |
lnk); |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return; |
} |
if (f->last == index - 1) { |
310,7 → 310,7 |
if (lnk->next != &u->freed_head) |
try_coalesce_intervals(lnk, lnk->next, |
lnk); |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return; |
} |
if (index > f->first) { |
321,7 → 321,7 |
n->first = index; |
n->last = index; |
list_insert_before(&n->link, lnk); |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return; |
} |
335,7 → 335,7 |
n->last = index; |
list_append(&n->link, &u->freed_head); |
} |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
} |
static fat_idx_t *fat_idx_create(dev_handle_t dev_handle) |
352,7 → 352,7 |
link_initialize(&fidx->uph_link); |
link_initialize(&fidx->uih_link); |
fibril_mutex_initialize(&fidx->lock); |
futex_initialize(&fidx->lock, 1); |
fidx->dev_handle = dev_handle; |
fidx->pfc = FAT_CLST_RES0; /* no parent yet */ |
fidx->pdi = 0; |
365,10 → 365,10 |
{ |
fat_idx_t *fidx; |
fibril_mutex_lock(&used_lock); |
futex_down(&used_futex); |
fidx = fat_idx_create(dev_handle); |
if (!fidx) { |
fibril_mutex_unlock(&used_lock); |
futex_up(&used_futex); |
return NULL; |
} |
378,8 → 378,8 |
}; |
hash_table_insert(&ui_hash, ikey, &fidx->uih_link); |
fibril_mutex_lock(&fidx->lock); |
fibril_mutex_unlock(&used_lock); |
futex_down(&fidx->lock); |
futex_up(&used_futex); |
return fidx; |
} |
395,7 → 395,7 |
[UPH_PDI_KEY] = pdi, |
}; |
fibril_mutex_lock(&used_lock); |
futex_down(&used_futex); |
l = hash_table_find(&up_hash, pkey); |
if (l) { |
fidx = hash_table_get_instance(l, fat_idx_t, uph_link); |
402,7 → 402,7 |
} else { |
fidx = fat_idx_create(dev_handle); |
if (!fidx) { |
fibril_mutex_unlock(&used_lock); |
futex_up(&used_futex); |
return NULL; |
} |
417,8 → 417,8 |
hash_table_insert(&up_hash, pkey, &fidx->uph_link); |
hash_table_insert(&ui_hash, ikey, &fidx->uih_link); |
} |
fibril_mutex_lock(&fidx->lock); |
fibril_mutex_unlock(&used_lock); |
futex_down(&fidx->lock); |
futex_up(&used_futex); |
return fidx; |
} |
431,9 → 431,9 |
[UPH_PDI_KEY] = idx->pdi, |
}; |
fibril_mutex_lock(&used_lock); |
futex_down(&used_futex); |
hash_table_insert(&up_hash, pkey, &idx->uph_link); |
fibril_mutex_unlock(&used_lock); |
futex_up(&used_futex); |
} |
void fat_idx_hashout(fat_idx_t *idx) |
444,9 → 444,9 |
[UPH_PDI_KEY] = idx->pdi, |
}; |
fibril_mutex_lock(&used_lock); |
futex_down(&used_futex); |
hash_table_remove(&up_hash, pkey, 3); |
fibril_mutex_unlock(&used_lock); |
futex_up(&used_futex); |
} |
fat_idx_t * |
459,13 → 459,13 |
[UIH_INDEX_KEY] = index, |
}; |
fibril_mutex_lock(&used_lock); |
futex_down(&used_futex); |
l = hash_table_find(&ui_hash, ikey); |
if (l) { |
fidx = hash_table_get_instance(l, fat_idx_t, uih_link); |
fibril_mutex_lock(&fidx->lock); |
futex_down(&fidx->lock); |
} |
fibril_mutex_unlock(&used_lock); |
futex_up(&used_futex); |
return fidx; |
} |
483,7 → 483,7 |
assert(idx->pfc == FAT_CLST_RES0); |
fibril_mutex_lock(&used_lock); |
futex_down(&used_futex); |
/* |
* Since we can only free unlinked nodes, the index structure is not |
* present in the position hash (uph). We therefore hash it out from |
490,7 → 490,7 |
* the index hash only. |
*/ |
hash_table_remove(&ui_hash, ikey, 2); |
fibril_mutex_unlock(&used_lock); |
futex_up(&used_futex); |
/* Release the VFS index. */ |
fat_index_free(idx->dev_handle, idx->index); |
/* Deallocate the structure. */ |
524,12 → 524,12 |
if (!u) |
return ENOMEM; |
unused_initialize(u, dev_handle); |
fibril_mutex_lock(&unused_lock); |
futex_down(&unused_futex); |
if (!unused_find(dev_handle, false)) |
list_append(&u->link, &unused_head); |
else |
rc = EEXIST; |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
return rc; |
} |
540,7 → 540,7 |
u = unused_find(dev_handle, true); |
assert(u); |
list_remove(&u->link); |
fibril_mutex_unlock(&unused_lock); |
futex_up(&unused_futex); |
while (!list_empty(&u->freed_head)) { |
freed_t *f; |
/branches/dynload/uspace/srv/fs/fat/fat_fat.c |
---|
45,15 → 45,14 |
#include <byteorder.h> |
#include <align.h> |
#include <assert.h> |
#include <fibril_sync.h> |
#include <mem.h> |
#include <futex.h> |
/** |
* The fat_alloc_lock mutex protects all copies of the File Allocation Table |
* The fat_alloc_lock futex protects all copies of the File Allocation Table |
* during allocation of clusters. The lock does not have to be held durring |
* deallocation of clusters. |
*/ |
static FIBRIL_MUTEX_INITIALIZE(fat_alloc_lock); |
static futex_t fat_alloc_lock = FUTEX_INITIALIZER; |
/** Walk the cluster chain. |
* |
326,7 → 325,7 |
/* |
* Search FAT1 for unused clusters. |
*/ |
fibril_mutex_lock(&fat_alloc_lock); |
futex_down(&fat_alloc_lock); |
for (b = 0, cl = 0; b < sf; b++) { |
blk = block_get(dev_handle, rscnt + b, BLOCK_FLAGS_NONE); |
for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) { |
350,7 → 349,7 |
*mcl = lifo[found - 1]; |
*lcl = lifo[0]; |
free(lifo); |
fibril_mutex_unlock(&fat_alloc_lock); |
futex_up(&fat_alloc_lock); |
return EOK; |
} |
} |
357,7 → 356,7 |
} |
block_put(blk); |
} |
fibril_mutex_unlock(&fat_alloc_lock); |
futex_up(&fat_alloc_lock); |
/* |
* We could not find enough clusters. Now we need to free the clusters |