Changeset 4f9ab1e in mainline


Ignore:
Timestamp:
2017-03-18T14:25:47Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f6b6b40
Parents:
7f59d6c
Message:

vfs_node_peek() should add a reference to the node

Location:
uspace/srv/vfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_lookup.c

    r7f59d6c r4f9ab1e  
    314314                if (nlen > 0) {
    315315                        base = vfs_node_peek(&res);
    316                         if (base == NULL || base->mount == NULL) {
     316                        if (!base) {
    317317                                rc = ENOENT;
    318318                                goto out;
    319319                        }
     320                        if (!base->mount) {
     321                                vfs_node_put(base);
     322                                rc = ENOENT;
     323                                goto out;
     324                        }
     325                        vfs_node_put(base);
    320326                        if (lflag & L_DISABLE_MOUNTS) {
    321327                                rc = EXDEV;
     
    330336        if (result != NULL) {
    331337                /* The found file may be a mount point. Try to cross it. */
    332                 if (!(lflag & (L_MP|L_DISABLE_MOUNTS))) {
     338                if (!(lflag & (L_MP | L_DISABLE_MOUNTS))) {
    333339                        base = vfs_node_peek(&res);
    334                         if (base != NULL && base->mount != NULL) {
    335                                 while (base->mount != NULL) {
    336                                         base = base->mount;
     340                        if (base && base->mount) {
     341                                while (base->mount) {
     342                                        vfs_node_addref(base->mount);
     343                                        vfs_node_t *nbase = base->mount;
     344                                        vfs_node_put(base);
     345                                        base = nbase;
    337346                                }
    338347                               
    339                                 result->triplet = *(vfs_triplet_t *)base;
     348                                result->triplet = *((vfs_triplet_t *) base);
    340349                                result->type = base->type;
    341                                 result->size = base->size;                             
    342                                 goto out;
    343                         }
     350                                result->size = base->size;
     351                                vfs_node_put(base);
     352                                goto out;
     353                        }
     354                        if (base)
     355                                vfs_node_put(base);
    344356                }
    345357
  • uspace/srv/vfs/vfs_node.c

    r7f59d6c r4f9ab1e  
    204204        if (tmp) {
    205205                node = hash_table_get_inst(tmp, vfs_node_t, nh_link);
     206                _vfs_node_addref(node);
    206207        }
    207208        fibril_mutex_unlock(&nodes_mutex);
  • uspace/srv/vfs/vfs_ops.c

    r7f59d6c r4f9ab1e  
    618618       
    619619        /* If the node is not held by anyone, try to destroy it. */
    620         if (orig_unlinked && vfs_node_peek(&new_lr_orig) == NULL) {
    621                 out_destroy(&new_lr_orig.triplet);
     620        if (orig_unlinked) {
     621                vfs_node_t *node = vfs_node_peek(&new_lr_orig);
     622                if (!node)
     623                        out_destroy(&new_lr_orig.triplet);
     624                else
     625                        vfs_node_put(node);
    622626        }
    623627       
     
    824828                }
    825829               
    826                 vfs_node_t *found_node = vfs_node_peek(&lr);           
     830                vfs_node_t *found_node = vfs_node_peek(&lr);
     831                vfs_node_put(found_node);
    827832                if (expect->node != found_node) {
    828833                        rc = ENOENT;
     
    841846
    842847        /* If the node is not held by anyone, try to destroy it. */
    843         if (vfs_node_peek(&lr) == NULL) {
     848        vfs_node_t *node = vfs_node_peek(&lr);
     849        if (!node)
    844850                out_destroy(&lr.triplet);
    845         }
     851        else
     852                vfs_node_put(node);
    846853
    847854exit:
Note: See TracChangeset for help on using the changeset viewer.