Changeset f2ec8c8 in mainline


Ignore:
Timestamp:
2008-03-11T20:33:53Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
923c39e
Parents:
8ad8e49
Message:

Introduce fs_handle_t, dev_handle_t and fs_index_t.

Location:
uspace
Files:
8 edited

Legend:

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

    r8ad8e49 rf2ec8c8  
    135135 * @param request       VFS_LOOKUP request data itself.
    136136 */
    137 void libfs_lookup(libfs_ops_t *ops, int fs_handle, ipc_callid_t rid,
     137void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
    138138    ipc_call_t *request)
    139139{
    140140        unsigned next = IPC_GET_ARG1(*request);
    141141        unsigned last = IPC_GET_ARG2(*request);
    142         int dev_handle = IPC_GET_ARG3(*request);
     142        dev_handle_t dev_handle = IPC_GET_ARG3(*request);
    143143        int lflag = IPC_GET_ARG4(*request);
    144         int index = IPC_GET_ARG5(*request); /* when L_LINK specified */
     144        fs_index_t index = IPC_GET_ARG5(*request); /* when L_LINK specified */
    145145
    146146        if (last < next)
  • uspace/lib/libfs/libfs.h

    r8ad8e49 rf2ec8c8  
    4444typedef struct {
    4545        bool (* match)(void *, void *, const char *);
    46         void * (* node_get)(int, int, unsigned long);
     46        void * (* node_get)(fs_handle_t, dev_handle_t, fs_index_t);
    4747        void * (* create)(int);
    4848        void (* destroy)(void *);
    4949        bool (* link)(void *, void *, const char *);
    5050        int (* unlink)(void *, void *);
    51         unsigned long (* index_get)(void *);
    52         unsigned long (* size_get)(void *);
     51        fs_index_t (* index_get)(void *);
     52        size_t (* size_get)(void *);
    5353        unsigned (* lnkcnt_get)(void *);
    5454        void *(* child_get)(void *);
     
    7575extern bool node_is_mp(int, unsigned long);
    7676
    77 extern void libfs_lookup(libfs_ops_t *, int, ipc_callid_t, ipc_call_t *);
     77extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    7878
    7979#endif
  • uspace/srv/fs/tmpfs/tmpfs.h

    r8ad8e49 rf2ec8c8  
    4444
    4545typedef struct tmpfs_dentry {
    46         unsigned long index;    /**< TMPFS node index. */
     46        fs_index_t index;       /**< TMPFS node index. */
    4747        link_t dh_link;         /**< Dentries hash table link. */
    4848        struct tmpfs_dentry *sibling;
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r8ad8e49 rf2ec8c8  
    7171/* Forward declarations of static functions. */
    7272static bool tmpfs_match(void *, void *, const char *);
    73 static void *tmpfs_node_get(int, int, unsigned long);
     73static void *tmpfs_node_get(fs_handle_t, dev_handle_t, fs_index_t);
    7474static void *tmpfs_create_node(int);
    7575static bool tmpfs_link_node(void *, void *, const char *);
     
    7878
    7979/* Implementation of helper functions. */
    80 static unsigned long tmpfs_index_get(void *nodep)
     80static fs_index_t tmpfs_index_get(void *nodep)
    8181{
    8282        return ((tmpfs_dentry_t *) nodep)->index;
    8383}
    8484
    85 static unsigned long tmpfs_size_get(void *nodep)
     85static size_t tmpfs_size_get(void *nodep)
    8686{
    8787        return ((tmpfs_dentry_t *) nodep)->size;
     
    170170};
    171171
    172 unsigned tmpfs_next_index = 1;
     172fs_index_t tmpfs_next_index = 1;
    173173
    174174typedef struct {
     
    263263}
    264264
    265 void *tmpfs_node_get(int fs_handle, int dev_handle, unsigned long index)
    266 {
    267         link_t *lnk = hash_table_find(&dentries, &index);
     265void *
     266tmpfs_node_get(fs_handle_t fs_handle, dev_handle_t dev_handle, fs_index_t index)
     267{
     268        unsigned long key = index;
     269        link_t *lnk = hash_table_find(&dentries, &key);
    268270        if (!lnk)
    269271                return NULL;
     
    290292
    291293        /* Insert the new node into the dentry hash table. */
    292         hash_table_insert(&dentries, &node->index, &node->dh_link);
     294        unsigned long key = node->index;
     295        hash_table_insert(&dentries, &key, &node->dh_link);
    293296        return (void *) node;
    294297}
     
    370373        assert(!dentry->sibling);
    371374
    372         unsigned long index = dentry->index;
    373         hash_table_remove(&dentries, &index, 1);
     375        unsigned long key = dentry->index;
     376        hash_table_remove(&dentries, &key, 1);
    374377
    375378        hash_table_destroy(&dentry->names);
     
    392395void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
    393396{
    394         int dev_handle = IPC_GET_ARG1(*request);
    395         unsigned long index = IPC_GET_ARG2(*request);
    396         off_t pos = IPC_GET_ARG3(*request);
     397        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     398        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     399        off_t pos = (off_t)IPC_GET_ARG3(*request);
    397400
    398401        /*
     
    400403         */
    401404        link_t *hlp;
    402         hlp = hash_table_find(&dentries, &index);
     405        unsigned long key = index;
     406        hlp = hash_table_find(&dentries, &key);
    403407        if (!hlp) {
    404408                ipc_answer_0(rid, ENOENT);
     
    464468void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
    465469{
    466         int dev_handle = IPC_GET_ARG1(*request);
    467         unsigned long index = IPC_GET_ARG2(*request);
    468         off_t pos = IPC_GET_ARG3(*request);
     470        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     471        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     472        off_t pos = (off_t)IPC_GET_ARG3(*request);
    469473
    470474        /*
     
    472476         */
    473477        link_t *hlp;
    474         hlp = hash_table_find(&dentries, &index);
     478        unsigned long key = index;
     479        hlp = hash_table_find(&dentries, &key);
    475480        if (!hlp) {
    476481                ipc_answer_0(rid, ENOENT);
     
    524529void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
    525530{
    526         int dev_handle = IPC_GET_ARG1(*request);
    527         unsigned long index = IPC_GET_ARG2(*request);
    528         size_t size = IPC_GET_ARG3(*request);
     531        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     532        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     533        size_t size = (off_t)IPC_GET_ARG3(*request);
    529534
    530535        /*
     
    532537         */
    533538        link_t *hlp;
    534         hlp = hash_table_find(&dentries, &index);
     539        unsigned long key = index;
     540        hlp = hash_table_find(&dentries, &key);
    535541        if (!hlp) {
    536542                ipc_answer_0(rid, ENOENT);
     
    561567void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
    562568{
    563         int dev_handle = IPC_GET_ARG1(*request);
    564         unsigned long index = IPC_GET_ARG2(*request);
     569        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     570        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    565571
    566572        link_t *hlp;
    567         hlp = hash_table_find(&dentries, &index);
     573        unsigned long key = index;
     574        hlp = hash_table_find(&dentries, &key);
    568575        if (!hlp) {
    569576                ipc_answer_0(rid, ENOENT);
  • uspace/srv/vfs/vfs.h

    r8ad8e49 rf2ec8c8  
    4747#define IPC_METHOD_TO_VFS_OP(m) ((m) - VFS_FIRST)       
    4848
     49/* Basic types. */
     50typedef int16_t fs_handle_t;
     51typedef int16_t dev_handle_t;
     52typedef uint32_t fs_index_t;
     53
    4954typedef enum {
    5055        VFS_READ = VFS_FIRST,
     
    107112        link_t fs_link;
    108113        vfs_info_t vfs_info;
    109         int fs_handle;
     114        fs_handle_t fs_handle;
    110115        futex_t phone_futex;    /**< Phone serializing futex. */
    111116        ipcarg_t phone;
     
    115120 * VFS_PAIR uniquely represents a file system instance.
    116121 */
    117 #define VFS_PAIR        \
    118         int fs_handle;  \
    119         int dev_handle;
     122#define VFS_PAIR                \
     123        fs_handle_t fs_handle;  \
     124        dev_handle_t dev_handle;
    120125
    121126/**
     
    128133#define VFS_TRIPLET     \
    129134        VFS_PAIR;       \
    130         uint64_t index;
     135        fs_index_t index;
    131136
    132137typedef struct {
     
    257262extern rwlock_t namespace_rwlock;
    258263
    259 extern int vfs_grab_phone(int);
     264extern int vfs_grab_phone(fs_handle_t);
    260265extern void vfs_release_phone(int);
    261266
    262 extern int fs_name_to_handle(char *, bool);
     267extern fs_handle_t fs_name_to_handle(char *, bool);
    263268
    264269extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *, vfs_pair_t *,
  • uspace/srv/vfs/vfs_lookup.c

    r8ad8e49 rf2ec8c8  
    8383                return EINVAL;
    8484       
    85         uint64_t index = 0;
     85        fs_index_t index = 0;
    8686        if (lflag & L_LINK) {
    8787                va_list ap;
    8888
    8989                va_start(ap, altroot);
    90                 index = va_arg(ap, uint64_t);
     90                index = va_arg(ap, fs_index_t);
    9191                va_end(ap);
    9292        }
     
    178178
    179179        if ((rc == EOK) && result) {
    180                 result->triplet.fs_handle = (int) IPC_GET_ARG1(answer);
    181                 result->triplet.dev_handle = (int) IPC_GET_ARG2(answer);
    182                 result->triplet.index = (uint64_t) IPC_GET_ARG3(answer);
     180                result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer);
     181                result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer);
     182                result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer);
    183183                result->size = (size_t) IPC_GET_ARG4(answer);
    184184                result->lnkcnt = (unsigned) IPC_GET_ARG5(answer);
  • uspace/srv/vfs/vfs_ops.c

    r8ad8e49 rf2ec8c8  
    5454
    5555/* Forward declarations of static functions. */
    56 static int vfs_truncate_internal(int, int, unsigned long, size_t);
     56static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t);
    5757
    5858/**
     
    6969};
    7070
    71 static int lookup_root(int fs_handle, int dev_handle, vfs_lookup_res_t *result)
     71static int
     72lookup_root(fs_handle_t fs_handle, dev_handle_t dev_handle,
     73    vfs_lookup_res_t *result)
    7274{
    7375        vfs_pair_t altroot = {
     
    8183void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
    8284{
    83         int dev_handle;
     85        dev_handle_t dev_handle;
    8486        vfs_node_t *mp_node = NULL;
    8587
     
    8991         * in the request.
    9092         */
    91         dev_handle = IPC_GET_ARG1(*request);
     93        dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
    9294
    9395        /*
     
    128130         * This will also give us its file system handle.
    129131         */
    130         int fs_handle = fs_name_to_handle(fs_name, true);
     132        fs_handle_t fs_handle = fs_name_to_handle(fs_name, true);
    131133        if (!fs_handle) {
    132134                ipc_answer_0(rid, ENOENT);
     
    572574}
    573575
    574 int vfs_truncate_internal(int fs_handle, int dev_handle, unsigned long index,
    575     size_t size)
     576int
     577vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle,
     578    fs_index_t index, size_t size)
    576579{
    577580        ipcarg_t rc;
  • uspace/srv/vfs/vfs_register.c

    r8ad8e49 rf2ec8c8  
    295295         * system a global file system handle.
    296296         */
    297         fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next);
     297        fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next);
    298298        ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);
    299299       
     
    312312 *                      sent. Return 0 if no phone was found.
    313313 */
    314 int vfs_grab_phone(int handle)
     314int vfs_grab_phone(fs_handle_t handle)
    315315{
    316316        /*
     
    387387 * @return              File system handle or zero if file system not found.
    388388 */
    389 int fs_name_to_handle(char *name, bool lock)
     389fs_handle_t fs_name_to_handle(char *name, bool lock)
    390390{
    391391        int handle = 0;
Note: See TracChangeset for help on using the changeset viewer.