Subversion Repositories HelenOS

Rev

Rev 2671 | Rev 2675 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2671 Rev 2674
Line 31... Line 31...
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <vfs.h>
35
#include <vfs.h>
-
 
36
#include <unistd.h>
-
 
37
#include <fcntl.h>
36
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
37
#include <ipc/services.h>
39
#include <ipc/services.h>
38
#include <async.h>
40
#include <async.h>
39
#include <atomic.h>
41
#include <atomic.h>
40
#include <futex.h>
42
#include <futex.h>
Line 138... Line 140...
138
            async_serialize_end();
140
            async_serialize_end();
139
            futex_up(&vfs_phone_futex);
141
            futex_up(&vfs_phone_futex);
140
            return res;
142
            return res;
141
        }
143
        }
142
    }
144
    }
143
    req = async_send_1(vfs_phone, VFS_READ, 0, &answer);
145
    req = async_send_1(vfs_phone, VFS_READ, fildes, &answer);
144
    if (ipc_data_read_send(vfs_phone, buf, sizeof(buf)) != EOK) {
146
    if (ipc_data_read_send(vfs_phone, buf, sizeof(buf)) != EOK) {
145
        async_wait_for(req, NULL);
147
        async_wait_for(req, NULL);
146
        async_serialize_end();
148
        async_serialize_end();
147
        futex_up(&vfs_phone_futex);
149
        futex_up(&vfs_phone_futex);
148
        return (ssize_t) rc;
150
        return (ssize_t) rc;
Line 151... Line 153...
151
    async_serialize_end();
153
    async_serialize_end();
152
    futex_up(&vfs_phone_futex);
154
    futex_up(&vfs_phone_futex);
153
    return (ssize_t) IPC_GET_ARG1(answer);
155
    return (ssize_t) IPC_GET_ARG1(answer);
154
}
156
}
155
 
157
 
-
 
158
ssize_t write(int fildes, const void *buf, size_t nbyte)
-
 
159
{
-
 
160
    int res;
-
 
161
    ipcarg_t rc;
-
 
162
    ipc_call_t answer;
-
 
163
    aid_t req;
-
 
164
 
-
 
165
    futex_down(&vfs_phone_futex);
-
 
166
    async_serialize_start();
-
 
167
    if (vfs_phone < 0) {
-
 
168
        res = vfs_connect();
-
 
169
        if (res < 0) {
-
 
170
            async_serialize_end();
-
 
171
            futex_up(&vfs_phone_futex);
-
 
172
            return res;
-
 
173
        }
-
 
174
    }
-
 
175
    req = async_send_1(vfs_phone, VFS_WRITE, fildes, &answer);
-
 
176
    if (ipc_data_write_send(vfs_phone, buf, sizeof(buf)) != EOK) {
-
 
177
        async_wait_for(req, NULL);
-
 
178
        async_serialize_end();
-
 
179
        futex_up(&vfs_phone_futex);
-
 
180
        return (ssize_t) rc;
-
 
181
    }
-
 
182
    async_wait_for(req, &rc);
-
 
183
    async_serialize_end();
-
 
184
    futex_up(&vfs_phone_futex);
-
 
185
    return (ssize_t) IPC_GET_ARG1(answer);
-
 
186
}
156
/** @}
187
/** @}
157
 */
188
 */