Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 75160a6 in mainline


Ignore:
Timestamp:
2009-06-28T19:18:15Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
415c7e0d
Parents:
852b801
Message:

Add libfs_stat() and let FAT and TMPFS use it.

Location:
uspace
Files:
4 edited

Legend:

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

    r852b801 r75160a6  
    4444#include <dirent.h>
    4545#include <mem.h>
     46#include <sys/stat.h>
    4647
    4748/** Register file system server.
     
    429430}
    430431
     432void libfs_stat(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
     433    ipc_call_t *request)
     434{
     435        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     436        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     437        fs_node_t *fn = ops->node_get(dev_handle, index);
     438
     439        ipc_callid_t callid;
     440        size_t size;
     441        if (!ipc_data_read_receive(&callid, &size) ||
     442            size < sizeof(struct stat)) {
     443                ipc_answer_0(callid, EINVAL);
     444                ipc_answer_0(rid, EINVAL);
     445                return;
     446        }
     447
     448        struct stat *stat = malloc(sizeof(struct stat));
     449        if (!stat) {
     450                ipc_answer_0(callid, ENOMEM);
     451                ipc_answer_0(rid, ENOMEM);
     452                return;
     453        }
     454        memset(stat, 0, sizeof(struct stat));
     455       
     456        stat->fs_handle = fs_handle;
     457        stat->dev_handle = dev_handle;
     458        stat->index = index;
     459        stat->lnkcnt = ops->lnkcnt_get(fn);
     460        stat->is_file = ops->is_file(fn);
     461        stat->size = ops->size_get(fn);
     462
     463        ipc_data_read_finalize(callid, stat, sizeof(struct stat));
     464        ipc_answer_0(rid, EOK);
     465
     466        free(stat);
     467}
     468
    431469/** Open VFS triplet.
    432470 *
  • uspace/lib/libfs/libfs.h

    r852b801 r75160a6  
    8585extern void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    8686extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
     87extern void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    8788extern void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
    8889    ipc_call_t *);
  • uspace/srv/fs/fat/fat_ops.c

    r852b801 r75160a6  
    12051205void fat_stat(ipc_callid_t rid, ipc_call_t *request)
    12061206{
    1207         ipc_answer_0(rid, ENOTSUP);
     1207        libfs_stat(&fat_libfs_ops, fat_reg.fs_handle, rid, request);
    12081208}
    12091209
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r852b801 r75160a6  
    631631void tmpfs_stat(ipc_callid_t rid, ipc_call_t *request)
    632632{
    633         ipc_answer_0(rid, ENOTSUP);
     633        libfs_stat(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request);
    634634}
    635635
Note: See TracChangeset for help on using the changeset viewer.