Changeset 2db4ac8 in mainline


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

VFS_OPEN now understands O_CREAT and O_EXCL.

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/fcntl.h

    r72bde81 r2db4ac8  
    3636#define LIBC_FCNTL_H_
    3737
     38#define O_CREAT         1
     39#define O_EXCL          2
     40#define O_TRUNC         4
     41#define O_APPEND        8
     42#define O_RDONLY        16
     43#define O_RDWR          32
     44#define O_WRONLY        64
     45
    3846extern int open(const char *, int, ...);
    3947
  • uspace/srv/vfs/vfs_ops.c

    r72bde81 r2db4ac8  
    4848#include <unistd.h>
    4949#include <ctype.h>
     50#include <fcntl.h>
    5051#include <assert.h>
    5152#include <atomic.h>
     
    292293        size_t len;
    293294
     295        if (oflag & O_CREAT)
     296                lflag |= L_CREATE;
     297        if (oflag & O_EXCL)
     298                lflag |= L_EXCLUSIVE;
     299
    294300        ipc_callid_t callid;
    295301
     
    326332         * triplet.
    327333         */
    328         rwlock_read_lock(&namespace_rwlock);
     334        if (lflag & L_CREATE)
     335                rwlock_write_lock(&namespace_rwlock);
     336        else
     337                rwlock_read_lock(&namespace_rwlock);
    329338
    330339        /* The path is now populated and we can call vfs_lookup_internal(). */
     
    332341        rc = vfs_lookup_internal(path, len, lflag, &lr, NULL);
    333342        if (rc) {
    334                 rwlock_read_unlock(&namespace_rwlock);
     343                if (lflag & L_CREATE)
     344                        rwlock_write_unlock(&namespace_rwlock);
     345                else
     346                        rwlock_read_unlock(&namespace_rwlock);
    335347                ipc_answer_0(rid, rc);
    336348                free(path);
     
    342354
    343355        vfs_node_t *node = vfs_node_get(&lr);
    344         rwlock_read_unlock(&namespace_rwlock);
     356        if (lflag & L_CREATE)
     357                rwlock_write_unlock(&namespace_rwlock);
     358        else
     359                rwlock_read_unlock(&namespace_rwlock);
    345360
    346361        /*
Note: See TracChangeset for help on using the changeset viewer.