Subversion Repositories HelenOS

Rev

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

Rev 2687 Rev 2688
Line 91... Line 91...
91
    /*
91
    /*
92
     * Lock the file's node so that no other client can read/write to it at
92
     * Lock the file's node so that no other client can read/write to it at
93
     * the same time.
93
     * the same time.
94
     */
94
     */
95
    if (read)
95
    if (read)
96
        rwlock_reader_lock(&file->node->contents_rwlock);
96
        rwlock_read_lock(&file->node->contents_rwlock);
97
    else
97
    else
98
        rwlock_writer_lock(&file->node->contents_rwlock);
98
        rwlock_write_lock(&file->node->contents_rwlock);
99
 
99
 
100
    int fs_phone = vfs_grab_phone(file->node->fs_handle);  
100
    int fs_phone = vfs_grab_phone(file->node->fs_handle);  
101
   
101
   
102
    /*
102
    /*
103
     * Make a VFS_READ/VFS_WRITE request at the destination FS server.
103
     * Make a VFS_READ/VFS_WRITE request at the destination FS server.
Line 126... Line 126...
126
 
126
 
127
    /*
127
    /*
128
     * Unlock the VFS node.
128
     * Unlock the VFS node.
129
     */
129
     */
130
    if (read)
130
    if (read)
131
        rwlock_reader_unlock(&file->node->contents_rwlock);
131
        rwlock_read_unlock(&file->node->contents_rwlock);
132
    else {
132
    else {
133
        /* Update the cached version of node's size. */
133
        /* Update the cached version of node's size. */
134
        file->node->size = IPC_GET_ARG2(answer);
134
        file->node->size = IPC_GET_ARG2(answer);
135
        rwlock_writer_unlock(&file->node->contents_rwlock);
135
        rwlock_write_unlock(&file->node->contents_rwlock);
136
    }
136
    }
137
 
137
 
138
    /*
138
    /*
139
     * Update the position pointer and unlock the open file.
139
     * Update the position pointer and unlock the open file.
140
     */
140
     */
Line 194... Line 194...
194
        futex_up(&file->lock);
194
        futex_up(&file->lock);
195
        ipc_answer_1(rid, EOK, newpos);
195
        ipc_answer_1(rid, EOK, newpos);
196
        return;
196
        return;
197
    }
197
    }
198
    if (whence == SEEK_END) {
198
    if (whence == SEEK_END) {
199
        rwlock_reader_lock(&file->node->contents_rwlock);
199
        rwlock_read_lock(&file->node->contents_rwlock);
200
        size_t size = file->node->size;
200
        size_t size = file->node->size;
201
        rwlock_reader_unlock(&file->node->contents_rwlock);
201
        rwlock_read_unlock(&file->node->contents_rwlock);
202
        if (size + off < size) {
202
        if (size + off < size) {
203
            futex_up(&file->lock);
203
            futex_up(&file->lock);
204
            ipc_answer_0(rid, EOVERFLOW);
204
            ipc_answer_0(rid, EOVERFLOW);
205
            return;
205
            return;
206
        }
206
        }