Changeset ff0c270 in mainline


Ignore:
Timestamp:
2011-08-25T22:15:33Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0dbe5ac
Parents:
abb7491c
Message:

Cstyle.

Location:
uspace/srv/fs/exfat
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat.h

    rabb7491c rff0c270  
    5151
    5252#define BPS(bs)                 ((uint32_t) (1 << (bs->bytes_per_sector)))
    53 #define SPC(bs)                 ((uint32_t)(1 << (bs->sec_per_cluster)))
    54 #define BPC(bs)                 ((uint32_t)(BPS(bs)*SPC(bs)))
     53#define SPC(bs)                 ((uint32_t) (1 << (bs->sec_per_cluster)))
     54#define BPC(bs)                 ((uint32_t) (BPS(bs) * SPC(bs)))
    5555#define VOL_FS(bs)              uint64_t_le2host(bs->volume_start)
    5656#define VOL_CNT(bs)             uint64_t_le2host(bs->volume_count)
     
    5858#define FAT_CNT(bs)             uint32_t_le2host(bs->fat_sector_count)
    5959#define DATA_FS(bs)             uint32_t_le2host(bs->data_start_sector)
    60 #define DATA_CNT(bs)    uint32_t_le2host(bs->data_clusters)
     60#define DATA_CNT(bs)            uint32_t_le2host(bs->data_clusters)
    6161#define ROOT_FC(bs)             uint32_t_le2host(bs->rootdir_cluster)
    62 #define VOL_FLAGS(bs)   uint16_t_le2host(bs->volume_flags)
     62#define VOL_FLAGS(bs)           uint16_t_le2host(bs->volume_flags)
    6363
    6464#define EXFAT_NODE(node)        ((node) ? (exfat_node_t *) (node)->data : NULL)
     
    181181extern void exfat_idx_fini_by_service_id(service_id_t);
    182182
    183 extern int exfat_node_expand(service_id_t service_id, exfat_node_t *nodep,
    184     exfat_cluster_t clusters);
     183extern int exfat_node_expand(service_id_t, exfat_node_t *, exfat_cluster_t);
    185184extern int exfat_node_put(fs_node_t *);
    186185extern int exfat_bitmap_get(fs_node_t **, service_id_t);
  • uspace/srv/fs/exfat/exfat_bitmap.c

    rabb7491c rff0c270  
    5353{
    5454        fs_node_t *fn;
    55         block_t *b=NULL;
     55        block_t *b = NULL;
    5656        exfat_node_t *bitmapp;
    5757        uint8_t *bitmap;
     
    9494{
    9595        fs_node_t *fn;
    96         block_t *b=NULL;
     96        block_t *b = NULL;
    9797        exfat_node_t *bitmapp;
    9898        uint8_t *bitmap;
     
    129129{
    130130        fs_node_t *fn;
    131         block_t *b=NULL;
     131        block_t *b = NULL;
    132132        exfat_node_t *bitmapp;
    133133        uint8_t *bitmap;
     
    142142       
    143143        aoff64_t offset = clst / 8;
    144         rc = exfat_block_get(&b, bs, bitmapp, offset / BPS(bs), BLOCK_FLAGS_NONE);
     144        rc = exfat_block_get(&b, bs, bitmapp, offset / BPS(bs),
     145            BLOCK_FLAGS_NONE);
    145146        if (rc != EOK) {
    146147                (void) exfat_node_put(fn);
     
    167168        clst = firstc;
    168169
    169         while (clst < firstc+count ) {
     170        while (clst < firstc + count ) {
    170171                rc = bitmap_set_cluster(bs, service_id, clst);
    171172                if (rc != EOK) {
    172                         if ((clst-firstc) > 0)
    173                                 (void) bitmap_clear_clusters(bs, service_id, firstc, clst-firstc);
     173                        if (clst - firstc > 0)
     174                                (void) bitmap_clear_clusters(bs, service_id,
     175                                    firstc, clst - firstc);
    174176                        return rc;
    175177                }
     
    186188        clst = firstc;
    187189
    188         while (clst < firstc+count ) {
     190        while (clst < firstc + count) {
    189191                rc = bitmap_clear_cluster(bs, service_id, clst);
    190192                if (rc != EOK)
     
    201203        startc = EXFAT_CLST_FIRST;
    202204
    203         while (startc < DATA_CNT(bs)+2) {
     205        while (startc < DATA_CNT(bs) + 2) {
    204206                endc = startc;
    205207                while (bitmap_is_free(bs, service_id, endc) == EOK) {
    206                         if ((endc - startc)+1 == count){
     208                        if ((endc - startc) + 1 == count) {
    207209                                *firstc = startc;
    208210                                return bitmap_set_clusters(bs, service_id, startc, count);
    209                         }
    210                         else
     211                        } else
    211212                                endc++;
    212213                }
     
    227228                lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;
    228229
    229                 clst = lastc+1;
     230                clst = lastc + 1;
    230231                while (bitmap_is_free(bs, nodep->idx->service_id, clst) == EOK) {
    231                         if ((clst - lastc) == count){
     232                        if (clst - lastc == count){
    232233                                return bitmap_set_clusters(bs, nodep->idx->service_id,
    233                                     lastc+1, count);
    234                         }
    235                         else
     234                                    lastc + 1, count);
     235                        } else
    236236                                clst++;
    237237                }
     
    248248        lastc -= count;
    249249
    250         return bitmap_clear_clusters(bs, nodep->idx->service_id, lastc+1, count);
     250        return bitmap_clear_clusters(bs, nodep->idx->service_id, lastc + 1, count);
    251251}
    252252
     
    260260
    261261        for (clst = nodep->firstc; clst < lastc; clst++) {
    262                 rc = exfat_set_cluster(bs, service_id, clst, clst+1);
     262                rc = exfat_set_cluster(bs, service_id, clst, clst + 1);
    263263                if (rc != EOK)
    264264                        return rc;
  • uspace/srv/fs/exfat/exfat_bitmap.h

    rabb7491c rff0c270  
    4242struct exfat_bs;
    4343
    44 extern int bitmap_alloc_clusters(struct exfat_bs *bs, service_id_t service_id,
    45     exfat_cluster_t *firstc, exfat_cluster_t count);
    46 extern int bitmap_append_clusters(struct exfat_bs *bs, struct exfat_node *nodep,
    47     exfat_cluster_t count);
    48 extern int bitmap_free_clusters(struct exfat_bs *bs, struct exfat_node *nodep,
    49     exfat_cluster_t count);
    50 extern int bitmap_replicate_clusters(struct exfat_bs *bs, struct exfat_node *nodep);
     44extern int bitmap_alloc_clusters(struct exfat_bs *, service_id_t,
     45    exfat_cluster_t *, exfat_cluster_t);
     46extern int bitmap_append_clusters(struct exfat_bs *, struct exfat_node *,
     47    exfat_cluster_t);
     48extern int bitmap_free_clusters(struct exfat_bs *, struct exfat_node *,
     49    exfat_cluster_t);
     50extern int bitmap_replicate_clusters(struct exfat_bs *, struct exfat_node *);
    5151
    52 extern int bitmap_is_free(struct exfat_bs *bs, service_id_t service_id,
    53     exfat_cluster_t clst);
    54 extern int bitmap_set_cluster(struct exfat_bs *bs, service_id_t service_id,
    55     exfat_cluster_t clst);
    56 extern int bitmap_clear_cluster(struct exfat_bs *bs, service_id_t service_id,
    57     exfat_cluster_t clst);
     52extern int bitmap_is_free(struct exfat_bs *, service_id_t, exfat_cluster_t);
     53extern int bitmap_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t);
     54extern int bitmap_clear_cluster(struct exfat_bs *, service_id_t,
     55    exfat_cluster_t);
    5856
    59 extern int bitmap_set_clusters(struct exfat_bs *bs, service_id_t service_id,
    60     exfat_cluster_t firstc, exfat_cluster_t count);
    61 extern int bitmap_clear_clusters(struct exfat_bs *bs, service_id_t service_id,
    62     exfat_cluster_t firstc, exfat_cluster_t count);
     57extern int bitmap_set_clusters(struct exfat_bs *, service_id_t,
     58    exfat_cluster_t, exfat_cluster_t);
     59extern int bitmap_clear_clusters(struct exfat_bs *, service_id_t,
     60    exfat_cluster_t, exfat_cluster_t);
    6361
    6462
  • uspace/srv/fs/exfat/exfat_dentry.c

    rabb7491c rff0c270  
    9090void exfat_dentry_get_name(const exfat_name_dentry_t *name, size_t size, uint16_t *dst, size_t *offset)
    9191{
    92         size_t i=0;
    93         while(i<EXFAT_NAME_PART_LEN && *offset < size) {
     92        size_t i = 0;
     93        while (i < EXFAT_NAME_PART_LEN && *offset < size) {
    9494                dst[*offset] = uint16_t_le2host(name->name[i]);
    9595                i++;
  • uspace/srv/fs/exfat/exfat_dentry.h

    rabb7491c rff0c270  
    149149
    150150
    151 extern exfat_dentry_clsf_t exfat_classify_dentry(const exfat_dentry_t *d);
     151extern exfat_dentry_clsf_t exfat_classify_dentry(const exfat_dentry_t *);
    152152
    153 extern uint16_t exfat_name_hash(const uint16_t *name, const uint16_t *uctable,
    154     size_t chars);
     153extern uint16_t exfat_name_hash(const uint16_t *, const uint16_t *, size_t);
    155154
    156 extern void exfat_dentry_get_name(const exfat_name_dentry_t *name, size_t size,
    157     uint16_t *dst, size_t *offset);
     155extern void exfat_dentry_get_name(const exfat_name_dentry_t *, size_t,
     156    uint16_t *, size_t *);
    158157
    159158
    160 extern bool exfat_valid_char(wchar_t ch);
    161 extern bool exfat_valid_name(const char *name);
     159extern bool exfat_valid_char(wchar_t);
     160extern bool exfat_valid_name(const char *);
    162161
    163 extern size_t utf16_length(const uint16_t *wstr);
     162extern size_t utf16_length(const uint16_t *);
    164163
    165164
  • uspace/srv/fs/exfat/exfat_directory.c

    rabb7491c rff0c270  
    7272        di->bs = block_bb_get(di->service_id);
    7373/*      di->blocks = nodep->size / BPS(di->bs); */
    74         di->blocks = ROUND_UP(nodep->size, BPS(di->bs))/BPS(di->bs);
     74        di->blocks = ROUND_UP(nodep->size, BPS(di->bs)) / BPS(di->bs);
    7575        return EOK;
    7676}
     
    9090int exfat_directory_close(exfat_directory_t *di)
    9191{
    92         int rc=EOK;
     92        int rc = EOK;
    9393       
    9494        if (di->b)
     
    113113        if (!di->b) {
    114114                if (di->nodep) {
    115                         rc = exfat_block_get(&di->b, di->bs, di->nodep, i, BLOCK_FLAGS_NONE);
     115                        rc = exfat_block_get(&di->b, di->bs, di->nodep, i,
     116                            BLOCK_FLAGS_NONE);
    116117                } else {
    117                         rc = exfat_block_get_by_clst(&di->b, di->bs, di->service_id,
    118                             di->fragmented, di->firstc, NULL, i, BLOCK_FLAGS_NONE);
     118                        rc = exfat_block_get_by_clst(&di->b, di->bs,
     119                            di->service_id, di->fragmented, di->firstc, NULL, i,
     120                            BLOCK_FLAGS_NONE);
    119121                }
    120122                if (rc != EOK) {
     
    133135        di->pos += 1;
    134136        rc = exfat_directory_block_load(di);
    135         if (rc!=EOK)
     137        if (rc != EOK)
    136138                di->pos -= 1;
    137139       
     
    141143int exfat_directory_prev(exfat_directory_t *di)
    142144{
    143         int rc=EOK;
     145        int rc = EOK;
    144146       
    145147        if (di->pos > 0) {
     
    163165        di->pos = pos;
    164166        rc = exfat_directory_block_load(di);
    165         if (rc!=EOK)
     167        if (rc != EOK)
    166168                di->pos = _pos;
    167169       
     
    182184}
    183185
    184 int exfat_directory_find(exfat_directory_t *di, exfat_dentry_clsf_t type, exfat_dentry_t **d)
     186int exfat_directory_find(exfat_directory_t *di, exfat_dentry_clsf_t type,
     187    exfat_dentry_t **d)
    185188{
    186189        do {
     
    195198}
    196199
    197 int exfat_directory_find_continue(exfat_directory_t *di, exfat_dentry_clsf_t type, exfat_dentry_t **d)
     200int
     201exfat_directory_find_continue(exfat_directory_t *di, exfat_dentry_clsf_t type,
     202    exfat_dentry_t **d)
    198203{
    199204        int rc;
     
    208213    exfat_file_dentry_t *df, exfat_stream_dentry_t *ds)
    209214{
    210         uint16_t wname[EXFAT_FILENAME_LEN+1];
     215        uint16_t wname[EXFAT_FILENAME_LEN + 1];
    211216        exfat_dentry_t *d = NULL;
    212217        int rc, i;
     
    233238                return EOVERFLOW;
    234239
    235         for (i=0; i<df->count-1; i++) {
     240        for (i = 0; i < df->count - 1; i++) {
    236241                rc = exfat_directory_next(di);
    237242                if (rc != EOK)
     
    269274{
    270275        int rc, i, count;
    271         exfat_dentry_t *array=NULL, *de;
     276        exfat_dentry_t *array = NULL, *de;
    272277        aoff64_t pos = di->pos;
    273278
     
    275280        if (rc != EOK)
    276281                return rc;
    277         count = de->file.count+1;
     282        count = de->file.count + 1;
    278283        array = (exfat_dentry_t *) malloc(count*sizeof(exfat_dentry_t));
    279284        if (!array)
    280285                return ENOMEM;
    281         for (i=0; i<count; i++) {
     286        for (i = 0; i < count; i++) {
    282287                rc = exfat_directory_get(di, &de);
    283288                if (rc != EOK)
     
    291296        }
    292297        rc = exfat_directory_seek(di, pos);
    293         if (rc!=EOK) {
     298        if (rc != EOK) {
    294299                free(array);
    295300                return rc;
     
    303308        array[1].stream.data_size = host2uint64_t_le(ds->data_size);
    304309        array[0].file.checksum = host2uint16_t_le(exfat_directory_set_checksum((uint8_t *)array,
    305             count*sizeof(exfat_dentry_t)));
     310            count * sizeof(exfat_dentry_t)));
    306311
    307312        /* Store */
    308         for (i=0; i<count; i++) {
     313        for (i = 0; i < count; i++) {
    309314                rc = exfat_directory_get(di, &de);
    310315                if (rc != EOK)
     
    313318                di->b->dirty = true;
    314319                rc = exfat_directory_next(di);
    315                 if (rc!=EOK) {
     320                if (rc != EOK) {
    316321                        free(array);
    317322                        return rc;
     
    329334        uint16_t *uctable;
    330335        exfat_dentry_t df, ds, *de;
    331         uint16_t wname[EXFAT_FILENAME_LEN+1];
     336        uint16_t wname[EXFAT_FILENAME_LEN + 1];
    332337        int rc, i;
    333338        size_t uctable_chars, j;
     
    399404        uint16_t *sname = wname;
    400405
    401         for (i=0; i<ds.stream.name_size; i++)
     406        for (i = 0; i < ds.stream.name_size; i++)
    402407                wname[i] = host2uint16_t_le(wname[i]);
    403408
    404         for (i=0; i < df.file.count-1; i++) {
     409        for (i = 0; i < df.file.count - 1; i++) {
    405410                rc = exfat_directory_next(di);
    406411                if (rc != EOK)
    407412                        return rc;
    408413
    409                 if (i == df.file.count-2)
    410                         chars = ds.stream.name_size - EXFAT_NAME_PART_LEN*(df.file.count-2);
     414                if (i == df.file.count - 2)
     415                        chars = ds.stream.name_size - EXFAT_NAME_PART_LEN*(df.file.count - 2);
    411416                rc = exfat_directory_get(di, &de);
    412417                if (rc != EOK)
     
    414419                de->type = EXFAT_TYPE_NAME;
    415420                /* test */
    416                 for (j=0; j<chars; j++){
     421                for (j = 0; j < chars; j++) {
    417422                        de->name.name[j] = *sname;
    418423                        sname++;
     
    434439        if (rc != EOK)
    435440                return rc;
    436         count = de->file.count+1;
     441        count = de->file.count + 1;
    437442       
    438443        while (count) {
     
    440445                if (rc != EOK)
    441446                        return rc;
    442                 de->type &= (~EXFAT_TYPE_USED);
     447                de->type &= ~EXFAT_TYPE_USED;
    443448                di->b->dirty = true;
    444449
    445450                rc = exfat_directory_next(di);
    446                 if (rc!=EOK)
     451                if (rc != EOK)
    447452                        return rc;
    448453                count--;
     
    489494                                case EXFAT_DENTRY_LAST:
    490495                                case EXFAT_DENTRY_FREE:
    491                                         if (found==0) pos = di->pos;
     496                                        if (found == 0)
     497                                                pos = di->pos;
    492498                                        found++;
    493499                                        if (found == count) {
  • uspace/srv/fs/exfat/exfat_directory.h

    rabb7491c rff0c270  
    5454
    5555
    56 extern void exfat_directory_init(exfat_directory_t *di);
    57 extern int exfat_directory_open(exfat_node_t *nodep, exfat_directory_t *di);
    58 extern int exfat_directory_open_parent(exfat_directory_t *di,
    59     service_id_t service_id, exfat_cluster_t firstc, bool fragmented);
    60 extern int exfat_directory_close(exfat_directory_t *di);
     56extern void exfat_directory_init(exfat_directory_t *);
     57extern int exfat_directory_open(exfat_node_t *, exfat_directory_t *);
     58extern int exfat_directory_open_parent(exfat_directory_t *, service_id_t,
     59    exfat_cluster_t, bool);
     60extern int exfat_directory_close(exfat_directory_t *);
    6161
    62 extern int exfat_directory_next(exfat_directory_t *di);
    63 extern int exfat_directory_prev(exfat_directory_t *di);
    64 extern int exfat_directory_seek(exfat_directory_t *di, aoff64_t pos);
    65 extern int exfat_directory_get(exfat_directory_t *di, exfat_dentry_t **de);
    66 extern int exfat_directory_find(exfat_directory_t *di,
    67     exfat_dentry_clsf_t type, exfat_dentry_t **d);
    68 extern int exfat_directory_find_continue(exfat_directory_t *di,
    69     exfat_dentry_clsf_t type, exfat_dentry_t **d);
     62extern int exfat_directory_next(exfat_directory_t *);
     63extern int exfat_directory_prev(exfat_directory_t *);
     64extern int exfat_directory_seek(exfat_directory_t *, aoff64_t);
     65extern int exfat_directory_get(exfat_directory_t *, exfat_dentry_t **);
     66extern int exfat_directory_find(exfat_directory_t *, exfat_dentry_clsf_t,
     67    exfat_dentry_t **);
     68extern int exfat_directory_find_continue(exfat_directory_t *,
     69    exfat_dentry_clsf_t, exfat_dentry_t **);
    7070
    71 extern int exfat_directory_read_file(exfat_directory_t *di, char *name,
    72     size_t size, exfat_file_dentry_t *df, exfat_stream_dentry_t *ds);
    73 extern int exfat_directory_sync_file(exfat_directory_t *di,
    74     exfat_file_dentry_t *df, exfat_stream_dentry_t *ds);
    75 extern int exfat_directory_write_file(exfat_directory_t *di, const char *name);
    76 extern int exfat_directory_erase_file(exfat_directory_t *di, aoff64_t pos);
     71extern int exfat_directory_read_file(exfat_directory_t *, char *, size_t,
     72    exfat_file_dentry_t *, exfat_stream_dentry_t *);
     73extern int exfat_directory_sync_file(exfat_directory_t *, exfat_file_dentry_t *,
     74    exfat_stream_dentry_t *);
     75extern int exfat_directory_write_file(exfat_directory_t *, const char *);
     76extern int exfat_directory_erase_file(exfat_directory_t *, aoff64_t);
    7777
    78 extern int exfat_directory_expand(exfat_directory_t *di);
    79 extern int exfat_directory_lookup_free(exfat_directory_t *di, size_t count);
    80 extern int exfat_directory_print(exfat_directory_t *di);
     78extern int exfat_directory_expand(exfat_directory_t *);
     79extern int exfat_directory_lookup_free(exfat_directory_t *, size_t);
     80extern int exfat_directory_print(exfat_directory_t *);
    8181
    8282
Note: See TracChangeset for help on using the changeset viewer.