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

Changeset 5d5863c in mainline


Ignore:
Timestamp:
2011-08-14T09:23:46Z (10 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master
Children:
25c60f4
Parents:
5f0e16e4
Message:

exFAT: move bitmap_* function to separate file exfat_bitmap.c

Location:
uspace/srv/fs/exfat
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/Makefile

    r5f0e16e4 r5d5863c  
    3636        exfat.c \
    3737        exfat_fat.c \
     38        exfat_bitmap.c \
    3839        exfat_ops.c \
    3940        exfat_idx.c \
  • uspace/srv/fs/exfat/exfat.h

    r5f0e16e4 r5d5863c  
    6262#define VOL_FLAGS(bs)   uint16_t_le2host(bs->volume_flags)
    6363
     64#define EXFAT_NODE(node)        ((node) ? (exfat_node_t *) (node)->data : NULL)
     65#define FS_NODE(node)   ((node) ? (node)->bp : NULL)
     66#define DPS(bs) (BPS((bs)) / sizeof(exfat_dentry_t))
    6467
    6568typedef struct exfat_bs {
     
    178181extern void exfat_idx_fini_by_devmap_handle(devmap_handle_t);
    179182
     183extern int exfat_node_put(fs_node_t *);
     184extern int exfat_bitmap_get(fs_node_t **, devmap_handle_t);
     185/*
     186static int exfat_uctable_get(fs_node_t **, devmap_handle_t);
     187*/
     188
     189
    180190#endif
    181191
  • uspace/srv/fs/exfat/exfat_fat.c

    r5f0e16e4 r5d5863c  
    3434/**
    3535 * @file        exfat_fat.c
    36  * @brief       Functions that manipulate the File Allocation Tables.
     36 * @brief       Functions that manipulate the File Allocation Table.
    3737 */
    3838
     
    169169}
    170170
    171 /** Read block from file located on a FAT file system.
     171/** Read block from file located on a exFAT file system.
    172172 *
    173173 * @param block         Pointer to a block pointer for storing result.
     
    476476}
    477477
    478 int bitmap_is_free(exfat_bs_t *bs, devmap_handle_t devmap_handle,
    479     exfat_cluster_t clst)
    480 {
    481         /* TODO */
    482         return EOK;
    483 }
    484 
    485 int bitmap_set_cluster(exfat_bs_t *bs, devmap_handle_t devmap_handle,
    486     exfat_cluster_t firstc)
    487 {
    488         /* TODO */
    489         return EOK;
    490 }
    491 
    492 int bitmap_clear_cluster(exfat_bs_t *bs, devmap_handle_t devmap_handle,
    493     exfat_cluster_t firstc)
    494 {
    495         /* TODO */
    496         return EOK;
    497 }
    498 
    499 int bitmap_set_clusters(exfat_bs_t *bs, devmap_handle_t devmap_handle,
    500     exfat_cluster_t firstc, exfat_cluster_t count)
    501 {
    502         int rc;
    503         exfat_cluster_t clst;
    504         clst = firstc;
    505 
    506         while (clst < firstc+count ) {
    507                 rc = bitmap_set_cluster(bs, devmap_handle, clst);
    508                 if (rc != EOK) {
    509                         if ((clst-firstc) > 0)
    510                                 (void) bitmap_clear_clusters(bs, devmap_handle, firstc, clst-firstc);
    511                         return rc;
    512                 }
    513                 clst++;
    514         }
    515         return EOK;
    516 }
    517 
    518 int bitmap_clear_clusters(exfat_bs_t *bs, devmap_handle_t devmap_handle,
    519     exfat_cluster_t firstc, exfat_cluster_t count)
    520 {
    521         int rc;
    522         exfat_cluster_t clst;
    523         clst = firstc;
    524 
    525         while (clst < firstc+count ) {
    526                 rc = bitmap_clear_cluster(bs, devmap_handle, clst);
    527                 if (rc != EOK)
    528                         return rc;
    529                 clst++;
    530         }
    531         return EOK;
    532 }
    533 
    534 int bitmap_alloc_clusters(exfat_bs_t *bs, devmap_handle_t devmap_handle,
    535     exfat_cluster_t *firstc, exfat_cluster_t count)
    536 {
    537         exfat_cluster_t startc, endc;
    538         startc = EXFAT_CLST_FIRST;
    539 
    540         while (startc < DATA_CNT(bs)+2) {
    541                 if (bitmap_is_free(bs, devmap_handle, startc) == EOK) {
    542                         endc = startc+1;
    543                         while (bitmap_is_free(bs, devmap_handle, endc) == EOK) {
    544                                 if ((endc - startc)+1 == count){
    545                                         *firstc = startc;
    546                                         return bitmap_set_clusters(bs, devmap_handle, startc, count);
    547                                 }
    548                                 else
    549                                         endc++;
    550                         }
    551                         startc = endc+1;
    552                 }
    553                 else
    554                         startc++;
    555         }
    556         return ENOSPC;
    557 }
    558 
    559 
    560 int bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep,
    561     exfat_cluster_t count)
    562 {
    563         if (nodep->firstc == 0) {
    564                 return bitmap_alloc_clusters(bs, nodep->idx->devmap_handle,
    565                     &nodep->firstc, count);
    566         } else {
    567                 exfat_cluster_t lastc, clst;
    568                 lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;
    569 
    570                 clst = lastc+1;
    571                 while (bitmap_is_free(bs, nodep->idx->devmap_handle, clst) == EOK) {
    572                         if ((clst - lastc) == count){
    573                                 return bitmap_set_clusters(bs, nodep->idx->devmap_handle,
    574                                     lastc+1, count);
    575                         }
    576                         else
    577                                 clst++;
    578                 }
    579                 return ENOSPC;
    580         }
    581 }
    582 
    583 
    584 int bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep,
    585     exfat_cluster_t count)
    586 {
    587         exfat_cluster_t lastc;
    588         lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;
    589         lastc -= count;
    590 
    591         return bitmap_clear_clusters(bs, nodep->idx->devmap_handle, lastc+1, count);
    592 }
    593 
    594 
    595 int bitmap_replicate_clusters(exfat_bs_t *bs, exfat_node_t *nodep)
    596 {
    597         int rc;
    598         exfat_cluster_t lastc, clst;
    599         devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
    600         lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;
    601 
    602         for (clst = nodep->firstc; clst < lastc; clst++) {
    603                 rc = exfat_set_cluster(bs, devmap_handle, clst, clst+1);
    604                 if (rc != EOK)
    605                         return rc;
    606         }
    607 
    608         return exfat_set_cluster(bs, devmap_handle, lastc, EXFAT_CLST_EOF);
    609 }
    610 
    611 
    612 
    613478/** Perform basic sanity checks on the file system.
    614479 *
     
    619484int exfat_sanity_check(exfat_bs_t *bs, devmap_handle_t devmap_handle)
    620485{
     486        /* TODO */
    621487        return EOK;
    622488}
  • uspace/srv/fs/exfat/exfat_fat.h

    r5f0e16e4 r5d5863c  
    7676extern int exfat_sanity_check(struct exfat_bs *, devmap_handle_t);
    7777
    78 extern int bitmap_alloc_clusters(struct exfat_bs *bs, devmap_handle_t devmap_handle,
    79     exfat_cluster_t *firstc, exfat_cluster_t count);
    80 extern int bitmap_append_clusters(struct exfat_bs *bs, struct exfat_node *nodep,
    81     exfat_cluster_t count);
    82 extern int bitmap_free_clusters(struct exfat_bs *bs, struct exfat_node *nodep,
    83     exfat_cluster_t count);
    84 extern int bitmap_replicate_clusters(struct exfat_bs *bs, struct exfat_node *nodep);
    85 
    86 extern int bitmap_is_free(struct exfat_bs *bs, devmap_handle_t devmap_handle,
    87     exfat_cluster_t clst);
    88 extern int bitmap_set_cluster(struct exfat_bs *bs, devmap_handle_t devmap_handle,
    89     exfat_cluster_t firstc);
    90 extern int bitmap_clear_cluster(struct exfat_bs *bs, devmap_handle_t devmap_handle,
    91     exfat_cluster_t firstc);
    92 extern int bitmap_set_clusters(struct exfat_bs *bs, devmap_handle_t devmap_handle,
    93     exfat_cluster_t firstc, exfat_cluster_t count);
    94 extern int bitmap_clear_clusters(struct exfat_bs *bs, devmap_handle_t devmap_handle,
    95     exfat_cluster_t firstc, exfat_cluster_t count);
    96 
    9778extern int exfat_append_clusters(struct exfat_bs *, struct exfat_node *,
    9879    exfat_cluster_t, exfat_cluster_t);
  • uspace/srv/fs/exfat/exfat_ops.c

    r5f0e16e4 r5d5863c  
    4141#include "exfat_dentry.h"
    4242#include "exfat_directory.h"
     43#include "exfat_bitmap.h"
    4344#include "../../vfs/vfs.h"
    4445#include <libfs.h>
     
    6061#include <stdio.h>
    6162
    62 #define EXFAT_NODE(node)        ((node) ? (exfat_node_t *) (node)->data : NULL)
    63 #define FS_NODE(node)   ((node) ? (node)->bp : NULL)
    64 #define DPS(bs) (BPS((bs)) / sizeof(exfat_dentry_t))
    65 
    6663/** Mutex protecting the list of cached free FAT nodes. */
    6764static FIBRIL_MUTEX_INITIALIZE(ffn_mutex);
     
    7370 * Forward declarations of FAT libfs operations.
    7471 */
    75 /*
    76 static int exfat_bitmap_get(fs_node_t **, devmap_handle_t);
    77 static int exfat_uctable_get(fs_node_t **, devmap_handle_t);
    78 */
     72
    7973static int exfat_root_get(fs_node_t **, devmap_handle_t);
    8074static int exfat_match(fs_node_t **, fs_node_t *, const char *);
    8175static int exfat_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
    8276static int exfat_node_open(fs_node_t *);
    83 static int exfat_node_put(fs_node_t *);
     77/* static int exfat_node_put(fs_node_t *); */
    8478static int exfat_create_node(fs_node_t **, devmap_handle_t, int);
    8579static int exfat_destroy_node(fs_node_t *);
     
    459453}
    460454
    461 /*
    462455int exfat_bitmap_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
    463456{
    464457        return exfat_node_get(rfn, devmap_handle, EXFAT_BITMAP_IDX);
    465458}
    466 */
     459
    467460/*
    468461int exfat_uctable_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
Note: See TracChangeset for help on using the changeset viewer.