Changeset 99de22b in mainline for uspace/lib


Ignore:
Timestamp:
2010-01-15T18:30:25Z (16 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eeb643d
Parents:
387416b (diff), 563d6077 (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.
Message:

Merged latest trunk changes.

Location:
uspace/lib
Files:
11 added
58 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libblock/Makefile

    r387416b r99de22b  
    3434all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
    3535        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build
     36        $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
    3737
    3838clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(LIBBLOCK)
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBBLOCK)
    4040        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/libblock/Makefile.build

    r387416b r99de22b  
    5353%.o: %.c $(DEPEND)
    5454        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     55ifeq ($(PRECHECK),y)
     56        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     57endif
    5558
    5659$(DEPEND):
  • uspace/lib/libblock/Makefile.common

    r387416b r99de22b  
    3434DEPEND = Makefile.depend
    3535DEPEND_PREV = $(DEPEND).prev
     36JOB = libblock.job
    3637LIBBLOCK = libblock.a
  • uspace/lib/libblock/libblock.c

    r387416b r99de22b  
    8787static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
    8888static int get_block_size(int dev_phone, size_t *bsize);
     89static int get_num_blocks(int dev_phone, bn_t *nblocks);
    8990
    9091static devcon_t *devcon_search(dev_handle_t dev_handle)
     
    714715
    715716        memcpy(devcon->comm_area, data, devcon->pblock_size * cnt);
    716         rc = read_blocks(devcon, ba, cnt);
     717        rc = write_blocks(devcon, ba, cnt);
    717718
    718719        fibril_mutex_unlock(&devcon->comm_area_lock);
     
    736737       
    737738        return get_block_size(devcon->dev_phone, bsize);
     739}
     740
     741/** Get number of blocks on device.
     742 *
     743 * @param dev_handle    Device handle of the block device.
     744 * @param nblocks       Output number of blocks.
     745 *
     746 * @return              EOK on success or negative error code on failure.
     747 */
     748int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)
     749{
     750        devcon_t *devcon;
     751
     752        devcon = devcon_search(dev_handle);
     753        assert(devcon);
     754       
     755        return get_num_blocks(devcon->dev_phone, nblocks);
    738756}
    739757
     
    789807}
    790808
     809/** Get total number of blocks on block device. */
     810static int get_num_blocks(int dev_phone, bn_t *nblocks)
     811{
     812        ipcarg_t nb_l, nb_h;
     813        int rc;
     814
     815        rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h);
     816        if (rc == EOK) {
     817                *nblocks = (bn_t) MERGE_LOUP32(nb_l, nb_h);
     818        }
     819
     820        return rc;
     821}
     822
    791823/** @}
    792824 */
  • uspace/lib/libblock/libblock.h

    r387416b r99de22b  
    6060#define BLOCK_FLAGS_NOREAD      1
    6161
    62 typedef uint64_t bn_t;  /**< Block number type. */
    63 
    6462typedef struct block {
    6563        /** Mutex protecting the reference count. */
     
    110108
    111109extern int block_get_bsize(dev_handle_t, size_t *);
     110extern int block_get_nblocks(dev_handle_t, bn_t *);
    112111extern int block_read_direct(dev_handle_t, bn_t, size_t, void *);
    113112extern int block_write_direct(dev_handle_t, bn_t, size_t, const void *);
  • uspace/lib/libc/Makefile

    r387416b r99de22b  
    3333all: ../../../Makefile.config ../../../config.h ../../../config.defs
    3434        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    35         $(MAKE) -f Makefile.build
     35        $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
    3636
    3737clean:
    38         rm -f $(DEPEND) $(DEPEND_PREV) $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(LIBC) arch/*/_link.ld
     38        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(LIBC) arch/*/_link.ld
    3939        find generic/ arch/*/ -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/libc/Makefile.build

    r387416b r99de22b  
    8787        generic/udebug.c \
    8888        generic/vfs/vfs.c \
    89         generic/vfs/canonify.c
     89        generic/vfs/canonify.c \
     90        generic/stacktrace.c
    9091
    9192ARCH_SOURCES += \
     
    111112%.o: %.S $(DEPEND)
    112113        $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
     114ifeq ($(PRECHECK),y)
     115        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__
     116endif
    113117
    114118%.o: %.s $(DEPEND)
    115119        $(AS) $(AFLAGS) $< -o $@
     120ifeq ($(PRECHECK),y)
     121        $(JOBFILE) $(JOB) $< $@ as asm $(AFLAGS)
     122endif
    116123
    117124%.o: %.c $(DEPEND)
    118125        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     126ifeq ($(PRECHECK),y)
     127        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     128endif
    119129
    120130$(DEPEND): $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH)
  • uspace/lib/libc/Makefile.common

    r387416b r99de22b  
    3333DEPEND = Makefile.depend
    3434DEPEND_PREV = $(DEPEND).prev
     35JOB = libc.job
    3536LIBC = libc.a
    3637INCLUDE_KERNEL = include/kernel
  • uspace/lib/libc/Makefile.toolchain

    r387416b r99de22b  
    7878#
    7979
     80JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
     81
    8082ifeq ($(COMPILER),gcc_cross)
    8183        CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc
  • uspace/lib/libc/arch/amd64/Makefile.inc

    r387416b r99de22b  
    3636ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
    3737        arch/$(UARCH)/src/fibril.S \
    38         arch/$(UARCH)/src/tls.c
     38        arch/$(UARCH)/src/tls.c \
     39        arch/$(UARCH)/src/stacktrace.S
    3940
     41GCC_CFLAGS += -fno-omit-frame-pointer
    4042LFLAGS += -N
    4143
  • uspace/lib/libc/arch/amd64/include/fibril.h

    r387416b r99de22b  
    4444#define SP_DELTA     16
    4545
     46#define context_set(c, _pc, stack, size, ptls) \
     47        do { \
     48                (c)->pc = (sysarg_t) (_pc); \
     49                (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     50                (c)->tls = (sysarg_t) (ptls); \
     51                (c)->rbp = 0; \
     52        } while (0)
     53
    4654/* We include only registers that must be preserved
    4755 * during function call
  • uspace/lib/libc/arch/amd64/src/entry.s

    r387416b r99de22b  
    3838#
    3939__entry:
     40        #
     41        # Create the first stack frame.
     42        #
     43        pushq $0
     44        mov %rsp, %rbp
     45       
    4046        # %rdi was deliberately chosen as the first argument is also in %rdi
    4147        # Pass PCB pointer to __main (no operation)
  • uspace/lib/libc/arch/amd64/src/thread_entry.s

    r387416b r99de22b  
    3636__thread_entry:
    3737        #
     38        # Create the first stack frame.
     39        #
     40        pushq $0
     41        movq %rsp, %rbp
     42
     43        #
    3844        # RAX contains address of uarg
    3945        #
  • uspace/lib/libc/arch/arm32/Makefile.inc

    r387416b r99de22b  
    3737        arch/$(UARCH)/src/fibril.S \
    3838        arch/$(UARCH)/src/tls.c \
    39         arch/$(UARCH)/src/eabi.S
     39        arch/$(UARCH)/src/eabi.S \
     40        arch/$(UARCH)/src/stacktrace.S
    4041
    41 GCC_CFLAGS += -ffixed-r9 -mtp=soft
     42GCC_CFLAGS += -ffixed-r9 -mtp=soft -mapcs-frame -fno-omit-frame-pointer
    4243LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a
    4344
  • uspace/lib/libc/arch/arm32/include/fibril.h

    r387416b r99de22b  
    5858 *  @param ptls  Pointer to the TCB.
    5959 */
    60 #define context_set(c, _pc, stack, size, ptls)                  \
    61         (c)->pc = (sysarg_t) (_pc);                             \
    62         (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA;     \
    63         (c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET;
    64 
     60#define context_set(c, _pc, stack, size, ptls) \
     61        do { \
     62                (c)->pc = (sysarg_t) (_pc); \
     63                (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     64                (c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET; \
     65                (c)->fp = 0; \
     66        } while (0)
    6567
    6668/** Fibril context.
     
    7981        uint32_t r7;
    8082        uint32_t r8;
    81         uint32_t tls;
     83        uint32_t tls;   /* r9 */
    8284        uint32_t r10;
    83         uint32_t r11;
     85        uint32_t fp;    /* r11 */
    8486} context_t;
    8587
  • uspace/lib/libc/arch/arm32/src/entry.s

    r387416b r99de22b  
    4343        str r2, [r0]
    4444
     45        #
     46        # Create the first stack frame.
     47        #
     48        mov fp, #0
     49        mov ip, sp
     50        push {fp, ip, lr, pc}
     51        sub fp, ip, #4
     52
    4553        # Pass pcb_ptr to __main as the first argument (in r0)
    4654        mov r0, r1
  • uspace/lib/libc/arch/arm32/src/thread_entry.s

    r387416b r99de22b  
    3535#
    3636__thread_entry:
     37        #
     38        # Create the first stack frame.
     39        #
     40        mov fp, #0
     41        mov ip, sp
     42        push {fp, ip, lr, pc}
     43        sub fp, ip, #4
     44
    3745        b __thread_main
  • uspace/lib/libc/arch/ia32/Makefile.inc

    r387416b r99de22b  
    3737        arch/$(UARCH)/src/fibril.S \
    3838        arch/$(UARCH)/src/tls.c \
    39         arch/$(UARCH)/src/setjmp.S
     39        arch/$(UARCH)/src/setjmp.S \
     40        arch/$(UARCH)/src/stacktrace.S
    4041
    4142GCC_CFLAGS += -march=pentium
  • uspace/lib/libc/arch/ia32/include/fibril.h

    r387416b r99de22b  
    4444#define SP_DELTA     (12)
    4545
     46#define context_set(c, _pc, stack, size, ptls) \
     47        do { \
     48                (c)->pc = (sysarg_t) (_pc); \
     49                (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     50                (c)->tls = (sysarg_t) (ptls); \
     51                (c)->ebp = 0; \
     52        } while (0)
     53       
    4654/* We include only registers that must be preserved
    4755 * during function call
  • uspace/lib/libc/arch/ia32/src/entry.s

    r387416b r99de22b  
    5555        movl $__syscall_fast, (%eax)
    56560:
     57        #
     58        # Create the first stack frame.
     59        #
     60        pushl $0
     61        movl %esp, %ebp
    5762
    5863        # Pass the PCB pointer to __main as the first argument
  • uspace/lib/libc/arch/ia32/src/thread_entry.s

    r387416b r99de22b  
    4242
    4343        #
     44        # Create the first stack frame.
     45        #
     46        pushl $0
     47        mov %esp, %ebp
     48
     49        #
    4450        # EAX contains address of uarg.
    4551        #
  • uspace/lib/libc/arch/ia64/Makefile.inc

    r387416b r99de22b  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/ddi.c
     38        arch/$(UARCH)/src/ddi.c \
     39        arch/$(UARCH)/src/stacktrace.S
    3940
    4041GCC_CFLAGS += -fno-unwind-tables
  • uspace/lib/libc/arch/mips32/Makefile.inc

    r387416b r99de22b  
    3535ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
    3636        arch/$(UARCH)/src/fibril.S \
    37         arch/$(UARCH)/src/tls.c
     37        arch/$(UARCH)/src/tls.c \
     38        arch/$(UARCH)/src/stacktrace.S
    3839
    3940GCC_CFLAGS += -mips3
  • uspace/lib/libc/arch/mips32eb/Makefile.inc

    r387416b r99de22b  
    3535ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
    3636        arch/$(UARCH)/src/fibril.S \
    37         arch/$(UARCH)/src/tls.c
     37        arch/$(UARCH)/src/tls.c \
     38        arch/$(UARCH)/src/stacktrace.S
    3839
    3940GCC_CFLAGS += -mips3
  • uspace/lib/libc/arch/ppc32/Makefile.inc

    r387416b r99de22b  
    3535ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
    3636        arch/$(UARCH)/src/fibril.S \
    37         arch/$(UARCH)/src/tls.c
     37        arch/$(UARCH)/src/tls.c \
     38        arch/$(UARCH)/src/stacktrace.S
    3839
    3940GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
  • uspace/lib/libc/arch/ppc32/src/entry.s

    r387416b r99de22b  
    3838#
    3939__entry:
     40        #
     41        # Create the first stack frame.
     42        #
     43        li %r3, 0
     44        stw %r3, 0(%r1)
     45        stwu %r1, -16(%r1)
     46
    4047        # Pass the PCB pointer to __main() as the first argument.
    4148        # The first argument is passed in r3.
  • uspace/lib/libc/arch/ppc32/src/thread_entry.s

    r387416b r99de22b  
    3535#
    3636__thread_entry:
     37        #
     38        # Create the first stack frame.
     39        #
     40        li %r4, 0
     41        stw %r4, 0(%r1)
     42        stwu %r1, -16(%r1)
     43
    3744        b __thread_main
    3845
  • uspace/lib/libc/arch/sparc64/Makefile.inc

    r387416b r99de22b  
    3434
    3535ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \
    36         arch/$(UARCH)/src/tls.c
     36        arch/$(UARCH)/src/tls.c \
     37        arch/$(UARCH)/src/stacktrace.S
    3738
    3839GCC_CFLAGS += -mcpu=ultrasparc -m64
  • uspace/lib/libc/arch/sparc64/include/fibril.h

    r387416b r99de22b  
    4646#endif
    4747
    48 #define context_set(c, _pc, stack, size, ptls)                  \
    49         (c)->pc = ((uintptr_t) _pc) - 8;                        \
    50         (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size),        \
    51                 STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);     \
    52         (c)->fp = -STACK_BIAS;                                  \
    53         (c)->tp = ptls
     48#define context_set(c, _pc, stack, size, ptls) \
     49        do { \
     50                (c)->pc = ((uintptr_t) _pc) - 8; \
     51                (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), \
     52                    STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
     53                (c)->fp = -STACK_BIAS; \
     54                (c)->tp = ptls; \
     55        } while (0)
    5456       
    5557/*
  • uspace/lib/libc/arch/sparc64/src/entry.s

    r387416b r99de22b  
    3939#
    4040__entry:
     41        #
     42        # Create the first stack frame.
     43        #
     44        save %sp, -176, %sp
     45        flushw
     46        add %g0, -0x7ff, %fp
     47
    4148        # Pass pcb_ptr as the first argument to __main()
    42         mov %o1, %o0
     49        mov %i1, %o0
    4350        sethi %hi(_gp), %l7
    4451        call __main
  • uspace/lib/libc/arch/sparc64/src/fibril.S

    r387416b r99de22b  
    3535
    3636context_save:
     37        #
     38        # We rely on the kernel to flush our active register windows to memory
     39        # should a thread switch occur.
     40        #
    3741        CONTEXT_SAVE_ARCH_CORE %o0
    3842        retl
     
    4246        #
    4347        # Flush all active windows.
    44         # This is essential, because CONTEXT_LOAD overwrites
    45         # %sp of CWP - 1 with the value written to %fp of CWP.
    46         # Flushing all active windows mitigates this problem
    47         # as CWP - 1 becomes the overlap window.
    48         #               
     48        # This is essential, because CONTEXT_RESTORE_ARCH_CORE overwrites %sp of
     49        # CWP - 1 with the value written to %fp of CWP.  Flushing all active
     50        # windows mitigates this problem as CWP - 1 becomes the overlap window.
     51        #
    4952        flushw
    5053       
  • uspace/lib/libc/arch/sparc64/src/thread_entry.s

    r387416b r99de22b  
    3535#
    3636__thread_entry:
     37        #
     38        # Create the first stack frame.
     39        #
     40        save %sp, -176, %sp
     41        flushw
     42        add %g0, -0x7ff, %fp
     43
    3744        sethi %hi(_gp), %l7
    3845        call __thread_main              ! %o0 contains address of uarg
  • uspace/lib/libc/generic/async.c

    r387416b r99de22b  
    13451345}
    13461346
     1347/** Wrapper for receiving blobs via the async_data_write_*
     1348 *
     1349 * 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.
     1358 *
     1359 * @return Zero on success or a value from @ref errno.h on failure.
     1360 *
     1361 */
     1362int async_data_blob_receive(char **blob, const size_t max_size, size_t *received)
     1363{
     1364        ipc_callid_t callid;
     1365        size_t size;
     1366        if (!async_data_write_receive(&callid, &size)) {
     1367                ipc_answer_0(callid, EINVAL);
     1368                return EINVAL;
     1369        }
     1370       
     1371        if ((max_size > 0) && (size > max_size)) {
     1372                ipc_answer_0(callid, EINVAL);
     1373                return EINVAL;
     1374        }
     1375       
     1376        char *data = (char *) malloc(size);
     1377        if (data == NULL) {
     1378                ipc_answer_0(callid, ENOMEM);
     1379                return ENOMEM;
     1380        }
     1381       
     1382        int rc = async_data_write_finalize(callid, data, size);
     1383        if (rc != EOK) {
     1384                free(data);
     1385                return rc;
     1386        }
     1387       
     1388        *blob = data;
     1389        if (received != NULL)
     1390                *received = size;
     1391       
     1392        return EOK;
     1393}
     1394
     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 */
     1409int async_data_string_receive(char **str, const size_t max_size)
     1410{
     1411        ipc_callid_t callid;
     1412        size_t size;
     1413        if (!async_data_write_receive(&callid, &size)) {
     1414                ipc_answer_0(callid, EINVAL);
     1415                return EINVAL;
     1416        }
     1417       
     1418        if ((max_size > 0) && (size > max_size)) {
     1419                ipc_answer_0(callid, EINVAL);
     1420                return EINVAL;
     1421        }
     1422       
     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;
     1438}
     1439
    13471440/** @}
    13481441 */
  • uspace/lib/libc/generic/devmap.c

    r387416b r99de22b  
    3535#include <async.h>
    3636#include <errno.h>
     37#include <malloc.h>
     38#include <bool.h>
    3739
    3840static int devmap_phone_driver = -1;
     
    105107        aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
    106108       
    107         ipcarg_t retval = async_data_write_start(phone, name, str_size(name) + 1);
    108        
     109        ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
    109110        if (retval != EOK) {
    110111                async_wait_for(req, NULL);
     
    126127/** Register new device.
    127128 *
    128  * @param name   Device name.
    129  * @param handle Output: Handle to the created instance of device.
     129 * @param namespace Namespace name.
     130 * @param fqdn      Fully qualified device name.
     131 * @param handle    Output: Handle to the created instance of device.
    130132 *
    131133 */
    132 int devmap_device_register(const char *name, dev_handle_t *handle)
     134int devmap_device_register(const char *fqdn, dev_handle_t *handle)
    133135{
    134136        int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
     
    143145            &answer);
    144146       
    145         ipcarg_t retval = async_data_write_start(phone, name, str_size(name) + 1);
    146        
     147        ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
    147148        if (retval != EOK) {
    148149                async_wait_for(req, NULL);
     
    167168}
    168169
    169 int devmap_device_get_handle(const char *name, dev_handle_t *handle, unsigned int flags)
     170int devmap_device_get_handle(const char *fqdn, dev_handle_t *handle, unsigned int flags)
    170171{
    171172        int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
     
    180181            &answer);
    181182       
    182         ipcarg_t retval = async_data_write_start(phone, name, str_size(name) + 1);
    183        
     183        ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
    184184        if (retval != EOK) {
    185185                async_wait_for(req, NULL);
     
    202202       
    203203        return retval;
     204}
     205
     206int devmap_namespace_get_handle(const char *name, dev_handle_t *handle, unsigned int flags)
     207{
     208        int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
     209       
     210        if (phone < 0)
     211                return phone;
     212       
     213        async_serialize_start();
     214       
     215        ipc_call_t answer;
     216        aid_t req = async_send_2(phone, DEVMAP_NAMESPACE_GET_HANDLE, flags, 0,
     217            &answer);
     218       
     219        ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
     220        if (retval != EOK) {
     221                async_wait_for(req, NULL);
     222                async_serialize_end();
     223                return retval;
     224        }
     225       
     226        async_wait_for(req, &retval);
     227       
     228        async_serialize_end();
     229       
     230        if (retval != EOK) {
     231                if (handle != NULL)
     232                        *handle = (dev_handle_t) -1;
     233                return retval;
     234        }
     235       
     236        if (handle != NULL)
     237                *handle = (dev_handle_t) IPC_GET_ARG1(answer);
     238       
     239        return retval;
     240}
     241
     242devmap_handle_type_t devmap_handle_probe(dev_handle_t handle)
     243{
     244        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     245       
     246        if (phone < 0)
     247                return phone;
     248       
     249        ipcarg_t type;
     250        int retval = async_req_1_1(phone, DEVMAP_HANDLE_PROBE, handle, &type);
     251        if (retval != EOK)
     252                return DEV_HANDLE_NONE;
     253       
     254        return (devmap_handle_type_t) type;
    204255}
    205256
     
    227278       
    228279        ipcarg_t null_id;
    229         int retval = async_req_0_1(phone, DEVMAP_DEVICE_NULL_CREATE, &null_id);
     280        int retval = async_req_0_1(phone, DEVMAP_NULL_CREATE, &null_id);
    230281        if (retval != EOK)
    231282                return -1;
     
    241292                return;
    242293       
    243         async_req_1_0(phone, DEVMAP_DEVICE_NULL_DESTROY, (ipcarg_t) null_id);
    244 }
    245 
    246 ipcarg_t devmap_device_get_count(void)
    247 {
    248         int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
    249        
    250         if (phone < 0)
    251                 return 0;
    252        
     294        async_req_1_0(phone, DEVMAP_NULL_DESTROY, (ipcarg_t) null_id);
     295}
     296
     297static size_t devmap_count_namespaces_internal(int phone)
     298{
    253299        ipcarg_t count;
    254         int retval = async_req_0_1(phone, DEVMAP_DEVICE_GET_COUNT, &count);
     300        int retval = async_req_0_1(phone, DEVMAP_GET_NAMESPACE_COUNT, &count);
    255301        if (retval != EOK)
    256302                return 0;
     
    259305}
    260306
    261 ipcarg_t devmap_device_get_devices(ipcarg_t count, dev_desc_t *data)
    262 {
    263         int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
    264        
    265         if (phone < 0)
    266                 return 0;
    267        
    268         async_serialize_start();
    269        
    270         ipc_call_t answer;
    271         aid_t req = async_send_0(phone, DEVMAP_DEVICE_GET_DEVICES, &answer);
    272        
    273         ipcarg_t retval = async_data_read_start(phone, data, count * sizeof(dev_desc_t));
    274        
    275         if (retval != EOK) {
    276                 async_wait_for(req, NULL);
    277                 async_serialize_end();
    278                 return 0;
    279         }
    280        
    281         async_wait_for(req, &retval);
    282        
    283         async_serialize_end();
    284        
     307static size_t devmap_count_devices_internal(int phone, dev_handle_t ns_handle)
     308{
     309        ipcarg_t count;
     310        int retval = async_req_1_1(phone, DEVMAP_GET_DEVICE_COUNT, ns_handle, &count);
    285311        if (retval != EOK)
    286312                return 0;
    287313       
    288         return IPC_GET_ARG1(answer);
    289 }
     314        return count;
     315}
     316
     317size_t devmap_count_namespaces(void)
     318{
     319        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     320       
     321        if (phone < 0)
     322                return 0;
     323       
     324        return devmap_count_namespaces_internal(phone);
     325}
     326
     327size_t devmap_count_devices(dev_handle_t ns_handle)
     328{
     329        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     330       
     331        if (phone < 0)
     332                return 0;
     333       
     334        return devmap_count_devices_internal(phone, ns_handle);
     335}
     336
     337size_t devmap_get_namespaces(dev_desc_t **data)
     338{
     339        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     340       
     341        if (phone < 0)
     342                return 0;
     343       
     344        /* Loop until namespaces read succesful */
     345        while (true) {
     346                size_t count = devmap_count_namespaces_internal(phone);
     347                if (count == 0)
     348                        return 0;
     349               
     350                dev_desc_t *devs = (dev_desc_t *) calloc(count, sizeof(dev_desc_t));
     351                if (devs == NULL)
     352                        return 0;
     353               
     354                async_serialize_start();
     355               
     356                ipc_call_t answer;
     357                aid_t req = async_send_0(phone, DEVMAP_GET_NAMESPACES, &answer);
     358               
     359                int rc = async_data_read_start(phone, devs, count * sizeof(dev_desc_t));
     360                if (rc == EOVERFLOW) {
     361                        /*
     362                         * Number of namespaces has changed since
     363                         * the last call of DEVMAP_DEVICE_GET_NAMESPACE_COUNT
     364                         */
     365                        async_serialize_end();
     366                        free(devs);
     367                        continue;
     368                }
     369               
     370                if (rc != EOK) {
     371                        async_wait_for(req, NULL);
     372                        async_serialize_end();
     373                        free(devs);
     374                        return 0;
     375                }
     376               
     377                ipcarg_t retval;
     378                async_wait_for(req, &retval);
     379                async_serialize_end();
     380               
     381                if (retval != EOK)
     382                        return 0;
     383               
     384                *data = devs;
     385                return count;
     386        }
     387}
     388
     389size_t devmap_get_devices(dev_handle_t ns_handle, dev_desc_t **data)
     390{
     391        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     392       
     393        if (phone < 0)
     394                return 0;
     395       
     396        /* Loop until namespaces read succesful */
     397        while (true) {
     398                size_t count = devmap_count_devices_internal(phone, ns_handle);
     399                if (count == 0)
     400                        return 0;
     401               
     402                dev_desc_t *devs = (dev_desc_t *) calloc(count, sizeof(dev_desc_t));
     403                if (devs == NULL)
     404                        return 0;
     405               
     406                async_serialize_start();
     407               
     408                ipc_call_t answer;
     409                aid_t req = async_send_1(phone, DEVMAP_GET_DEVICES, ns_handle, &answer);
     410               
     411                int rc = async_data_read_start(phone, devs, count * sizeof(dev_desc_t));
     412                if (rc == EOVERFLOW) {
     413                        /*
     414                         * Number of devices has changed since
     415                         * the last call of DEVMAP_DEVICE_GET_DEVICE_COUNT
     416                         */
     417                        async_serialize_end();
     418                        free(devs);
     419                        continue;
     420                }
     421               
     422                if (rc != EOK) {
     423                        async_wait_for(req, NULL);
     424                        async_serialize_end();
     425                        free(devs);
     426                        return 0;
     427                }
     428               
     429                ipcarg_t retval;
     430                async_wait_for(req, &retval);
     431                async_serialize_end();
     432               
     433                if (retval != EOK)
     434                        return 0;
     435               
     436                *data = devs;
     437                return count;
     438        }
     439}
  • uspace/lib/libc/generic/io/io.c

    r387416b r99de22b  
    554554}
    555555
     556int ftell(FILE *stream)
     557{
     558        off_t rc = lseek(stream->fd, 0, SEEK_CUR);
     559        if (rc == (off_t) (-1)) {
     560                /* errno has been set by lseek. */
     561                return -1;
     562        }
     563
     564        return rc;
     565}
     566
    556567void rewind(FILE *stream)
    557568{
     
    584595}
    585596
     597void clearerr(FILE *stream)
     598{
     599        stream->eof = false;
     600        stream->error = false;
     601}
     602
    586603int fphone(FILE *stream)
    587604{
  • uspace/lib/libc/generic/string.c

    r387416b r99de22b  
    896896}
    897897
     898char *str_dup(const char *src)
     899{
     900        size_t size = str_size(src);
     901        void *dest = malloc(size + 1);
     902       
     903        if (dest == NULL)
     904                return (char *) NULL;
     905       
     906        return (char *) memcpy(dest, src, size + 1);
     907}
     908
     909char *str_ndup(const char *src, size_t max_size)
     910{
     911        size_t size = str_size(src);
     912        if (size > max_size)
     913                size = max_size;
     914       
     915        char *dest = (char *) malloc(size + 1);
     916       
     917        if (dest == NULL)
     918                return (char *) NULL;
     919       
     920        memcpy(dest, src, size);
     921        dest[size] = 0;
     922        return dest;
     923}
     924
    898925
    899926/** Convert initial part of string to unsigned long according to given base.
     
    920947}
    921948
    922 char *str_dup(const char *src)
    923 {
    924         size_t size = str_size(src);
    925         void *dest = malloc(size + 1);
    926 
    927         if (dest == NULL)
    928                 return (char *) NULL;
    929 
    930         return (char *) memcpy(dest, src, size + 1);
    931 }
    932 
    933949char *strtok(char *s, const char *delim)
    934950{
  • uspace/lib/libc/generic/vfs/vfs.c

    r387416b r99de22b  
    117117}
    118118
    119 int mount(const char *fs_name, const char *mp, const char *dev,
     119int mount(const char *fs_name, const char *mp, const char *fqdn,
    120120    const char *opts, unsigned int flags)
    121121{
     
    126126        dev_handle_t dev_handle;
    127127       
    128         res = devmap_device_get_handle(dev, &dev_handle, flags);
     128        res = devmap_device_get_handle(fqdn, &dev_handle, flags);
    129129        if (res != EOK)
    130130                return res;
     
    703703        rc = fstat(fildes, &stat);
    704704
    705         if (!stat.devfs_stat.device)
     705        if (!stat.device)
    706706                return -1;
    707707       
    708         return devmap_device_connect(stat.devfs_stat.device, 0);
     708        return devmap_device_connect(stat.device, 0);
    709709}
    710710
  • uspace/lib/libc/include/assert.h

    r387416b r99de22b  
    5151
    5252#ifndef NDEBUG
    53 #       define assert(expr) if (!(expr)) { printf("Assertion failed (%s) at file '%s', line %d.\n", #expr, __FILE__, __LINE__); abort();}
     53#       define assert(expr) \
     54                do { \
     55                        if (!(expr)) { \
     56                                printf("Assertion failed (%s) at file '%s', " \
     57                                    "line %d.\n", #expr, __FILE__, __LINE__); \
     58                                abort(); \
     59                        } \
     60                } while (0)
    5461#else
    5562#       define assert(expr)
  • uspace/lib/libc/include/async.h

    r387416b r99de22b  
    284284extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
    285285
     286extern int async_data_blob_receive(char **, const size_t, size_t *);
     287extern int async_data_string_receive(char **, const size_t);
     288
    286289#endif
    287290
  • uspace/lib/libc/include/devmap.h

    r387416b r99de22b  
    3838#include <ipc/devmap.h>
    3939#include <async.h>
     40#include <bool.h>
    4041
    4142extern int devmap_get_phone(devmap_interface_t, unsigned int);
     
    4647
    4748extern int devmap_device_get_handle(const char *, dev_handle_t *, unsigned int);
     49extern int devmap_namespace_get_handle(const char *, dev_handle_t *, unsigned int);
     50extern devmap_handle_type_t devmap_handle_probe(dev_handle_t);
     51
    4852extern int devmap_device_connect(dev_handle_t, unsigned int);
    4953
     
    5155extern void devmap_null_destroy(int);
    5256
    53 extern ipcarg_t devmap_device_get_count(void);
    54 extern ipcarg_t devmap_device_get_devices(ipcarg_t, dev_desc_t *);
     57extern size_t devmap_count_namespaces(void);
     58extern size_t devmap_count_devices(dev_handle_t);
     59
     60extern size_t devmap_get_namespaces(dev_desc_t **);
     61extern size_t devmap_get_devices(dev_handle_t, dev_desc_t **);
    5562
    5663#endif
  • uspace/lib/libc/include/ipc/bd.h

    r387416b r99de22b  
    4040typedef enum {
    4141        BD_GET_BLOCK_SIZE = IPC_FIRST_USER_METHOD,
     42        BD_GET_NUM_BLOCKS,
    4243        BD_READ_BLOCKS,
    4344        BD_WRITE_BLOCKS
  • uspace/lib/libc/include/ipc/devmap.h

    r387416b r99de22b  
    4343
    4444typedef enum {
     45        DEV_HANDLE_NONE,
     46        DEV_HANDLE_NAMESPACE,
     47        DEV_HANDLE_DEVICE
     48} devmap_handle_type_t;
     49
     50typedef enum {
    4551        DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
    4652        DEVMAP_DRIVER_UNREGISTER,
    4753        DEVMAP_DEVICE_REGISTER,
    4854        DEVMAP_DEVICE_UNREGISTER,
    49         DEVMAP_DEVICE_GET_NAME,
    5055        DEVMAP_DEVICE_GET_HANDLE,
    51         DEVMAP_DEVICE_NULL_CREATE,
    52         DEVMAP_DEVICE_NULL_DESTROY,
    53         DEVMAP_DEVICE_GET_COUNT,
    54         DEVMAP_DEVICE_GET_DEVICES
     56        DEVMAP_NAMESPACE_GET_HANDLE,
     57        DEVMAP_HANDLE_PROBE,
     58        DEVMAP_NULL_CREATE,
     59        DEVMAP_NULL_DESTROY,
     60        DEVMAP_GET_NAMESPACE_COUNT,
     61        DEVMAP_GET_DEVICE_COUNT,
     62        DEVMAP_GET_NAMESPACES,
     63        DEVMAP_GET_DEVICES
    5564} devmap_request_t;
    5665
  • uspace/lib/libc/include/ipc/services.h

    r387416b r99de22b  
    4141        SERVICE_LOAD = 1,
    4242        SERVICE_PCI,
    43         SERVICE_KEYBOARD,
    4443        SERVICE_VIDEO,
    4544        SERVICE_CONSOLE,
  • uspace/lib/libc/include/stdlib.h

    r387416b r99de22b  
    3838#include <unistd.h>
    3939#include <malloc.h>
     40#include <stacktrace.h>
    4041
    41 #define abort()       _exit(1)
     42#define abort() \
     43        do { \
     44                stack_trace(); \
     45                _exit(1); \
     46        } while (0)
     47
    4248#define exit(status)  _exit((status))
    4349
  • uspace/lib/libc/include/string.h

    r387416b r99de22b  
    8484
    8585extern char *str_dup(const char *);
     86extern char *str_ndup(const char *, size_t max_size);
    8687
    8788/*
  • uspace/lib/libc/include/sys/stat.h

    r387416b r99de22b  
    4242
    4343struct stat {
    44         fs_handle_t     fs_handle;
    45         dev_handle_t    dev_handle;
    46         fs_index_t      index;
    47         unsigned        lnkcnt;
    48         bool            is_file;
    49         off_t           size;
    50         union {
    51                 struct {
    52                         dev_handle_t    device;
    53                 } devfs_stat;
    54         };
     44        fs_handle_t fs_handle;
     45        dev_handle_t dev_handle;
     46        fs_index_t index;
     47        unsigned int lnkcnt;
     48        bool is_file;
     49        bool is_directory;
     50        off_t size;
     51        dev_handle_t device;
    5552};
    5653
  • uspace/lib/libc/include/sys/types.h

    r387416b r99de22b  
    4040typedef long off_t;
    4141typedef int mode_t;
     42typedef uint64_t bn_t;  /**< Block number type. */
    4243
    4344typedef int32_t wchar_t;
  • uspace/lib/libfs/Makefile

    r387416b r99de22b  
    3434all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
    3535        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build
     36        $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
    3737
    3838clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(LIBFS)
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBFS)
    4040        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/libfs/Makefile.build

    r387416b r99de22b  
    5353%.o: %.c $(DEPEND)
    5454        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     55ifeq ($(PRECHECK),y)
     56        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     57endif
    5558
    5659$(DEPEND):
  • uspace/lib/libfs/Makefile.common

    r387416b r99de22b  
    3434DEPEND = Makefile.depend
    3535DEPEND_PREV = $(DEPEND).prev
     36JOB = libfs.job
    3637LIBFS = libfs.a
  • uspace/lib/libfs/libfs.c

    r387416b r99de22b  
    11/*
    2  * Copyright (c) 2009 Jakub Jermar 
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libfs 
     29/** @addtogroup libfs
    3030 * @{
    31  */ 
     31 */
    3232/**
    3333 * @file
    34  * Glue code which is commonod to all FS implementations.
    35  */
    36 
    37 #include "libfs.h" 
     34 * Glue code which is common to all FS implementations.
     35 */
     36
     37#include "libfs.h"
    3838#include "../../srv/vfs/vfs.h"
    3939#include <errno.h>
     
    6767 * code.
    6868 *
    69  * @param vfs_phone     Open phone for communication with VFS.
    70  * @param reg           File system registration structure. It will be
    71  *                      initialized by this function.
    72  * @param info          VFS info structure supplied by the file system
    73  *                      implementation.
    74  * @param conn          Connection fibril for handling all calls originating in
    75  *                      VFS.
    76  *
    77  * @return              EOK on success or a non-zero error code on errror.
     69 * @param vfs_phone Open phone for communication with VFS.
     70 * @param reg       File system registration structure. It will be
     71 *                  initialized by this function.
     72 * @param info      VFS info structure supplied by the file system
     73 *                  implementation.
     74 * @param conn      Connection fibril for handling all calls originating in
     75 *                  VFS.
     76 *
     77 * @return EOK on success or a non-zero error code on errror.
     78 *
    7879 */
    7980int fs_register(int vfs_phone, fs_reg_t *reg, vfs_info_t *info,
     
    8788        ipc_call_t answer;
    8889        aid_t req = async_send_0(vfs_phone, VFS_IN_REGISTER, &answer);
    89 
     90       
    9091        /*
    9192         * Send our VFS info structure to VFS.
     
    9697                return rc;
    9798        }
    98 
     99       
    99100        /*
    100101         * Ask VFS for callback connection.
    101102         */
    102103        ipc_connect_to_me(vfs_phone, 0, 0, 0, &reg->vfs_phonehash);
    103 
     104       
    104105        /*
    105106         * Allocate piece of address space for PLB.
     
    110111                return ENOMEM;
    111112        }
    112 
     113       
    113114        /*
    114115         * Request sharing the Path Lookup Buffer with VFS.
     
    136137         */
    137138        async_set_client_connection(conn);
    138 
     139       
    139140        return IPC_GET_RETVAL(answer);
    140141}
     
    154155        int res;
    155156        ipcarg_t rc;
    156 
     157       
    157158        ipc_call_t call;
    158159        ipc_callid_t callid;
    159 
    160         /* accept the phone */
     160       
     161        /* Accept the phone */
    161162        callid = async_get_call(&call);
    162163        int mountee_phone = (int)IPC_GET_ARG1(call);
    163164        if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) ||
    164             mountee_phone < 0) {
     165            (mountee_phone < 0)) {
    165166                ipc_answer_0(callid, EINVAL);
    166167                ipc_answer_0(rid, EINVAL);
    167168                return;
    168169        }
    169         ipc_answer_0(callid, EOK);      /* acknowledge the mountee_phone */
     170       
     171        /* Acknowledge the mountee_phone */
     172        ipc_answer_0(callid, EOK);
    170173       
    171174        res = async_data_write_receive(&callid, NULL);
     
    176179                return;
    177180        }
    178 
     181       
    179182        fs_node_t *fn;
    180183        res = ops->node_get(&fn, mp_dev_handle, mp_fs_index);
    181         if (res != EOK || !fn) {
     184        if ((res != EOK) || (!fn)) {
    182185                ipc_hangup(mountee_phone);
    183186                ipc_answer_0(callid, combine_rc(res, ENOENT));
     
    185188                return;
    186189        }
    187 
     190       
    188191        if (fn->mp_data.mp_active) {
    189192                ipc_hangup(mountee_phone);
     
    193196                return;
    194197        }
    195 
     198       
    196199        rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME);
    197200        if (rc != EOK) {
     
    215218                fn->mp_data.phone = mountee_phone;
    216219        }
     220       
    217221        /*
    218222         * Do not release the FS node so that it stays in memory.
     
    238242    ipc_call_t *request)
    239243{
    240         unsigned first = IPC_GET_ARG1(*request);
    241         unsigned last = IPC_GET_ARG2(*request);
    242         unsigned next = first;
     244        unsigned int first = IPC_GET_ARG1(*request);
     245        unsigned int last = IPC_GET_ARG2(*request);
     246        unsigned int next = first;
    243247        dev_handle_t dev_handle = IPC_GET_ARG3(*request);
    244248        int lflag = IPC_GET_ARG4(*request);
    245         fs_index_t index = IPC_GET_ARG5(*request); /* when L_LINK specified */
     249        fs_index_t index = IPC_GET_ARG5(*request);
    246250        char component[NAME_MAX + 1];
    247251        int len;
    248252        int rc;
    249 
     253       
    250254        if (last < next)
    251255                last += PLB_SIZE;
    252 
     256       
    253257        fs_node_t *par = NULL;
    254258        fs_node_t *cur = NULL;
    255259        fs_node_t *tmp = NULL;
    256 
     260       
    257261        rc = ops->root_get(&cur, dev_handle);
    258262        on_error(rc, goto out_with_answer);
    259 
     263       
    260264        if (cur->mp_data.mp_active) {
    261265                ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
     
    265269                return;
    266270        }
    267 
     271       
     272        /* Eat slash */
    268273        if (ops->plb_get_char(next) == '/')
    269                 next++;         /* eat slash */
     274                next++;
    270275       
    271276        while (next <= last) {
    272277                bool has_children;
    273 
     278               
    274279                rc = ops->has_children(&has_children, cur);
    275280                on_error(rc, goto out_with_answer);
    276281                if (!has_children)
    277282                        break;
    278 
    279                 /* collect the component */
     283               
     284                /* Collect the component */
    280285                len = 0;
    281                 while ((next <= last) &&  (ops->plb_get_char(next) != '/')) {
     286                while ((next <= last) && (ops->plb_get_char(next) != '/')) {
    282287                        if (len + 1 == NAME_MAX) {
    283                                 /* component length overflow */
     288                                /* Component length overflow */
    284289                                ipc_answer_0(rid, ENAMETOOLONG);
    285290                                goto out;
    286291                        }
    287292                        component[len++] = ops->plb_get_char(next);
    288                         next++; /* process next character */
     293                        /* Process next character */
     294                        next++;
    289295                }
    290 
     296               
    291297                assert(len);
    292298                component[len] = '\0';
    293                 next++;         /* eat slash */
    294 
    295                 /* match the component */
     299                /* Eat slash */
     300                next++;
     301               
     302                /* Match the component */
    296303                rc = ops->match(&tmp, cur, component);
    297304                on_error(rc, goto out_with_answer);
    298 
    299                 if (tmp && tmp->mp_data.mp_active) {
     305               
     306                if ((tmp) && (tmp->mp_data.mp_active)) {
    300307                        if (next > last)
    301308                                next = last = first;
    302309                        else
    303310                                next--;
    304                                
     311                       
    305312                        ipc_forward_slow(rid, tmp->mp_data.phone,
    306313                            VFS_OUT_LOOKUP, next, last, tmp->mp_data.dev_handle,
     
    312319                        return;
    313320                }
    314 
    315                 /* handle miss: match amongst siblings */
     321               
     322                /* Handle miss: match amongst siblings */
    316323                if (!tmp) {
    317324                        if (next <= last) {
    318                                 /* there are unprocessed components */
     325                                /* There are unprocessed components */
    319326                                ipc_answer_0(rid, ENOENT);
    320327                                goto out;
    321328                        }
    322                         /* miss in the last component */
    323                         if (lflag & (L_CREATE | L_LINK)) {
    324                                 /* request to create a new link */
     329                       
     330                        /* Miss in the last component */
     331                        if (lflag & (L_CREATE | L_LINK)) {
     332                                /* Request to create a new link */
    325333                                if (!ops->is_directory(cur)) {
    326334                                        ipc_answer_0(rid, ENOTDIR);
    327335                                        goto out;
    328336                                }
     337                               
    329338                                fs_node_t *fn;
    330339                                if (lflag & L_CREATE)
     
    335344                                            index);
    336345                                on_error(rc, goto out_with_answer);
     346                               
    337347                                if (fn) {
    338348                                        rc = ops->link(cur, fn, component);
     
    349359                                                (void) ops->node_put(fn);
    350360                                        }
    351                                 } else {
     361                                } else
    352362                                        ipc_answer_0(rid, ENOSPC);
    353                                 }
     363                               
    354364                                goto out;
    355                         }
     365                        }
     366                       
    356367                        ipc_answer_0(rid, ENOENT);
    357368                        goto out;
    358369                }
    359 
     370               
    360371                if (par) {
    361372                        rc = ops->node_put(par);
    362373                        on_error(rc, goto out_with_answer);
    363374                }
    364 
    365                 /* descend one level */
     375               
     376                /* Descend one level */
    366377                par = cur;
    367378                cur = tmp;
    368379                tmp = NULL;
    369380        }
    370 
    371         /* handle miss: excessive components */
     381       
     382        /* Handle miss: excessive components */
    372383        if (next <= last) {
    373384                bool has_children;
    374 
    375385                rc = ops->has_children(&has_children, cur);
    376386                on_error(rc, goto out_with_answer);
     387               
    377388                if (has_children)
    378389                        goto skip_miss;
    379 
     390               
    380391                if (lflag & (L_CREATE | L_LINK)) {
    381392                        if (!ops->is_directory(cur)) {
     
    383394                                goto out;
    384395                        }
    385 
    386                         /* collect next component */
     396                       
     397                        /* Collect next component */
    387398                        len = 0;
    388399                        while (next <= last) {
    389400                                if (ops->plb_get_char(next) == '/') {
    390                                         /* more than one component */
     401                                        /* More than one component */
    391402                                        ipc_answer_0(rid, ENOENT);
    392403                                        goto out;
    393404                                }
     405                               
    394406                                if (len + 1 == NAME_MAX) {
    395                                         /* component length overflow */
     407                                        /* Component length overflow */
    396408                                        ipc_answer_0(rid, ENAMETOOLONG);
    397409                                        goto out;
    398410                                }
     411                               
    399412                                component[len++] = ops->plb_get_char(next);
    400                                 next++; /* process next character */
     413                                /* Process next character */
     414                                next++;
    401415                        }
     416                       
    402417                        assert(len);
    403418                        component[len] = '\0';
    404                                
     419                       
    405420                        fs_node_t *fn;
    406421                        if (lflag & L_CREATE)
     
    409424                                rc = ops->node_get(&fn, dev_handle, index);
    410425                        on_error(rc, goto out_with_answer);
     426                       
    411427                        if (fn) {
    412428                                rc = ops->link(cur, fn, component);
     
    423439                                        (void) ops->node_put(fn);
    424440                                }
    425                         } else {
     441                        } else
    426442                                ipc_answer_0(rid, ENOSPC);
    427                         }
     443                       
    428444                        goto out;
    429445                }
     446               
    430447                ipc_answer_0(rid, ENOENT);
    431448                goto out;
    432449        }
     450       
    433451skip_miss:
    434 
    435         /* handle hit */
     452       
     453        /* Handle hit */
    436454        if (lflag & L_UNLINK) {
    437                 unsigned old_lnkcnt = ops->lnkcnt_get(cur);
     455                unsigned int old_lnkcnt = ops->lnkcnt_get(cur);
    438456                rc = ops->unlink(par, cur, component);
    439                 ipc_answer_5(rid, (ipcarg_t)rc, fs_handle, dev_handle,
     457                ipc_answer_5(rid, (ipcarg_t) rc, fs_handle, dev_handle,
    440458                    ops->index_get(cur), ops->size_get(cur), old_lnkcnt);
    441459                goto out;
    442460        }
     461       
    443462        if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) ||
    444463            (lflag & L_LINK)) {
     
    446465                goto out;
    447466        }
     467       
    448468        if ((lflag & L_FILE) && (ops->is_directory(cur))) {
    449469                ipc_answer_0(rid, EISDIR);
    450470                goto out;
    451471        }
     472       
    452473        if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) {
    453474                ipc_answer_0(rid, ENOTDIR);
    454475                goto out;
    455476        }
    456 
     477       
    457478out_with_answer:
     479       
    458480        if (rc == EOK) {
    459                 ipc_answer_5(rid, EOK, fs_handle, dev_handle,
     481                if (lflag & L_OPEN)
     482                        rc = ops->node_open(cur);
     483               
     484                ipc_answer_5(rid, rc, fs_handle, dev_handle,
    460485                    ops->index_get(cur), ops->size_get(cur),
    461486                    ops->lnkcnt_get(cur));
    462         } else {
     487        } else
    463488                ipc_answer_0(rid, rc);
    464         }
    465 
     489       
    466490out:
     491       
    467492        if (par)
    468493                (void) ops->node_put(par);
     494       
    469495        if (cur)
    470496                (void) ops->node_put(cur);
     497       
    471498        if (tmp)
    472499                (void) ops->node_put(tmp);
     
    478505        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
    479506        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     507       
    480508        fs_node_t *fn;
    481         int rc;
    482 
    483         rc = ops->node_get(&fn, dev_handle, index);
     509        int rc = ops->node_get(&fn, dev_handle, index);
    484510        on_error(rc, answer_and_return(rid, rc));
    485 
     511       
    486512        ipc_callid_t callid;
    487513        size_t size;
    488         if (!async_data_read_receive(&callid, &size) ||
    489             size != sizeof(struct stat)) {
     514        if ((!async_data_read_receive(&callid, &size)) ||
     515            (size != sizeof(struct stat))) {
     516                ops->node_put(fn);
    490517                ipc_answer_0(callid, EINVAL);
    491518                ipc_answer_0(rid, EINVAL);
    492519                return;
    493520        }
    494 
     521       
    495522        struct stat stat;
    496523        memset(&stat, 0, sizeof(struct stat));
     
    499526        stat.dev_handle = dev_handle;
    500527        stat.index = index;
    501         stat.lnkcnt = ops->lnkcnt_get(fn); 
     528        stat.lnkcnt = ops->lnkcnt_get(fn);
    502529        stat.is_file = ops->is_file(fn);
     530        stat.is_directory = ops->is_directory(fn);
    503531        stat.size = ops->size_get(fn);
    504 
     532        stat.device = ops->device_get(fn);
     533       
     534        ops->node_put(fn);
     535       
    505536        async_data_read_finalize(callid, &stat, sizeof(struct stat));
    506537        ipc_answer_0(rid, EOK);
     
    509540/** Open VFS triplet.
    510541 *
    511  * @param ops       libfs operations structure with function pointers to
    512  *                  file system implementation
    513  * @param rid       Request ID of the VFS_OUT_OPEN_NODE request.
    514  * @param request   VFS_OUT_OPEN_NODE request data itself.
     542 * @param ops     libfs operations structure with function pointers to
     543 *                file system implementation
     544 * @param rid     Request ID of the VFS_OUT_OPEN_NODE request.
     545 * @param request VFS_OUT_OPEN_NODE request data itself.
    515546 *
    516547 */
     
    531562        }
    532563       
    533         ipc_answer_3(rid, EOK, ops->size_get(fn), ops->lnkcnt_get(fn),
     564        rc = ops->node_open(fn);
     565        ipc_answer_3(rid, rc, ops->size_get(fn), ops->lnkcnt_get(fn),
    534566            (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    535567       
  • uspace/lib/libfs/libfs.h

    r387416b r99de22b  
    6464        int (* match)(fs_node_t **, fs_node_t *, const char *);
    6565        int (* node_get)(fs_node_t **, dev_handle_t, fs_index_t);
     66        int (* node_open)(fs_node_t *);
    6667        int (* node_put)(fs_node_t *);
    6768        int (* create)(fs_node_t **, dev_handle_t, int);
     
    7677        fs_index_t (* index_get)(fs_node_t *);
    7778        size_t (* size_get)(fs_node_t *);
    78         unsigned (* lnkcnt_get)(fs_node_t *);
     79        unsigned int (* lnkcnt_get)(fs_node_t *);
    7980        char (* plb_get_char)(unsigned pos);
    8081        bool (* is_directory)(fs_node_t *);
    8182        bool (* is_file)(fs_node_t *);
     83        dev_handle_t (* device_get)(fs_node_t *);
    8284} libfs_ops_t;
    8385
  • uspace/lib/softfloat/Makefile

    r387416b r99de22b  
    3434all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
    3535        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build
     36        $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
    3737
    3838clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(LIBSOFTFLOAT)
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBSOFTFLOAT)
    4040        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/softfloat/Makefile.build

    r387416b r99de22b  
    6363%.o: %.c $(DEPEND)
    6464        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     65ifeq ($(PRECHECK),y)
     66        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     67endif
    6568
    6669$(DEPEND):
  • uspace/lib/softfloat/Makefile.common

    r387416b r99de22b  
    3434DEPEND = Makefile.depend
    3535DEPEND_PREV = $(DEPEND).prev
     36JOB = softfloat.job
    3637LIBSOFTFLOAT = libsoftfloat.a
  • uspace/lib/softint/Makefile

    r387416b r99de22b  
    3434all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
    3535        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build
     36        $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
    3737
    3838clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(LIBSOFTINT)
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBSOFTINT)
    4040        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/softint/Makefile.build

    r387416b r99de22b  
    5656%.o: %.c $(DEPEND)
    5757        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     58ifeq ($(PRECHECK),y)
     59        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     60endif
    5861
    5962$(DEPEND):
  • uspace/lib/softint/Makefile.common

    r387416b r99de22b  
    3434DEPEND = Makefile.depend
    3535DEPEND_PREV = $(DEPEND).prev
     36JOB = softint.job
    3637LIBSOFTINT = libsoftint.a
Note: See TracChangeset for help on using the changeset viewer.