Changeset a35b458 in mainline for uspace/srv/fs/cdfs/cdfs_ops.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/cdfs/cdfs_ops.c

    r3061bc1 ra35b458  
    9292        uint8_t mon[2];
    9393        uint8_t day[2];
    94        
     94
    9595        uint8_t hour[2];
    9696        uint8_t min[2];
    9797        uint8_t sec[2];
    9898        uint8_t msec[2];
    99        
     99
    100100        uint8_t offset;
    101101} __attribute__((packed)) cdfs_datetime_t;
     
    105105        uint8_t mon;
    106106        uint8_t day;
    107        
     107
    108108        uint8_t hour;
    109109        uint8_t min;
    110110        uint8_t sec;
    111        
     111
    112112        uint8_t offset;
    113113} __attribute__((packed)) cdfs_timestamp_t;
     
    121121        uint8_t length;
    122122        uint8_t ea_length;
    123        
     123
    124124        uint32_t_lb lba;
    125125        uint32_t_lb size;
    126        
     126
    127127        cdfs_timestamp_t timestamp;
    128128        uint8_t flags;
     
    130130        uint8_t gap_size;
    131131        uint16_t_lb sequence_nr;
    132        
     132
    133133        uint8_t name_length;
    134134        uint8_t name[];
     
    139139        uint8_t length;
    140140        uint8_t ea_length;
    141        
     141
    142142        uint32_t_lb lba;
    143143        uint32_t_lb size;
    144        
     144
    145145        cdfs_timestamp_t timestamp;
    146146        uint8_t flags;
     
    148148        uint8_t gap_size;
    149149        uint16_t_lb sequence_nr;
    150        
     150
    151151        uint8_t name_length;
    152152        uint8_t name[1];
     
    155155typedef struct {
    156156        uint8_t flags; /* reserved in primary */
    157        
     157
    158158        uint8_t system_ident[32];
    159159        uint8_t ident[32];
    160        
     160
    161161        uint64_t res1;
    162162        uint32_t_lb lba_size;
    163        
     163
    164164        uint8_t esc_seq[32]; /* reserved in primary */
    165165        uint16_t_lb set_size;
    166166        uint16_t_lb sequence_nr;
    167        
     167
    168168        uint16_t_lb block_size;
    169169        uint32_t_lb path_table_size;
    170        
     170
    171171        uint32_t path_table_lsb;
    172172        uint32_t opt_path_table_lsb;
    173173        uint32_t path_table_msb;
    174174        uint32_t opt_path_table_msb;
    175        
     175
    176176        cdfs_root_dir_t root_dir;
    177177        uint8_t pad0;
    178        
     178
    179179        uint8_t set_ident[128];
    180180        uint8_t publisher_ident[128];
    181181        uint8_t preparer_ident[128];
    182182        uint8_t app_ident[128];
    183        
     183
    184184        uint8_t copyright_file_ident[37];
    185185        uint8_t abstract_file_ident[37];
    186186        uint8_t biblio_file_ident[37];
    187        
     187
    188188        cdfs_datetime_t creation;
    189189        cdfs_datetime_t modification;
    190190        cdfs_datetime_t expiration;
    191191        cdfs_datetime_t effective;
    192        
     192
    193193        uint8_t fs_version;
    194194} __attribute__((packed)) cdfs_vol_desc_prisec_t;
     
    236236        fs_index_t index;         /**< Node index */
    237237        cdfs_t *fs;               /**< File system */
    238        
     238
    239239        ht_link_t nh_link;        /**< Nodes hash table link */
    240240        cdfs_dentry_type_t type;  /**< Dentry type */
    241        
     241
    242242        unsigned int lnkcnt;      /**< Link count */
    243243        uint32_t size;            /**< File size if type is CDFS_FILE */
    244        
     244
    245245        list_t cs_list;           /**< Child's siblings list */
    246246        cdfs_lba_t lba;           /**< LBA of data on disk */
     
    301301        cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link);
    302302        ht_key_t *key = (ht_key_t*)k;
    303        
     303
    304304        return key->service_id == node->fs->service_id && key->index == node->index;
    305305}
     
    308308{
    309309        cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link);
    310        
     310
    311311        if (node->type == CDFS_DIRECTORY) {
    312312                link_t *link;
     
    317317                }
    318318        }
    319        
     319
    320320        free(node->fs_node);
    321321        free(node);
     
    338338                .service_id = service_id
    339339        };
    340        
     340
    341341        ht_link_t *link = hash_table_find(&nodes, &key);
    342342        if (link) {
    343343                cdfs_node_t *node =
    344344                    hash_table_get_inst(link, cdfs_node_t, nh_link);
    345                
     345
    346346                *rfn = FS_NODE(node);
    347347        } else
    348348                *rfn = NULL;
    349        
     349
    350350        return EOK;
    351351}
     
    367367        node->processed = false;
    368368        node->opened = 0;
    369        
     369
    370370        list_initialize(&node->cs_list);
    371371}
     
    375375{
    376376        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
    377        
     377
    378378        cdfs_node_t *node = malloc(sizeof(cdfs_node_t));
    379379        if (!node)
    380380                return ENOMEM;
    381        
     381
    382382        cdfs_node_initialize(node);
    383        
     383
    384384        node->fs_node = malloc(sizeof(fs_node_t));
    385385        if (!node->fs_node) {
     
    387387                return ENOMEM;
    388388        }
    389        
     389
    390390        fs_node_initialize(node->fs_node);
    391391        node->fs_node->data = node;
    392        
     392
    393393        fs_node_t *rootfn;
    394394        errno_t rc = cdfs_root_get(&rootfn, fs->service_id);
    395        
     395
    396396        assert(rc == EOK);
    397        
     397
    398398        if (!rootfn)
    399399                node->index = CDFS_SOME_ROOT;
    400400        else
    401401                node->index = index;
    402        
     402
    403403        node->fs = fs;
    404        
     404
    405405        if (lflag & L_DIRECTORY)
    406406                node->type = CDFS_DIRECTORY;
    407407        else
    408408                node->type = CDFS_FILE;
    409        
     409
    410410        /* Insert the new node into the nodes hash table. */
    411411        hash_table_insert(&nodes, &node->nh_link);
    412        
     412
    413413        *rfn = FS_NODE(node);
    414414        nodes_cached++;
    415        
     415
    416416        return EOK;
    417417}
     
    421421        cdfs_node_t *parent = CDFS_NODE(pfn);
    422422        cdfs_node_t *node = CDFS_NODE(fn);
    423        
     423
    424424        assert(parent->type == CDFS_DIRECTORY);
    425        
     425
    426426        /* Check for duplicate entries */
    427427        list_foreach(parent->cs_list, link, cdfs_dentry_t, dentry) {
     
    429429                        return EEXIST;
    430430        }
    431        
     431
    432432        /* Allocate and initialize the dentry */
    433433        cdfs_dentry_t *dentry = malloc(sizeof(cdfs_dentry_t));
    434434        if (!dentry)
    435435                return ENOMEM;
    436        
     436
    437437        /* Populate and link the new dentry */
    438438        dentry->name = str_dup(name);
     
    441441                return ENOMEM;
    442442        }
    443        
     443
    444444        link_initialize(&dentry->link);
    445445        dentry->index = node->index;
    446        
     446
    447447        node->lnkcnt++;
    448448        list_append(&dentry->link, &parent->cs_list);
    449        
     449
    450450        return EOK;
    451451}
     
    463463        char *str;
    464464        uint16_t *buf;
    465        
     465
    466466        switch (enc) {
    467467        case enc_ascii:
     
    476476                if (buf == NULL)
    477477                        return NULL;
    478                
     478
    479479                size_t i;
    480480                for (i = 0; i < dsize / sizeof(uint16_t); i++) {
     
    482482                            ((unaligned_uint16_t *)data)[i]);
    483483                }
    484                
     484
    485485                size_t dstr_size = dsize / sizeof(uint16_t) * 4 + 1;
    486486                str = malloc(dstr_size);
    487487                if (str == NULL)
    488488                        return NULL;
    489                
     489
    490490                rc = utf16_to_str(str, dstr_size, buf);
    491491                free(buf);
    492                
     492
    493493                if (rc != EOK)
    494494                        return NULL;
     
    498498                str = NULL;
    499499        }
    500        
     500
    501501        return str;
    502502}
     
    516516        char *dot;
    517517        char *scolon;
    518        
     518
    519519        name = cdfs_decode_str(data, dsize, enc);
    520520        if (name == NULL)
    521521                return NULL;
    522        
     522
    523523        if (dtype == CDFS_DIRECTORY)
    524524                return name;
    525        
     525
    526526        dot = str_chr(name, '.');
    527        
     527
    528528        if (dot != NULL) {
    529529                scolon = str_chr(dot, ';');
     
    532532                        *scolon = '\0';
    533533                }
    534        
     534
    535535                /* If the extension is an empty string, trim the dot separator. */
    536536                if (dot[1] == '\0')
    537537                        *dot = '\0';
    538538        }
    539        
     539
    540540        return name;
    541541}
     
    552552        char *ident;
    553553        size_t i;
    554        
     554
    555555        ident = cdfs_decode_str(data, dsize, enc);
    556556        if (ident == NULL)
    557557                return NULL;
    558        
     558
    559559        /* Trim trailing spaces */
    560560        i = str_size(ident);
     
    562562                --i;
    563563        ident[i] = '\0';
    564        
     564
    565565        return ident;
    566566}
     
    570570        cdfs_node_t *node = CDFS_NODE(fs_node);
    571571        assert(node);
    572        
     572
    573573        if (node->processed)
    574574                return EOK;
    575        
     575
    576576        uint32_t blocks = node->size / BLOCK_SIZE;
    577577        if ((node->size % BLOCK_SIZE) != 0)
    578578                blocks++;
    579        
     579
    580580        for (uint32_t i = 0; i < blocks; i++) {
    581581                block_t *block;
     
    583583                if (rc != EOK)
    584584                        return rc;
    585                
     585
    586586                cdfs_dir_t *dir;
    587                
     587
    588588                for (size_t offset = 0; offset < BLOCK_SIZE;
    589589                    offset += dir->length) {
     
    595595                                break;
    596596                        }
    597                        
     597
    598598                        cdfs_dentry_type_t dentry_type;
    599599                        if (dir->flags & DIR_FLAG_DIRECTORY)
     
    601601                        else
    602602                                dentry_type = CDFS_FILE;
    603                        
     603
    604604                        /* Skip special entries */
    605                        
     605
    606606                        if (dir->name_length == 1 &&
    607607                            dir->name[0] == CDFS_NAME_CURDIR)
     
    610610                            dir->name[0] == CDFS_NAME_PARENTDIR)
    611611                                continue;
    612                        
     612
    613613                        // FIXME: hack - indexing by dentry byte offset on disc
    614                        
     614
    615615                        fs_node_t *fn;
    616616                        errno_t rc = create_node(&fn, fs, dentry_type,
     
    620620
    621621                        assert(fn != NULL);
    622                        
     622
    623623                        cdfs_node_t *cur = CDFS_NODE(fn);
    624624                        cur->lba = uint32_lb(dir->lba);
    625625                        cur->size = uint32_lb(dir->size);
    626                        
     626
    627627                        char *name = cdfs_decode_name(dir->name,
    628628                            dir->name_length, node->fs->enc, dentry_type);
    629629                        if (name == NULL)
    630630                                return EIO;
    631                        
     631
    632632                        // FIXME: check return value
    633                        
     633
    634634                        link_node(fs_node, fn, name);
    635635                        free(name);
    636                        
     636
    637637                        if (dentry_type == CDFS_FILE)
    638638                                cur->processed = true;
    639639                }
    640                
     640
    641641                block_put(block);
    642642        }
    643        
     643
    644644        node->processed = true;
    645645        return EOK;
     
    650650        cdfs_lba_t lba = index / BLOCK_SIZE;
    651651        size_t offset = index % BLOCK_SIZE;
    652        
     652
    653653        block_t *block;
    654654        errno_t rc = block_get(&block, fs->service_id, lba, BLOCK_FLAGS_NONE);
    655655        if (rc != EOK)
    656656                return NULL;
    657        
     657
    658658        cdfs_dir_t *dir = (cdfs_dir_t *) (block->data + offset);
    659        
     659
    660660        cdfs_dentry_type_t dentry_type;
    661661        if (dir->flags & DIR_FLAG_DIRECTORY)
     
    663663        else
    664664                dentry_type = CDFS_FILE;
    665        
     665
    666666        fs_node_t *fn;
    667667        rc = create_node(&fn, fs, dentry_type, index);
    668668        if ((rc != EOK) || (fn == NULL))
    669669                return NULL;
    670        
     670
    671671        cdfs_node_t *node = CDFS_NODE(fn);
    672672        node->lba = uint32_lb(dir->lba);
    673673        node->size = uint32_lb(dir->size);
    674674        node->lnkcnt = 1;
    675        
     675
    676676        if (dentry_type == CDFS_FILE)
    677677                node->processed = true;
    678        
     678
    679679        block_put(block);
    680680        return fn;
     
    687687                .service_id = fs->service_id
    688688        };
    689        
     689
    690690        ht_link_t *link = hash_table_find(&nodes, &key);
    691691        if (link) {
     
    694694                return FS_NODE(node);
    695695        }
    696        
     696
    697697        return get_uncached_node(fs, index);
    698698}
     
    701701{
    702702        cdfs_node_t *parent = CDFS_NODE(pfn);
    703        
     703
    704704        if (!parent->processed) {
    705705                errno_t rc = cdfs_readdir(parent->fs, pfn);
     
    707707                        return rc;
    708708        }
    709        
     709
    710710        list_foreach(parent->cs_list, link, cdfs_dentry_t, dentry) {
    711711                if (str_cmp(dentry->name, component) == 0) {
     
    714714                }
    715715        }
    716        
     716
    717717        *fn = NULL;
    718718        return EOK;
     
    722722{
    723723        cdfs_node_t *node = CDFS_NODE(fn);
    724        
     724
    725725        if (!node->processed)
    726726                cdfs_readdir(node->fs, fn);
    727        
     727
    728728        node->opened++;
    729729        return EOK;
     
    763763{
    764764        cdfs_node_t *node = CDFS_NODE(fn);
    765        
     765
    766766        if ((node->type == CDFS_DIRECTORY) && (!node->processed))
    767767                cdfs_readdir(node->fs, fn);
    768        
     768
    769769        *has_children = !list_empty(&node->cs_list);
    770770        return EOK;
     
    809809{
    810810        *size = BLOCK_SIZE;
    811        
     811
    812812        return EOK;
    813813}
     
    816816{
    817817        *count = 0;
    818        
     818
    819819        return EOK;
    820820}
     
    823823{
    824824        *count = 0;
    825        
     825
    826826        return EOK;
    827827}
     
    855855        size_t i, j, k;
    856856        bool match;
    857        
     857
    858858        i = 0;
    859859        while (i + ucs2_esc_seq_len <= 32) {
    860860                if (seq[i] == 0)
    861861                        break;
    862                
     862
    863863                for (j = 0; j < ucs2_esc_seq_no; j++) {
    864864                        match = true;
     
    870870                        }
    871871                }
    872                
     872
    873873                if (!match)
    874874                        return EINVAL;
    875                
     875
    876876                i += ucs2_esc_seq_len;
    877877        }
    878        
     878
    879879        while (i < 32) {
    880880                if (seq[i] != 0)
     
    882882                ++i;
    883883        }
    884        
     884
    885885        return EOK;
    886886}
     
    905905                if (rc != EOK)
    906906                        break;
    907                
     907
    908908                cdfs_vol_desc_t *vol_desc = (cdfs_vol_desc_t *) block->data;
    909                
     909
    910910                if (vol_desc->type == VOL_DESC_SET_TERMINATOR) {
    911911                        block_put(block);
    912912                        break;
    913913                }
    914                
     914
    915915                if ((vol_desc->type != VOL_DESC_SUPPLEMENTARY) ||
    916916                    (memcmp(vol_desc->standard_ident, CDFS_STANDARD_IDENT, 5) != 0) ||
     
    919919                        continue;
    920920                }
    921                
     921
    922922                uint16_t set_size = uint16_lb(vol_desc->data.prisec.set_size);
    923923                if (set_size > 1) {
     
    929929                         */
    930930                }
    931                
     931
    932932                uint16_t sequence_nr = uint16_lb(vol_desc->data.prisec.sequence_nr);
    933933                if (sequence_nr != 1) {
     
    939939                        continue;
    940940                }
    941                
     941
    942942                uint16_t block_size = uint16_lb(vol_desc->data.prisec.block_size);
    943943                if (block_size != BLOCK_SIZE) {
     
    945945                        continue;
    946946                }
    947                
     947
    948948                rc = cdfs_verify_joliet_esc_seq(vol_desc->data.prisec.esc_seq);
    949949                if (rc != EOK)
     
    958958                return EOK;
    959959        }
    960        
     960
    961961        return ENOENT;
    962962}
     
    971971        if (rc != EOK)
    972972                return rc;
    973        
     973
    974974        cdfs_vol_desc_t *vol_desc = (cdfs_vol_desc_t *) block->data;
    975        
     975
    976976        /*
    977977         * Test for primary volume descriptor
     
    984984                return ENOTSUP;
    985985        }
    986        
     986
    987987        uint16_t set_size = uint16_lb(vol_desc->data.prisec.set_size);
    988988        if (set_size > 1) {
     
    994994                 */
    995995        }
    996        
     996
    997997        uint16_t sequence_nr = uint16_lb(vol_desc->data.prisec.sequence_nr);
    998998        if (sequence_nr != 1) {
     
    10041004                return ENOTSUP;
    10051005        }
    1006        
     1006
    10071007        uint16_t block_size = uint16_lb(vol_desc->data.prisec.block_size);
    10081008        if (block_size != BLOCK_SIZE) {
     
    10101010                return ENOTSUP;
    10111011        }
    1012        
     1012
    10131013        // TODO: implement path table support
    1014        
     1014
    10151015        /* Search for Joliet SVD */
    1016        
     1016
    10171017        uint32_t jrlba;
    10181018        uint32_t jrsize;
    1019        
     1019
    10201020        rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize, vol_ident);
    10211021        if (rc == EOK) {
     
    10311031                    32, enc_ascii);
    10321032        }
    1033        
     1033
    10341034        block_put(block);
    10351035        return EOK;
     
    10401040{
    10411041        cdfs_node_t *node = CDFS_NODE(rfn);
    1042        
     1042
    10431043        errno_t rc = iso_read_vol_desc(fs->service_id, altroot, &node->lba,
    10441044            &node->size, &fs->enc, &fs->vol_ident);
    10451045        if (rc != EOK)
    10461046                return rc;
    1047        
     1047
    10481048        return cdfs_readdir(fs, rfn);
    10491049}
     
    10601060        if (fs == NULL)
    10611061                goto error;
    1062        
     1062
    10631063        fs->service_id = sid;
    1064        
     1064
    10651065        /* Create root node */
    10661066        errno_t rc = create_node(&rfn, fs, L_DIRECTORY, cdfs_index++);
    1067        
     1067
    10681068        if ((rc != EOK) || (!rfn))
    10691069                goto error;
    1070        
     1070
    10711071        /* FS root is not linked */
    10721072        CDFS_NODE(rfn)->lnkcnt = 0;
    10731073        CDFS_NODE(rfn)->lba = 0;
    10741074        CDFS_NODE(rfn)->processed = false;
    1075        
     1075
    10761076        /* Check if there is cdfs in given session */
    10771077        if (iso_readfs(fs, rfn, altroot) != EOK)
    10781078                goto error;
    1079        
     1079
    10801080        list_append(&fs->link, &cdfs_instances);
    10811081        return fs;
     
    10941094        if (rc != EOK)
    10951095                return rc;
    1096        
     1096
    10971097        cdfs_lba_t altroot = 0;
    1098        
     1098
    10991099        /*
    11001100         * Read TOC multisession information and get the start address
     
    11061106        if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10))
    11071107                altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
    1108        
     1108
    11091109        /* Initialize the block cache */
    11101110        rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT);
     
    11131113                return rc;
    11141114        }
    1115        
     1115
    11161116        /* Check if this device is not already mounted */
    11171117        fs_node_t *rootfn;
     
    11231123                return EOK;
    11241124        }
    1125        
     1125
    11261126        /* Read volume descriptors */
    11271127        uint32_t rlba;
     
    11351135                return rc;
    11361136        }
    1137        
     1137
    11381138        str_cpy(info->label, FS_LABEL_MAXLEN + 1, vol_ident);
    11391139        free(vol_ident);
    1140        
     1140
    11411141        block_cache_fini(service_id);
    11421142        block_fini(service_id);
     
    11511151        if (rc != EOK)
    11521152                return rc;
    1153        
     1153
    11541154        cdfs_lba_t altroot = 0;
    1155        
     1155
    11561156        if (str_lcmp(opts, "altroot=", 8) == 0) {
    11571157                /* User-defined alternative root on a multi-session disk */
     
    11691169                        altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
    11701170        }
    1171        
     1171
    11721172        /* Initialize the block cache */
    11731173        rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT);
     
    11761176                return rc;
    11771177        }
    1178        
     1178
    11791179        /* Check if this device is not already mounted */
    11801180        fs_node_t *rootfn;
     
    11841184                block_cache_fini(service_id);
    11851185                block_fini(service_id);
    1186                
     1186
    11871187                return EEXIST;
    11881188        }
    1189        
     1189
    11901190        /* Create cdfs instance */
    11911191        if (cdfs_fs_create(service_id, altroot) == NULL) {
    11921192                block_cache_fini(service_id);
    11931193                block_fini(service_id);
    1194                
     1194
    11951195                return ENOMEM;
    11961196        }
    1197        
     1197
    11981198        rc = cdfs_root_get(&rootfn, service_id);
    11991199        assert(rc == EOK);
    1200        
     1200
    12011201        cdfs_node_t *root = CDFS_NODE(rootfn);
    12021202        *index = root->index;
    12031203        *size = root->size;
    1204        
     1204
    12051205        return EOK;
    12061206}
     
    12101210        service_id_t service_id = *(service_id_t*)arg;
    12111211        cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link);
    1212        
     1212
    12131213        if (node->fs->service_id == service_id) {
    12141214                hash_table_remove_item(&nodes, &node->nh_link);
    12151215        }
    1216        
     1216
    12171217        return true;
    12181218}
     
    12341234                        return fs;
    12351235        }
    1236        
     1236
    12371237        return NULL;
    12381238}
     
    12451245        if (fs == NULL)
    12461246                return ENOENT;
    1247        
     1247
    12481248        cdfs_fs_destroy(fs);
    12491249        return EOK;
     
    12571257                .service_id = service_id
    12581258        };
    1259        
     1259
    12601260        ht_link_t *link = hash_table_find(&nodes, &key);
    12611261        if (link == NULL)
    12621262                return ENOENT;
    1263        
     1263
    12641264        cdfs_node_t *node =
    12651265            hash_table_get_inst(link, cdfs_node_t, nh_link);
    1266        
     1266
    12671267        if (!node->processed) {
    12681268                errno_t rc = cdfs_readdir(node->fs, FS_NODE(node));
     
    12701270                        return rc;
    12711271        }
    1272        
     1272
    12731273        ipc_callid_t callid;
    12741274        size_t len;
     
    12771277                return EINVAL;
    12781278        }
    1279        
     1279
    12801280        if (node->type == CDFS_FILE) {
    12811281                if (pos >= node->size) {
     
    12851285                        cdfs_lba_t lba = pos / BLOCK_SIZE;
    12861286                        size_t offset = pos % BLOCK_SIZE;
    1287                        
     1287
    12881288                        *rbytes = min(len, BLOCK_SIZE - offset);
    12891289                        *rbytes = min(*rbytes, node->size - pos);
    1290                        
     1290
    12911291                        block_t *block;
    12921292                        errno_t rc = block_get(&block, service_id, node->lba + lba,
     
    12961296                                return rc;
    12971297                        }
    1298                        
     1298
    12991299                        async_data_read_finalize(callid, block->data + offset,
    13001300                            *rbytes);
     
    13091309                        return ENOENT;
    13101310                }
    1311                
     1311
    13121312                cdfs_dentry_t *dentry =
    13131313                    list_get_instance(link, cdfs_dentry_t, link);
    1314                
     1314
    13151315                *rbytes = 1;
    13161316                async_data_read_finalize(callid, dentry->name,
    13171317                    str_size(dentry->name) + 1);
    13181318        }
    1319        
     1319
    13201320        return EOK;
    13211321}
     
    13281328         * the operation is not supported.
    13291329         */
    1330        
     1330
    13311331        return ENOTSUP;
    13321332}
     
    13391339         * the operation is not supported.
    13401340         */
    1341        
     1341
    13421342        return ENOTSUP;
    13431343}
     
    13461346{
    13471347        size_t *premove_cnt = (size_t*)arg;
    1348        
     1348
    13491349        /* Some nodes were requested to be removed from the cache. */
    13501350        if (0 < *premove_cnt) {
     
    13531353                if (!node->opened) {
    13541354                        hash_table_remove_item(&nodes, item);
    1355                        
     1355
    13561356                        --nodes_cached;
    13571357                        --*premove_cnt;
    13581358                }
    13591359        }
    1360        
     1360
    13611361        /* Only continue if more nodes were requested to be removed. */
    13621362        return 0 < *premove_cnt;
     
    13671367        if (nodes_cached > NODE_CACHE_SIZE) {
    13681368                size_t remove_cnt = nodes_cached - NODE_CACHE_SIZE;
    1369                
     1369
    13701370                if (0 < remove_cnt)
    13711371                        hash_table_apply(&nodes, cache_remove_closed, &remove_cnt);
     
    13781378        if (index == 0)
    13791379                return EOK;
    1380        
     1380
    13811381        ht_key_t key = {
    13821382                .index = index,
    13831383                .service_id = service_id
    13841384        };
    1385        
     1385
    13861386        ht_link_t *link = hash_table_find(&nodes, &key);
    13871387        if (link == 0)
    13881388                return ENOENT;
    1389        
     1389
    13901390        cdfs_node_t *node =
    13911391            hash_table_get_inst(link, cdfs_node_t, nh_link);
    1392        
     1392
    13931393        assert(node->opened > 0);
    1394        
     1394
    13951395        node->opened--;
    13961396        cleanup_cache(service_id);
    1397        
     1397
    13981398        return EOK;
    13991399}
     
    14051405         * the operation is not supported.
    14061406         */
    1407        
     1407
    14081408        return ENOTSUP;
    14091409}
     
    14151415         * the sync operation is a no-op.
    14161416         */
    1417        
     1417
    14181418        return EOK;
    14191419}
     
    14381438        if (!hash_table_create(&nodes, 0, 0, &nodes_ops))
    14391439                return false;
    1440        
     1440
    14411441        return true;
    14421442}
Note: See TracChangeset for help on using the changeset viewer.