Changeset a35b458 in mainline for uspace/srv/fs/locfs/locfs_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/locfs/locfs_ops.c

    r3061bc1 ra35b458  
    109109                return ENOMEM;
    110110        }
    111        
     111
    112112        *rfn = (fs_node_t *) malloc(sizeof(fs_node_t));
    113113        if (*rfn == NULL) {
     
    116116                return ENOMEM;
    117117        }
    118        
     118
    119119        fs_node_initialize(*rfn);
    120120        node->type = type;
    121121        node->service_id = service_id;
    122        
     122
    123123        (*rfn)->data = node;
    124124        return EOK;
     
    134134        locfs_node_t *node = (locfs_node_t *) pfn->data;
    135135        errno_t ret;
    136        
     136
    137137        if (node->service_id == 0) {
    138138                /* Root directory */
    139                
     139
    140140                loc_sdesc_t *nspaces;
    141141                size_t count = loc_get_namespaces(&nspaces);
    142                
     142
    143143                if (count > 0) {
    144144                        size_t pos;
     
    147147                                if (str_cmp(nspaces[pos].name, "") == 0)
    148148                                        continue;
    149                                
     149
    150150                                if (str_cmp(nspaces[pos].name, component) == 0) {
    151151                                        ret = locfs_node_get_internal(rfn, LOC_OBJECT_NAMESPACE, nspaces[pos].id);
     
    154154                                }
    155155                        }
    156                        
     156
    157157                        free(nspaces);
    158158                }
    159                
     159
    160160                /* Search root namespace */
    161161                service_id_t namespace;
     
    163163                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
    164164                        count = loc_get_services(namespace, &svcs);
    165                        
     165
    166166                        if (count > 0) {
    167167                                size_t pos;
     
    173173                                        }
    174174                                }
    175                                
     175
    176176                                free(svcs);
    177177                        }
    178178                }
    179                
     179
    180180                *rfn = NULL;
    181181                return EOK;
    182182        }
    183        
     183
    184184        if (node->type == LOC_OBJECT_NAMESPACE) {
    185185                /* Namespace directory */
    186                
     186
    187187                loc_sdesc_t *svcs;
    188188                size_t count = loc_get_services(node->service_id, &svcs);
     
    196196                                }
    197197                        }
    198                        
     198
    199199                        free(svcs);
    200200                }
    201                
     201
    202202                *rfn = NULL;
    203203                return EOK;
    204204        }
    205        
     205
    206206        *rfn = NULL;
    207207        return EOK;
     
    216216{
    217217        locfs_node_t *node = (locfs_node_t *) fn->data;
    218        
     218
    219219        if (node->service_id == 0) {
    220220                /* Root directory */
    221221                return EOK;
    222222        }
    223        
     223
    224224        loc_object_type_t type = loc_id_probe(node->service_id);
    225        
     225
    226226        if (type == LOC_OBJECT_NAMESPACE) {
    227227                /* Namespace directory */
    228228                return EOK;
    229229        }
    230        
     230
    231231        if (type == LOC_OBJECT_SERVICE) {
    232232                /* Device node */
    233                
     233
    234234                fibril_mutex_lock(&services_mutex);
    235235                ht_link_t *lnk;
     
    242242                                return ENOMEM;
    243243                        }
    244                        
     244
    245245                        dev->service_id = node->service_id;
    246                        
     246
    247247                        /* Mark as incomplete */
    248248                        dev->sess = NULL;
    249249                        dev->refcount = 1;
    250250                        fibril_condvar_initialize(&dev->cv);
    251                        
     251
    252252                        /*
    253253                         * Insert the incomplete device structure so that other
     
    256256                         */
    257257                        hash_table_insert(&services, &dev->link);
    258                        
     258
    259259                        /*
    260260                         * Drop the mutex to allow recursive locfs requests.
    261261                         */
    262262                        fibril_mutex_unlock(&services_mutex);
    263                        
     263
    264264                        async_sess_t *sess = loc_service_connect(node->service_id,
    265265                            INTERFACE_FS, 0);
    266                        
     266
    267267                        fibril_mutex_lock(&services_mutex);
    268                        
     268
    269269                        /*
    270270                         * Notify possible waiters about this device structure
     
    272272                         */
    273273                        fibril_condvar_broadcast(&dev->cv);
    274                        
     274
    275275                        if (!sess) {
    276276                                /*
     
    280280                                hash_table_remove(&services, &node->service_id);
    281281                                fibril_mutex_unlock(&services_mutex);
    282                                
     282
    283283                                return ENOENT;
    284284                        }
    285                        
     285
    286286                        /* Set the correct session. */
    287287                        dev->sess = sess;
    288288                } else {
    289289                        service_t *dev = hash_table_get_inst(lnk, service_t, link);
    290                        
     290
    291291                        if (!dev->sess) {
    292292                                /*
     
    303303                        dev->refcount++;
    304304                }
    305                
     305
    306306                fibril_mutex_unlock(&services_mutex);
    307                
    308                 return EOK;
    309         }
    310        
     307
     308                return EOK;
     309        }
     310
    311311        return ENOENT;
    312312}
     
    322322{
    323323        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
    324        
     324
    325325        *rfn = NULL;
    326326        return ENOTSUP;
     
    345345{
    346346        locfs_node_t *node = (locfs_node_t *) fn->data;
    347        
     347
    348348        if (node->service_id == 0) {
    349349                size_t count = loc_count_namespaces();
     
    352352                        return EOK;
    353353                }
    354                
     354
    355355                /* Root namespace */
    356356                service_id_t namespace;
     
    362362                        }
    363363                }
    364                
     364
    365365                *has_children = false;
    366366                return EOK;
    367367        }
    368        
     368
    369369        if (node->type == LOC_OBJECT_NAMESPACE) {
    370370                size_t count = loc_count_services(node->service_id);
     
    373373                        return EOK;
    374374                }
    375                
     375
    376376                *has_children = false;
    377377                return EOK;
    378378        }
    379        
     379
    380380        *has_children = false;
    381381        return EOK;
     
    396396{
    397397        locfs_node_t *node = (locfs_node_t *) fn->data;
    398        
     398
    399399        if (node->service_id == 0)
    400400                return 0;
    401        
     401
    402402        return 1;
    403403}
     
    406406{
    407407        locfs_node_t *node = (locfs_node_t *) fn->data;
    408        
     408
    409409        return ((node->type == LOC_OBJECT_NONE) || (node->type == LOC_OBJECT_NAMESPACE));
    410410}
     
    413413{
    414414        locfs_node_t *node = (locfs_node_t *) fn->data;
    415        
     415
    416416        return (node->type == LOC_OBJECT_SERVICE);
    417417}
     
    420420{
    421421        locfs_node_t *node = (locfs_node_t *) fn->data;
    422        
     422
    423423        if (node->type == LOC_OBJECT_SERVICE)
    424424                return node->service_id;
    425        
     425
    426426        return 0;
    427427}
     
    451451        if (!hash_table_create(&services, 0,  0, &services_ops))
    452452                return false;
    453        
     453
    454454        return true;
    455455}
     
    484484                        return EINVAL;
    485485                }
    486                
     486
    487487                loc_sdesc_t *desc;
    488488                size_t count = loc_get_namespaces(&desc);
    489                
     489
    490490                /* Get rid of root namespace */
    491491                size_t i;
     
    494494                                if (pos >= i)
    495495                                        pos++;
    496                                
     496
    497497                                break;
    498498                        }
    499499                }
    500                
     500
    501501                if (pos < count) {
    502502                        async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
     
    505505                        return EOK;
    506506                }
    507                
     507
    508508                free(desc);
    509509                pos -= count;
    510                
     510
    511511                /* Search root namespace */
    512512                service_id_t namespace;
    513513                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
    514514                        count = loc_get_services(namespace, &desc);
    515                        
     515
    516516                        if (pos < count) {
    517517                                async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
     
    520520                                return EOK;
    521521                        }
    522                        
     522
    523523                        free(desc);
    524524                }
    525                
     525
    526526                async_answer_0(callid, ENOENT);
    527527                return ENOENT;
    528528        }
    529        
     529
    530530        loc_object_type_t type = loc_id_probe(index);
    531        
     531
    532532        if (type == LOC_OBJECT_NAMESPACE) {
    533533                /* Namespace directory */
     
    538538                        return EINVAL;
    539539                }
    540                
     540
    541541                loc_sdesc_t *desc;
    542542                size_t count = loc_get_services(index, &desc);
    543                
     543
    544544                if (pos < count) {
    545545                        async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
     
    548548                        return EOK;
    549549                }
    550                
     550
    551551                free(desc);
    552552                async_answer_0(callid, ENOENT);
    553553                return ENOENT;
    554554        }
    555        
     555
    556556        if (type == LOC_OBJECT_SERVICE) {
    557557                /* Device node */
    558                
     558
    559559                fibril_mutex_lock(&services_mutex);
    560560                service_id_t service_index = index;
     
    564564                        return ENOENT;
    565565                }
    566                
     566
    567567                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    568568                assert(dev->sess);
    569                
     569
    570570                ipc_callid_t callid;
    571571                if (!async_data_read_receive(&callid, NULL)) {
     
    574574                        return EINVAL;
    575575                }
    576                
     576
    577577                /* Make a request at the driver */
    578578                async_exch_t *exch = async_exchange_begin(dev->sess);
    579                
     579
    580580                ipc_call_t answer;
    581581                aid_t msg = async_send_4(exch, VFS_OUT_READ, service_id,
    582582                    index, LOWER32(pos), UPPER32(pos), &answer);
    583                
     583
    584584                /* Forward the IPC_M_DATA_READ request to the driver */
    585585                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    586                
     586
    587587                async_exchange_end(exch);
    588                
     588
    589589                fibril_mutex_unlock(&services_mutex);
    590                
     590
    591591                /* Wait for reply from the driver. */
    592592                errno_t rc;
     
    596596                if ((errno_t) rc == EHANGUP)
    597597                        rc = ENOTSUP;
    598                
     598
    599599                *rbytes = IPC_GET_ARG1(answer);
    600600                return rc;
    601601        }
    602        
     602
    603603        return ENOENT;
    604604}
     
    610610        if (index == 0)
    611611                return ENOTSUP;
    612        
     612
    613613        loc_object_type_t type = loc_id_probe(index);
    614        
     614
    615615        if (type == LOC_OBJECT_NAMESPACE) {
    616616                /* Namespace directory */
    617617                return ENOTSUP;
    618618        }
    619        
     619
    620620        if (type == LOC_OBJECT_SERVICE) {
    621621                /* Device node */
    622                
     622
    623623                fibril_mutex_lock(&services_mutex);
    624624                service_id_t service_index = index;
     
    628628                        return ENOENT;
    629629                }
    630                
     630
    631631                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    632632                assert(dev->sess);
    633                
     633
    634634                ipc_callid_t callid;
    635635                if (!async_data_write_receive(&callid, NULL)) {
     
    638638                        return EINVAL;
    639639                }
    640                
     640
    641641                /* Make a request at the driver */
    642642                async_exch_t *exch = async_exchange_begin(dev->sess);
    643                
     643
    644644                ipc_call_t answer;
    645645                aid_t msg = async_send_4(exch, VFS_OUT_WRITE, service_id,
    646646                    index, LOWER32(pos), UPPER32(pos), &answer);
    647                
     647
    648648                /* Forward the IPC_M_DATA_WRITE request to the driver */
    649649                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    650                
     650
    651651                async_exchange_end(exch);
    652                
     652
    653653                fibril_mutex_unlock(&services_mutex);
    654                
     654
    655655                /* Wait for reply from the driver. */
    656656                errno_t rc;
     
    660660                if ((errno_t) rc == EHANGUP)
    661661                        rc = ENOTSUP;
    662                
     662
    663663                *wbytes = IPC_GET_ARG1(answer);
    664664                *nsize = 0;
    665665                return rc;
    666666        }
    667        
     667
    668668        return ENOENT;
    669669}
     
    679679        if (index == 0)
    680680                return EOK;
    681        
     681
    682682        loc_object_type_t type = loc_id_probe(index);
    683        
     683
    684684        if (type == LOC_OBJECT_NAMESPACE) {
    685685                /* Namespace directory */
    686686                return EOK;
    687687        }
    688        
     688
    689689        if (type == LOC_OBJECT_SERVICE) {
    690                
     690
    691691                fibril_mutex_lock(&services_mutex);
    692692                service_id_t service_index = index;
     
    696696                        return ENOENT;
    697697                }
    698                
     698
    699699                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    700700                assert(dev->sess);
    701701                dev->refcount--;
    702                
     702
    703703                if (dev->refcount == 0) {
    704704                        async_hangup(dev->sess);
     
    706706                        hash_table_remove(&services, &service_index);
    707707                }
    708                
     708
    709709                fibril_mutex_unlock(&services_mutex);
    710                
    711                 return EOK;
    712         }
    713        
     710
     711                return EOK;
     712        }
     713
    714714        return ENOENT;
    715715}
     
    719719        if (index == 0)
    720720                return EOK;
    721        
     721
    722722        loc_object_type_t type = loc_id_probe(index);
    723        
     723
    724724        if (type == LOC_OBJECT_NAMESPACE) {
    725725                /* Namespace directory */
    726726                return EOK;
    727727        }
    728        
     728
    729729        if (type == LOC_OBJECT_SERVICE) {
    730730
     
    736736                        return ENOENT;
    737737                }
    738                
     738
    739739                service_t *dev = hash_table_get_inst(lnk, service_t, link);
    740740                assert(dev->sess);
    741                
     741
    742742                /* Make a request at the driver */
    743743                async_exch_t *exch = async_exchange_begin(dev->sess);
    744                
     744
    745745                ipc_call_t answer;
    746746                aid_t msg = async_send_2(exch, VFS_OUT_SYNC, service_id,
    747747                    index, &answer);
    748                
     748
    749749                async_exchange_end(exch);
    750                
     750
    751751                fibril_mutex_unlock(&services_mutex);
    752                
     752
    753753                /* Wait for reply from the driver */
    754754                errno_t rc;
    755755                async_wait_for(msg, &rc);
    756                
     756
    757757                return rc;
    758758        }
    759        
     759
    760760        return  ENOENT;
    761761}
Note: See TracChangeset for help on using the changeset viewer.