Changeset 1fe186f in mainline


Ignore:
Timestamp:
2008-01-27T10:47:15Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
72bde81
Parents:
b8b23c8
Message:

Move handling of the miss on excessive components out of the main loop in
tmpfs_lookup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    rb8b23c8 r1fe186f  
    246246        char component[NAME_MAX + 1];
    247247        int len = 0;
    248         while (next <= last) {
     248        while (dtmp && next <= last) {
    249249
    250250                /* collect the component */
     
    296296                dcur = dtmp;
    297297                dtmp = dtmp->child;
    298 
    299                 /* handle miss: excessive components */
    300                 if (!dtmp && next <= last) {
    301                         if (lflag & L_CREATE) {
    302                                 if (dcur->type != TMPFS_DIRECTORY) {
    303                                         ipc_answer_0(rid, ENOTDIR);
     298        }
     299
     300        /* handle miss: excessive components */
     301        if (!dtmp && next <= last) {
     302                if (lflag & L_CREATE) {
     303                        if (dcur->type != TMPFS_DIRECTORY) {
     304                                ipc_answer_0(rid, ENOTDIR);
     305                                return;
     306                        }
     307
     308                        /* collect next component */
     309                        while (next <= last) {
     310                                if (PLB_GET_CHAR(next) == '/') {
     311                                        /* more than one component */
     312                                        ipc_answer_0(rid, ENOENT);
    304313                                        return;
    305314                                }
    306 
    307                                 /* collect next component */
    308                                 while (next <= last) {
    309                                         if (PLB_GET_CHAR(next) == '/') {
    310                                                 /* more than one component */
    311                                                 ipc_answer_0(rid, ENOENT);
    312                                                 return;
    313                                         }
    314                                         if (len + 1 == NAME_MAX) {
    315                                                 /* component length overflow */
    316                                                 ipc_answer_0(rid, ENAMETOOLONG);
    317                                                 return;
    318                                         }
    319                                         component[len++] = PLB_GET_CHAR(next);
    320                                         next++; /* process next character */
     315                                if (len + 1 == NAME_MAX) {
     316                                        /* component length overflow */
     317                                        ipc_answer_0(rid, ENAMETOOLONG);
     318                                        return;
    321319                                }
    322                                 assert(len);
    323                                 component[len] = '\0';
    324                                 len = 0;
     320                                component[len++] = PLB_GET_CHAR(next);
     321                                next++; /* process next character */
     322                        }
     323                        assert(len);
     324                        component[len] = '\0';
     325                        len = 0;
    325326                               
    326                                 unsigned long index;
    327                                 index = create_node(dcur, component, lflag);
    328                                 if (index) {
    329                                         ipc_answer_4(rid, EOK,
    330                                             tmpfs_reg.fs_handle, dev_handle,
    331                                             index, 0);
    332                                 } else {
    333                                         ipc_answer_0(rid, ENOSPC);
    334                                 }
    335                                 return;
     327                        unsigned long index;
     328                        index = create_node(dcur, component, lflag);
     329                        if (index) {
     330                                ipc_answer_4(rid, EOK, tmpfs_reg.fs_handle,
     331                                    dev_handle, index, 0);
     332                        } else {
     333                                ipc_answer_0(rid, ENOSPC);
    336334                        }
    337                         ipc_answer_0(rid, ENOENT);
    338335                        return;
    339336                }
    340        
     337                ipc_answer_0(rid, ENOENT);
     338                return;
    341339        }
    342340
Note: See TracChangeset for help on using the changeset viewer.