Changeset 828d215 in mainline
- Timestamp:
- 2007-11-03T15:25:01Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ec01adf
- Parents:
- 20614d0
- Location:
- uspace/srv/vfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.c
r20614d0 r828d215 57 57 58 58 /* 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 /*67 59 * The connection was opened via the IPC_CONNECT_ME_TO call. 68 60 * This call needs to be answered. … … 97 89 break; 98 90 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; 99 97 case VFS_UNMOUNT: 100 case VFS_OPEN:101 98 case VFS_CREATE: 102 99 case VFS_CLOSE: -
uspace/srv/vfs/vfs.h
r20614d0 r828d215 176 176 #define MAX_OPEN_FILES 128 177 177 178 extern bool vfs_conn_open_files_init(void);179 180 178 extern void vfs_register(ipc_callid_t, ipc_call_t *); 181 179 extern void vfs_mount(ipc_callid_t, ipc_call_t *); -
uspace/srv/vfs/vfs_open.c
r20614d0 r828d215 44 44 #include <futex.h> 45 45 #include <libadt/list.h> 46 #include <sys/types.h> 46 47 #include "vfs.h" 48 49 /** Per-connection futex protecting the files array. */ 50 __thread atomic_t files_futex = FUTEX_INITIALIZER; 47 51 48 52 /** … … 54 58 * the functionality will stay unchanged. So unless the client knows what it is 55 59 * 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. 56 63 */ 57 __thread vfs_file_t files[MAX_OPEN_FILES];64 __thread vfs_file_t *files = NULL; 58 65 59 66 /** Initialize the table of open files. */ 60 bool vfs_conn_open_files_init(void)67 static bool vfs_conn_open_files_init(void) 61 68 { 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); 63 79 return true; 64 80 } … … 66 82 void vfs_open(ipc_callid_t rid, ipc_call_t *request) 67 83 { 84 if (!vfs_conn_open_files_init()) { 85 ipc_answer_fast_0(rid, ENOMEM); 86 return; 87 } 68 88 } 69 89
Note:
See TracChangeset
for help on using the changeset viewer.