Changeset ae78b53 in mainline


Ignore:
Timestamp:
2008-01-19T13:40:38Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4bb31f7
Parents:
5973fd0
Message:

Introduce the notion of lflag (i.e. lookup flags) to support the ability to
limit the scope of VFS node types that can be opened by open() and opendir(). In
the future, lflag will also specify actions for VFS_LOOKUP handlers that will be
carried out in situations such as the VFS node is not found (e.g. implementation
of mkdir() and open() with O_CREAT in oflag).

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/vfs.c

    r5973fd0 rae78b53  
    9696}
    9797
    98 
    99 int open(const char *path, int oflag, ...)
     98static int _open(const char *path, int lflag, int oflag, ...)
    10099{
    101100        int res;
     
    114113                }
    115114        }
    116         req = async_send_2(vfs_phone, VFS_OPEN, oflag, 0, &answer);
     115        req = async_send_3(vfs_phone, VFS_OPEN, lflag, oflag, 0, &answer);
    117116        rc = ipc_data_write_start(vfs_phone, path, strlen(path));
    118117        if (rc != EOK) {
     
    126125        futex_up(&vfs_phone_futex);
    127126        return (int) IPC_GET_ARG1(answer);
     127}
     128
     129int open(const char *path, int oflag, ...)
     130{
     131        return _open(path, L_FILE, oflag);
    128132}
    129133
     
    243247        if (!dirp)
    244248                return NULL;
    245         dirp->fd = open(dirname, 0);    /* TODO: must be a directory */
     249        dirp->fd = _open(dirname, L_DIRECTORY, 0);
    246250        if (dirp->fd < 0) {
    247251                free(dirp);
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r5973fd0 rae78b53  
    237237        unsigned last = IPC_GET_ARG2(*request);
    238238        int dev_handle = IPC_GET_ARG3(*request);
     239        int lflag = IPC_GET_ARG4(*request);
    239240
    240241        if (last < next)
  • uspace/srv/vfs/vfs.h

    r5973fd0 rae78b53  
    139139} vfs_triplet_t;
    140140
     141#define L_FILE          1
     142#define L_DIRECTORY     2
     143
    141144typedef struct {
    142145        vfs_triplet_t triplet;
     
    204207extern int fs_name_to_handle(char *, bool);
    205208
    206 extern int vfs_lookup_internal(char *, size_t, vfs_lookup_res_t *,
     209extern int vfs_lookup_internal(char *, size_t, int, vfs_lookup_res_t *,
    207210    vfs_pair_t *);
    208211
  • uspace/srv/vfs/vfs_lookup.c

    r5973fd0 rae78b53  
    5656 * @param path          Path to be resolved; it needn't be an ASCIIZ string.
    5757 * @param len           Number of path characters pointed by path.
     58 * @param lflag         Flags to be used during lookup.
    5859 * @param result        Empty structure where the lookup result will be stored.
    5960 * @param altroot       If non-empty, will be used instead of rootfs as the root
     
    6263 * @return              EOK on success or an error code from errno.h.
    6364 */
    64 int vfs_lookup_internal(char *path, size_t len, vfs_lookup_res_t *result,
    65     vfs_pair_t *altroot)
     65int vfs_lookup_internal(char *path, size_t len, int lflag,
     66    vfs_lookup_res_t *result, vfs_pair_t *altroot)
    6667{
    6768        vfs_pair_t *root;
     
    145146        ipc_call_t answer;
    146147        int phone = vfs_grab_phone(root->fs_handle);
    147         aid_t req = async_send_3(phone, VFS_LOOKUP, (ipcarg_t) first,
     148        aid_t req = async_send_4(phone, VFS_LOOKUP, (ipcarg_t) first,
    148149            (ipcarg_t) (first + len - 1) % PLB_SIZE,
    149             (ipcarg_t) root->dev_handle, &answer);
     150            (ipcarg_t) root->dev_handle, (ipcarg_t) lflag, &answer);
    150151        vfs_release_phone(phone);
    151152
  • uspace/srv/vfs/vfs_ops.c

    r5973fd0 rae78b53  
    7272        };
    7373
    74         return vfs_lookup_internal("/", strlen("/"), result, &altroot);
     74        return vfs_lookup_internal("/", strlen("/"), L_DIRECTORY, result,
     75            &altroot);
    7576}
    7677
     
    196197                 */
    197198                rwlock_write_lock(&namespace_rwlock);
    198                 rc = vfs_lookup_internal(buf, size, &mp_res, NULL);
     199                rc = vfs_lookup_internal(buf, size, L_DIRECTORY, &mp_res,
     200                    NULL);
    199201                if (rc != EOK) {
    200202                        /*
     
    298300
    299301        /*
    300          * The POSIX interface is open(path, flags, mode).
    301          * We can receive flags and mode along with the VFS_OPEN call; the path
     302         * The POSIX interface is open(path, oflag, mode).
     303         * We can receive oflags and mode along with the VFS_OPEN call; the path
    302304         * will need to arrive in another call.
    303          */
    304         int flags = IPC_GET_ARG1(*request);
    305         int mode = IPC_GET_ARG2(*request);
     305         *
     306         * We also receive one private, non-POSIX set of flags called lflag
     307         * used to pass information to vfs_lookup_internal().
     308         */
     309        int lflag = IPC_GET_ARG1(*request);
     310        int oflag = IPC_GET_ARG2(*request);
     311        int mode = IPC_GET_ARG3(*request);
    306312        size_t len;
    307313
     
    346352         */
    347353        vfs_lookup_res_t lr;
    348         rc = vfs_lookup_internal(path, len, &lr, NULL);
     354        rc = vfs_lookup_internal(path, len, lflag, &lr, NULL);
    349355        if (rc) {
    350356                rwlock_read_unlock(&namespace_rwlock);
Note: See TracChangeset for help on using the changeset viewer.