Rev 4587 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4587 | Rev 4608 | ||
---|---|---|---|
Line 284... | Line 284... | ||
284 | fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); |
284 | fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); |
285 | 285 | ||
286 | ipc_callid_t callid; |
286 | ipc_callid_t callid; |
287 | size_t size; |
287 | size_t size; |
288 | if (!ipc_data_read_receive(&callid, &size) || |
288 | if (!ipc_data_read_receive(&callid, &size) || |
289 | size < sizeof(struct stat)) { |
289 | size != sizeof(struct stat)) { |
290 | ipc_answer_0(callid, EINVAL); |
290 | ipc_answer_0(callid, EINVAL); |
291 | ipc_answer_0(rid, EINVAL); |
291 | ipc_answer_0(rid, EINVAL); |
292 | return; |
292 | return; |
293 | } |
293 | } |
294 | 294 | ||
295 | struct stat *stat = malloc(sizeof(struct stat)); |
- | |
296 | if (!stat) { |
295 | struct stat stat; |
297 | ipc_answer_0(callid, ENOMEM); |
- | |
298 | ipc_answer_0(rid, ENOMEM); |
- | |
299 | return; |
- | |
300 | } |
- | |
301 | memset(stat, 0, sizeof(struct stat)); |
296 | memset(&stat, 0, sizeof(struct stat)); |
302 | 297 | ||
303 | stat->fs_handle = devfs_reg.fs_handle; |
298 | stat.fs_handle = devfs_reg.fs_handle; |
304 | stat->dev_handle = dev_handle; |
299 | stat.dev_handle = dev_handle; |
305 | stat->index = index; |
300 | stat.index = index; |
306 | stat->lnkcnt = 1; |
301 | stat.lnkcnt = 1; |
307 | stat->is_file = (index != 0); |
302 | stat.is_file = (index != 0); |
308 | stat->size = 0; |
303 | stat.size = 0; |
309 | 304 | ||
310 | if (index != 0) { |
305 | if (index != 0) { |
311 | unsigned long key[] = { |
306 | unsigned long key[] = { |
312 | [DEVICES_KEY_HANDLE] = (unsigned long) index |
307 | [DEVICES_KEY_HANDLE] = (unsigned long) index |
313 | }; |
308 | }; |
314 | 309 | ||
315 | fibril_mutex_lock(&devices_mutex); |
310 | fibril_mutex_lock(&devices_mutex); |
316 | link_t *lnk = hash_table_find(&devices, key); |
311 | link_t *lnk = hash_table_find(&devices, key); |
317 | if (lnk != NULL) |
312 | if (lnk != NULL) |
318 | stat->devfs_stat.device = (dev_handle_t)index; |
313 | stat.devfs_stat.device = (dev_handle_t)index; |
319 | fibril_mutex_unlock(&devices_mutex); |
314 | fibril_mutex_unlock(&devices_mutex); |
320 | } |
315 | } |
321 | 316 | ||
322 | ipc_data_read_finalize(callid, stat, sizeof(struct stat)); |
317 | ipc_data_read_finalize(callid, &stat, sizeof(struct stat)); |
323 | ipc_answer_0(rid, EOK); |
318 | ipc_answer_0(rid, EOK); |
324 | - | ||
325 | free(stat); |
- | |
326 | } |
319 | } |
327 | 320 | ||
328 | void devfs_read(ipc_callid_t rid, ipc_call_t *request) |
321 | void devfs_read(ipc_callid_t rid, ipc_call_t *request) |
329 | { |
322 | { |
330 | fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); |
323 | fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); |