Changeset b17186d in mainline


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().

Location:
uspace/srv/vfs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    rabd36f7 rb17186d  
    191191#define L_PARENT        64     
    192192
     193typedef enum vfs_node_type {
     194        VFS_NODE_UNKNOWN,
     195        VFS_NODE_FILE,
     196        VFS_NODE_DIRECTORY,
     197} vfs_node_type_t;
     198
    193199typedef struct {
    194200        vfs_triplet_t triplet;
     201        vfs_node_type_t type;
    195202        size_t size;
    196203        unsigned lnkcnt;
     
    214221
    215222        link_t nh_link;         /**< Node hash-table link. */
     223
     224        vfs_node_type_t type;   /**< Partial info about the node type. */
     225
    216226        size_t size;            /**< Cached size if the node is a file. */
    217227
  • uspace/srv/vfs/vfs_lookup.c

    rabd36f7 rb17186d  
    183183                result->size = (size_t) IPC_GET_ARG4(answer);
    184184                result->lnkcnt = (unsigned) IPC_GET_ARG5(answer);
     185                if (lflag & L_FILE)
     186                        result->type = VFS_NODE_FILE;
     187                else if (lflag & L_DIRECTORY)
     188                        result->type = VFS_NODE_DIRECTORY;
     189                else
     190                        result->type = VFS_NODE_UNKNOWN;
    185191        }
    186192
  • uspace/srv/vfs/vfs_node.c

    rabd36f7 rb17186d  
    176176                node->size = result->size;
    177177                node->lnkcnt = result->lnkcnt;
     178                node->type = result->type;
    178179                link_initialize(&node->nh_link);
    179180                rwlock_initialize(&node->contents_rwlock);
     
    181182        } else {
    182183                node = hash_table_get_instance(tmp, vfs_node_t, nh_link);       
     184                if (node->type == VFS_NODE_UNKNOWN &&
     185                    result->type != VFS_NODE_UNKNOWN) {
     186                        /* Upgrade the node type. */
     187                        node->type = result->type;
     188                }
    183189        }
    184190
    185191        assert(node->size == result->size);
    186192        assert(node->lnkcnt == result->lnkcnt);
     193        assert(node->type == result->type || result->type == VFS_NODE_UNKNOWN);
    187194
    188195        _vfs_node_addref(node);
  • 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.