Changes in / [aa2a049:23b7c02] in mainline


Ignore:
Files:
3 added
19 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    raa2a049 r23b7c02  
    205205        $(USPACE_PATH)/app/websrv/websrv \
    206206        $(USPACE_PATH)/app/date/date \
    207         $(USPACE_PATH)/app/vdemo/vdemo
     207        $(USPACE_PATH)/app/vdemo/vdemo \
     208        $(USPACE_PATH)/app/df/df
    208209
    209210ifeq ($(CONFIG_PCC),y)
  • uspace/Makefile

    raa2a049 r23b7c02  
    8080        app/vlaunch \
    8181        app/vterm \
     82        app/df \
    8283        app/wavplay \
    8384        app/websrv \
  • uspace/app/trace/trace.c

    raa2a049 r23b7c02  
    724724        o = oper_new("stat", 0, arg_def, V_ERRNO, 0, resp_def);
    725725        proto_add_oper(p, VFS_IN_STAT, o);
     726        o = oper_new("statfs", 0, arg_def, V_ERRNO, 0, resp_def);
     727        proto_add_oper(p, VFS_IN_STATFS, o);
    726728
    727729        proto_register(SERVICE_VFS, p);
  • uspace/lib/c/generic/vfs/vfs.c

    raa2a049 r23b7c02  
    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

    raa2a049 r23b7c02  
    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

    raa2a049 r23b7c02  
    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

    raa2a049 r23b7c02  
    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

    raa2a049 r23b7c02  
    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
  • uspace/srv/fs/cdfs/cdfs_ops.c

    raa2a049 r23b7c02  
    625625}
    626626
     627static int cdfs_size_block(service_id_t service_id, uint32_t *size)
     628{
     629        *size = BLOCK_SIZE;
     630
     631        return EOK;
     632}
     633
     634static int cdfs_total_block_count(service_id_t service_id, uint64_t *count)
     635{
     636        *count = 0;
     637       
     638        return EOK;
     639}
     640
     641static int cdfs_free_block_count(service_id_t service_id, uint64_t *count)
     642{
     643        *count = 0;
     644       
     645        return EOK;
     646}
     647
    627648libfs_ops_t cdfs_libfs_ops = {
    628649        .root_get = cdfs_root_get,
     
    641662        .is_directory = cdfs_is_directory,
    642663        .is_file = cdfs_is_file,
    643         .service_get = cdfs_service_get
     664        .service_get = cdfs_service_get,
     665        .size_block = cdfs_size_block,
     666        .total_block_count = cdfs_total_block_count,
     667        .free_block_count = cdfs_free_block_count
    644668};
    645669
  • uspace/srv/fs/exfat/exfat_ops.c

    raa2a049 r23b7c02  
    8989static bool exfat_is_file(fs_node_t *node);
    9090static service_id_t exfat_service_get(fs_node_t *node);
     91static int exfat_size_block(service_id_t, uint32_t *);
     92static int exfat_total_block_count(service_id_t, uint64_t *);
     93static int exfat_free_block_count(service_id_t, uint64_t *);
    9194
    9295/*
     
    912915}
    913916
     917int exfat_size_block(service_id_t service_id, uint32_t *size)
     918{
     919        exfat_bs_t *bs;
     920        bs = block_bb_get(service_id);
     921        *size = BPC(bs);
     922
     923        return EOK;
     924}
     925
     926int exfat_total_block_count(service_id_t service_id, uint64_t *count)
     927{
     928        exfat_bs_t *bs;
     929        bs = block_bb_get(service_id);
     930        *count = DATA_CNT(bs);
     931       
     932        return EOK;
     933}
     934
     935int exfat_free_block_count(service_id_t service_id, uint64_t *count)
     936{
     937        fs_node_t *node;
     938        exfat_node_t *bmap_node;
     939        exfat_bs_t *bs;
     940        uint64_t free_block_count = 0;
     941        uint64_t block_count;
     942        unsigned sector;
     943        int rc;
     944
     945        rc = exfat_total_block_count(service_id, &block_count);
     946        if (rc != EOK)
     947                goto exit;
     948
     949        bs = block_bb_get(service_id);
     950        node = NULL;
     951        rc = exfat_bitmap_get(&node, service_id);
     952        if (rc != EOK)
     953                goto exit;
     954
     955        bmap_node = (exfat_node_t *) node->data;
     956
     957        unsigned const bmap_sectors = ROUND_UP(bmap_node->size, BPS(bs)) /
     958            BPS(bs);
     959
     960        for (sector = 0; sector < bmap_sectors; ++sector) {
     961
     962                block_t *block;
     963                uint8_t *bitmap;
     964                unsigned bit;
     965
     966                rc = exfat_block_get(&block, bs, bmap_node, sector,
     967                    BLOCK_FLAGS_NONE);
     968                if (rc != EOK) {
     969                        free_block_count = 0;
     970                        goto exit;
     971                }
     972
     973                bitmap = (uint8_t *) block->data;
     974
     975                for (bit = 0; bit < BPS(bs) * 8 && block_count > 0;
     976                    ++bit, --block_count) {
     977                        if (!(bitmap[bit / 8] & (1 << (bit % 8))))
     978                                ++free_block_count;
     979                }
     980
     981                block_put(block);
     982
     983                if (block_count == 0) {
     984                        /* Reached the end of the bitmap */
     985                        goto exit;
     986                }
     987        }
     988
     989exit:
     990        exfat_node_put(node);
     991        *count = free_block_count;
     992        return rc;
     993}
    914994
    915995/** libfs operations */
     
    9301010        .is_directory = exfat_is_directory,
    9311011        .is_file = exfat_is_file,
    932         .service_get = exfat_service_get
     1012        .service_get = exfat_service_get,
     1013        .size_block = exfat_size_block,
     1014        .total_block_count = exfat_total_block_count,
     1015        .free_block_count = exfat_free_block_count
    9331016};
    9341017
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    raa2a049 r23b7c02  
    101101static bool ext4fs_is_file(fs_node_t *node);
    102102static service_id_t ext4fs_service_get(fs_node_t *node);
     103static int ext4fs_size_block(service_id_t, uint32_t *);
     104static int ext4fs_total_block_count(service_id_t, uint64_t *);
     105static int ext4fs_free_block_count(service_id_t, uint64_t *);
    103106
    104107/* Static variables */
     
    836839        ext4fs_node_t *enode = EXT4FS_NODE(fn);
    837840        return enode->instance->service_id;
     841}
     842
     843int ext4fs_size_block(service_id_t service_id, uint32_t *size)
     844{
     845        ext4fs_instance_t *inst;
     846        int rc = ext4fs_instance_get(service_id, &inst);
     847        if (rc != EOK)
     848                return rc;
     849
     850        if (NULL == inst)
     851                return ENOENT;
     852
     853        ext4_superblock_t *sb = inst->filesystem->superblock;
     854        *size = ext4_superblock_get_block_size(sb);
     855
     856        return EOK;
     857}
     858
     859int ext4fs_total_block_count(service_id_t service_id, uint64_t *count)
     860{
     861        ext4fs_instance_t *inst;
     862        int rc = ext4fs_instance_get(service_id, &inst);
     863        if (rc != EOK)
     864                return rc;
     865
     866        if (NULL == inst)
     867                return ENOENT;
     868
     869        ext4_superblock_t *sb = inst->filesystem->superblock;
     870        *count = ext4_superblock_get_blocks_count(sb);
     871
     872        return EOK;
     873}
     874
     875int ext4fs_free_block_count(service_id_t service_id, uint64_t *count)
     876{
     877        ext4fs_instance_t *inst;
     878        int rc = ext4fs_instance_get(service_id, &inst);
     879        if (rc != EOK)
     880                return rc;
     881        if (NULL == inst)
     882                return ENOENT;
     883
     884        ext4_superblock_t *sb = inst->filesystem->superblock;
     885        *count = ext4_superblock_get_free_blocks_count(sb);
     886
     887        return EOK;
    838888}
    839889
     
    857907        .is_directory = ext4fs_is_directory,
    858908        .is_file = ext4fs_is_file,
    859         .service_get = ext4fs_service_get
     909        .service_get = ext4fs_service_get,
     910        .size_block = ext4fs_size_block,
     911        .total_block_count = ext4fs_total_block_count,
     912        .free_block_count = ext4fs_free_block_count
    860913};
    861914
  • uspace/srv/fs/fat/fat_ops.c

    raa2a049 r23b7c02  
    9191static bool fat_is_file(fs_node_t *node);
    9292static service_id_t fat_service_get(fs_node_t *node);
     93static int fat_size_block(service_id_t, uint32_t *);
     94static int fat_total_block_count(service_id_t, uint64_t *);
     95static int fat_free_block_count(service_id_t, uint64_t *);
    9396
    9497/*
     
    843846}
    844847
     848int fat_size_block(service_id_t service_id, uint32_t *size)
     849{
     850        fat_bs_t *bs;
     851
     852        bs = block_bb_get(service_id);
     853        *size = BPC(bs);
     854
     855        return EOK;
     856}
     857
     858int fat_total_block_count(service_id_t service_id, uint64_t *count)
     859{
     860        fat_bs_t *bs;
     861       
     862        bs = block_bb_get(service_id);
     863        *count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     864
     865        return EOK;
     866}
     867
     868int fat_free_block_count(service_id_t service_id, uint64_t *count)
     869{
     870        fat_bs_t *bs;
     871        fat_cluster_t e0;
     872        uint64_t block_count;
     873        int rc;
     874        uint32_t cluster_no, clusters;
     875
     876        block_count = 0;
     877        bs = block_bb_get(service_id);
     878        clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     879        for (cluster_no = 0; cluster_no < clusters; cluster_no++) {
     880                rc = fat_get_cluster(bs, service_id, FAT1, cluster_no, &e0);
     881                if (rc != EOK)
     882                        return EIO;
     883
     884                if (e0 == FAT_CLST_RES0)
     885                        block_count++;
     886        }
     887        *count = block_count;
     888       
     889        return EOK;
     890}
     891
    845892/** libfs operations */
    846893libfs_ops_t fat_libfs_ops = {
     
    860907        .is_directory = fat_is_directory,
    861908        .is_file = fat_is_file,
    862         .service_get = fat_service_get
     909        .service_get = fat_service_get,
     910        .size_block = fat_size_block,
     911        .total_block_count = fat_total_block_count,
     912        .free_block_count = fat_free_block_count
    863913};
    864914
  • uspace/srv/fs/mfs/mfs.h

    raa2a049 r23b7c02  
    5858#endif
    5959
     60#define MFS_BMAP_START_BLOCK(sbi, bid) \
     61    ((bid) == BMAP_ZONE ? 2 + (sbi)->ibmap_blocks : 2)
     62
     63#define MFS_BMAP_SIZE_BITS(sbi, bid) \
     64    ((bid) == BMAP_ZONE ? (sbi)->nzones - (sbi)->firstdatazone - 1 : \
     65    (sbi)->ninodes - 1)
     66
     67#define MFS_BMAP_SIZE_BLOCKS(sbi, bid) \
     68    ((bid) == BMAP_ZONE ? (sbi)->zbmap_blocks : (sbi)->ibmap_blocks)
     69
    6070typedef uint32_t bitchunk_t;
    6171
     
    201211mfs_free_zone(struct mfs_instance *inst, uint32_t zone);
    202212
     213extern int
     214mfs_count_free_zones(struct mfs_instance *inst, uint32_t *zones);
     215
     216extern int
     217mfs_count_free_inodes(struct mfs_instance *inst, uint32_t *inodes);
     218
     219
    203220/* mfs_utils.c */
    204221extern uint16_t
  • uspace/srv/fs/mfs/mfs_balloc.c

    raa2a049 r23b7c02  
    4444mfs_alloc_bit(struct mfs_instance *inst, uint32_t *idx, bmap_id_t bid);
    4545
     46static int
     47mfs_count_free_bits(struct mfs_instance *inst, bmap_id_t bid, uint32_t *free);
     48
     49
    4650/**Allocate a new inode.
    4751 *
     
    102106
    103107        return mfs_free_bit(inst, zone, BMAP_ZONE);
     108}
     109
     110/** Count the number of free zones
     111 *
     112 * @param inst          Pointer to the instance structure.
     113 * @param zones         Pointer to the memory location where the result
     114 *                      will be stored.
     115 *
     116 * @return              EOK on success or a negative error code.
     117 */
     118int
     119mfs_count_free_zones(struct mfs_instance *inst, uint32_t *zones)
     120{
     121        return mfs_count_free_bits(inst, BMAP_ZONE, zones);
     122}
     123
     124/** Count the number of free inodes
     125 *
     126 * @param inst          Pointer to the instance structure.
     127 * @param zones         Pointer to the memory location where the result
     128 *                      will be stored.
     129 *
     130 * @return              EOK on success or a negative error code.
     131 */
     132
     133int
     134mfs_count_free_inodes(struct mfs_instance *inst, uint32_t *inodes)
     135{
     136        return mfs_count_free_bits(inst, BMAP_INODE, inodes);
     137}
     138
     139/** Count the number of free bits in a bitmap
     140 *
     141 * @param inst          Pointer to the instance structure.
     142 * @param bid           Type of the bitmap (inode or zone).
     143 * @param free          Pointer to the memory location where the result
     144 *                      will be stores.
     145 *
     146 * @return              EOK on success or a negative error code.
     147 */
     148static int
     149mfs_count_free_bits(struct mfs_instance *inst, bmap_id_t bid, uint32_t *free)
     150{
     151        int r;
     152        unsigned start_block;
     153        unsigned long nblocks;
     154        unsigned long nbits;
     155        unsigned long block;
     156        unsigned long free_bits = 0;
     157        bitchunk_t chunk;
     158        size_t const bitchunk_bits = sizeof(bitchunk_t) * 8;
     159        block_t *b;
     160        struct mfs_sb_info *sbi = inst->sbi;
     161
     162        start_block = MFS_BMAP_START_BLOCK(sbi, bid);
     163        nblocks = MFS_BMAP_SIZE_BLOCKS(sbi, bid);
     164        nbits = MFS_BMAP_SIZE_BITS(sbi, bid);
     165
     166        for (block = 0; block < nblocks; ++block) {
     167                r = block_get(&b, inst->service_id, block + start_block,
     168                    BLOCK_FLAGS_NONE);
     169                if (r != EOK)
     170                        return r;
     171
     172                size_t i;
     173                bitchunk_t *data = (bitchunk_t *) b->data;
     174
     175                /* Read the bitmap block, chunk per chunk,
     176                 * counting the zero bits.
     177                 */
     178                for (i = 0; i < sbi->block_size / sizeof(bitchunk_t); ++i) {
     179                        chunk = conv32(sbi->native, data[i]);
     180
     181                        size_t bit;
     182                        for (bit = 0; bit < bitchunk_bits && nbits > 0;
     183                            ++bit, --nbits) {
     184                                if (!(chunk & (1 << bit)))
     185                                        free_bits++;
     186                        }
     187
     188                        if (nbits == 0)
     189                                break;
     190                }
     191
     192                r = block_put(b);
     193                if (r != EOK)
     194                        return r;
     195        }
     196
     197        *free = free_bits;
     198        assert(nbits == 0);
     199
     200        return EOK;
    104201}
    105202
     
    124221        sbi = inst->sbi;
    125222
     223        start_block = MFS_BMAP_START_BLOCK(sbi, bid);
     224
    126225        if (bid == BMAP_ZONE) {
    127226                search = &sbi->zsearch;
    128                 start_block = 2 + sbi->ibmap_blocks;
    129227                if (idx > sbi->nzones) {
    130228                        printf(NAME ": Error! Trying to free beyond the "
     
    135233                /* bid == BMAP_INODE */
    136234                search = &sbi->isearch;
    137                 start_block = 2;
    138235                if (idx > sbi->ninodes) {
    139236                        printf(NAME ": Error! Trying to free beyond the "
     
    192289        sbi = inst->sbi;
    193290
     291        start_block = MFS_BMAP_START_BLOCK(sbi, bid);
     292        limit = MFS_BMAP_SIZE_BITS(sbi, bid);
     293        nblocks = MFS_BMAP_SIZE_BLOCKS(sbi, bid);
     294
    194295        if (bid == BMAP_ZONE) {
    195296                search = &sbi->zsearch;
    196                 start_block = 2 + sbi->ibmap_blocks;
    197                 nblocks = sbi->zbmap_blocks;
    198                 limit = sbi->nzones - sbi->firstdatazone - 1;
    199297        } else {
    200298                /* bid == BMAP_INODE */
    201299                search = &sbi->isearch;
    202                 start_block = 2;
    203                 nblocks = sbi->ibmap_blocks;
    204                 limit = sbi->ninodes - 1;
    205300        }
    206301        bits_per_block = sbi->block_size * 8;
  • uspace/srv/fs/mfs/mfs_ops.c

    raa2a049 r23b7c02  
    6464static int mfs_check_sanity(struct mfs_sb_info *sbi);
    6565static bool is_power_of_two(uint32_t n);
     66static int mfs_size_block(service_id_t service_id, uint32_t *size);
     67static int mfs_total_block_count(service_id_t service_id, uint64_t *count);
     68static int mfs_free_block_count(service_id_t service_id, uint64_t *count);
    6669
    6770static hash_table_t open_nodes;
     
    8487        .destroy = mfs_destroy_node,
    8588        .has_children = mfs_has_children,
    86         .lnkcnt_get = mfs_lnkcnt_get
     89        .lnkcnt_get = mfs_lnkcnt_get,
     90        .size_block = mfs_size_block,
     91        .total_block_count = mfs_total_block_count,
     92        .free_block_count = mfs_free_block_count
    8793};
    8894
     
    11291135}
    11301136
     1137static int
     1138mfs_size_block(service_id_t service_id, uint32_t *size)
     1139{
     1140        struct mfs_instance *inst;
     1141        int rc;
     1142
     1143        rc = mfs_instance_get(service_id, &inst);
     1144        if (rc != EOK)
     1145                return rc;
     1146
     1147        if (NULL == inst)
     1148                return ENOENT;
     1149       
     1150        *size = inst->sbi->block_size;
     1151
     1152        return EOK;
     1153}
     1154
     1155static int
     1156mfs_total_block_count(service_id_t service_id, uint64_t *count)
     1157{
     1158        struct mfs_instance *inst;
     1159        int rc;
     1160       
     1161        rc = mfs_instance_get(service_id, &inst);
     1162        if (rc != EOK)
     1163                return rc;
     1164
     1165        if (NULL == inst)
     1166                return ENOENT;
     1167       
     1168        *count = (uint64_t) MFS_BMAP_SIZE_BITS(inst->sbi, BMAP_ZONE);
     1169
     1170        return EOK;
     1171}
     1172
     1173static int
     1174mfs_free_block_count(service_id_t service_id, uint64_t *count)
     1175{
     1176        uint32_t block_free;
     1177       
     1178        struct mfs_instance *inst;
     1179        int rc = mfs_instance_get(service_id, &inst);
     1180        if (rc != EOK)
     1181                return rc;
     1182
     1183        if (NULL == inst)
     1184                return ENOENT;
     1185
     1186        mfs_count_free_zones(inst, &block_free);
     1187        *count = block_free;
     1188
     1189        return EOK;
     1190}
     1191
    11311192vfs_out_ops_t mfs_ops = {
    11321193        .mounted = mfs_mounted,
  • uspace/srv/fs/udf/udf_ops.c

    raa2a049 r23b7c02  
    249249}
    250250
     251static int udf_size_block(service_id_t service_id, uint32_t *size)
     252{
     253        udf_instance_t *instance;
     254        int rc = fs_instance_get(service_id, (void **) &instance);
     255        if (rc != EOK)
     256                return rc;
     257
     258        if (NULL == instance)
     259                return ENOENT;
     260       
     261        *size = instance->volumes[DEFAULT_VOL].logical_block_size;
     262       
     263        return EOK;
     264}
     265
     266static int udf_total_block_count(service_id_t service_id, uint64_t *count)
     267{
     268        *count = 0;
     269       
     270        return EOK;
     271}
     272
     273static int udf_free_block_count(service_id_t service_id, uint64_t *count)
     274{
     275        *count = 0;
     276       
     277        return EOK;
     278}
     279
    251280libfs_ops_t udf_libfs_ops = {
    252281        .root_get = udf_root_get,
     
    265294        .is_directory = udf_is_directory,
    266295        .is_file = udf_is_file,
    267         .service_get = udf_service_get
     296        .service_get = udf_service_get,
     297        .size_block = udf_size_block,
     298        .total_block_count = udf_total_block_count,
     299        .free_block_count = udf_free_block_count
    268300};
    269301
  • uspace/srv/vfs/vfs.c

    raa2a049 r23b7c02  
    130130                        vfs_get_mtab(callid, &call);
    131131                        break;
     132                case VFS_IN_STATFS:
     133                        vfs_statfs(callid, &call);
     134                        break;
    132135                default:
    133136                        async_answer_0(callid, ENOTSUP);
  • uspace/srv/vfs/vfs.h

    raa2a049 r23b7c02  
    222222extern void vfs_wait_handle(ipc_callid_t, ipc_call_t *);
    223223extern void vfs_get_mtab(ipc_callid_t, ipc_call_t *);
     224extern void vfs_statfs(ipc_callid_t, ipc_call_t *);
    224225
    225226#endif
  • uspace/srv/vfs/vfs_ops.c

    raa2a049 r23b7c02  
    14181418}
    14191419
     1420void vfs_statfs(ipc_callid_t rid, ipc_call_t *request)
     1421{
     1422        char *path;
     1423        int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
     1424        if (rc != EOK) {
     1425                async_answer_0(rid, rc);
     1426                return;
     1427        }
     1428       
     1429        ipc_callid_t callid;
     1430        if (!async_data_read_receive(&callid, NULL)) {
     1431                free(path);
     1432                async_answer_0(callid, EINVAL);
     1433                async_answer_0(rid, EINVAL);
     1434                return;
     1435        }
     1436
     1437        vfs_lookup_res_t lr;
     1438        fibril_rwlock_read_lock(&namespace_rwlock);
     1439        rc = vfs_lookup_internal(path, L_NONE, &lr, NULL);
     1440        free(path);
     1441        if (rc != EOK) {
     1442                fibril_rwlock_read_unlock(&namespace_rwlock);
     1443                async_answer_0(callid, rc);
     1444                async_answer_0(rid, rc);
     1445                return;
     1446        }
     1447        vfs_node_t *node = vfs_node_get(&lr);
     1448        if (!node) {
     1449                fibril_rwlock_read_unlock(&namespace_rwlock);
     1450                async_answer_0(callid, ENOMEM);
     1451                async_answer_0(rid, ENOMEM);
     1452                return;
     1453        }
     1454
     1455        fibril_rwlock_read_unlock(&namespace_rwlock);
     1456
     1457        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
     1458       
     1459        aid_t msg;
     1460        msg = async_send_3(exch, VFS_OUT_STATFS, node->service_id,
     1461            node->index, false, NULL);
     1462        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     1463       
     1464        vfs_exchange_release(exch);
     1465       
     1466        sysarg_t rv;
     1467        async_wait_for(msg, &rv);
     1468
     1469        async_answer_0(rid, rv);
     1470
     1471        vfs_node_put(node);
     1472}
     1473
    14201474/**
    14211475 * @}
Note: See TracChangeset for help on using the changeset viewer.