Subversion Repositories HelenOS

Rev

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

Rev 2587 Rev 2588
Line 84... Line 84...
84
     */
84
     */
85
    ipc_callid_t callid;
85
    ipc_callid_t callid;
86
    ipc_call_t call;
86
    ipc_call_t call;
87
    size_t size;
87
    size_t size;
88
    if (!ipc_data_receive(&callid, &call, NULL, &size)) {
88
    if (!ipc_data_receive(&callid, &call, NULL, &size)) {
89
        ipc_answer_fast(callid, EINVAL, 0, 0);
89
        ipc_answer_fast_0(callid, EINVAL);
90
        ipc_answer_fast(rid, EINVAL, 0, 0);
90
        ipc_answer_fast_0(rid, EINVAL);
91
        return;
91
        return;
92
    }
92
    }
93
 
93
 
94
    /*
94
    /*
95
     * There is no sense in receiving data that can't hold a single
95
     * There is no sense in receiving data that can't hold a single
96
     * character of path. We won't accept data that exceed certain limits
96
     * character of path. We won't accept data that exceed certain limits
97
     * either.
97
     * either.
98
     */
98
     */
99
    if ((size < FS_NAME_MAXLEN + 1) ||
99
    if ((size < FS_NAME_MAXLEN + 1) ||
100
        (size > FS_NAME_MAXLEN + MAX_PATH_LEN)) {
100
        (size > FS_NAME_MAXLEN + MAX_PATH_LEN)) {
101
        ipc_answer_fast(callid, EINVAL, 0, 0);
101
        ipc_answer_fast_0(callid, EINVAL);
102
        ipc_answer_fast(rid, EINVAL, 0, 0);
102
        ipc_answer_fast_0(rid, EINVAL);
103
        return;
103
        return;
104
    }
104
    }
105
 
105
 
106
    /*
106
    /*
107
     * Allocate buffer for the data being received.
107
     * Allocate buffer for the data being received.
108
     */
108
     */
109
    uint8_t *buf;
109
    uint8_t *buf;
110
    buf = malloc(size);
110
    buf = malloc(size);
111
    if (!buf) {
111
    if (!buf) {
112
        ipc_answer_fast(callid, ENOMEM, 0, 0);
112
        ipc_answer_fast_0(callid, ENOMEM);
113
        ipc_answer_fast(rid, ENOMEM, 0, 0);
113
        ipc_answer_fast_0(rid, ENOMEM);
114
        return;
114
        return;
115
    }
115
    }
116
 
116
 
117
    /*
117
    /*
118
     * Deliver the data.
118
     * Deliver the data.
Line 128... Line 128...
128
     * This will also give us its file system handle.
128
     * This will also give us its file system handle.
129
     */
129
     */
130
    int fs_handle = fs_name_to_handle(fs_name, true);
130
    int fs_handle = fs_name_to_handle(fs_name, true);
131
    if (!fs_handle) {
131
    if (!fs_handle) {
132
        free(buf);
132
        free(buf);
133
        ipc_answer_fast(rid, ENOENT, 0, 0);
133
        ipc_answer_fast_0(rid, ENOENT);
134
        return;
134
        return;
135
    }
135
    }
136
 
136
 
137
    /*
137
    /*
138
     * Lookup the root node of the filesystem being mounted.
138
     * Lookup the root node of the filesystem being mounted.
Line 140... Line 140...
140
    int rc;
140
    int rc;
141
    vfs_triplet_t mounted_root;
141
    vfs_triplet_t mounted_root;
142
    rc = lookup_root(fs_handle, dev_handle, &mounted_root);
142
    rc = lookup_root(fs_handle, dev_handle, &mounted_root);
143
    if (rc != EOK) {
143
    if (rc != EOK) {
144
        free(buf);
144
        free(buf);
145
        ipc_answer_fast(rid, rc, 0, 0);
145
        ipc_answer_fast_0(rid, rc);
146
        return;
146
        return;
147
    }
147
    }
148
 
148
 
149
    /*
149
    /*
150
     * Finally, we need to resolve the path to the mountpoint.
150
     * Finally, we need to resolve the path to the mountpoint.
Line 161... Line 161...
161
            /*
161
            /*
162
             * The lookup failed for some reason.
162
             * The lookup failed for some reason.
163
             */
163
             */
164
            futex_up(&rootfs_futex);
164
            futex_up(&rootfs_futex);
165
            free(buf);
165
            free(buf);
166
            ipc_answer_fast(rid, rc, 0, 0);
166
            ipc_answer_fast_0(rid, rc);
167
            return;
167
            return;
168
        }
168
        }
169
    } else {
169
    } else {
170
        /*
170
        /*
171
         * We still don't have the root file system mounted.
171
         * We still don't have the root file system mounted.
Line 176... Line 176...
176
             * For this simple, but important case, we are done.
176
             * For this simple, but important case, we are done.
177
             */
177
             */
178
            rootfs = mounted_root;
178
            rootfs = mounted_root;
179
            futex_up(&rootfs_futex);
179
            futex_up(&rootfs_futex);
180
            free(buf);
180
            free(buf);
181
            ipc_answer_fast(rid, EOK, 0, 0);
181
            ipc_answer_fast_0(rid, EOK);
182
            return;
182
            return;
183
        } else {
183
        } else {
184
            /*
184
            /*
185
             * We can't resolve this without the root filesystem
185
             * We can't resolve this without the root filesystem
186
             * being mounted first.
186
             * being mounted first.
187
             */
187
             */
188
            futex_up(&rootfs_futex);
188
            futex_up(&rootfs_futex);
189
            free(buf);
189
            free(buf);
190
            ipc_answer_fast(rid, ENOENT, 0, 0);
190
            ipc_answer_fast_0(rid, ENOENT);
191
            return;
191
            return;
192
        }
192
        }
193
    }
193
    }
194
    futex_up(&rootfs_futex);
194
    futex_up(&rootfs_futex);
195
   
195
   
Line 216... Line 216...
216
    async_wait_for(req1, &rc1);
216
    async_wait_for(req1, &rc1);
217
    async_wait_for(req2, &rc2);
217
    async_wait_for(req2, &rc2);
218
    vfs_release_phone(phone);
218
    vfs_release_phone(phone);
219
 
219
 
220
    if (rc2 == EOK)
220
    if (rc2 == EOK)
221
        ipc_answer_fast(rid, rc1, 0, 0);
221
        ipc_answer_fast_0(rid, rc1);
222
    else if (rc1 == EOK)
222
    else if (rc1 == EOK)
223
        ipc_answer_fast(rid, rc2, 0, 0);
223
        ipc_answer_fast_0(rid, rc2);
224
    else
224
    else
225
        ipc_answer_fast(rid, rc1, 0, 0);
225
        ipc_answer_fast_0(rid, rc1);
226
}
226
}
227
 
227
 
228
/**
228
/**
229
 * @}
229
 * @}
230
 */
230
 */