Changeset b17186d in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2008-11-29T15:39:24Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dfd77382
Parents:
abd36f7
Message:

Hold the namespace_rwlock during readdir().

File:
1 edited

Legend:

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

    rabd36f7 rb17186d  
    235235                        mr_res.size = (size_t) rsize;
    236236                        mr_res.lnkcnt = (unsigned) rlnkcnt;
     237                        mr_res.type = VFS_NODE_DIRECTORY;
    237238
    238239                        rootfs.fs_handle = fs_handle;
     
    302303        int mode = IPC_GET_ARG3(*request);
    303304        size_t len;
     305
     306        /*
     307         * Make sure that we are called with exactly one of L_FILE and
     308         * L_DIRECTORY.
     309         */
     310        if ((lflag & (L_FILE | L_DIRECTORY)) == 0 ||
     311            (lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) {
     312                ipc_answer_0(rid, EINVAL);
     313                return;
     314        }
    304315
    305316        if (oflag & O_CREAT)
     
    457468         */
    458469        futex_down(&file->lock);
    459        
     470
    460471        /*
    461472         * Lock the file's node so that no other client can read/write to it at
     
    466477        else
    467478                rwlock_write_lock(&file->node->contents_rwlock);
     479
     480        if (file->node->type == VFS_NODE_DIRECTORY) {
     481                /*
     482                 * Make sure that no one is modifying the namespace
     483                 * while we are in readdir().
     484                 */
     485                assert(read);
     486                rwlock_read_lock(&namespace_rwlock);
     487        }
    468488       
    469489        int fs_phone = vfs_grab_phone(file->node->fs_handle);   
     
    491511        async_wait_for(msg, &rc);
    492512        size_t bytes = IPC_GET_ARG1(answer);
     513
     514        if (file->node->type == VFS_NODE_DIRECTORY)
     515                rwlock_read_unlock(&namespace_rwlock);
    493516       
    494517        /* Unlock the VFS node. */
Note: See TracChangeset for help on using the changeset viewer.