Changeset 852b801 in mainline for uspace/srv/fs/devfs/devfs_ops.c
- Timestamp:
- 2009-06-28T18:59:02Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 75160a6
- Parents:
- 4198f9c3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/devfs/devfs_ops.c
r4198f9c3 r852b801 44 44 #include <fibril_sync.h> 45 45 #include <adt/hash_table.h> 46 #include <sys/stat.h> 46 47 #include "devfs.h" 47 48 #include "devfs_ops.h" … … 278 279 } 279 280 280 void devfs_device(ipc_callid_t rid, ipc_call_t *request) 281 { 281 void devfs_stat(ipc_callid_t rid, ipc_call_t *request) 282 { 283 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 282 284 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 285 286 ipc_callid_t callid; 287 size_t size; 288 if (!ipc_data_read_receive(&callid, &size) || 289 size < sizeof(struct stat)) { 290 ipc_answer_0(callid, EINVAL); 291 ipc_answer_0(rid, EINVAL); 292 return; 293 } 294 295 struct stat *stat = malloc(sizeof(struct stat)); 296 if (!stat) { 297 ipc_answer_0(callid, ENOMEM); 298 ipc_answer_0(rid, ENOMEM); 299 return; 300 } 301 memset(stat, 0, sizeof(struct stat)); 302 303 stat->fs_handle = devfs_reg.fs_handle; 304 stat->dev_handle = dev_handle; 305 stat->index = index; 306 stat->lnkcnt = 1; 307 stat->is_file = (index != 0); 308 stat->size = 0; 283 309 284 310 if (index != 0) { … … 289 315 fibril_mutex_lock(&devices_mutex); 290 316 link_t *lnk = hash_table_find(&devices, key); 291 if (lnk == NULL) { 292 fibril_mutex_unlock(&devices_mutex); 293 ipc_answer_0(rid, ENOENT); 294 return; 295 } 317 if (lnk != NULL) 318 stat->devfs_stat.device = (dev_handle_t)index; 296 319 fibril_mutex_unlock(&devices_mutex); 297 298 ipc_answer_1(rid, EOK, (ipcarg_t) index); 299 } else 300 ipc_answer_0(rid, ENOTSUP); 320 } 321 322 ipc_data_read_finalize(callid, stat, sizeof(struct stat)); 323 ipc_answer_0(rid, EOK); 324 325 free(stat); 301 326 } 302 327
Note:
See TracChangeset
for help on using the changeset viewer.