Changeset 828d215 in mainline


Ignore:
Timestamp:
2007-11-03T15:25:01Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ec01adf
Parents:
20614d0
Message:

VFS work.

Allocate the open filess array dynamically and protect access to it via a
per-connection futex. Defer its allocation until the client makes a first
VFS_OPEN request.

Actually call vfs_mount() and vfs_open(), respectively, when the VFS_MOUNT and
VFS_OPEN requests, respectively, are received from the client.

Location:
uspace/srv/vfs
Files:
3 edited

Legend:

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

    r20614d0 r828d215  
    5757
    5858        /*
    59          * Initialize the table of open files.
    60          */
    61         if (!vfs_conn_open_files_init()) {
    62                 ipc_answer_fast_0(iid, ENOMEM);
    63                 return;
    64         }
    65 
    66         /*
    6759         * The connection was opened via the IPC_CONNECT_ME_TO call.
    6860         * This call needs to be answered.
     
    9789                        break;
    9890                case VFS_MOUNT:
     91                        vfs_mount(callid, &call);
     92                        keep_on_going = false;
     93                        break;
     94                case VFS_OPEN:
     95                        vfs_open(callid, &call);
     96                        break;
    9997                case VFS_UNMOUNT:
    100                 case VFS_OPEN:
    10198                case VFS_CREATE:
    10299                case VFS_CLOSE:
  • uspace/srv/vfs/vfs.h

    r20614d0 r828d215  
    176176#define MAX_OPEN_FILES  128     
    177177
    178 extern bool vfs_conn_open_files_init(void);
    179 
    180178extern void vfs_register(ipc_callid_t, ipc_call_t *);
    181179extern void vfs_mount(ipc_callid_t, ipc_call_t *);
  • uspace/srv/vfs/vfs_open.c

    r20614d0 r828d215  
    4444#include <futex.h>
    4545#include <libadt/list.h>
     46#include <sys/types.h>
    4647#include "vfs.h"
     48
     49/** Per-connection futex protecting the files array. */
     50__thread atomic_t files_futex = FUTEX_INITIALIZER;
    4751
    4852/**
     
    5458 * the functionality will stay unchanged. So unless the client knows what it is
    5559 * doing, it should open one connection to VFS only.
     60 *
     61 * Allocation of the open files table is deferred until the client makes the
     62 * first VFS_OPEN operation.
    5663 */
    57 __thread vfs_file_t files[MAX_OPEN_FILES];
     64__thread vfs_file_t *files = NULL;
    5865
    5966/** Initialize the table of open files. */
    60 bool vfs_conn_open_files_init(void)
     67static bool vfs_conn_open_files_init(void)
    6168{
    62         memset(files, 0, MAX_OPEN_FILES * sizeof(vfs_file_t));
     69        futex_down(&files_futex);
     70        if (!files) {
     71                files = malloc(MAX_OPEN_FILES * sizeof(vfs_file_t));
     72                if (!files) {
     73                        futex_up(&files_futex);
     74                        return false;
     75                }
     76                memset(files, 0, MAX_OPEN_FILES * sizeof(vfs_file_t));
     77        }
     78        futex_up(&files_futex);
    6379        return true;
    6480}
     
    6682void vfs_open(ipc_callid_t rid, ipc_call_t *request)
    6783{
     84        if (!vfs_conn_open_files_init()) {
     85                ipc_answer_fast_0(rid, ENOMEM);
     86                return;
     87        }
    6888}
    6989
Note: See TracChangeset for help on using the changeset viewer.