Changeset 758f8d5 in mainline for uspace/lib


Ignore:
Timestamp:
2013-09-11T21:53:36Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e1ec5a2
Parents:
1e371cf (diff), 9dbdda9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge the df branch

Location:
uspace/lib
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/vfs.c

    r1e371cf r758f8d5  
    4343#include <stdio.h>
    4444#include <sys/stat.h>
     45#include <sys/statfs.h>
    4546#include <sys/types.h>
    4647#include <ipc/services.h>
     
    892893}
    893894
     895int statfs(const char *path, struct statfs *statfs)
     896{
     897        sysarg_t rc;
     898        sysarg_t rc_orig;
     899        aid_t req;
     900        size_t pa_size;
     901       
     902        char *pa = absolutize(path, &pa_size);
     903        if (!pa)
     904                return ENOMEM;
     905        async_exch_t *exch = vfs_exchange_begin();
     906       
     907        req = async_send_0(exch, VFS_IN_STATFS, NULL);
     908        rc = async_data_write_start(exch, pa, pa_size);
     909        if (rc != EOK) {
     910                vfs_exchange_end(exch);
     911                free(pa);
     912                async_wait_for(req, &rc_orig);
     913                if (rc_orig == EOK)
     914                        return (int) rc;
     915                else
     916                        return (int) rc_orig;
     917        }
     918        rc = async_data_read_start(exch, (void *) statfs, sizeof(struct statfs));
     919        if (rc != EOK) {
     920                vfs_exchange_end(exch);
     921                free(pa);
     922                async_wait_for(req, &rc_orig);
     923                if (rc_orig == EOK)
     924                        return (int) rc;
     925                else
     926                        return (int) rc_orig;
     927        }
     928        vfs_exchange_end(exch);
     929        free(pa);
     930        async_wait_for(req, &rc);
     931        return rc;
     932}
     933
    894934/** @}
    895935 */
  • uspace/lib/c/include/ipc/vfs.h

    r1e371cf r758f8d5  
    8282        VFS_IN_WAIT_HANDLE,
    8383        VFS_IN_MTAB_GET,
     84        VFS_IN_STATFS
    8485} vfs_in_request_t;
    8586
     
    9899        VFS_OUT_LOOKUP,
    99100        VFS_OUT_DESTROY,
     101        VFS_OUT_STATFS,
    100102        VFS_OUT_LAST
    101103} vfs_out_request_t;
  • uspace/lib/c/include/vfs/vfs.h

    r1e371cf r758f8d5  
    4444#include "vfs_mtab.h"
    4545
     46
    4647enum vfs_change_state_type {
    4748        VFS_PASS_HANDLE
    4849};
     50
    4951
    5052extern char *absolutize(const char *, size_t *);
     
    6163extern async_exch_t *vfs_exchange_begin(void);
    6264extern void vfs_exchange_end(async_exch_t *);
    63 
    6465#endif
    6566
  • uspace/lib/fs/libfs.c

    r1e371cf r758f8d5  
    4545#include <mem.h>
    4646#include <sys/stat.h>
     47#include <sys/statfs.h>
    4748#include <stdlib.h>
    4849
     
    7475static void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
    7576    ipc_call_t *);
     77static void libfs_statfs(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    7678
    7779static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req)
     
    219221}
    220222
     223static void vfs_out_statfs(ipc_callid_t rid, ipc_call_t *req)
     224{
     225        libfs_statfs(libfs_ops, reg.fs_handle, rid, req);
     226}
    221227static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    222228{
     
    276282                case VFS_OUT_SYNC:
    277283                        vfs_out_sync(callid, &call);
     284                        break;
     285                case VFS_OUT_STATFS:
     286                        vfs_out_statfs(callid, &call);
    278287                        break;
    279288                default:
     
    825834       
    826835        ops->node_put(fn);
    827        
     836
     837
    828838        async_data_read_finalize(callid, &stat, sizeof(struct stat));
    829839        async_answer_0(rid, EOK);
    830840}
     841
     842void libfs_statfs(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
     843    ipc_call_t *request)
     844{
     845        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
     846        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     847       
     848        fs_node_t *fn;
     849        int rc = ops->node_get(&fn, service_id, index);
     850        on_error(rc, answer_and_return(rid, rc));
     851       
     852        ipc_callid_t callid;
     853        size_t size;
     854        if ((!async_data_read_receive(&callid, &size)) ||
     855            (size != sizeof(struct statfs))) {
     856                ops->node_put(fn);
     857                async_answer_0(callid, EINVAL);
     858                async_answer_0(rid, EINVAL);
     859                return;
     860        }
     861       
     862        struct statfs statfs;
     863        memset(&statfs, 0, sizeof(struct statfs));
     864
     865        if (NULL != ops->size_block) { 
     866                rc = ops->size_block(service_id, &statfs.f_bsize);
     867                if (rc != EOK) goto error;
     868        }
     869
     870        if (NULL != ops->total_block_count) {
     871                rc = ops->total_block_count(service_id, &statfs.f_blocks);
     872                if (rc != EOK) goto error;
     873        }
     874
     875        if (NULL != ops->free_block_count) {
     876                rc = ops->free_block_count(service_id, &statfs.f_bfree);
     877                if (rc != EOK) goto error;
     878        }
     879
     880        ops->node_put(fn);
     881        async_data_read_finalize(callid, &statfs, sizeof(struct statfs));
     882        async_answer_0(rid, EOK);
     883        return;
     884
     885error:
     886        ops->node_put(fn);
     887        async_answer_0(callid, EINVAL);
     888        async_answer_0(rid, EINVAL);
     889}
     890
    831891
    832892/** Open VFS triplet.
  • uspace/lib/fs/libfs.h

    r1e371cf r758f8d5  
    9393        bool (* is_file)(fs_node_t *);
    9494        service_id_t (* service_get)(fs_node_t *);
     95        int (* size_block)(service_id_t, uint32_t *);
     96        int (* total_block_count)(service_id_t, uint64_t *);
     97        int (* free_block_count)(service_id_t, uint64_t *);
    9598} libfs_ops_t;
    9699
Note: See TracChangeset for help on using the changeset viewer.