Changeset 06901c6b in mainline for uspace/lib/libfs/libfs.c


Ignore:
Timestamp:
2008-04-14T05:15:16Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e13d1feb
Parents:
c9f6e49f
Message:

Add node_put() to libfs operations and instrument libfs_lookup() to use it at
appropriate places.
Add node_put() to libfs operations and instrument libfs_lookup() to use it at
appropriate places.
Add node_put() to libfs operations and instrument libfs_lookup() to use it at
appropriate places.
Add node_put() to libfs operations and instrument libfs_lookup() to use it at
appropriate places.
Add node_put() to libfs operations and instrument libfs_lookup() to use it at
appropriate places.
Add node_put() to libfs operations and instrument libfs_lookup() to use it at
appropriate places.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libfs/libfs.c

    rc9f6e49f r06901c6b  
    151151        void *par = NULL;
    152152        void *cur = ops->root_get(dev_handle);
     153        void *tmp = NULL;
    153154
    154155        if (ops->plb_get_char(next) == '/')
     
    156157       
    157158        while (ops->has_children(cur) && next <= last) {
    158                 void *tmp;
    159 
    160159                /* collect the component */
    161160                len = 0;
     
    164163                                /* comopnent length overflow */
    165164                                ipc_answer_0(rid, ENAMETOOLONG);
    166                                 return;
     165                                goto out;
    167166                        }
    168167                        component[len++] = ops->plb_get_char(next);
     
    182181                                /* there are unprocessed components */
    183182                                ipc_answer_0(rid, ENOENT);
    184                                 return;
     183                                goto out;
    185184                        }
    186185                        /* miss in the last component */
     
    189188                                if (!ops->is_directory(cur)) {
    190189                                        ipc_answer_0(rid, ENOTDIR);
    191                                         return;
     190                                        goto out;
    192191                                }
    193192                                void *nodep;
     
    208207                                                    ops->size_get(nodep),
    209208                                                    ops->lnkcnt_get(nodep));
     209                                                ops->node_put(nodep);
    210210                                        }
    211211                                } else {
    212212                                        ipc_answer_0(rid, ENOSPC);
    213213                                }
    214                                 return;
     214                                goto out;
    215215                        } else if (lflag & L_PARENT) {
    216216                                /* return parent */
     
    220220                        }
    221221                        ipc_answer_0(rid, ENOENT);
    222                         return;
     222                        goto out;
    223223                }
     224
     225                if (par)
     226                        ops->node_put(par);
    224227
    225228                /* descend one level */
    226229                par = cur;
    227230                cur = tmp;
     231                tmp = NULL;
    228232        }
    229233
     
    233237                        if (!ops->is_directory(cur)) {
    234238                                ipc_answer_0(rid, ENOTDIR);
    235                                 return;
     239                                goto out;
    236240                        }
    237241
     
    242246                                        /* more than one component */
    243247                                        ipc_answer_0(rid, ENOENT);
    244                                         return;
     248                                        goto out;
    245249                                }
    246250                                if (len + 1 == NAME_MAX) {
    247251                                        /* component length overflow */
    248252                                        ipc_answer_0(rid, ENAMETOOLONG);
    249                                         return;
     253                                        goto out;
    250254                                }
    251255                                component[len++] = ops->plb_get_char(next);
     
    272276                                            ops->size_get(nodep),
    273277                                            ops->lnkcnt_get(nodep));
     278                                        ops->node_put(nodep);
    274279                                }
    275280                        } else {
    276281                                ipc_answer_0(rid, ENOSPC);
    277282                        }
    278                         return;
     283                        goto out;
    279284                }
    280285                ipc_answer_0(rid, ENOENT);
    281                 return;
     286                goto out;
    282287        }
    283288
    284289        /* handle hit */
    285290        if (lflag & L_PARENT) {
     291                ops->node_put(cur);
    286292                cur = par;
     293                par = NULL;
    287294                if (!cur) {
    288295                        ipc_answer_0(rid, ENOENT);
    289                         return;
     296                        goto out;
    290297                }
    291298        }
     
    295302                ipc_answer_5(rid, (ipcarg_t)res, fs_handle, dev_handle,
    296303                    ops->index_get(cur), ops->size_get(cur), old_lnkcnt);
    297                 return;
     304                goto out;
    298305        }
    299306        if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) ||
    300307            (lflag & L_LINK)) {
    301308                ipc_answer_0(rid, EEXIST);
    302                 return;
     309                goto out;
    303310        }
    304311        if ((lflag & L_FILE) && (ops->is_directory(cur))) {
    305312                ipc_answer_0(rid, EISDIR);
    306                 return;
     313                goto out;
    307314        }
    308315        if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) {
    309316                ipc_answer_0(rid, ENOTDIR);
    310                 return;
     317                goto out;
    311318        }
    312319
    313320        ipc_answer_5(rid, EOK, fs_handle, dev_handle, ops->index_get(cur),
    314321            ops->size_get(cur), ops->lnkcnt_get(cur));
     322
     323out:
     324        if (par)
     325                ops->node_put(par);
     326        if (cur)
     327                ops->node_put(cur);
     328        if (tmp)
     329                ops->node_put(tmp);
    315330}
    316331
Note: See TracChangeset for help on using the changeset viewer.