Changeset cb569e6 in mainline for uspace/lib
- Timestamp:
- 2010-11-18T21:58:27Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4e5c7ba
- Parents:
- 69e0d6d (diff), 45f04f8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib
- Files:
-
- 1 deleted
- 29 edited
-
block/libblock.c (modified) (31 diffs)
-
block/libblock.h (modified) (2 diffs)
-
c/generic/adt/measured_strings.c (modified) (14 diffs)
-
c/generic/devman.c (modified) (7 diffs)
-
c/generic/devmap.c (modified) (8 diffs)
-
c/generic/net/modules.c (modified) (5 diffs)
-
c/generic/net/packet.c (modified) (4 diffs)
-
c/generic/net/socket_client.c (modified) (14 diffs)
-
c/generic/vfs/vfs.c (modified) (4 diffs)
-
c/include/adt/generic_char_map.h (modified) (4 diffs)
-
c/include/devman.h (modified) (1 diff)
-
c/include/devmap.h (modified) (2 diffs)
-
c/include/err.h (modified) (2 diffs)
-
c/include/ipc/devman.h (modified) (1 diff)
-
c/include/ipc/devmap.h (modified) (2 diffs)
-
c/include/ipc/serial.h (deleted)
-
c/include/stdio.h (modified) (1 diff)
-
c/include/sys/stat.h (modified) (2 diffs)
-
c/include/unistd.h (modified) (1 diff)
-
c/include/vfs/vfs.h (modified) (1 diff)
-
drv/generic/driver.c (modified) (3 diffs)
-
drv/include/driver.h (modified) (1 diff)
-
fs/libfs.c (modified) (18 diffs)
-
fs/libfs.h (modified) (3 diffs)
-
net/adt/module_map.c (modified) (3 diffs)
-
net/generic/packet_remote.c (modified) (7 diffs)
-
net/netif/netif_local.c (modified) (15 diffs)
-
net/tl/socket_core.c (modified) (13 diffs)
-
net/tl/tl_common.c (modified) (5 diffs)
-
packet/generic/packet_server.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r69e0d6d rcb569e6 75 75 typedef struct { 76 76 link_t link; 77 dev _handle_t dev_handle;77 devmap_handle_t devmap_handle; 78 78 int dev_phone; 79 79 fibril_mutex_t comm_area_lock; … … 91 91 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 92 92 93 static devcon_t *devcon_search(dev _handle_t dev_handle)93 static devcon_t *devcon_search(devmap_handle_t devmap_handle) 94 94 { 95 95 link_t *cur; … … 98 98 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 99 99 devcon_t *devcon = list_get_instance(cur, devcon_t, link); 100 if (devcon->dev _handle == dev_handle) {100 if (devcon->devmap_handle == devmap_handle) { 101 101 fibril_mutex_unlock(&dcl_lock); 102 102 return devcon; … … 107 107 } 108 108 109 static int devcon_add(dev _handle_t dev_handle, int dev_phone, size_t bsize,109 static int devcon_add(devmap_handle_t devmap_handle, int dev_phone, size_t bsize, 110 110 void *comm_area, size_t comm_size) 111 111 { … … 121 121 122 122 link_initialize(&devcon->link); 123 devcon->dev _handle = dev_handle;123 devcon->devmap_handle = devmap_handle; 124 124 devcon->dev_phone = dev_phone; 125 125 fibril_mutex_initialize(&devcon->comm_area_lock); … … 134 134 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 135 135 devcon_t *d = list_get_instance(cur, devcon_t, link); 136 if (d->dev _handle == dev_handle) {136 if (d->devmap_handle == devmap_handle) { 137 137 fibril_mutex_unlock(&dcl_lock); 138 138 free(devcon); … … 152 152 } 153 153 154 int block_init(dev _handle_t dev_handle, size_t comm_size)154 int block_init(devmap_handle_t devmap_handle, size_t comm_size) 155 155 { 156 156 int rc; … … 165 165 } 166 166 167 dev_phone = devmap_device_connect(dev _handle, IPC_FLAG_BLOCKING);167 dev_phone = devmap_device_connect(devmap_handle, IPC_FLAG_BLOCKING); 168 168 if (dev_phone < 0) { 169 169 munmap(comm_area, comm_size); … … 185 185 } 186 186 187 rc = devcon_add(dev _handle, dev_phone, bsize, comm_area, comm_size);187 rc = devcon_add(devmap_handle, dev_phone, bsize, comm_area, comm_size); 188 188 if (rc != EOK) { 189 189 munmap(comm_area, comm_size); … … 195 195 } 196 196 197 void block_fini(dev _handle_t dev_handle)198 { 199 devcon_t *devcon = devcon_search(dev _handle);197 void block_fini(devmap_handle_t devmap_handle) 198 { 199 devcon_t *devcon = devcon_search(devmap_handle); 200 200 assert(devcon); 201 201 202 202 if (devcon->cache) 203 (void) block_cache_fini(dev _handle);203 (void) block_cache_fini(devmap_handle); 204 204 205 205 devcon_remove(devcon); … … 214 214 } 215 215 216 int block_bb_read(dev _handle_t dev_handle, aoff64_t ba)216 int block_bb_read(devmap_handle_t devmap_handle, aoff64_t ba) 217 217 { 218 218 void *bb_buf; 219 219 int rc; 220 220 221 devcon_t *devcon = devcon_search(dev _handle);221 devcon_t *devcon = devcon_search(devmap_handle); 222 222 if (!devcon) 223 223 return ENOENT; … … 244 244 } 245 245 246 void *block_bb_get(dev _handle_t dev_handle)247 { 248 devcon_t *devcon = devcon_search(dev _handle);246 void *block_bb_get(devmap_handle_t devmap_handle) 247 { 248 devcon_t *devcon = devcon_search(devmap_handle); 249 249 assert(devcon); 250 250 return devcon->bb_buf; … … 272 272 }; 273 273 274 int block_cache_init(dev _handle_t dev_handle, size_t size, unsigned blocks,274 int block_cache_init(devmap_handle_t devmap_handle, size_t size, unsigned blocks, 275 275 enum cache_mode mode) 276 276 { 277 devcon_t *devcon = devcon_search(dev _handle);277 devcon_t *devcon = devcon_search(devmap_handle); 278 278 cache_t *cache; 279 279 if (!devcon) … … 305 305 } 306 306 307 int block_cache_fini(dev _handle_t dev_handle)308 { 309 devcon_t *devcon = devcon_search(dev _handle);307 int block_cache_fini(devmap_handle_t devmap_handle) 308 { 309 devcon_t *devcon = devcon_search(devmap_handle); 310 310 cache_t *cache; 311 311 int rc; … … 374 374 * @param block Pointer to where the function will store the 375 375 * block pointer on success. 376 * @param dev _handle Device handle of the block device.376 * @param devmap_handle Device handle of the block device. 377 377 * @param boff Block offset. 378 378 * @param flags If BLOCK_FLAGS_NOREAD is specified, block_get() … … 382 382 * @return EOK on success or a negative error code. 383 383 */ 384 int block_get(block_t **block, dev _handle_t dev_handle, aoff64_t boff, int flags)384 int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t boff, int flags) 385 385 { 386 386 devcon_t *devcon; … … 391 391 int rc; 392 392 393 devcon = devcon_search(dev _handle);393 devcon = devcon_search(devmap_handle); 394 394 395 395 assert(devcon); … … 500 500 501 501 block_initialize(b); 502 b->dev _handle = dev_handle;502 b->devmap_handle = devmap_handle; 503 503 b->size = cache->lblock_size; 504 504 b->boff = boff; … … 549 549 int block_put(block_t *block) 550 550 { 551 devcon_t *devcon = devcon_search(block->dev _handle);551 devcon_t *devcon = devcon_search(block->devmap_handle); 552 552 cache_t *cache; 553 553 unsigned blocks_cached; … … 645 645 /** Read sequential data from a block device. 646 646 * 647 * @param dev _handle Device handle of the block device.647 * @param devmap_handle Device handle of the block device. 648 648 * @param bufpos Pointer to the first unread valid offset within the 649 649 * communication buffer. … … 657 657 * @return EOK on success or a negative return code on failure. 658 658 */ 659 int block_seqread(dev _handle_t dev_handle, size_t *bufpos, size_t *buflen,659 int block_seqread(devmap_handle_t devmap_handle, size_t *bufpos, size_t *buflen, 660 660 aoff64_t *pos, void *dst, size_t size) 661 661 { … … 665 665 devcon_t *devcon; 666 666 667 devcon = devcon_search(dev _handle);667 devcon = devcon_search(devmap_handle); 668 668 assert(devcon); 669 669 block_size = devcon->pblock_size; … … 711 711 /** Read blocks directly from device (bypass cache). 712 712 * 713 * @param dev _handle Device handle of the block device.713 * @param devmap_handle Device handle of the block device. 714 714 * @param ba Address of first block. 715 715 * @param cnt Number of blocks. … … 718 718 * @return EOK on success or negative error code on failure. 719 719 */ 720 int block_read_direct(dev _handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf)720 int block_read_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, void *buf) 721 721 { 722 722 devcon_t *devcon; 723 723 int rc; 724 724 725 devcon = devcon_search(dev _handle);725 devcon = devcon_search(devmap_handle); 726 726 assert(devcon); 727 727 … … 739 739 /** Write blocks directly to device (bypass cache). 740 740 * 741 * @param dev _handle Device handle of the block device.741 * @param devmap_handle Device handle of the block device. 742 742 * @param ba Address of first block. 743 743 * @param cnt Number of blocks. … … 746 746 * @return EOK on success or negative error code on failure. 747 747 */ 748 int block_write_direct(dev _handle_t dev_handle, aoff64_t ba, size_t cnt,748 int block_write_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, 749 749 const void *data) 750 750 { … … 752 752 int rc; 753 753 754 devcon = devcon_search(dev _handle);754 devcon = devcon_search(devmap_handle); 755 755 assert(devcon); 756 756 … … 767 767 /** Get device block size. 768 768 * 769 * @param dev _handle Device handle of the block device.769 * @param devmap_handle Device handle of the block device. 770 770 * @param bsize Output block size. 771 771 * 772 772 * @return EOK on success or negative error code on failure. 773 773 */ 774 int block_get_bsize(dev _handle_t dev_handle, size_t *bsize)774 int block_get_bsize(devmap_handle_t devmap_handle, size_t *bsize) 775 775 { 776 776 devcon_t *devcon; 777 777 778 devcon = devcon_search(dev _handle);778 devcon = devcon_search(devmap_handle); 779 779 assert(devcon); 780 780 … … 784 784 /** Get number of blocks on device. 785 785 * 786 * @param dev _handle Device handle of the block device.786 * @param devmap_handle Device handle of the block device. 787 787 * @param nblocks Output number of blocks. 788 788 * 789 789 * @return EOK on success or negative error code on failure. 790 790 */ 791 int block_get_nblocks(dev _handle_t dev_handle, aoff64_t *nblocks)791 int block_get_nblocks(devmap_handle_t devmap_handle, aoff64_t *nblocks) 792 792 { 793 793 devcon_t *devcon; 794 794 795 devcon = devcon_search(dev _handle);795 devcon = devcon_search(devmap_handle); 796 796 assert(devcon); 797 797 … … 818 818 printf("Error %d reading %d blocks starting at block %" PRIuOFF64 819 819 " from device handle %d\n", rc, cnt, ba, 820 devcon->dev _handle);820 devcon->devmap_handle); 821 821 #ifndef NDEBUG 822 822 stacktrace_print(); … … 844 844 if (rc != EOK) { 845 845 printf("Error %d writing %d blocks starting at block %" PRIuOFF64 846 " to device handle %d\n", rc, cnt, ba, devcon->dev _handle);846 " to device handle %d\n", rc, cnt, ba, devcon->devmap_handle); 847 847 #ifndef NDEBUG 848 848 stacktrace_print(); -
uspace/lib/block/libblock.h
r69e0d6d rcb569e6 72 72 fibril_rwlock_t contents_lock; 73 73 /** Handle of the device where the block resides. */ 74 dev _handle_t dev_handle;74 devmap_handle_t devmap_handle; 75 75 /** Block offset on the block device. Counted in 'size'-byte blocks. */ 76 76 aoff64_t boff; … … 93 93 }; 94 94 95 extern int block_init(dev _handle_t, size_t);96 extern void block_fini(dev _handle_t);95 extern int block_init(devmap_handle_t, size_t); 96 extern void block_fini(devmap_handle_t); 97 97 98 extern int block_bb_read(dev _handle_t, aoff64_t);99 extern void *block_bb_get(dev _handle_t);98 extern int block_bb_read(devmap_handle_t, aoff64_t); 99 extern void *block_bb_get(devmap_handle_t); 100 100 101 extern int block_cache_init(dev _handle_t, size_t, unsigned, enum cache_mode);102 extern int block_cache_fini(dev _handle_t);101 extern int block_cache_init(devmap_handle_t, size_t, unsigned, enum cache_mode); 102 extern int block_cache_fini(devmap_handle_t); 103 103 104 extern int block_get(block_t **, dev _handle_t, aoff64_t, int);104 extern int block_get(block_t **, devmap_handle_t, aoff64_t, int); 105 105 extern int block_put(block_t *); 106 106 107 extern int block_seqread(dev _handle_t, size_t *, size_t *, aoff64_t *, void *,107 extern int block_seqread(devmap_handle_t, size_t *, size_t *, aoff64_t *, void *, 108 108 size_t); 109 109 110 extern int block_get_bsize(dev _handle_t, size_t *);111 extern int block_get_nblocks(dev _handle_t, aoff64_t *);112 extern int block_read_direct(dev _handle_t, aoff64_t, size_t, void *);113 extern int block_write_direct(dev _handle_t, aoff64_t, size_t, const void *);110 extern int block_get_bsize(devmap_handle_t, size_t *); 111 extern int block_get_nblocks(devmap_handle_t, aoff64_t *); 112 extern int block_read_direct(devmap_handle_t, aoff64_t, size_t, void *); 113 extern int block_write_direct(devmap_handle_t, aoff64_t, size_t, const void *); 114 114 115 115 #endif -
uspace/lib/c/generic/adt/measured_strings.c
r69e0d6d rcb569e6 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 #include <async.h> 45 44 … … 135 134 size_t count) 136 135 { 137 ERROR_DECLARE;138 139 136 size_t *lengths; 140 137 size_t index; … … 142 139 char *next; 143 140 ipc_callid_t callid; 141 int rc; 144 142 145 143 if ((!strings) || (!data) || (count <= 0)) … … 155 153 return EINVAL; 156 154 } 157 if (ERROR_OCCURRED(async_data_write_finalize(callid, lengths,158 length))) {159 free(lengths); 160 return ERROR_CODE;155 rc = async_data_write_finalize(callid, lengths, length); 156 if (rc != EOK) { 157 free(lengths); 158 return rc; 161 159 } 162 160 … … 187 185 return EINVAL; 188 186 } 189 if (ERROR_OCCURRED(async_data_write_finalize(callid, 190 next, lengths[index]))) { 187 rc = async_data_write_finalize(callid, next, 188 lengths[index]); 189 if (rc != EOK) { 191 190 free(*data); 192 191 free(*strings); 193 192 free(lengths); 194 return ERROR_CODE;193 return rc; 195 194 } 196 195 (*strings)[index].value = next; … … 251 250 int measured_strings_reply(const measured_string_ref strings, size_t count) 252 251 { 253 ERROR_DECLARE;254 255 252 size_t *lengths; 256 253 size_t index; 257 254 size_t length; 258 255 ipc_callid_t callid; 256 int rc; 259 257 260 258 if ((!strings) || (count <= 0)) … … 270 268 return EINVAL; 271 269 } 272 if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths, length))) { 273 free(lengths); 274 return ERROR_CODE; 270 rc = async_data_read_finalize(callid, lengths, length); 271 if (rc != EOK) { 272 free(lengths); 273 return rc; 275 274 } 276 275 free(lengths); … … 282 281 return EINVAL; 283 282 } 284 ERROR_PROPAGATE(async_data_read_finalize(callid, 285 strings[index].value, strings[index].length)); 283 rc = async_data_read_finalize(callid, 284 strings[index].value, strings[index].length); 285 if (rc != EOK) 286 return rc; 286 287 } 287 288 } … … 313 314 size_t count) 314 315 { 315 ERROR_DECLARE;316 317 316 size_t *lengths; 318 317 size_t index; 319 318 char *next; 319 int rc; 320 320 321 321 if ((phone < 0) || (!strings) || (!data) || (count <= 0)) … … 326 326 return ENOMEM; 327 327 328 if (ERROR_OCCURRED(async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)))) { 330 free(lengths); 331 return ERROR_CODE; 328 rc = async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)); 330 if (rc != EOK) { 331 free(lengths); 332 return rc; 332 333 } 333 334 … … 350 351 (*strings)[index].length = lengths[index]; 351 352 if (lengths[index] > 0) { 352 if (ERROR_OCCURRED(async_data_read_start(phone, next,353 lengths[index]))) {353 rc = async_data_read_start(phone, next, lengths[index]); 354 if (rc != EOK) { 354 355 free(lengths); 355 356 free(data); 356 357 free(strings); 357 return ERROR_CODE;358 return rc; 358 359 } 359 360 (*strings)[index].value = next; … … 387 388 size_t count) 388 389 { 389 ERROR_DECLARE;390 391 390 size_t *lengths; 392 391 size_t index; 392 int rc; 393 393 394 394 if ((phone < 0) || (!strings) || (count <= 0)) … … 399 399 return ENOMEM; 400 400 401 if (ERROR_OCCURRED(async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)))) { 403 free(lengths); 404 return ERROR_CODE; 401 rc = async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)); 403 if (rc != EOK) { 404 free(lengths); 405 return rc; 405 406 } 406 407 … … 409 410 for (index = 0; index < count; index++) { 410 411 if (strings[index].length > 0) { 411 ERROR_PROPAGATE(async_data_write_start(phone, 412 strings[index].value, strings[index].length)); 412 rc = async_data_write_start(phone, strings[index].value, 413 strings[index].length); 414 if (rc != EOK) 415 return rc; 413 416 } 414 417 } -
uspace/lib/c/generic/devman.c
r69e0d6d rcb569e6 141 141 142 142 int devman_child_device_register( 143 const char *name, match_id_list_t *match_ids, dev ice_handle_t parent_handle, device_handle_t *handle)143 const char *name, match_id_list_t *match_ids, devman_handle_t parent_handle, devman_handle_t *handle) 144 144 { 145 145 int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING); … … 180 180 } 181 181 182 int devman_add_device_to_class(dev ice_handle_t dev_handle, const char *class_name)182 int devman_add_device_to_class(devman_handle_t devman_handle, const char *class_name) 183 183 { 184 184 int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING); … … 189 189 async_serialize_start(); 190 190 ipc_call_t answer; 191 aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, dev _handle, &answer);191 aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, devman_handle, &answer); 192 192 193 193 ipcarg_t retval = async_data_write_start(phone, class_name, str_size(class_name)); … … 224 224 } 225 225 226 int devman_device_connect(dev ice_handle_t handle, unsigned int flags)226 int devman_device_connect(devman_handle_t handle, unsigned int flags) 227 227 { 228 228 int phone; … … 239 239 } 240 240 241 int devman_parent_device_connect(dev ice_handle_t handle, unsigned int flags)241 int devman_parent_device_connect(devman_handle_t handle, unsigned int flags) 242 242 { 243 243 int phone; … … 254 254 } 255 255 256 int devman_device_get_handle(const char *pathname, dev ice_handle_t *handle, unsigned int flags)256 int devman_device_get_handle(const char *pathname, devman_handle_t *handle, unsigned int flags) 257 257 { 258 258 int phone = devman_get_phone(DEVMAN_CLIENT, flags); … … 280 280 if (retval != EOK) { 281 281 if (handle != NULL) 282 *handle = (dev ice_handle_t) -1;282 *handle = (devman_handle_t) -1; 283 283 return retval; 284 284 } 285 285 286 286 if (handle != NULL) 287 *handle = (dev ice_handle_t) IPC_GET_ARG1(answer);287 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 288 288 289 289 return retval; -
uspace/lib/c/generic/devmap.c
r69e0d6d rcb569e6 132 132 * 133 133 */ 134 int devmap_device_register(const char *fqdn, dev _handle_t *handle)134 int devmap_device_register(const char *fqdn, devmap_handle_t *handle) 135 135 { 136 136 int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING); … … 163 163 164 164 if (handle != NULL) 165 *handle = (dev _handle_t) IPC_GET_ARG1(answer);165 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 166 166 167 167 return retval; 168 168 } 169 169 170 int devmap_device_get_handle(const char *fqdn, dev _handle_t *handle, unsigned int flags)170 int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags) 171 171 { 172 172 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 194 194 if (retval != EOK) { 195 195 if (handle != NULL) 196 *handle = (dev _handle_t) -1;196 *handle = (devmap_handle_t) -1; 197 197 return retval; 198 198 } 199 199 200 200 if (handle != NULL) 201 *handle = (dev _handle_t) IPC_GET_ARG1(answer);201 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 202 202 203 203 return retval; 204 204 } 205 205 206 int devmap_namespace_get_handle(const char *name, dev _handle_t *handle, unsigned int flags)206 int devmap_namespace_get_handle(const char *name, devmap_handle_t *handle, unsigned int flags) 207 207 { 208 208 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 230 230 if (retval != EOK) { 231 231 if (handle != NULL) 232 *handle = (dev _handle_t) -1;232 *handle = (devmap_handle_t) -1; 233 233 return retval; 234 234 } 235 235 236 236 if (handle != NULL) 237 *handle = (dev _handle_t) IPC_GET_ARG1(answer);237 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 238 238 239 239 return retval; 240 240 } 241 241 242 devmap_handle_type_t devmap_handle_probe(dev _handle_t handle)242 devmap_handle_type_t devmap_handle_probe(devmap_handle_t handle) 243 243 { 244 244 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 255 255 } 256 256 257 int devmap_device_connect(dev _handle_t handle, unsigned int flags)257 int devmap_device_connect(devmap_handle_t handle, unsigned int flags) 258 258 { 259 259 int phone; … … 305 305 } 306 306 307 static size_t devmap_count_devices_internal(int phone, dev _handle_t ns_handle)307 static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle) 308 308 { 309 309 ipcarg_t count; … … 325 325 } 326 326 327 size_t devmap_count_devices(dev _handle_t ns_handle)327 size_t devmap_count_devices(devmap_handle_t ns_handle) 328 328 { 329 329 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 387 387 } 388 388 389 size_t devmap_get_devices(dev _handle_t ns_handle, dev_desc_t **data)389 size_t devmap_get_devices(devmap_handle_t ns_handle, dev_desc_t **data) 390 390 { 391 391 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); -
uspace/lib/c/generic/net/modules.c
r69e0d6d rcb569e6 41 41 #include <async.h> 42 42 #include <malloc.h> 43 #include <err .h>43 #include <errno.h> 44 44 #include <sys/time.h> 45 45 … … 137 137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 ERROR_DECLARE;139 int rc; 140 140 141 141 /* Connect to the needed service */ … … 144 144 /* Request the bidirectional connection */ 145 145 ipcarg_t phonehash; 146 if (ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, 147 &phonehash))) { 146 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); 148 if (rc != EOK) { 148 149 ipc_hangup(phone); 149 return ERROR_CODE;150 return rc; 150 151 } 151 152 async_new_connection(phonehash, 0, NULL, client_receiver); … … 212 213 int data_receive(void **data, size_t *length) 213 214 { 214 ERROR_DECLARE;215 216 215 ipc_callid_t callid; 216 int rc; 217 217 218 218 if (!data || !length) … … 229 229 230 230 // fetch the data 231 if (ERROR_OCCURRED(async_data_write_finalize(callid, *data, *length))) { 231 rc = async_data_write_finalize(callid, *data, *length); 232 if (rc != EOK) { 232 233 free(data); 233 return ERROR_CODE;234 return rc; 234 235 } 235 236 -
uspace/lib/c/generic/net/packet.c
r69e0d6d rcb569e6 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 45 44 #include <sys/mman.h> … … 91 90 int pm_init(void) 92 91 { 93 ERROR_DECLARE;92 int rc; 94 93 95 94 fibril_rwlock_initialize(&pm_globals.lock); 95 96 96 fibril_rwlock_write_lock(&pm_globals.lock); 97 ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map));97 rc = gpm_initialize(&pm_globals.packet_map); 98 98 fibril_rwlock_write_unlock(&pm_globals.lock); 99 return EOK; 99 100 return rc; 100 101 } 101 102 … … 139 140 int pm_add(packet_t packet) 140 141 { 141 ERROR_DECLARE;142 143 142 packet_map_ref map; 143 int rc; 144 144 145 145 if (!packet_is_valid(packet)) … … 160 160 } 161 161 bzero(map, sizeof(packet_map_t)); 162 if ((ERROR_CODE =163 gpm_add(&pm_globals.packet_map, map))< 0) {162 rc = gpm_add(&pm_globals.packet_map, map); 163 if (rc < 0) { 164 164 fibril_rwlock_write_unlock(&pm_globals.lock); 165 165 free(map); 166 return ERROR_CODE;166 return rc; 167 167 } 168 168 } while (PACKET_MAP_PAGE(packet->packet_id) >= -
uspace/lib/c/generic/net/socket_client.c
r69e0d6d rcb569e6 43 43 #include <stdlib.h> 44 44 #include <errno.h> 45 #include <err.h>46 45 47 46 #include <ipc/services.h> … … 212 211 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall) 213 212 { 214 ERROR_DECLARE;215 216 213 ipc_callid_t callid; 217 214 ipc_call_t call; 218 215 socket_ref socket; 216 int rc; 219 217 220 218 loop: … … 231 229 SOCKET_GET_SOCKET_ID(call)); 232 230 if (!socket) { 233 ERROR_CODE= ENOTSOCK;231 rc = ENOTSOCK; 234 232 fibril_rwlock_read_unlock(&socket_globals.lock); 235 233 break; … … 240 238 fibril_mutex_lock(&socket->receive_lock); 241 239 // push the number of received packet fragments 242 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->received,240 rc = dyn_fifo_push(&socket->received, 243 241 SOCKET_GET_DATA_FRAGMENTS(call), 244 SOCKET_MAX_RECEIVED_SIZE))) { 242 SOCKET_MAX_RECEIVED_SIZE); 243 if (rc == EOK) { 245 244 // signal the received packet 246 245 fibril_condvar_signal(&socket->receive_signal); … … 252 251 // push the new socket identifier 253 252 fibril_mutex_lock(&socket->accept_lock); 254 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->accepted, 255 1, SOCKET_MAX_ACCEPTED_SIZE))) { 253 rc = dyn_fifo_push(&socket->accepted, 1, 254 SOCKET_MAX_ACCEPTED_SIZE); 255 if (rc == EOK) { 256 256 // signal the accepted socket 257 257 fibril_condvar_signal(&socket->accept_signal); … … 261 261 262 262 default: 263 ERROR_CODE= ENOTSUP;263 rc = ENOTSUP; 264 264 } 265 265 … … 280 280 281 281 default: 282 ERROR_CODE= ENOTSUP;283 } 284 285 ipc_answer_0(callid, (ipcarg_t) ERROR_CODE);282 rc = ENOTSUP; 283 } 284 285 ipc_answer_0(callid, (ipcarg_t) rc); 286 286 goto loop; 287 287 } … … 405 405 int socket(int domain, int type, int protocol) 406 406 { 407 ERROR_DECLARE;408 409 407 socket_ref socket; 410 408 int phone; … … 413 411 ipcarg_t fragment_size; 414 412 ipcarg_t header_size; 413 int rc; 415 414 416 415 // find the appropriate service … … 479 478 } 480 479 481 if (ERROR_OCCURRED((int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, 482 service, NULL, &fragment_size, &header_size))) { 480 rc = (int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 481 &fragment_size, &header_size); 482 if (rc != EOK) { 483 483 fibril_rwlock_write_unlock(&socket_globals.lock); 484 484 free(socket); 485 return ERROR_CODE;485 return rc; 486 486 } 487 487 … … 492 492 socket_initialize(socket, socket_id, phone, service); 493 493 // store the new socket 494 ERROR_CODE= sockets_add(socket_get_sockets(), socket_id, socket);494 rc = sockets_add(socket_get_sockets(), socket_id, socket); 495 495 496 496 fibril_rwlock_write_unlock(&socket_globals.lock); 497 if ( ERROR_CODE< 0) {497 if (rc < 0) { 498 498 dyn_fifo_destroy(&socket->received); 499 499 dyn_fifo_destroy(&socket->accepted); … … 501 501 async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0, 502 502 service); 503 return ERROR_CODE;503 return rc; 504 504 } 505 505 … … 770 770 int closesocket(int socket_id) 771 771 { 772 ERROR_DECLARE;773 774 772 socket_ref socket; 773 int rc; 775 774 776 775 fibril_rwlock_write_lock(&socket_globals.lock); … … 787 786 788 787 // request close 789 ERROR_PROPAGATE((int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 790 (ipcarg_t) socket->socket_id, 0, socket->service)); 788 rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 789 (ipcarg_t) socket->socket_id, 0, socket->service); 790 if (rc != EOK) { 791 fibril_rwlock_write_unlock(&socket_globals.lock); 792 return rc; 793 } 791 794 // free the socket structure 792 795 socket_destroy(socket); -
uspace/lib/c/generic/vfs/vfs.c
r69e0d6d rcb569e6 136 136 } 137 137 138 dev _handle_t dev_handle;139 int res = devmap_device_get_handle(fqdn, &dev _handle, flags);138 devmap_handle_t devmap_handle; 139 int res = devmap_device_get_handle(fqdn, &devmap_handle, flags); 140 140 if (res != EOK) { 141 141 if (null_id != -1) … … 159 159 160 160 ipcarg_t rc_orig; 161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev _handle, flags, NULL);161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, devmap_handle, flags, NULL); 162 162 ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 163 163 if (rc != EOK) { … … 328 328 ipc_call_t answer; 329 329 aid_t req = async_send_4(vfs_phone, VFS_IN_OPEN_NODE, node->fs_handle, 330 node->dev _handle, node->index, oflag, &answer);330 node->devmap_handle, node->index, oflag, &answer); 331 331 332 332 ipcarg_t rc; … … 797 797 if (rc == EOK) { 798 798 node->fs_handle = stat.fs_handle; 799 node->dev _handle = stat.dev_handle;799 node->devmap_handle = stat.devmap_handle; 800 800 node->index = stat.index; 801 801 } -
uspace/lib/c/include/adt/generic_char_map.h
r69e0d6d rcb569e6 40 40 #include <unistd.h> 41 41 #include <errno.h> 42 #include <err.h>43 42 44 43 #include <adt/char_map.h> … … 85 84 type *value) \ 86 85 { \ 87 ERROR_DECLARE; \86 int rc; \ 88 87 int index; \ 89 88 if (!name##_is_valid(map)) \ … … 92 91 if (index < 0) \ 93 92 return index; \ 94 if (ERROR_OCCURRED(char_map_add(&map->names, name, length,\95 index))) { \93 rc = char_map_add(&map->names, name, length, index); \ 94 if (rc != EOK) { \ 96 95 name##_items_exclude_index(&map->values, index); \ 97 return ERROR_CODE; \96 return rc; \ 98 97 } \ 99 98 return EOK; \ … … 141 140 int name##_initialize(name##_ref map) \ 142 141 { \ 143 ERROR_DECLARE; \142 int rc; \ 144 143 if (!map) \ 145 144 return EINVAL; \ 146 ERROR_PROPAGATE(char_map_initialize(&map->names)); \ 147 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \ 145 rc = char_map_initialize(&map->names); \ 146 if (rc != EOK) \ 147 return rc; \ 148 rc = name##_items_initialize(&map->values); \ 149 if (rc != EOK) { \ 148 150 char_map_destroy(&map->names); \ 149 return ERROR_CODE; \151 return rc; \ 150 152 } \ 151 153 map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \ -
uspace/lib/c/include/devman.h
r69e0d6d rcb569e6 42 42 43 43 44 int devman_get_phone(devman_interface_t, unsigned int);45 void devman_hangup_phone(devman_interface_t iface);44 extern int devman_get_phone(devman_interface_t, unsigned int); 45 extern void devman_hangup_phone(devman_interface_t); 46 46 47 int devman_driver_register(const char *, async_client_conn_t); 48 int devman_child_device_register(const char *, match_id_list_t *, device_handle_t, device_handle_t *); 47 extern int devman_driver_register(const char *, async_client_conn_t); 48 extern int devman_child_device_register(const char *, match_id_list_t *, 49 devman_handle_t, devman_handle_t *); 49 50 50 int devman_device_connect(device_handle_t handle, unsigned int flags);51 int devman_parent_device_connect(device_handle_t handle, unsigned int flags);51 extern int devman_device_connect(devman_handle_t, unsigned int); 52 extern int devman_parent_device_connect(devman_handle_t, unsigned int); 52 53 53 int devman_device_get_handle(const char *pathname, device_handle_t *handle, unsigned int flags); 54 extern int devman_device_get_handle(const char *, devman_handle_t *, 55 unsigned int); 54 56 55 int devman_add_device_to_class(device_handle_t dev_handle, const char *class_name);57 extern int devman_add_device_to_class(devman_handle_t, const char *); 56 58 57 59 #endif -
uspace/lib/c/include/devmap.h
r69e0d6d rcb569e6 44 44 45 45 extern int devmap_driver_register(const char *, async_client_conn_t); 46 extern int devmap_device_register(const char *, dev _handle_t *);46 extern int devmap_device_register(const char *, devmap_handle_t *); 47 47 48 extern int devmap_device_get_handle(const char *, dev _handle_t *, unsigned int);49 extern int devmap_namespace_get_handle(const char *, dev _handle_t *, unsigned int);50 extern devmap_handle_type_t devmap_handle_probe(dev _handle_t);48 extern int devmap_device_get_handle(const char *, devmap_handle_t *, unsigned int); 49 extern int devmap_namespace_get_handle(const char *, devmap_handle_t *, unsigned int); 50 extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t); 51 51 52 extern int devmap_device_connect(dev _handle_t, unsigned int);52 extern int devmap_device_connect(devmap_handle_t, unsigned int); 53 53 54 54 extern int devmap_null_create(void); … … 56 56 57 57 extern size_t devmap_count_namespaces(void); 58 extern size_t devmap_count_devices(dev _handle_t);58 extern size_t devmap_count_devices(devmap_handle_t); 59 59 60 60 extern size_t devmap_get_namespaces(dev_desc_t **); 61 extern size_t devmap_get_devices(dev _handle_t, dev_desc_t **);61 extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **); 62 62 63 63 #endif -
uspace/lib/c/include/err.h
r69e0d6d rcb569e6 37 37 38 38 #include <stdio.h> 39 #include <errno.h>40 41 #ifdef CONFIG_DEBUG42 #include <str_error.h>43 #endif44 39 45 40 #define errx(status, fmt, ...) { \ … … 48 43 } 49 44 50 51 /** An actual stored error code. */52 #define ERROR_CODE error_check_return_value53 54 /** An error processing routines declaration.55 *56 * This has to be declared in the block where the error processing57 * is desired.58 */59 #define ERROR_DECLARE int ERROR_CODE60 61 /** Store the value as an error code and checks if an error occurred.62 *63 * @param[in] value The value to be checked. May be a function call.64 * @return False if the value indicates success (EOK).65 * @return True otherwise.66 */67 #ifdef CONFIG_DEBUG68 69 #define ERROR_OCCURRED(value) \70 (((ERROR_CODE = (value)) != EOK) && \71 ({ \72 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \73 __FILE__, __LINE__, str_error(ERROR_CODE)); \74 1; \75 }))76 77 #else78 79 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK)80 81 #endif82 83 #define ERROR_NONE(value) !ERROR_OCCURRED((value))84 85 /** Error propagation86 *87 * Check if an error occurred and immediately exit the actual88 * function returning the error code.89 *90 * @param[in] value The value to be checked. May be a function call.91 *92 */93 94 #define ERROR_PROPAGATE(value) \95 if (ERROR_OCCURRED(value)) \96 return ERROR_CODE97 98 45 #endif 99 46 100 47 /** @} 101 48 */ 49 -
uspace/lib/c/include/ipc/devman.h
r69e0d6d rcb569e6 42 42 #define DEVMAN_NAME_MAXLEN 256 43 43 44 typedef ipcarg_t dev ice_handle_t;44 typedef ipcarg_t devman_handle_t; 45 45 46 46 /** Ids of device models used for device-to-driver matching. -
uspace/lib/c/include/ipc/devmap.h
r69e0d6d rcb569e6 40 40 #define DEVMAP_NAME_MAXLEN 255 41 41 42 typedef ipcarg_t dev _handle_t;42 typedef ipcarg_t devmap_handle_t; 43 43 44 44 typedef enum { … … 81 81 82 82 typedef struct { 83 dev _handle_t handle;83 devmap_handle_t handle; 84 84 char name[DEVMAP_NAME_MAXLEN + 1]; 85 85 } dev_desc_t; -
uspace/lib/c/include/stdio.h
r69e0d6d rcb569e6 46 46 #define BUFSIZ 4096 47 47 48 #define DEBUG(fmt, ...) se\48 #define DEBUG(fmt, ...) \ 49 49 { \ 50 50 char _buf[256]; \ -
uspace/lib/c/include/sys/stat.h
r69e0d6d rcb569e6 43 43 struct stat { 44 44 fs_handle_t fs_handle; 45 dev _handle_t dev_handle;45 devmap_handle_t devmap_handle; 46 46 fs_index_t index; 47 47 unsigned int lnkcnt; … … 49 49 bool is_directory; 50 50 aoff64_t size; 51 dev _handle_t device;51 devmap_handle_t device; 52 52 }; 53 53 -
uspace/lib/c/include/unistd.h
r69e0d6d rcb569e6 41 41 42 42 #ifndef NULL 43 #define NULL 0 43 #define NULL 0UL 44 44 #endif 45 45 -
uspace/lib/c/include/vfs/vfs.h
r69e0d6d rcb569e6 47 47 typedef struct { 48 48 fs_handle_t fs_handle; 49 dev _handle_t dev_handle;49 devmap_handle_t devmap_handle; 50 50 fs_index_t index; 51 51 } fdi_node_t; -
uspace/lib/drv/generic/driver.c
r69e0d6d rcb569e6 139 139 } 140 140 141 static device_t * driver_get_device(link_t *devices, dev ice_handle_t handle)141 static device_t * driver_get_device(link_t *devices, devman_handle_t handle) 142 142 { 143 143 device_t *dev = NULL; … … 163 163 int res = EOK; 164 164 165 dev ice_handle_t dev_handle = IPC_GET_ARG1(*icall);165 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 166 166 device_t *dev = create_device(); 167 167 dev->handle = dev_handle; … … 221 221 * the device to which the client connected. 222 222 */ 223 dev ice_handle_t handle = IPC_GET_ARG2(*icall);223 devman_handle_t handle = IPC_GET_ARG2(*icall); 224 224 device_t *dev = driver_get_device(&devices, handle); 225 225 -
uspace/lib/drv/include/driver.h
r69e0d6d rcb569e6 118 118 * device manager). 119 119 */ 120 dev ice_handle_t handle;120 devman_handle_t handle; 121 121 122 122 /** -
uspace/lib/fs/libfs.c
r69e0d6d rcb569e6 150 150 ipc_call_t *request) 151 151 { 152 dev _handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);152 devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 153 153 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 154 154 fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request); 155 dev _handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);155 devmap_handle_t mr_devmap_handle = (devmap_handle_t) IPC_GET_ARG4(*request); 156 156 int res; 157 157 ipcarg_t rc; … … 174 174 175 175 fs_node_t *fn; 176 res = ops->node_get(&fn, mp_dev _handle, mp_fs_index);176 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 177 177 if ((res != EOK) || (!fn)) { 178 178 ipc_hangup(mountee_phone); … … 201 201 ipc_call_t answer; 202 202 rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED, 203 mr_dev _handle, &answer);203 mr_devmap_handle, &answer); 204 204 205 205 if (rc == EOK) { 206 206 fn->mp_data.mp_active = true; 207 207 fn->mp_data.fs_handle = mr_fs_handle; 208 fn->mp_data.dev _handle = mr_dev_handle;208 fn->mp_data.devmap_handle = mr_devmap_handle; 209 209 fn->mp_data.phone = mountee_phone; 210 210 } … … 219 219 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request) 220 220 { 221 dev _handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);221 devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 222 222 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 223 223 fs_node_t *fn; 224 224 int res; 225 225 226 res = ops->node_get(&fn, mp_dev _handle, mp_fs_index);226 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 227 227 if ((res != EOK) || (!fn)) { 228 228 ipc_answer_0(rid, combine_rc(res, ENOENT)); … … 243 243 */ 244 244 res = async_req_1_0(fn->mp_data.phone, VFS_OUT_UNMOUNTED, 245 fn->mp_data.dev _handle);245 fn->mp_data.devmap_handle); 246 246 247 247 /* … … 252 252 fn->mp_data.mp_active = false; 253 253 fn->mp_data.fs_handle = 0; 254 fn->mp_data.dev _handle = 0;254 fn->mp_data.devmap_handle = 0; 255 255 fn->mp_data.phone = 0; 256 256 /* Drop the reference created in libfs_mount(). */ … … 281 281 unsigned int last = IPC_GET_ARG2(*request); 282 282 unsigned int next = first; 283 dev _handle_t dev_handle = IPC_GET_ARG3(*request);283 devmap_handle_t devmap_handle = IPC_GET_ARG3(*request); 284 284 int lflag = IPC_GET_ARG4(*request); 285 285 fs_index_t index = IPC_GET_ARG5(*request); … … 295 295 fs_node_t *tmp = NULL; 296 296 297 rc = ops->root_get(&cur, dev _handle);297 rc = ops->root_get(&cur, devmap_handle); 298 298 on_error(rc, goto out_with_answer); 299 299 300 300 if (cur->mp_data.mp_active) { 301 301 ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP, 302 next, last, cur->mp_data.dev _handle, lflag, index,302 next, last, cur->mp_data.devmap_handle, lflag, index, 303 303 IPC_FF_ROUTE_FROM_ME); 304 304 (void) ops->node_put(cur); … … 358 358 359 359 ipc_forward_slow(rid, tmp->mp_data.phone, 360 VFS_OUT_LOOKUP, next, last, tmp->mp_data.dev _handle,360 VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle, 361 361 lflag, index, IPC_FF_ROUTE_FROM_ME); 362 362 (void) ops->node_put(cur); … … 385 385 fs_node_t *fn; 386 386 if (lflag & L_CREATE) 387 rc = ops->create(&fn, dev _handle,387 rc = ops->create(&fn, devmap_handle, 388 388 lflag); 389 389 else 390 rc = ops->node_get(&fn, dev _handle,390 rc = ops->node_get(&fn, devmap_handle, 391 391 index); 392 392 on_error(rc, goto out_with_answer); … … 401 401 aoff64_t size = ops->size_get(fn); 402 402 ipc_answer_5(rid, fs_handle, 403 dev _handle,403 devmap_handle, 404 404 ops->index_get(fn), 405 405 LOWER32(size), … … 469 469 fs_node_t *fn; 470 470 if (lflag & L_CREATE) 471 rc = ops->create(&fn, dev _handle, lflag);471 rc = ops->create(&fn, devmap_handle, lflag); 472 472 else 473 rc = ops->node_get(&fn, dev _handle, index);473 rc = ops->node_get(&fn, devmap_handle, index); 474 474 on_error(rc, goto out_with_answer); 475 475 … … 483 483 aoff64_t size = ops->size_get(fn); 484 484 ipc_answer_5(rid, fs_handle, 485 dev _handle,485 devmap_handle, 486 486 ops->index_get(fn), 487 487 LOWER32(size), … … 509 509 if (rc == EOK) { 510 510 aoff64_t size = ops->size_get(cur); 511 ipc_answer_5(rid, fs_handle, dev _handle,511 ipc_answer_5(rid, fs_handle, devmap_handle, 512 512 ops->index_get(cur), LOWER32(size), UPPER32(size), 513 513 old_lnkcnt); … … 547 547 if (rc == EOK) { 548 548 aoff64_t size = ops->size_get(cur); 549 ipc_answer_5(rid, fs_handle, dev _handle,549 ipc_answer_5(rid, fs_handle, devmap_handle, 550 550 ops->index_get(cur), LOWER32(size), UPPER32(size), 551 551 ops->lnkcnt_get(cur)); … … 571 571 ipc_call_t *request) 572 572 { 573 dev _handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);573 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 574 574 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 575 575 576 576 fs_node_t *fn; 577 int rc = ops->node_get(&fn, dev _handle, index);577 int rc = ops->node_get(&fn, devmap_handle, index); 578 578 on_error(rc, answer_and_return(rid, rc)); 579 579 … … 592 592 593 593 stat.fs_handle = fs_handle; 594 stat.dev _handle = dev_handle;594 stat.devmap_handle = devmap_handle; 595 595 stat.index = index; 596 596 stat.lnkcnt = ops->lnkcnt_get(fn); … … 617 617 ipc_call_t *request) 618 618 { 619 dev _handle_t dev_handle = IPC_GET_ARG1(*request);619 devmap_handle_t devmap_handle = IPC_GET_ARG1(*request); 620 620 fs_index_t index = IPC_GET_ARG2(*request); 621 621 622 622 fs_node_t *fn; 623 int rc = ops->node_get(&fn, dev _handle, index);623 int rc = ops->node_get(&fn, devmap_handle, index); 624 624 on_error(rc, answer_and_return(rid, rc)); 625 625 -
uspace/lib/fs/libfs.h
r69e0d6d rcb569e6 47 47 int phone; 48 48 fs_handle_t fs_handle; 49 dev _handle_t dev_handle;49 devmap_handle_t devmap_handle; 50 50 } mp_data_t; 51 51 … … 61 61 * argument holds the output argument. 62 62 */ 63 int (* root_get)(fs_node_t **, dev _handle_t);63 int (* root_get)(fs_node_t **, devmap_handle_t); 64 64 int (* match)(fs_node_t **, fs_node_t *, const char *); 65 int (* node_get)(fs_node_t **, dev _handle_t, fs_index_t);65 int (* node_get)(fs_node_t **, devmap_handle_t, fs_index_t); 66 66 int (* node_open)(fs_node_t *); 67 67 int (* node_put)(fs_node_t *); 68 int (* create)(fs_node_t **, dev _handle_t, int);68 int (* create)(fs_node_t **, devmap_handle_t, int); 69 69 int (* destroy)(fs_node_t *); 70 70 int (* link)(fs_node_t *, fs_node_t *, const char *); … … 81 81 bool (* is_directory)(fs_node_t *); 82 82 bool (* is_file)(fs_node_t *); 83 dev _handle_t (* device_get)(fs_node_t *);83 devmap_handle_t (* device_get)(fs_node_t *); 84 84 } libfs_ops_t; 85 85 -
uspace/lib/net/adt/module_map.c
r69e0d6d rcb569e6 38 38 #include <task.h> 39 39 #include <unistd.h> 40 #include <err .h>40 #include <errno.h> 41 41 42 42 #include <ipc/services.h> … … 67 67 connect_module_t connect_module) 68 68 { 69 ERROR_DECLARE;70 71 69 module_ref tmp_module; 70 int rc; 72 71 73 72 tmp_module = (module_ref) malloc(sizeof(module_t)); … … 83 82 tmp_module->connect_module = connect_module; 84 83 85 if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0,86 tmp_module))) {84 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 85 if (rc != EOK) { 87 86 free(tmp_module); 88 return ERROR_CODE;87 return rc; 89 88 } 90 89 if (module) -
uspace/lib/net/generic/packet_remote.c
r69e0d6d rcb569e6 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <err.h>41 40 #include <ipc/ipc.h> 42 41 #include <ipc/packet.h> … … 67 66 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size) 68 67 { 69 ERROR_DECLARE;70 71 68 ipc_call_t answer; 72 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 69 aid_t message; 70 int rc; 71 72 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 73 74 74 *packet = (packet_t) as_get_mappable_page(size); 75 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||76 ERROR_OCCURRED(pm_add(*packet))) {75 rc = async_share_in_start_0_0(phone, *packet, size); 76 if (rc != EOK) { 77 77 munmap(*packet, size); 78 78 async_wait_for(message, NULL); 79 return ERROR_CODE; 79 return rc; 80 } 81 rc = pm_add(*packet); 82 if (rc != EOK) { 83 munmap(*packet, size); 84 async_wait_for(message, NULL); 85 return rc; 80 86 } 81 87 … … 103 109 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 104 110 { 105 ERROR_DECLARE;111 int rc; 106 112 107 113 if (!packet) … … 112 118 ipcarg_t size; 113 119 114 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, 115 packet_id, &size)); 116 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 120 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 if (rc != EOK) 123 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 125 if (rc != EOK) 126 return rc; 117 127 } 118 128 if ((*packet)->next) { … … 141 151 size_t max_prefix, size_t max_suffix) 142 152 { 143 ERROR_DECLARE;144 145 153 ipcarg_t packet_id; 146 154 ipcarg_t size; 147 148 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, 149 max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))) 155 int rc; 156 157 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 158 max_prefix, max_suffix, &packet_id, &size); 159 if (rc != EOK) 150 160 return NULL; 151 161 … … 153 163 packet_t packet = pm_find(packet_id); 154 164 if (!packet) { 155 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,156 size)))165 rc = packet_return(phone, &packet, packet_id, size); 166 if (rc != EOK) 157 167 return NULL; 158 168 } … … 172 182 packet_t packet_get_1_remote(int phone, size_t content) 173 183 { 174 ERROR_DECLARE;175 176 184 ipcarg_t packet_id; 177 185 ipcarg_t size; 178 179 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 180 &packet_id, &size))) 186 int rc; 187 188 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 189 &size); 190 if (rc != EOK) 181 191 return NULL; 182 192 183 193 packet_t packet = pm_find(packet_id); 184 194 if (!packet) { 185 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,186 size)))195 rc = packet_return(phone, &packet, packet_id, size); 196 if (rc != EOK) 187 197 return NULL; 188 198 } -
uspace/lib/net/netif/netif_local.c
r69e0d6d rcb569e6 43 43 #include <ipc/services.h> 44 44 #include <ipc/netif.h> 45 #include <err .h>45 #include <errno.h> 46 46 47 47 #include <generic.h> … … 113 113 int netif_start_req_local(int netif_phone, device_id_t device_id) 114 114 { 115 ERROR_DECLARE;115 int rc; 116 116 117 117 fibril_rwlock_write_lock(&netif_globals.lock); 118 118 119 119 netif_device_t *device; 120 if (ERROR_OCCURRED(find_device(device_id, &device))) { 120 rc = find_device(device_id, &device); 121 if (rc != EOK) { 121 122 fibril_rwlock_write_unlock(&netif_globals.lock); 122 return ERROR_CODE;123 return rc; 123 124 } 124 125 … … 148 149 int netif_stop_req_local(int netif_phone, device_id_t device_id) 149 150 { 150 ERROR_DECLARE;151 int rc; 151 152 152 153 fibril_rwlock_write_lock(&netif_globals.lock); 153 154 154 155 netif_device_t *device; 155 if (ERROR_OCCURRED(find_device(device_id, &device))) { 156 rc = find_device(device_id, &device); 157 if (rc != EOK) { 156 158 fibril_rwlock_write_unlock(&netif_globals.lock); 157 return ERROR_CODE;159 return rc; 158 160 } 159 161 … … 203 205 measured_string_ref *address, char **data) 204 206 { 205 ERROR_DECLARE;207 int rc; 206 208 207 209 if (!address || !data) … … 211 213 212 214 measured_string_t translation; 213 if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) { 215 rc = netif_get_addr_message(device_id, &translation); 216 if (rc == EOK) { 214 217 *address = measured_string_copy(&translation); 215 ERROR_CODE= (*address) ? EOK : ENOMEM;218 rc = (*address) ? EOK : ENOMEM; 216 219 } 217 220 … … 220 223 *data = (**address).value; 221 224 222 return ERROR_CODE;225 return rc; 223 226 } 224 227 … … 264 267 int netif_init_module(async_client_conn_t client_connection) 265 268 { 266 ERROR_DECLARE;269 int rc; 267 270 268 271 async_set_client_connection(client_connection); … … 271 274 netif_device_map_initialize(&netif_globals.device_map); 272 275 273 ERROR_PROPAGATE(pm_init()); 276 rc = pm_init(); 277 if (rc != EOK) 278 return rc; 274 279 275 280 fibril_rwlock_initialize(&netif_globals.lock); 276 if (ERROR_OCCURRED(netif_initialize())) { 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 277 284 pm_destroy(); 278 return ERROR_CODE;285 return rc; 279 286 } 280 287 … … 317 324 static int register_message(const char *name, device_id_t device_id, int phone) 318 325 { 319 ERROR_DECLARE;320 321 326 netif_device_t *device; 322 ERROR_PROPAGATE(find_device(device_id, &device)); 323 if(device->nil_phone > 0) 327 int rc; 328 329 rc = find_device(device_id, &device); 330 if (rc != EOK) 331 return rc; 332 333 if (device->nil_phone > 0) 324 334 return ELIMIT; 325 335 … … 349 359 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 350 360 { 351 ERROR_DECLARE;352 353 361 size_t length; 354 362 device_stats_t stats; 355 363 packet_t packet; 356 364 measured_string_t address; 365 int rc; 357 366 358 367 *answer_count = 0; … … 367 376 case IPC_M_CONNECT_TO_ME: 368 377 fibril_rwlock_write_lock(&netif_globals.lock); 369 ERROR_CODE= register_message(name, IPC_GET_DEVICE(call),378 rc = register_message(name, IPC_GET_DEVICE(call), 370 379 IPC_GET_PHONE(call)); 371 380 fibril_rwlock_write_unlock(&netif_globals.lock); 372 return ERROR_CODE;381 return rc; 373 382 374 383 case NET_NETIF_SEND: 375 ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone, 376 &packet, IPC_GET_PACKET(call))); 384 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET(call)); 386 if (rc != EOK) 387 return rc; 377 388 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 378 389 IPC_GET_SENDER(call)); 379 390 380 391 case NET_NETIF_START: 381 392 return netif_start_req_local(0, IPC_GET_DEVICE(call)); … … 384 395 fibril_rwlock_read_lock(&netif_globals.lock); 385 396 386 if (ERROR_OCCURRED(async_data_read_receive(&callid, &length))) { 397 rc = async_data_read_receive(&callid, &length); 398 if (rc != EOK) { 387 399 fibril_rwlock_read_unlock(&netif_globals.lock); 388 return ERROR_CODE;400 return rc; 389 401 } 390 402 if (length < sizeof(device_stats_t)) { … … 393 405 } 394 406 395 if (ERROR_NONE(netif_get_device_stats(IPC_GET_DEVICE(call),396 &stats))) {397 ERROR_CODE= async_data_read_finalize(callid, &stats,407 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats); 408 if (rc == EOK) { 409 rc = async_data_read_finalize(callid, &stats, 398 410 sizeof(device_stats_t)); 399 411 } 400 412 401 413 fibril_rwlock_read_unlock(&netif_globals.lock); 402 return ERROR_CODE;414 return rc; 403 415 404 416 case NET_NETIF_STOP: … … 407 419 case NET_NETIF_GET_ADDR: 408 420 fibril_rwlock_read_lock(&netif_globals.lock); 409 if (ERROR_NONE(netif_get_addr_message(IPC_GET_DEVICE(call),410 &address)))411 ERROR_CODE= measured_strings_reply(&address, 1);421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address); 422 if (rc == EOK) 423 rc = measured_strings_reply(&address, 1); 412 424 fibril_rwlock_read_unlock(&netif_globals.lock); 413 return ERROR_CODE;425 return rc; 414 426 } 415 427 … … 431 443 int netif_module_start_standalone(async_client_conn_t client_connection) 432 444 { 433 ERROR_DECLARE; 434 435 ERROR_PROPAGATE(netif_init_module(client_connection)); 445 int rc; 446 447 rc = netif_init_module(client_connection); 448 if (rc != EOK) 449 return rc; 436 450 437 451 async_manager(); -
uspace/lib/net/tl/socket_core.c
r69e0d6d rcb569e6 48 48 #include <stdlib.h> 49 49 #include <errno.h> 50 #include <err.h>51 50 52 51 #include <adt/dynamic_fifo.h> … … 164 163 const char *key, size_t key_length) 165 164 { 166 ERROR_DECLARE;167 168 165 socket_core_ref *socket_ref; 166 int rc; 169 167 170 168 // create a wrapper … … 175 173 *socket_ref = socket; 176 174 // add the wrapper 177 if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key, 178 key_length, socket_ref))) { 175 rc = socket_port_map_add(&socket_port->map, key, key_length, 176 socket_ref); 177 if (rc != EOK) { 179 178 free(socket_ref); 180 return ERROR_CODE;179 return rc; 181 180 } 182 181 … … 204 203 int port) 205 204 { 206 ERROR_DECLARE;207 208 205 socket_port_ref socket_port; 206 int rc; 209 207 210 208 // create a wrapper … … 214 212 215 213 socket_port->count = 0; 216 if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) || 217 ERROR_OCCURRED(socket_port_add_core(socket_port, socket, 218 SOCKET_MAP_KEY_LISTENING, 0))) { 219 socket_port_map_destroy(&socket_port->map); 220 free(socket_port); 221 return ERROR_CODE; 222 } 214 rc = socket_port_map_initialize(&socket_port->map); 215 if (rc != EOK) 216 goto fail; 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING, 219 0); 220 if (rc != EOK) 221 goto fail; 223 222 224 223 // register the incomming port 225 ERROR_CODE = socket_ports_add(global_sockets, port, socket_port); 226 if (ERROR_CODE < 0) { 227 socket_port_map_destroy(&socket_port->map); 228 free(socket_port); 229 return ERROR_CODE; 230 } 224 rc = socket_ports_add(global_sockets, port, socket_port); 225 if (rc < 0) 226 goto fail; 231 227 232 228 socket->port = port; 233 229 return EOK; 230 231 fail: 232 socket_port_map_destroy(&socket_port->map); 233 free(socket_port); 234 return rc; 235 234 236 } 235 237 … … 416 418 void *specific_data, int *socket_id) 417 419 { 418 ERROR_DECLARE;419 420 420 socket_core_ref socket; 421 int res;422 421 int positive; 422 int rc; 423 423 424 424 if (!socket_id) … … 447 447 socket->key_length = 0; 448 448 socket->specific_data = specific_data; 449 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,450 SOCKET_INITIAL_RECEIVED_SIZE))) {449 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 450 if (rc != EOK) { 451 451 free(socket); 452 return ERROR_CODE; 453 } 454 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted, 455 SOCKET_INITIAL_ACCEPTED_SIZE))) { 452 return rc; 453 } 454 455 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 456 if (rc != EOK) { 456 457 dyn_fifo_destroy(&socket->received); 457 458 free(socket); 458 return ERROR_CODE;459 return rc; 459 460 } 460 461 socket->socket_id = *socket_id; 461 r es= socket_cores_add(local_sockets, socket->socket_id, socket);462 if (r es< 0) {462 rc = socket_cores_add(local_sockets, socket->socket_id, socket); 463 if (rc < 0) { 463 464 dyn_fifo_destroy(&socket->received); 464 465 dyn_fifo_destroy(&socket->accepted); 465 466 free(socket); 466 return r es;467 return rc; 467 468 } 468 469 … … 523 524 int socket_reply_packets(packet_t packet, size_t *length) 524 525 { 525 ERROR_DECLARE;526 527 526 packet_t next_packet; 528 527 size_t fragments; 529 528 size_t *lengths; 530 529 size_t index; 530 int rc; 531 531 532 532 if (!length) … … 536 536 if (!next_packet) { 537 537 // write all if only one fragment 538 ERROR_PROPAGATE(data_reply(packet_get_data(packet), 539 packet_get_data_length(packet))); 538 rc = data_reply(packet_get_data(packet), 539 packet_get_data_length(packet)); 540 if (rc != EOK) 541 return rc; 540 542 // store the total length 541 543 *length = packet_get_data_length(packet); … … 564 566 565 567 // write the fragment lengths 566 if (ERROR_OCCURRED(data_reply(lengths,567 sizeof(int) * (fragments + 1)))) {568 rc = data_reply(lengths, sizeof(int) * (fragments + 1)); 569 if (rc != EOK) { 568 570 free(lengths); 569 return ERROR_CODE;571 return rc; 570 572 } 571 573 next_packet = packet; … … 573 575 // write the fragments 574 576 for (index = 0; index < fragments; ++index) { 575 ERROR_CODE= data_reply(packet_get_data(next_packet),577 rc = data_reply(packet_get_data(next_packet), 576 578 lengths[index]); 577 if ( ERROR_OCCURRED(ERROR_CODE)) {579 if (rc != EOK) { 578 580 free(lengths); 579 return ERROR_CODE;581 return rc; 580 582 } 581 583 next_packet = pq_next(next_packet); … … 680 682 socket_core_ref socket, const char *key, size_t key_length) 681 683 { 682 ERROR_DECLARE;683 684 684 socket_port_ref socket_port; 685 int rc; 685 686 686 687 // find ports … … 690 691 691 692 // add the socket 692 ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key, 693 key_length)); 693 rc = socket_port_add_core(socket_port, socket, key, key_length); 694 if (rc != EOK) 695 return rc; 694 696 695 697 socket->port = port; -
uspace/lib/net/tl/tl_common.c
r69e0d6d rcb569e6 54 54 #include <ipc/services.h> 55 55 #include <errno.h> 56 #include <err.h>57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 124 123 packet_dimension_ref *packet_dimension) 125 124 { 126 ERROR_DECLARE;125 int rc; 127 126 128 127 if (!packet_dimension) … … 137 136 return ENOMEM; 138 137 139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,140 *packet_dimension))) {138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension); 139 if (rc != EOK) { 141 140 free(*packet_dimension); 142 return ERROR_CODE;141 return rc; 143 142 } 144 143 145 ERROR_CODE= packet_dimensions_add(packet_dimensions, device_id,144 rc = packet_dimensions_add(packet_dimensions, device_id, 146 145 *packet_dimension); 147 if ( ERROR_CODE< 0) {146 if (rc < 0) { 148 147 free(*packet_dimension); 149 return ERROR_CODE;148 return rc; 150 149 } 151 150 } … … 292 291 socklen_t addrlen) 293 292 { 294 ERROR_DECLARE;295 296 293 ipc_callid_t callid; 297 294 size_t length; 298 void * data; 295 void *data; 296 int rc; 299 297 300 298 if (!dimension) … … 319 317 320 318 // read the data into the packet 321 if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) || 322 // set the packet destination address 323 ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, 324 addrlen))) { 319 rc = async_data_write_finalize(callid, data, length); 320 if (rc != EOK) { 325 321 pq_release_remote(packet_phone, packet_get_id(*packet)); 326 return ERROR_CODE; 322 return rc; 323 } 324 325 // set the packet destination address 326 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 if (rc != EOK) { 328 pq_release_remote(packet_phone, packet_get_id(*packet)); 329 return rc; 327 330 } 328 331 -
uspace/lib/packet/generic/packet_server.c
r69e0d6d rcb569e6 42 42 #include <async.h> 43 43 #include <errno.h> 44 #include <err.h>45 44 #include <fibril_synch.h> 46 45 #include <unistd.h> … … 162 161 size_t max_content, size_t max_suffix) 163 162 { 164 ERROR_DECLARE;165 166 163 packet_t packet; 164 int rc; 167 165 168 166 // already locked … … 177 175 packet_init(packet, addr_len, max_prefix, max_content, max_suffix); 178 176 packet->magic_value = PACKET_MAGIC_VALUE; 179 if (ERROR_OCCURRED(pm_add(packet))) { 177 rc = pm_add(packet); 178 if (rc != EOK) { 180 179 munmap(packet, packet->length); 181 180 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
