Rev 2679 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2679 | Rev 2680 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | 37 | ||
38 | #include "vfs.h" |
38 | #include "vfs.h" |
39 | #include <ipc/ipc.h> |
39 | #include <ipc/ipc.h> |
40 | #include <async.h> |
40 | #include <async.h> |
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | #include <futex.h> |
42 | #include <rwlock.h> |
43 | 43 | ||
44 | static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) |
44 | static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) |
45 | { |
45 | { |
46 | 46 | ||
47 | /* |
47 | /* |
Line 83... | Line 83... | ||
83 | 83 | ||
84 | /* |
84 | /* |
85 | * Lock the file's node so that no other client can read/write to it at |
85 | * Lock the file's node so that no other client can read/write to it at |
86 | * the same time. |
86 | * the same time. |
87 | */ |
87 | */ |
- | 88 | if (read) |
|
- | 89 | rwlock_reader_lock(&file->node->contents_rwlock); |
|
- | 90 | else |
|
88 | futex_down(&file->node->contents_futex); |
91 | rwlock_writer_lock(&file->node->contents_rwlock); |
89 | 92 | ||
90 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
93 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
91 | 94 | ||
92 | /* |
95 | /* |
93 | * Make a VFS_READ/VFS_WRITE request at the destination FS server. |
96 | * Make a VFS_READ/VFS_WRITE request at the destination FS server. |
Line 115... | Line 118... | ||
115 | size_t bytes = IPC_GET_ARG1(answer); |
118 | size_t bytes = IPC_GET_ARG1(answer); |
116 | 119 | ||
117 | /* |
120 | /* |
118 | * Unlock the VFS node. |
121 | * Unlock the VFS node. |
119 | */ |
122 | */ |
- | 123 | if (read) |
|
- | 124 | rwlock_reader_unlock(&file->node->contents_rwlock); |
|
- | 125 | else |
|
120 | futex_up(&file->node->contents_futex); |
126 | rwlock_writer_unlock(&file->node->contents_rwlock); |
121 | 127 | ||
122 | /* |
128 | /* |
123 | * Update the position pointer. |
129 | * Update the position pointer. |
124 | */ |
130 | */ |
125 | file->pos += bytes; |
131 | file->pos += bytes; |