Changeset e27cf669 in mainline for uspace/lib
- Timestamp:
- 2010-02-09T20:19:23Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fb150d78
- Parents:
- 975e7e9 (diff), eb73a50 (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:
-
- 27 added
- 1 deleted
- 36 edited
- 6 moved
-
libblock/libblock.c (modified) (2 diffs)
-
libblock/libblock.h (modified) (1 diff)
-
libc/arch/amd64/Makefile.inc (modified) (1 diff)
-
libc/arch/amd64/include/inttypes.h (added)
-
libc/arch/amd64/include/istate.h (added)
-
libc/arch/amd64/include/types.h (modified) (1 diff)
-
libc/arch/amd64/src/stacktrace.c (added)
-
libc/arch/amd64/src/stacktrace_asm.S (moved) (moved from uspace/lib/libc/arch/amd64/src/stacktrace.S ) (1 diff)
-
libc/arch/arm32/Makefile.inc (modified) (1 diff)
-
libc/arch/arm32/include/inttypes.h (added)
-
libc/arch/arm32/include/istate.h (added)
-
libc/arch/arm32/include/types.h (modified) (1 diff)
-
libc/arch/arm32/src/stacktrace.c (added)
-
libc/arch/arm32/src/stacktrace_asm.S (moved) (moved from uspace/lib/libc/arch/arm32/src/stacktrace.S ) (1 diff)
-
libc/arch/ia32/Makefile.inc (modified) (1 diff)
-
libc/arch/ia32/include/inttypes.h (added)
-
libc/arch/ia32/include/istate.h (added)
-
libc/arch/ia32/include/types.h (modified) (1 diff)
-
libc/arch/ia32/src/stacktrace.c (added)
-
libc/arch/ia32/src/stacktrace_asm.S (moved) (moved from uspace/lib/libc/arch/ia32/src/stacktrace.S ) (1 diff)
-
libc/arch/ia64/Makefile.inc (modified) (1 diff)
-
libc/arch/ia64/include/fibril.h (modified) (1 diff)
-
libc/arch/ia64/include/inttypes.h (added)
-
libc/arch/ia64/include/istate.h (added)
-
libc/arch/ia64/include/types.h (modified) (1 diff)
-
libc/arch/ia64/src/stacktrace.c (added)
-
libc/arch/ia64/src/stacktrace_asm.S (moved) (moved from uspace/lib/libc/arch/ia64/src/stacktrace.S ) (1 diff)
-
libc/arch/mips32/Makefile.inc (modified) (1 diff)
-
libc/arch/mips32/include/inttypes.h (added)
-
libc/arch/mips32/include/istate.h (added)
-
libc/arch/mips32/include/types.h (modified) (1 diff)
-
libc/arch/mips32/src/stacktrace.c (added)
-
libc/arch/mips32/src/stacktrace_asm.S (moved) (moved from uspace/lib/libc/arch/mips32/src/stacktrace.S ) (1 diff)
-
libc/arch/mips32eb/Makefile.inc (modified) (1 diff)
-
libc/arch/mips32eb/include/inttypes.h (added)
-
libc/arch/mips32eb/include/istate.h (added)
-
libc/arch/ppc32/Makefile.inc (modified) (1 diff)
-
libc/arch/ppc32/include/inttypes.h (added)
-
libc/arch/ppc32/include/istate.h (added)
-
libc/arch/ppc32/include/types.h (modified) (1 diff)
-
libc/arch/ppc32/src/stacktrace.c (added)
-
libc/arch/ppc32/src/stacktrace_asm.S (moved) (moved from uspace/lib/libc/arch/ppc32/src/stacktrace.S ) (1 diff)
-
libc/arch/sparc64/Makefile.inc (modified) (1 diff)
-
libc/arch/sparc64/include/fibril.h (modified) (1 diff)
-
libc/arch/sparc64/include/inttypes.h (added)
-
libc/arch/sparc64/include/istate.h (added)
-
libc/arch/sparc64/include/types.h (modified) (1 diff)
-
libc/arch/sparc64/src/stacktrace.S (deleted)
-
libc/arch/sparc64/src/stacktrace.c (added)
-
libc/arch/sparc64/src/stacktrace_asm.S (added)
-
libc/generic/adt/hash_table.c (modified) (1 diff)
-
libc/generic/async.c (modified) (8 diffs)
-
libc/generic/clipboard.c (modified) (2 diffs)
-
libc/generic/stacktrace.c (modified) (2 diffs)
-
libc/generic/udebug.c (modified) (2 diffs)
-
libc/generic/vfs/vfs.c (modified) (3 diffs)
-
libc/include/adt/hash_table.h (modified) (1 diff)
-
libc/include/async.h (modified) (1 diff)
-
libc/include/fibril.h (modified) (4 diffs)
-
libc/include/inttypes.h (added)
-
libc/include/ipc/adb.h (added)
-
libc/include/ipc/clipboard.h (modified) (1 diff)
-
libc/include/ipc/vfs.h (modified) (5 diffs)
-
libc/include/stacktrace.h (modified) (2 diffs)
-
libc/include/stdlib.h (modified) (1 diff)
-
libc/include/sys/typefmt.h (added)
-
libc/include/udebug.h (modified) (1 diff)
-
libc/include/vfs/vfs.h (modified) (1 diff)
-
libfs/libfs.c (modified) (8 diffs)
-
libfs/libfs.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/libblock.c
r975e7e9 re27cf669 198 198 assert(devcon); 199 199 200 if (devcon->cache) 201 (void) block_cache_fini(dev_handle); 202 200 203 devcon_remove(devcon); 201 204 202 205 if (devcon->bb_buf) 203 206 free(devcon->bb_buf); 204 205 if (devcon->cache) {206 hash_table_destroy(&devcon->cache->block_hash);207 free(devcon->cache);208 }209 207 210 208 munmap(devcon->comm_area, devcon->comm_size); … … 302 300 303 301 devcon->cache = cache; 302 return EOK; 303 } 304 305 int block_cache_fini(dev_handle_t dev_handle) 306 { 307 devcon_t *devcon = devcon_search(dev_handle); 308 cache_t *cache; 309 int rc; 310 311 if (!devcon) 312 return ENOENT; 313 if (!devcon->cache) 314 return EOK; 315 cache = devcon->cache; 316 317 /* 318 * We are expecting to find all blocks for this device handle on the 319 * free list, i.e. the block reference count should be zero. Do not 320 * bother with the cache and block locks because we are single-threaded. 321 */ 322 while (!list_empty(&cache->free_head)) { 323 block_t *b = list_get_instance(cache->free_head.next, 324 block_t, free_link); 325 326 list_remove(&b->free_link); 327 if (b->dirty) { 328 memcpy(devcon->comm_area, b->data, b->size); 329 rc = write_blocks(devcon, b->boff, 1); 330 if (rc != EOK) 331 return rc; 332 } 333 334 long key = b->boff; 335 hash_table_remove(&cache->block_hash, &key, 1); 336 337 free(b->data); 338 free(b); 339 } 340 341 hash_table_destroy(&cache->block_hash); 342 devcon->cache = NULL; 343 free(cache); 344 304 345 return EOK; 305 346 } -
uspace/lib/libblock/libblock.h
r975e7e9 re27cf669 100 100 101 101 extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode); 102 extern int block_cache_fini(dev_handle_t); 102 103 103 104 extern int block_get(block_t **, dev_handle_t, bn_t, int); -
uspace/lib/libc/arch/amd64/Makefile.inc
r975e7e9 re27cf669 37 37 arch/$(UARCH)/src/fibril.S \ 38 38 arch/$(UARCH)/src/tls.c \ 39 arch/$(UARCH)/src/stacktrace.S 39 arch/$(UARCH)/src/stacktrace.c \ 40 arch/$(UARCH)/src/stacktrace_asm.S 40 41 41 42 GCC_CFLAGS += -fno-omit-frame-pointer -
uspace/lib/libc/arch/amd64/include/types.h
r975e7e9 re27cf669 36 36 #define LIBC_amd64_TYPES_H_ 37 37 38 #define __64_BITS__ 39 38 40 typedef unsigned long long sysarg_t; 39 41 -
uspace/lib/libc/arch/amd64/src/stacktrace_asm.S
r975e7e9 re27cf669 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get: 35 stacktrace_prepare: 36 ret 37 38 stacktrace_fp_get: 38 39 movq %rbp, %rax 39 40 ret 40 41 41 frame_pointer_prev: 42 movq (%rdi), %rax 43 ret 44 45 frame_pointer_validate: 46 movq %rdi, %rax 47 ret 48 49 return_address_get: 50 movq 8(%rdi), %rax 51 ret 52 53 program_counter_get: 42 stacktrace_pc_get: 54 43 movq (%rsp), %rax 55 44 ret -
uspace/lib/libc/arch/arm32/Makefile.inc
r975e7e9 re27cf669 38 38 arch/$(UARCH)/src/tls.c \ 39 39 arch/$(UARCH)/src/eabi.S \ 40 arch/$(UARCH)/src/stacktrace.S 40 arch/$(UARCH)/src/stacktrace.c \ 41 arch/$(UARCH)/src/stacktrace_asm.S 41 42 42 43 GCC_CFLAGS += -ffixed-r9 -mtp=soft -mapcs-frame -fno-omit-frame-pointer -
uspace/lib/libc/arch/arm32/include/types.h
r975e7e9 re27cf669 37 37 #define LIBC_arm32_TYPES_H_ 38 38 39 #define __32_BITS__ 40 39 41 typedef unsigned int sysarg_t; 40 42 -
uspace/lib/libc/arch/arm32/src/stacktrace_asm.S
r975e7e9 re27cf669 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get: 35 stacktrace_prepare: 36 mov pc, lr 37 38 stacktrace_fp_get: 38 39 mov r0, fp 39 40 mov pc, lr 40 41 41 frame_pointer_prev: 42 ldr r0, [r0, #-12] 43 mov pc, lr 44 45 frame_pointer_validate: 46 mov pc, lr 47 48 return_address_get: 49 ldr r0, [r0, #-4] 50 mov pc, lr 51 52 program_counter_get: 42 stacktrace_pc_get: 53 43 mov r0, lr 54 44 mov pc, lr 55 -
uspace/lib/libc/arch/ia32/Makefile.inc
r975e7e9 re27cf669 38 38 arch/$(UARCH)/src/tls.c \ 39 39 arch/$(UARCH)/src/setjmp.S \ 40 arch/$(UARCH)/src/stacktrace.S 40 arch/$(UARCH)/src/stacktrace.c \ 41 arch/$(UARCH)/src/stacktrace_asm.S 41 42 42 43 GCC_CFLAGS += -march=pentium -
uspace/lib/libc/arch/ia32/include/types.h
r975e7e9 re27cf669 36 36 #define LIBC_ia32_TYPES_H_ 37 37 38 #define __32_BITS__ 39 38 40 typedef unsigned int sysarg_t; 39 41 -
uspace/lib/libc/arch/ia32/src/stacktrace_asm.S
r975e7e9 re27cf669 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get: 35 stacktrace_prepare: 36 ret 37 38 stacktrace_fp_get: 38 39 movl %ebp, %eax 39 40 ret 40 41 41 frame_pointer_prev: 42 movl 4(%esp), %eax 43 movl (%eax), %eax 44 ret 45 46 frame_pointer_validate: 47 movl 4(%esp), %eax 48 ret 49 50 return_address_get: 51 movl 4(%esp), %eax 52 movl 4(%eax), %eax 53 ret 54 55 program_counter_get: 42 stacktrace_pc_get: 56 43 movl (%esp), %eax 57 44 ret -
uspace/lib/libc/arch/ia64/Makefile.inc
r975e7e9 re27cf669 37 37 arch/$(UARCH)/src/tls.c \ 38 38 arch/$(UARCH)/src/ddi.c \ 39 arch/$(UARCH)/src/stacktrace.S 39 arch/$(UARCH)/src/stacktrace.c \ 40 arch/$(UARCH)/src/stacktrace_asm.S 40 41 41 42 GCC_CFLAGS += -fno-unwind-tables -
uspace/lib/libc/arch/ia64/include/fibril.h
r975e7e9 re27cf669 52 52 /* Stack is divided into two equal parts (for memory stack and register stack). */ 53 53 #define PSTHREAD_INITIAL_STACK_DIVISION 2 54 55 #ifdef context_set56 #undef context_set57 #endif58 54 59 55 #define context_set(c, _pc, stack, size, tls) \ -
uspace/lib/libc/arch/ia64/include/types.h
r975e7e9 re27cf669 36 36 #define LIBC_ia64_TYPES_H_ 37 37 38 #define __64_BITS__ 39 38 40 typedef unsigned long long sysarg_t; 39 41 -
uspace/lib/libc/arch/ia64/src/stacktrace_asm.S
r975e7e9 re27cf669 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get:38 frame_pointer_prev: 39 frame_pointer_validate: 40 return_address_get:41 program_counter_get:35 stacktrace_prepare: 36 br.ret.sptk.many b0 37 38 stacktrace_fp_get: 39 stacktrace_pc_get: 42 40 mov r8 = r0 43 41 br.ret.sptk.many b0 -
uspace/lib/libc/arch/mips32/Makefile.inc
r975e7e9 re27cf669 36 36 arch/$(UARCH)/src/fibril.S \ 37 37 arch/$(UARCH)/src/tls.c \ 38 arch/$(UARCH)/src/stacktrace.S 38 arch/$(UARCH)/src/stacktrace.c \ 39 arch/$(UARCH)/src/stacktrace_asm.S 39 40 40 41 GCC_CFLAGS += -mips3 -
uspace/lib/libc/arch/mips32/include/types.h
r975e7e9 re27cf669 37 37 #define LIBC_mips32_TYPES_H_ 38 38 39 #define __32_BITS__ 40 39 41 typedef unsigned int sysarg_t; 40 42 -
uspace/lib/libc/arch/mips32/src/stacktrace_asm.S
r975e7e9 re27cf669 32 32 .set noreorder 33 33 34 .global frame_pointer_get 35 .global frame_pointer_prev 36 .global frame_pointer_validate 37 .global return_address_get 38 .global program_counter_get 34 .global stacktrace_prepare 35 .global stacktrace_fp_get 36 .global stacktrace_pc_get 39 37 40 frame_pointer_get: 41 frame_pointer_prev: 42 frame_pointer_validate: 43 return_address_get: 44 program_counter_get: 38 stacktrace_prepare: 39 stacktrace_fp_get: 40 stacktrace_pc_get: 45 41 j $ra 46 42 xor $v0, $v0 -
uspace/lib/libc/arch/mips32eb/Makefile.inc
r975e7e9 re27cf669 36 36 arch/$(UARCH)/src/fibril.S \ 37 37 arch/$(UARCH)/src/tls.c \ 38 arch/$(UARCH)/src/stacktrace.S 38 arch/$(UARCH)/src/stacktrace.c \ 39 arch/$(UARCH)/src/stacktrace_asm.S 39 40 40 41 GCC_CFLAGS += -mips3 -
uspace/lib/libc/arch/ppc32/Makefile.inc
r975e7e9 re27cf669 36 36 arch/$(UARCH)/src/fibril.S \ 37 37 arch/$(UARCH)/src/tls.c \ 38 arch/$(UARCH)/src/stacktrace.S 38 arch/$(UARCH)/src/stacktrace.c \ 39 arch/$(UARCH)/src/stacktrace_asm.S 39 40 40 41 GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32 -
uspace/lib/libc/arch/ppc32/include/types.h
r975e7e9 re27cf669 36 36 #define LIBC_ppc32_TYPES_H_ 37 37 38 #define __32_BITS__ 39 38 40 typedef unsigned int sysarg_t; 39 41 -
uspace/lib/libc/arch/ppc32/src/stacktrace_asm.S
r975e7e9 re27cf669 31 31 #include <libarch/regname.h> 32 32 33 .global frame_pointer_get 34 .global frame_pointer_prev 35 .global frame_pointer_validate 36 .global return_address_get 37 .global program_counter_get 33 .global stacktrace_prepare 34 .global stacktrace_fp_get 35 .global stacktrace_pc_get 38 36 39 frame_pointer_get: 37 stacktrace_prepare: 38 blr 39 40 stacktrace_fp_get: 40 41 mr r3, sp 41 42 blr 42 43 43 frame_pointer_prev: 44 lwz r3, 0(r3) 45 blr 46 47 frame_pointer_validate: 48 blr 49 50 return_address_get: 51 lwz r3, 4(r3) 52 blr 53 54 program_counter_get: 44 stacktrace_pc_get: 55 45 mflr r3 56 46 blr -
uspace/lib/libc/arch/sparc64/Makefile.inc
r975e7e9 re27cf669 35 35 ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \ 36 36 arch/$(UARCH)/src/tls.c \ 37 arch/$(UARCH)/src/stacktrace.S 37 arch/$(UARCH)/src/stacktrace.c \ 38 arch/$(UARCH)/src/stacktrace_asm.S 38 39 39 40 GCC_CFLAGS += -mcpu=ultrasparc -m64 -
uspace/lib/libc/arch/sparc64/include/fibril.h
r975e7e9 re27cf669 42 42 #define SP_DELTA (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE) 43 43 44 #ifdef context_set45 #undef context_set46 #endif47 48 44 #define context_set(c, _pc, stack, size, ptls) \ 49 45 do { \ -
uspace/lib/libc/arch/sparc64/include/types.h
r975e7e9 re27cf669 36 36 #define LIBC_sparc64_TYPES_H_ 37 37 38 #define __64_BITS__ 39 38 40 typedef unsigned long sysarg_t; 39 41 -
uspace/lib/libc/generic/adt/hash_table.c
r975e7e9 re27cf669 193 193 } 194 194 195 /** Apply fucntion to all items in hash table. 196 * 197 * @param h Hash table. 198 * @param f Function to be applied. 199 * @param arg Argument to be passed to the function. 200 */ 201 void 202 hash_table_apply(hash_table_t *h, void (*f)(link_t *, void *), void *arg) 203 { 204 hash_index_t bucket; 205 link_t *cur; 206 207 for (bucket = 0; bucket < h->entries; bucket++) { 208 for (cur = h->entry[bucket].next; cur != &h->entry[bucket]; 209 cur = cur->next) { 210 f(cur, arg); 211 } 212 } 213 } 214 195 215 /** @} 196 216 */ -
uspace/lib/libc/generic/async.c
r975e7e9 re27cf669 1287 1287 } 1288 1288 1289 /** Wrapper for forwarding any read request 1290 * 1291 * 1292 */ 1293 int async_data_read_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, 1294 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr) 1295 { 1296 ipc_callid_t callid; 1297 if (!async_data_read_receive(&callid, NULL)) { 1298 ipc_answer_0(callid, EINVAL); 1299 return EINVAL; 1300 } 1301 1302 aid_t msg = async_send_fast(phoneid, method, arg1, arg2, arg3, arg4, 1303 dataptr); 1304 if (msg == 0) { 1305 ipc_answer_0(callid, EINVAL); 1306 return EINVAL; 1307 } 1308 1309 int retval = ipc_forward_fast(callid, phoneid, 0, 0, 0, 1310 IPC_FF_ROUTE_FROM_ME); 1311 if (retval != EOK) { 1312 async_wait_for(msg, NULL); 1313 ipc_answer_0(callid, retval); 1314 return retval; 1315 } 1316 1317 ipcarg_t rc; 1318 async_wait_for(msg, &rc); 1319 1320 return (int) rc; 1321 } 1322 1289 1323 /** Wrapper for making IPC_M_DATA_WRITE calls using the async framework. 1290 1324 * 1291 * @param phoneid Phone that will be used to contact the receiving side. 1292 * @param src Address of the beginning of the source buffer. 1293 * @param size Size of the source buffer. 1294 * 1295 * @return Zero on success or a negative error code from errno.h. 1325 * @param phoneid Phone that will be used to contact the receiving side. 1326 * @param src Address of the beginning of the source buffer. 1327 * @param size Size of the source buffer. 1328 * 1329 * @return Zero on success or a negative error code from errno.h. 1330 * 1296 1331 */ 1297 1332 int async_data_write_start(int phoneid, const void *src, size_t size) … … 1308 1343 * So far, this wrapper is to be used from within a connection fibril. 1309 1344 * 1310 * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will 1311 * be stored. 1312 * @param size Storage where the suggested size will be stored. May be 1313 * NULL 1314 * 1315 * @return Non-zero on success, zero on failure. 1345 * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will 1346 * be stored. 1347 * @param size Storage where the suggested size will be stored. May be 1348 * NULL 1349 * 1350 * @return Non-zero on success, zero on failure. 1351 * 1316 1352 */ 1317 1353 int async_data_write_receive(ipc_callid_t *callid, size_t *size) … … 1320 1356 1321 1357 assert(callid); 1322 1358 1323 1359 *callid = async_get_call(&data); 1324 1360 if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE) 1325 1361 return 0; 1362 1326 1363 if (size) 1327 1364 *size = (size_t) IPC_GET_ARG2(data); 1365 1328 1366 return 1; 1329 1367 } … … 1334 1372 * so that the user doesn't have to remember the meaning of each IPC argument. 1335 1373 * 1336 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 1337 * @param dst Final destination address for the IPC_M_DATA_WRITE call. 1338 * @param size Final size for the IPC_M_DATA_WRITE call. 1339 * 1340 * @return Zero on success or a value from @ref errno.h on failure. 1374 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 1375 * @param dst Final destination address for the IPC_M_DATA_WRITE call. 1376 * @param size Final size for the IPC_M_DATA_WRITE call. 1377 * 1378 * @return Zero on success or a value from @ref errno.h on failure. 1379 * 1341 1380 */ 1342 1381 int async_data_write_finalize(ipc_callid_t callid, void *dst, size_t size) … … 1345 1384 } 1346 1385 1347 /** Wrapper for receiving b lobs via the async_data_write_*1386 /** Wrapper for receiving binary data or strings 1348 1387 * 1349 1388 * This wrapper only makes it more comfortable to use async_data_write_* 1350 * functions to receive blobs. 1351 * 1352 * @param blob Pointer to data pointer (which should be later disposed 1353 * by free()). If the operation fails, the pointer is not 1354 * touched. 1355 * @param max_size Maximum size (in bytes) of the blob to receive. 0 means 1356 * no limit. 1357 * @param received If not NULL, the size of the received data is stored here. 1389 * functions to receive binary data or strings. 1390 * 1391 * @param data Pointer to data pointer (which should be later disposed 1392 * by free()). If the operation fails, the pointer is not 1393 * touched. 1394 * @param nullterm If true then the received data is always zero terminated. 1395 * This also causes to allocate one extra byte beyond the 1396 * raw transmitted data. 1397 * @param min_size Minimum size (in bytes) of the data to receive. 1398 * @param max_size Maximum size (in bytes) of the data to receive. 0 means 1399 * no limit. 1400 * @param granulariy If non-zero then the size of the received data has to 1401 * be divisible by this value. 1402 * @param received If not NULL, the size of the received data is stored here. 1358 1403 * 1359 1404 * @return Zero on success or a value from @ref errno.h on failure. 1360 1405 * 1361 1406 */ 1362 int async_data_blob_receive(char **blob, const size_t max_size, size_t *received) 1407 int async_data_write_accept(void **data, const bool nullterm, 1408 const size_t min_size, const size_t max_size, const size_t granularity, 1409 size_t *received) 1363 1410 { 1364 1411 ipc_callid_t callid; … … 1369 1416 } 1370 1417 1418 if (size < min_size) { 1419 ipc_answer_0(callid, EINVAL); 1420 return EINVAL; 1421 } 1422 1371 1423 if ((max_size > 0) && (size > max_size)) { 1372 1424 ipc_answer_0(callid, EINVAL); … … 1374 1426 } 1375 1427 1376 char *data = (char *) malloc(size); 1377 if (data == NULL) { 1428 if ((granularity > 0) && ((size % granularity) != 0)) { 1429 ipc_answer_0(callid, EINVAL); 1430 return EINVAL; 1431 } 1432 1433 void *_data; 1434 1435 if (nullterm) 1436 _data = malloc(size + 1); 1437 else 1438 _data = malloc(size); 1439 1440 if (_data == NULL) { 1378 1441 ipc_answer_0(callid, ENOMEM); 1379 1442 return ENOMEM; 1380 1443 } 1381 1444 1382 int rc = async_data_write_finalize(callid, data, size);1445 int rc = async_data_write_finalize(callid, _data, size); 1383 1446 if (rc != EOK) { 1384 free( data);1447 free(_data); 1385 1448 return rc; 1386 1449 } 1387 1450 1388 *blob = data; 1451 if (nullterm) 1452 ((char *) _data)[size] = 0; 1453 1454 *data = _data; 1389 1455 if (received != NULL) 1390 1456 *received = size; … … 1393 1459 } 1394 1460 1395 /** Wrapper for receiving strings via the async_data_write_* 1396 * 1397 * This wrapper only makes it more comfortable to use async_data_write_* 1398 * functions to receive strings. 1399 * 1400 * @param str Pointer to string pointer (which should be later disposed 1401 * by free()). If the operation fails, the pointer is not 1402 * touched. 1403 * @param max_size Maximum size (in bytes) of the string to receive. 0 means 1404 * no limit. 1405 * 1406 * @return Zero on success or a value from @ref errno.h on failure. 1407 * 1408 */ 1409 int async_data_string_receive(char **str, const size_t max_size) 1461 /** Wrapper for voiding any data that is about to be received 1462 * 1463 * This wrapper can be used to void any pending data 1464 * 1465 * @param retval Error value from @ref errno.h to be returned to the caller. 1466 * 1467 */ 1468 void async_data_write_void(const int retval) 1410 1469 { 1411 1470 ipc_callid_t callid; 1412 size_t size; 1413 if (!async_data_write_receive(&callid, &size)) { 1471 async_data_write_receive(&callid, NULL); 1472 ipc_answer_0(callid, retval); 1473 } 1474 1475 /** Wrapper for forwarding any data that is about to be received 1476 * 1477 * 1478 */ 1479 int async_data_write_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, 1480 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr) 1481 { 1482 ipc_callid_t callid; 1483 if (!async_data_write_receive(&callid, NULL)) { 1414 1484 ipc_answer_0(callid, EINVAL); 1415 1485 return EINVAL; 1416 1486 } 1417 1487 1418 if ((max_size > 0) && (size > max_size)) { 1488 aid_t msg = async_send_fast(phoneid, method, arg1, arg2, arg3, arg4, 1489 dataptr); 1490 if (msg == 0) { 1419 1491 ipc_answer_0(callid, EINVAL); 1420 1492 return EINVAL; 1421 1493 } 1422 1494 1423 char *data = (char *) malloc(size + 1); 1424 if (data == NULL) { 1425 ipc_answer_0(callid, ENOMEM); 1426 return ENOMEM; 1427 } 1428 1429 int rc = async_data_write_finalize(callid, data, size); 1430 if (rc != EOK) { 1431 free(data); 1432 return rc; 1433 } 1434 1435 data[size] = 0; 1436 *str = data; 1437 return EOK; 1495 int retval = ipc_forward_fast(callid, phoneid, 0, 0, 0, 1496 IPC_FF_ROUTE_FROM_ME); 1497 if (retval != EOK) { 1498 async_wait_for(msg, NULL); 1499 ipc_answer_0(callid, retval); 1500 return retval; 1501 } 1502 1503 ipcarg_t rc; 1504 async_wait_for(msg, &rc); 1505 1506 return (int) rc; 1438 1507 } 1439 1508 -
uspace/lib/libc/generic/clipboard.c
r975e7e9 re27cf669 84 84 clip_connect(); 85 85 86 aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_ BLOB, NULL);86 aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA, NULL); 87 87 ipcarg_t rc = async_data_write_start(clip_phone, (void *) str, size); 88 88 if (rc != EOK) { … … 139 139 *str = sbuf; 140 140 return EOK; 141 case CLIPBOARD_TAG_ BLOB:141 case CLIPBOARD_TAG_DATA: 142 142 sbuf = malloc(size + 1); 143 143 if (sbuf == NULL) -
uspace/lib/libc/generic/stacktrace.c
r975e7e9 re27cf669 1 1 /* 2 2 * Copyright (c) 2009 Jakub Jermar 3 * Copyright (c) 2010 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 36 37 #include <stdio.h> 37 38 #include <sys/types.h> 39 #include <errno.h> 38 40 39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc) 41 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); 42 43 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 40 44 { 41 while (frame_pointer_validate(fp)) { 45 stacktrace_t st; 46 uintptr_t nfp; 47 48 st.op_arg = NULL; 49 st.read_uintptr = stacktrace_read_uintptr; 50 51 while (stacktrace_fp_valid(&st, fp)) { 42 52 printf("%p: %p()\n", fp, pc); 43 pc = return_address_get(fp); 44 fp = frame_pointer_prev(fp); 53 (void) stacktrace_ra_get(&st, fp, &pc); 54 (void) stacktrace_fp_prev(&st, fp, &nfp); 55 fp = nfp; 45 56 } 46 57 } 47 58 48 void stack _trace(void)59 void stacktrace_print(void) 49 60 { 50 stack_trace_fp_pc(frame_pointer_get(), program_counter_get()); 61 stacktrace_prepare(); 62 stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get()); 51 63 /* 52 64 * Prevent the tail call optimization of the previous call by 53 65 * making it a non-tail call. 54 66 */ 55 (void) frame_pointer_get(); 67 (void) stacktrace_fp_get(); 68 } 69 70 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data) 71 { 72 (void) arg; 73 *data = *((uintptr_t *) addr); 74 return EOK; 56 75 } 57 76 -
uspace/lib/libc/generic/udebug.c
r975e7e9 re27cf669 69 69 } 70 70 71 int udebug_name_read(int phoneid, void *buffer, size_t n, 72 size_t *copied, size_t *needed) 73 { 74 ipcarg_t a_copied, a_needed; 75 int rc; 76 77 rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_NAME_READ, 78 (sysarg_t)buffer, n, NULL, &a_copied, &a_needed); 79 80 *copied = (size_t)a_copied; 81 *needed = (size_t)a_needed; 82 83 return rc; 84 } 85 86 int udebug_areas_read(int phoneid, void *buffer, size_t n, 87 size_t *copied, size_t *needed) 88 { 89 ipcarg_t a_copied, a_needed; 90 int rc; 91 92 rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_AREAS_READ, 93 (sysarg_t)buffer, n, NULL, &a_copied, &a_needed); 94 95 *copied = (size_t)a_copied; 96 *needed = (size_t)a_needed; 97 98 return rc; 99 } 100 71 101 int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n) 72 102 { … … 78 108 { 79 109 return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ, 110 tid, (sysarg_t)buffer); 111 } 112 113 int udebug_regs_read(int phoneid, thash_t tid, void *buffer) 114 { 115 return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_REGS_READ, 80 116 tid, (sysarg_t)buffer); 81 117 } -
uspace/lib/libc/generic/vfs/vfs.c
r975e7e9 re27cf669 120 120 const char *opts, unsigned int flags) 121 121 { 122 int res; 122 int null_id = -1; 123 char null[DEVMAP_NAME_MAXLEN]; 124 125 if (str_cmp(fqdn, "") == 0) { 126 /* No device specified, create a fresh 127 null/%d device instead */ 128 null_id = devmap_null_create(); 129 130 if (null_id == -1) 131 return ENOMEM; 132 133 snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id); 134 fqdn = null; 135 } 136 137 dev_handle_t dev_handle; 138 int res = devmap_device_get_handle(fqdn, &dev_handle, flags); 139 if (res != EOK) { 140 if (null_id != -1) 141 devmap_null_destroy(null_id); 142 143 return res; 144 } 145 146 size_t mpa_size; 147 char *mpa = absolutize(mp, &mpa_size); 148 if (!mpa) { 149 if (null_id != -1) 150 devmap_null_destroy(null_id); 151 152 return ENOMEM; 153 } 154 155 futex_down(&vfs_phone_futex); 156 async_serialize_start(); 157 vfs_connect(); 158 159 ipcarg_t rc_orig; 160 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL); 161 ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 162 if (rc != EOK) { 163 async_wait_for(req, &rc_orig); 164 async_serialize_end(); 165 futex_up(&vfs_phone_futex); 166 free(mpa); 167 168 if (null_id != -1) 169 devmap_null_destroy(null_id); 170 171 if (rc_orig == EOK) 172 return (int) rc; 173 else 174 return (int) rc_orig; 175 } 176 177 rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts)); 178 if (rc != EOK) { 179 async_wait_for(req, &rc_orig); 180 async_serialize_end(); 181 futex_up(&vfs_phone_futex); 182 free(mpa); 183 184 if (null_id != -1) 185 devmap_null_destroy(null_id); 186 187 if (rc_orig == EOK) 188 return (int) rc; 189 else 190 return (int) rc_orig; 191 } 192 193 rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); 194 if (rc != EOK) { 195 async_wait_for(req, &rc_orig); 196 async_serialize_end(); 197 futex_up(&vfs_phone_futex); 198 free(mpa); 199 200 if (null_id != -1) 201 devmap_null_destroy(null_id); 202 203 if (rc_orig == EOK) 204 return (int) rc; 205 else 206 return (int) rc_orig; 207 } 208 209 /* Ask VFS whether it likes fs_name. */ 210 rc = async_req_0_0(vfs_phone, IPC_M_PING); 211 if (rc != EOK) { 212 async_wait_for(req, &rc_orig); 213 async_serialize_end(); 214 futex_up(&vfs_phone_futex); 215 free(mpa); 216 217 if (null_id != -1) 218 devmap_null_destroy(null_id); 219 220 if (rc_orig == EOK) 221 return (int) rc; 222 else 223 return (int) rc_orig; 224 } 225 226 async_wait_for(req, &rc); 227 async_serialize_end(); 228 futex_up(&vfs_phone_futex); 229 free(mpa); 230 231 if ((rc != EOK) && (null_id != -1)) 232 devmap_null_destroy(null_id); 233 234 return (int) rc; 235 } 236 237 int unmount(const char *mp) 238 { 123 239 ipcarg_t rc; 124 240 ipcarg_t rc_orig; 125 241 aid_t req; 126 dev_handle_t dev_handle;127 128 res = devmap_device_get_handle(fqdn, &dev_handle, flags);129 if (res != EOK)130 return res;131 132 242 size_t mpa_size; 133 char *mpa = absolutize(mp, &mpa_size); 243 char *mpa; 244 245 mpa = absolutize(mp, &mpa_size); 134 246 if (!mpa) 135 247 return ENOMEM; … … 139 251 vfs_connect(); 140 252 141 req = async_send_ 2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL);253 req = async_send_0(vfs_phone, VFS_IN_UNMOUNT, NULL); 142 254 rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 143 255 if (rc != EOK) { … … 152 264 } 153 265 154 rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts)); 155 if (rc != EOK) { 156 async_wait_for(req, &rc_orig); 157 async_serialize_end(); 158 futex_up(&vfs_phone_futex); 159 free(mpa); 160 if (rc_orig == EOK) 161 return (int) rc; 162 else 163 return (int) rc_orig; 164 } 165 166 rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); 167 if (rc != EOK) { 168 async_wait_for(req, &rc_orig); 169 async_serialize_end(); 170 futex_up(&vfs_phone_futex); 171 free(mpa); 172 if (rc_orig == EOK) 173 return (int) rc; 174 else 175 return (int) rc_orig; 176 } 177 178 /* Ask VFS whether it likes fs_name. */ 179 rc = async_req_0_0(vfs_phone, IPC_M_PING); 180 if (rc != EOK) { 181 async_wait_for(req, &rc_orig); 182 async_serialize_end(); 183 futex_up(&vfs_phone_futex); 184 free(mpa); 185 if (rc_orig == EOK) 186 return (int) rc; 187 else 188 return (int) rc_orig; 189 } 190 266 191 267 async_wait_for(req, &rc); 192 268 async_serialize_end(); -
uspace/lib/libc/include/adt/hash_table.h
r975e7e9 re27cf669 88 88 extern void hash_table_remove(hash_table_t *, unsigned long [], hash_count_t); 89 89 extern void hash_table_destroy(hash_table_t *); 90 extern void hash_table_apply(hash_table_t *, void (*)(link_t *, void *), 91 void *); 90 92 91 93 #endif -
uspace/lib/libc/include/async.h
r975e7e9 re27cf669 277 277 extern int async_share_out_receive(ipc_callid_t *, size_t *, int *); 278 278 extern int async_share_out_finalize(ipc_callid_t, void *); 279 280 /* 281 * User-friendly wrappers for async_data_read_forward_fast(). 282 */ 283 #define async_data_read_forward_0_0(phoneid, method, answer) \ 284 async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL) 285 #define async_data_read_forward_0_1(phoneid, method, answer) \ 286 async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer)) 287 #define async_data_read_forward_1_0(phoneid, method, arg1, answer) \ 288 async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL) 289 #define async_data_read_forward_1_1(phoneid, method, arg1, answer) \ 290 async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, (answer)) 291 #define async_data_read_forward_2_0(phoneid, method, arg1, arg2, answer) \ 292 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, NULL) 293 #define async_data_read_forward_2_1(phoneid, method, arg1, arg2, answer) \ 294 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \ 295 (answer)) 296 #define async_data_read_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \ 297 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \ 298 NULL) 299 #define async_data_read_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \ 300 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \ 301 (answer)) 302 #define async_data_read_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \ 303 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \ 304 (arg4), NULL) 305 #define async_data_read_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \ 306 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \ 307 (arg4), (answer)) 308 279 309 extern int async_data_read_start(int, void *, size_t); 280 310 extern int async_data_read_receive(ipc_callid_t *, size_t *); 281 311 extern int async_data_read_finalize(ipc_callid_t, const void *, size_t); 312 313 extern int async_data_read_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, 314 ipcarg_t, ipcarg_t, ipc_call_t *); 315 316 /* 317 * User-friendly wrappers for async_data_write_forward_fast(). 318 */ 319 #define async_data_write_forward_0_0(phoneid, method, answer) \ 320 async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL) 321 #define async_data_write_forward_0_1(phoneid, method, answer) \ 322 async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer)) 323 #define async_data_write_forward_1_0(phoneid, method, arg1, answer) \ 324 async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL) 325 #define async_data_write_forward_1_1(phoneid, method, arg1, answer) \ 326 async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, \ 327 (answer)) 328 #define async_data_write_forward_2_0(phoneid, method, arg1, arg2, answer) \ 329 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \ 330 NULL) 331 #define async_data_write_forward_2_1(phoneid, method, arg1, arg2, answer) \ 332 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \ 333 (answer)) 334 #define async_data_write_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \ 335 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \ 336 0, NULL) 337 #define async_data_write_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \ 338 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \ 339 0, (answer)) 340 #define async_data_write_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \ 341 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \ 342 (arg4), NULL) 343 #define async_data_write_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \ 344 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \ 345 (arg4), (answer)) 346 282 347 extern int async_data_write_start(int, const void *, size_t); 283 348 extern int async_data_write_receive(ipc_callid_t *, size_t *); 284 349 extern int async_data_write_finalize(ipc_callid_t, void *, size_t); 285 350 286 extern int async_data_blob_receive(char **, const size_t, size_t *); 287 extern int async_data_string_receive(char **, const size_t); 351 extern int async_data_write_accept(void **, const bool, const size_t, 352 const size_t, const size_t, size_t *); 353 extern void async_data_write_void(const int); 354 355 extern int async_data_write_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, 356 ipcarg_t, ipcarg_t, ipc_call_t *); 288 357 289 358 #endif -
uspace/lib/libc/include/fibril.h
r975e7e9 re27cf669 40 40 #include <libarch/tls.h> 41 41 42 #ifndef context_set 43 #define context_set(c, _pc, stack, size, ptls) \ 42 #define context_set_generic(c, _pc, stack, size, ptls) \ 44 43 (c)->pc = (sysarg_t) (_pc); \ 45 44 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \ 46 45 (c)->tls = (sysarg_t) (ptls); 47 #endif /* context_set */48 46 49 #define FIBRIL_SERIALIZED 150 #define FIBRIL_WRITER 247 #define FIBRIL_SERIALIZED 1 48 #define FIBRIL_WRITER 2 51 49 52 50 typedef enum { … … 59 57 typedef sysarg_t fid_t; 60 58 61 struct fibril {59 typedef struct fibril { 62 60 link_t link; 63 61 context_t ctx; … … 70 68 int retval; 71 69 int flags; 72 }; 73 typedef struct fibril fibril_t; 70 } fibril_t; 74 71 75 72 /** Fibril-local variable specifier */ 76 73 #define fibril_local __thread 77 74 78 extern int context_save(context_t *c ) __attribute__((returns_twice));79 extern void context_restore(context_t *c ) __attribute__((noreturn));75 extern int context_save(context_t *ctx) __attribute__((returns_twice)); 76 extern void context_restore(context_t *ctx) __attribute__((noreturn)); 80 77 81 78 extern fid_t fibril_create(int (*func)(void *), void *arg); … … 90 87 extern void fibril_dec_sercount(void); 91 88 92 static inline int fibril_yield(void) { 89 static inline int fibril_yield(void) 90 { 93 91 return fibril_switch(FIBRIL_PREEMPT); 94 92 } -
uspace/lib/libc/include/ipc/clipboard.h
r975e7e9 re27cf669 46 46 typedef enum { 47 47 CLIPBOARD_TAG_NONE, 48 CLIPBOARD_TAG_ BLOB48 CLIPBOARD_TAG_DATA 49 49 } clipboard_tag_t; 50 50 -
uspace/lib/libc/include/ipc/vfs.h
r975e7e9 re27cf669 86 86 VFS_OUT_MOUNTED, 87 87 VFS_OUT_UNMOUNT, 88 VFS_OUT_UNMOUNTED, 88 89 VFS_OUT_SYNC, 89 90 VFS_OUT_STAT, … … 100 101 * No lookup flags used. 101 102 */ 102 #define L_NONE 0103 #define L_NONE 0 103 104 104 105 /** … … 107 108 * with L_DIRECTORY. 108 109 */ 109 #define L_FILE 1110 #define L_FILE 1 110 111 111 112 /** 112 * Lookup wil succeed only if the object is a directory. If L_CREATE is113 * Lookup will succeed only if the object is a directory. If L_CREATE is 113 114 * specified, an empty directory will be created. This flag is mutually 114 115 * exclusive with L_FILE. 115 116 */ 116 #define L_DIRECTORY 2 117 #define L_DIRECTORY 2 118 119 /** 120 * Lookup will succeed only if the object is a root directory. The flag is 121 * mutually exclusive with L_FILE and L_MP. 122 */ 123 #define L_ROOT 4 124 125 /** 126 * Lookup will succeed only if the object is a mount point. The flag is mutually 127 * exclusive with L_FILE and L_ROOT. 128 */ 129 #define L_MP 8 130 117 131 118 132 /** … … 120 134 * object already exists. L_EXCLUSIVE is implied when L_DIRECTORY is used. 121 135 */ 122 #define L_EXCLUSIVE 4136 #define L_EXCLUSIVE 16 123 137 124 138 /** 125 139 * L_CREATE is used for creating both regular files and directories. 126 140 */ 127 #define L_CREATE 8141 #define L_CREATE 32 128 142 129 143 /** 130 144 * L_LINK is used for linking to an already existing nodes. 131 145 */ 132 #define L_LINK 16146 #define L_LINK 64 133 147 134 148 /** … … 137 151 * VFS_UNLINK. 138 152 */ 139 #define L_UNLINK 32153 #define L_UNLINK 128 140 154 141 155 /** 142 * L_OPEN is used to indicate that the lookup operation is a part of VFS_ OPEN156 * L_OPEN is used to indicate that the lookup operation is a part of VFS_IN_OPEN 143 157 * call from the client. This means that the server might allocate some 144 158 * resources for the opened file. This flag cannot be passed directly by the 145 159 * client. 146 160 */ 147 #define L_OPEN 64161 #define L_OPEN 256 148 162 149 163 #endif -
uspace/lib/libc/include/stacktrace.h
r975e7e9 re27cf669 1 1 /* 2 2 * Copyright (c) 2009 Jakub Jermar 3 * Copyright (c) 2010 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 39 40 #include <bool.h> 40 41 41 extern void stack_trace(void); 42 extern void stack_trace_fp_pc(uintptr_t, uintptr_t); 42 typedef struct { 43 void *op_arg; 44 int (*read_uintptr)(void *, uintptr_t, uintptr_t *); 45 } stacktrace_t; 46 47 extern void stacktrace_print(void); 48 extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t); 43 49 44 50 /* 45 51 * The following interface is to be implemented by each architecture. 46 52 */ 47 extern bool frame_pointer_validate(uintptr_t); 48 extern uintptr_t frame_pointer_get(void); 49 extern uintptr_t frame_pointer_prev(uintptr_t); 50 extern uintptr_t return_address_get(uintptr_t); 51 extern uintptr_t program_counter_get(); 53 extern bool stacktrace_fp_valid(stacktrace_t *, uintptr_t); 54 extern int stacktrace_fp_prev(stacktrace_t *, uintptr_t, uintptr_t *); 55 extern int stacktrace_ra_get(stacktrace_t *, uintptr_t, uintptr_t *); 56 57 extern void stacktrace_prepare(void); 58 extern uintptr_t stacktrace_fp_get(void); 59 extern uintptr_t stacktrace_pc_get(); 52 60 53 61 #endif -
uspace/lib/libc/include/stdlib.h
r975e7e9 re27cf669 42 42 #define abort() \ 43 43 do { \ 44 stack _trace(); \44 stacktrace_print(); \ 45 45 _exit(1); \ 46 46 } while (0) -
uspace/lib/libc/include/udebug.h
r975e7e9 re27cf669 47 47 int udebug_thread_read(int phoneid, void *buffer, size_t n, 48 48 size_t *copied, size_t *needed); 49 int udebug_name_read(int phoneid, void *buffer, size_t n, 50 size_t *copied, size_t *needed); 51 int udebug_areas_read(int phoneid, void *buffer, size_t n, 52 size_t *copied, size_t *needed); 49 53 int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n); 50 54 int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer); 55 int udebug_regs_read(int phoneid, thash_t tid, void *buffer); 51 56 int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type, 52 57 sysarg_t *val0, sysarg_t *val1); -
uspace/lib/libc/include/vfs/vfs.h
r975e7e9 re27cf669 55 55 extern int mount(const char *, const char *, const char *, const char *, 56 56 unsigned int); 57 extern int unmount(const char *); 57 58 58 59 extern void __stdio_init(int filc, fdi_node_t *filv[]); -
uspace/lib/libfs/libfs.c
r975e7e9 re27cf669 161 161 /* Accept the phone */ 162 162 callid = async_get_call(&call); 163 int mountee_phone = (int) IPC_GET_ARG1(call);163 int mountee_phone = (int) IPC_GET_ARG1(call); 164 164 if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) || 165 165 (mountee_phone < 0)) { … … 172 172 ipc_answer_0(callid, EOK); 173 173 174 res = async_data_write_receive(&callid, NULL);175 if (!res) {176 ipc_hangup(mountee_phone);177 ipc_answer_0(callid, EINVAL);178 ipc_answer_0(rid, EINVAL);179 return;180 }181 182 174 fs_node_t *fn; 183 175 res = ops->node_get(&fn, mp_dev_handle, mp_fs_index); 184 176 if ((res != EOK) || (!fn)) { 185 177 ipc_hangup(mountee_phone); 186 ipc_answer_0(callid,combine_rc(res, ENOENT));178 async_data_write_void(combine_rc(res, ENOENT)); 187 179 ipc_answer_0(rid, combine_rc(res, ENOENT)); 188 180 return; … … 192 184 ipc_hangup(mountee_phone); 193 185 (void) ops->node_put(fn); 194 ipc_answer_0(callid,EBUSY);186 async_data_write_void(EBUSY); 195 187 ipc_answer_0(rid, EBUSY); 196 188 return; … … 201 193 ipc_hangup(mountee_phone); 202 194 (void) ops->node_put(fn); 203 ipc_answer_0(callid,rc);195 async_data_write_void(rc); 204 196 ipc_answer_0(rid, rc); 205 197 return; … … 207 199 208 200 ipc_call_t answer; 209 aid_t msg = async_send_1(mountee_phone, VFS_OUT_MOUNTED, mr_dev_handle, 210 &answer); 211 ipc_forward_fast(callid, mountee_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 212 async_wait_for(msg, &rc); 201 rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED, 202 mr_dev_handle, &answer); 213 203 214 204 if (rc == EOK) { … … 224 214 ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer), 225 215 IPC_GET_ARG3(answer)); 216 } 217 218 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request) 219 { 220 dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 221 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 222 fs_node_t *fn; 223 int res; 224 225 res = ops->node_get(&fn, mp_dev_handle, mp_fs_index); 226 if ((res != EOK) || (!fn)) { 227 ipc_answer_0(rid, combine_rc(res, ENOENT)); 228 return; 229 } 230 231 /* 232 * We are clearly expecting to find the mount point active. 233 */ 234 if (!fn->mp_data.mp_active) { 235 (void) ops->node_put(fn); 236 ipc_answer_0(rid, EINVAL); 237 return; 238 } 239 240 /* 241 * Tell the mounted file system to unmount. 242 */ 243 res = async_req_1_0(fn->mp_data.phone, VFS_OUT_UNMOUNTED, 244 fn->mp_data.dev_handle); 245 246 /* 247 * If everything went well, perform the clean-up on our side. 248 */ 249 if (res == EOK) { 250 ipc_hangup(fn->mp_data.phone); 251 fn->mp_data.mp_active = false; 252 fn->mp_data.fs_handle = 0; 253 fn->mp_data.dev_handle = 0; 254 fn->mp_data.phone = 0; 255 /* Drop the reference created in libfs_mount(). */ 256 (void) ops->node_put(fn); 257 } 258 259 (void) ops->node_put(fn); 260 ipc_answer_0(rid, res); 226 261 } 227 262 … … 304 339 on_error(rc, goto out_with_answer); 305 340 306 if ((tmp) && (tmp->mp_data.mp_active)) { 341 /* 342 * If the matching component is a mount point, there are two 343 * legitimate semantics of the lookup operation. The first is 344 * the commonly used one in which the lookup crosses each mount 345 * point into the mounted file system. The second semantics is 346 * used mostly during unmount() and differs from the first one 347 * only in that the last mount point in the looked up path, 348 * which is also its last component, is not crossed. 349 */ 350 351 if ((tmp) && (tmp->mp_data.mp_active) && 352 (!(lflag & L_MP) || (next <= last))) { 307 353 if (next > last) 308 354 next = last = first; … … 475 521 goto out; 476 522 } 523 524 if ((lflag & L_ROOT) && par) { 525 ipc_answer_0(rid, EINVAL); 526 goto out; 527 } 477 528 478 529 out_with_answer: -
uspace/lib/libfs/libfs.h
r975e7e9 re27cf669 95 95 96 96 extern void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); 97 extern void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *); 97 98 extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); 98 99 extern void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
Note:
See TracChangeset
for help on using the changeset viewer.
