Changeset 5a4fef9 in mainline for uspace


Ignore:
Timestamp:
2009-11-16T21:24:28Z (16 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
18baf9c0
Parents:
5f678b1c (diff), 9c70ed6 (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 head changes to this branch

Location:
uspace
Files:
68 added
68 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile

    r5f678b1c r5a4fef9  
    5555        app/init \
    5656        app/getvc \
     57        app/redir \
    5758        app/bdsh
    5859
     
    8687.PHONY: all $(LIBC_BUILD) $(LIBS_BUILD) $(BUILDS) $(CLEANS) clean
    8788
    88 all: ../Makefile.config ../config.h ../config.defs $(BUILDS)
     89all: $(BUILDS)
    8990
    9091clean: $(CLEANS)
  • uspace/app/bdsh/Makefile

    r5f678b1c r5a4fef9  
    1 # Copyright (c) 2005,  Martin Decky
    2 # All rights reserved.
    3 # Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
     1#
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    44# All rights reserved.
    55#
    66# Redistribution and use in source and binary forms, with or without
    7 # modification, are permitted provided that the following conditions are met:
     7# modification, are permitted provided that the following conditions
     8# are met:
    89#
    9 # Redistributions of source code must retain the above copyright notice, this
    10 # list of conditions and the following disclaimer.
     10# - Redistributions of source code must retain the above copyright
     11#   notice, this list of conditions and the following disclaimer.
     12# - Redistributions in binary form must reproduce the above copyright
     13#   notice, this list of conditions and the following disclaimer in the
     14#   documentation and/or other materials provided with the distribution.
     15# - The name of the author may not be used to endorse or promote products
     16#   derived from this software without specific prior written permission.
    1117#
    12 # Redistributions in binary form must reproduce the above copyright notice,
    13 # this list of conditions and the following disclaimer in the documentation
    14 # and/or other materials provided with the distribution.
     18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1528#
    16 # Neither the name of the original program's authors nor the names of its
    17 # contributors may be used to endorse or promote products derived from this
    18 # software without specific prior written permission.
    19 #
    20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    23 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    24 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    30 # POSSIBILITY OF SUCH DAMAGE.
    3129
    32 include ../../../version
     30include Makefile.common
    3331
    34 LIBC_PREFIX = ../../lib/libc
    35 SOFTINT_PREFIX = ../../lib/softint
    36 LIBBLOCK_PREFIX = ../../lib/libblock
     32.PHONY: all clean
    3733
    38 include $(LIBC_PREFIX)/Makefile.toolchain
    39 
    40 CFLAGS += -I../../srv/kbd/include -I$(LIBBLOCK_PREFIX)
    41 
    42 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a
    43 DEFS += -DRELEASE=$(RELEASE)
    44 
    45 PROGRAM = bdsh
    46 
    47 # Any directory that cleaning targets should know about
    48 SUBDIRS = \
    49         ./ \
    50         cmds/ \
    51         cmds/modules/ \
    52         cmds/modules/help/ \
    53         cmds/modules/mkdir/ \
    54         cmds/modules/rm/ \
    55         cmds/modules/bdd/ \
    56         cmds/modules/cat/ \
    57         cmds/modules/touch/ \
    58         cmds/modules/ls/ \
    59         cmds/modules/pwd/ \
    60         cmds/modules/sleep/ \
    61         cmds/modules/cp/ \
    62         cmds/modules/mv/ \
    63         cmds/modules/mount/ \
    64         cmds/modules/kcon/ \
    65         cmds/builtins/ \
    66         cmds/builtins/exit/\
    67         cmds/builtins/cd/
    68 
    69 SOURCES = \
    70         cmds/modules/help/help.c \
    71         cmds/modules/mkdir/mkdir.c \
    72         cmds/modules/rm/rm.c \
    73         cmds/modules/bdd/bdd.c \
    74         cmds/modules/cat/cat.c \
    75         cmds/modules/touch/touch.c \
    76         cmds/modules/ls/ls.c \
    77         cmds/modules/pwd/pwd.c \
    78         cmds/modules/sleep/sleep.c \
    79         cmds/modules/cp/cp.c \
    80         cmds/modules/mv/mv.c \
    81         cmds/modules/mount/mount.c \
    82         cmds/modules/kcon/kcon.c \
    83         cmds/builtins/exit/exit.c \
    84         cmds/builtins/cd/cd.c \
    85         cmds/mod_cmds.c \
    86         cmds/builtin_cmds.c \
    87         errors.c \
    88         input.c \
    89         util.c \
    90         exec.c \
    91         scli.c
    92 
    93 CFLAGS += -I. -Icmds/ -Icmds/builtins -Icmds/modules
    94 
    95 OBJECTS = $(SOURCES:.c=.o)
    96 
    97 # For easy cleaning, *.o is already handled
    98 CLEANDIRS := $(addsuffix *~,$(SUBDIRS))
    99 CLEANDIRS += $(addsuffix *.bak,$(SUBDIRS))
    100 CLEANDIRS += $(addsuffix *.tmp,$(SUBDIRS))
    101 CLEANDIRS += $(addsuffix *.out,$(SUBDIRS))
    102 CLEANDIRS += $(addsuffix *.d,$(SUBDIRS))
    103 CLEANDIRS += $(addsuffix *.gch,$(SUBDIRS) )
    104 
    105 %.o: %.S
    106         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    107 
    108 %.o: %.s
    109         $(AS) $(AFLAGS) $< -o $@
    110 
    111 %.o: %.c
    112         $(CC) $(CFLAGS) $(INC) -c $< -o $@
    113         @$(CC) -M $(CFLAGS) $(INC) $*.c > $*.d
    114 
    115 $(PROGRAM): $(OBJECTS) $(LIBS)
    116         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(PROGRAM).map
    117 
    118 # Everything else is a phony target
    119 .PHONY: all clean distclean depend
    120 
    121 all: $(PROGRAM) $(PROGRAM).disasm
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    12237
    12338clean:
    124         @-rm -f $(OBJECTS)
    125         @-rm -f $(PROGRAM)
    126         @-rm -f $(PROGRAM).map
    127         @-rm -f $(PROGRAM).disasm
    128         @-rm -f $(CLEANDIRS)
    129 
    130 depend:
    131         @echo ''
    132 
    133 $(PROGRAM).disasm: $(PROGRAM)
    134         $(OBJDUMP) -d $< > $@
    135 
    136 distclean: clean
    137 
    138 # Do not delete - dependencies
    139 -include $(OBJECTS:.o=.d)
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/bdsh/scli.c

    r5f678b1c r5a4fef9  
    6161        usr->line = (char *) NULL;
    6262        usr->name = "root";
    63         usr->home = "/";
    6463        usr->cwd = (char *) NULL;
    6564        usr->prompt = (char *) NULL;
    66         chdir(usr->home);
    6765        usr->lasterr = 0;
    6866        return (int) cli_set_prompt(usr);
  • uspace/app/bdsh/scli.h

    r5f678b1c r5a4fef9  
    77typedef struct {
    88        char *name;
    9         char *home;
    109        char *line;
    1110        char *cwd;
  • uspace/app/edit/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 CFLAGS += -I../../..
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = edit
    44 SOURCES = \
    45         edit.c \
    46         sheet.c
    47 
    48 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    49 
    50 .PHONY: all clean depend
    51 
    52 all: $(OUTPUT) $(OUTPUT).disasm
    53 
    54 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5537
    5638clean:
    57         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    58 
    59 depend:
    60         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    61 
    62 $(OUTPUT): $(OBJECTS) $(LIBS)
    63         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    64 
    65 $(OUTPUT).disasm: $(OUTPUT)
    66         $(OBJDUMP) -d $< > $@
    67 
    68 %.o: %.S
    69         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    70 
    71 %.o: %.s
    72         $(AS) $(AFLAGS) $< -o $@
    73 
    74 %.o: %.c
    75         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/edit/edit.c

    r5f678b1c r5a4fef9  
    665665
    666666        sheet_get_num_rows(&doc.sh, &num_rows);
    667         coord.row = num_rows;
     667        coord.row = num_rows + 1;
    668668        coord.column = 1;
    669669
  • uspace/app/getvc/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2009 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 include ../../../version
     30include Makefile.common
    3031
    31 ## Setup toolchain
    32 #
     32.PHONY: all clean
    3333
    34 LIBC_PREFIX = ../../lib/libc
    35 SOFTINT_PREFIX = ../../lib/softint
    36 
    37 include $(LIBC_PREFIX)/Makefile.toolchain
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    40 DEFS += -DRELEASE=$(RELEASE) "-DNAME=$(NAME)"
    41 
    42 ## Sources
    43 #
    44 
    45 OUTPUT = getvc
    46 SOURCES = \
    47         getvc.c \
    48         version.c
    49 
    50 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    51 
    52 .PHONY: all clean depend
    53 
    54 all: $(OUTPUT) $(OUTPUT).disasm
    55 
    56 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../version $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5737
    5838clean:
    59         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    60 
    61 depend:
    62         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    63 
    64 $(OUTPUT): $(OBJECTS) $(LIBS)
    65         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    66 
    67 $(OUTPUT).disasm: $(OUTPUT)
    68         $(OBJDUMP) -d $< > $@
    69 
    70 %.o: %.S
    71         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    72 
    73 %.o: %.s
    74         $(AS) $(AFLAGS) $< -o $@
    75 
    76 %.o: %.c
    77         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/getvc/getvc.c

    r5f678b1c r5a4fef9  
    3636
    3737#include <sys/types.h>
     38#include <fcntl.h>
    3839#include <unistd.h>
    3940#include <stdio.h>
     
    4647}
    4748
    48 static void closeall(void)
     49static void reopen(FILE **stream, int fd, const char *path, int flags, const char *mode)
    4950{
    50         fclose(stdin);
    51         fclose(stdout);
    52         fclose(stderr);
     51        if (fclose(*stream))
     52                return;
    5353       
    54         close(0);
    55         close(1);
    56         close(2);
     54        *stream = NULL;
     55       
     56        int oldfd = open(path, flags);
     57        if (oldfd < 0)
     58                return;
     59       
     60        if (oldfd != fd) {
     61                if (dup2(oldfd, fd) != fd)
     62                        return;
     63               
     64                if (close(oldfd))
     65                        return;
     66        }
     67       
     68        *stream = fdopen(fd, mode);
    5769}
    5870
    5971static task_id_t spawn(char *fname)
    6072{
    61         char *argv[2];
     73        char *args[2];
    6274       
    63         argv[0] = fname;
    64         argv[1] = NULL;
     75        args[0] = fname;
     76        args[1] = NULL;
    6577       
    66         task_id_t id = task_spawn(fname, argv);
     78        task_id_t id = task_spawn(fname, args);
    6779       
    6880        if (id == 0)
     
    7486int main(int argc, char *argv[])
    7587{
    76         task_exit_t texit;
    77         int retval;
    78 
    7988        if (argc < 3) {
    8089                usage();
     
    8291        }
    8392       
    84         closeall();
     93        reopen(&stdin, 0, argv[1], O_RDONLY, "r");
     94        reopen(&stdout, 1, argv[1], O_WRONLY, "w");
     95        reopen(&stderr, 2, argv[1], O_WRONLY, "w");
    8596       
    86         stdin = fopen(argv[1], "r");
    87         stdout = fopen(argv[1], "w");
    88         stderr = fopen(argv[1], "w");
    89 
    9097        /*
    91          * FIXME: fopen() should actually detect that we are opening a console
     98         * FIXME: fdopen() should actually detect that we are opening a console
    9299         * and it should set line-buffering mode automatically.
    93100         */
    94101        setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
    95102       
    96         if ((stdin == NULL)
    97             || (stdout == NULL)
    98             || (stderr == NULL))
     103        if (stdin == NULL)
    99104                return -2;
     105       
     106        if (stdout == NULL)
     107                return -3;
     108       
     109        if (stderr == NULL)
     110                return -4;
    100111       
    101112        version_print(argv[1]);
    102113        task_id_t id = spawn(argv[2]);
    103         task_wait(id, &texit, &retval);
    104114       
    105         return 0;
     115        if (id != 0) {
     116                task_exit_t texit;
     117                int retval;
     118                task_wait(id, &texit, &retval);
     119               
     120                return 0;
     121        }
     122       
     123        return -5;
    106124}
    107125
  • uspace/app/init/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 CFLAGS += -I../../..
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = init
    44 SOURCES = \
    45         init.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/init/init.c

    r5f678b1c r5a4fef9  
    4848#include <string.h>
    4949#include <devmap.h>
    50 #include <config.h>
    5150#include "init.h"
    5251
  • uspace/app/klog/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 LIBS = $(LIBC_PREFIX)/libc.a
    38 
    39 ## Sources
    40 #
    41 
    42 OUTPUT = klog
    43 SOURCES = \
    44         klog.c
    45 
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/tester/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 CFLAGS += -I../../srv/kbd/include
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    40 
    41 ## Sources
    42 #
    43 
    44 OUTPUT = tester
    45 SOURCES = tester.c \
    46         thread/thread1.c \
    47         print/print1.c \
    48         print/print2.c \
    49         print/print3.c \
    50         print/print4.c \
    51         console/console1.c \
    52         stdio/stdio1.c \
    53         stdio/stdio2.c \
    54         fault/fault1.c \
    55         fault/fault2.c \
    56         vfs/vfs1.c \
    57         ipc/ping_pong.c \
    58         ipc/register.c \
    59         ipc/connect.c \
    60         loop/loop1.c \
    61         mm/malloc1.c
    62 
    63 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    64 
    65 .PHONY: all clean depend disasm
    66 
    67 all: $(OUTPUT) $(OUTPUT).disasm
    68 
    69 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    7037
    7138clean:
    72         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    73 
    74 depend:
    75         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    76 
    77 $(OUTPUT): $(OBJECTS) $(LIBS)
    78         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    79 
    80 $(OUTPUT).disasm: $(OUTPUT)
    81         $(OBJDUMP) -d $< > $@
    82 
    83 %.o: %.S
    84         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    85 
    86 %.o: %.s
    87         $(AS) $(AFLAGS) $< -o $@
    88 
    89 %.o: %.c
    90         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/tetris/Makefile

    r5f678b1c r5a4fef9  
    1 LIBC_PREFIX = ../../lib/libc
    2 SOFTINT_PREFIX = ../../lib/softint
     1#
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
     4# All rights reserved.
     5#
     6# Redistribution and use in source and binary forms, with or without
     7# modification, are permitted provided that the following conditions
     8# are met:
     9#
     10# - Redistributions of source code must retain the above copyright
     11#   notice, this list of conditions and the following disclaimer.
     12# - Redistributions in binary form must reproduce the above copyright
     13#   notice, this list of conditions and the following disclaimer in the
     14#   documentation and/or other materials provided with the distribution.
     15# - The name of the author may not be used to endorse or promote products
     16#   derived from this software without specific prior written permission.
     17#
     18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28#
    329
    4 include $(LIBC_PREFIX)/Makefile.toolchain
     30include Makefile.common
    531
    6 LIBS = $(LIBC_PREFIX)/libc.a
     32.PHONY: all clean
    733
    8 OUTPUT = tetris
    9 SOURCES = shapes.c scores.c input.c tetris.c screen.c
    10 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    11 
    12 .PHONY: all clean depend
    13 
    14 all: $(OUTPUT) $(OUTPUT).disasm
    15 
    16 -include Makefile.depend
    17 
    18 depend:
    19         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    20 
    21 $(OUTPUT): $(OBJECTS) $(LIBS)
    22         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    2337
    2438clean:
    25         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend *.o
    26 
    27 $(OUTPUT).disasm: $(OUTPUT)
    28         $(OBJDUMP) -d $< > $@
    29 
    30 %.o: %.S
    31         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    32 
    33 %.o: %.s
    34         $(AS) $(AFLAGS) $< -o $@
    35 
    36 %.o: %.c
    37         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/app/trace/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 CFLAGS += -I../../srv/kbd/include
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    40 
    41 ## Sources
    42 #
    43 
    44 OUTPUT = trace
    45 SOURCES = trace.c \
    46         syscalls.c \
    47         ipcp.c \
    48         ipc_desc.c \
    49         proto.c \
    50         errors.c
    51 
    52 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    53 
    54 .PHONY: all clean depend
    55 
    56 all: $(OUTPUT) $(OUTPUT).disasm
    57 
    58 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5937
    6038clean:
    61         -rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend
    62 
    63 depend:
    64         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    65 
    66 $(OUTPUT): $(OBJECTS) $(LIBS)
    67         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    68 
    69 $(OUTPUT).disasm: $(OUTPUT)
    70         $(OBJDUMP) -d $< > $@
    71 
    72 %.o: %.S
    73         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    74 
    75 %.o: %.s
    76         $(AS) $(AFLAGS) $< -o $@
    77 
    78 %.o: %.c
    79         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/libblock/Makefile

    r5f678b1c r5a4fef9  
    2828#
    2929
    30 ## Common compiler flags
    31 #
     30include Makefile.common
    3231
    33 LIBC_PREFIX = ../libc
     32.PHONY: all clean
    3433
    35 ## Setup toolchain
    36 #
    37 
    38 include $(LIBC_PREFIX)/Makefile.toolchain
    39 
    40 CFLAGS += -Iinclude
    41 
    42 ## Sources
    43 #
    44 
    45 SOURCES = \
    46         libblock.c
    47 
    48 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    49 
    50 .PHONY: all clean depend
    51 
    52 all: libblock.a
    53 
    54 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5537
    5638clean:
    57         -rm -f libblock.a Makefile.depend
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(LIBBLOCK)
    5840        find . -name '*.o' -follow -exec rm \{\} \;
    59 
    60 depend:
    61         -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
    62 
    63 libblock.a: depend $(OBJECTS)
    64         $(AR) rc libblock.a $(OBJECTS)
    65 
    66 %.o: %.c
    67         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
  • uspace/lib/libc/Makefile

    r5f678b1c r5a4fef9  
    2727#
    2828
    29 ## Common compiler flags
    30 #
     29include Makefile.common
    3130
    32 LIBC_PREFIX = $(shell pwd)
    33 SOFTINT_PREFIX = ../softint
     31.PHONY: all clean
    3432
    35 
    36 ## Setup toolchain
    37 #
    38 
    39 include $(LIBC_PREFIX)/Makefile.toolchain
    40 
    41 
    42 ## Sources
    43 #
    44 
    45 GENERIC_SOURCES = \
    46         generic/libc.c \
    47         generic/ddi.c \
    48         generic/as.c \
    49         generic/cap.c \
    50         generic/devmap.c \
    51         generic/event.c \
    52         generic/errno.c \
    53         generic/mem.c \
    54         generic/string.c \
    55         generic/fibril.c \
    56         generic/fibril_sync.c \
    57         generic/pcb.c \
    58         generic/smc.c \
    59         generic/thread.c \
    60         generic/tls.c \
    61         generic/task.c \
    62         generic/futex.c \
    63         generic/io/asprintf.c \
    64         generic/io/io.c \
    65         generic/io/printf.c \
    66         generic/io/klog.c \
    67         generic/io/snprintf.c \
    68         generic/io/vprintf.c \
    69         generic/io/vsnprintf.c \
    70         generic/io/printf_core.c \
    71         generic/io/console.c \
    72         generic/malloc.c \
    73         generic/sysinfo.c \
    74         generic/ipc.c \
    75         generic/async.c \
    76         generic/loader.c \
    77         generic/getopt.c \
    78         generic/adt/list.o \
    79         generic/adt/hash_table.o \
    80         generic/time.c \
    81         generic/err.c \
    82         generic/stdlib.c \
    83         generic/mman.c \
    84         generic/udebug.c \
    85         generic/vfs/vfs.c \
    86         generic/vfs/canonify.c
    87 
    88 ARCH_SOURCES += \
    89         arch/$(UARCH)/src/entry.s \
    90         arch/$(UARCH)/src/thread_entry.s
    91 
    92 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
    93 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
    94 OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
    95 
    96 .PHONY: all clean depend kerninc
    97 
    98 all: libc.a
    99 
    100 -include Makefile.depend
     33all: ../../../Makefile.config ../../../config.h ../../../config.defs
     34        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     35        $(MAKE) -f Makefile.build
    10136
    10237clean:
    103         -rm -f include/kernel include/arch include/libarch libc.a arch/$(UARCH)/_link.ld Makefile.depend
    104         find generic/ arch/$(UARCH)/ -name '*.o' -follow -exec rm \{\} \;
    105 
    106 depend: kerninc arch/$(UARCH)/_link.ld
    107         -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
    108 
    109 libc.a: depend $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    110         $(AR) rc libc.a $(LIBS) $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    111 
    112 kerninc:
    113         ln -sfn ../../../../kernel/generic/include include/kernel
    114         ln -sfn kernel/arch include/arch
    115         ln -sfn ../arch/$(UARCH)/include include/libarch
    116 
    117 arch/$(UARCH)/_link.ld: arch/$(UARCH)/_link.ld.in
    118         $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
    119 
    120 %.o: %.S
    121         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    122 
    123 %.o: %.s
    124         $(AS) $(AFLAGS) $< -o $@
    125 
    126 %.o: %.c
    127         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     38        rm -f $(DEPEND) $(DEPEND_PREV) $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(LIBC) arch/*/_link.ld
     39        find generic/ arch/*/ -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/libc/Makefile.toolchain

    r5f678b1c r5a4fef9  
    5959#
    6060
    61 -include $(LIBC_PREFIX)/../../../Makefile.config
    62 -include $(LIBC_PREFIX)/../../../config.defs
    63 -include $(LIBC_PREFIX)/arch/$(UARCH)/Makefile.inc
     61include $(LIBC_PREFIX)/../../../Makefile.config
     62include $(LIBC_PREFIX)/../../../config.defs
     63include $(LIBC_PREFIX)/arch/$(UARCH)/Makefile.inc
    6464
    6565## Simple detection of the host system
  • uspace/lib/libc/arch/ia32/include/syscall.h

    r5f678b1c r5a4fef9  
    4040#include <kernel/syscall/syscall.h>
    4141
    42 #define __syscall0      __syscall_sysenter
    43 #define __syscall1      __syscall_sysenter
    44 #define __syscall2      __syscall_sysenter
    45 #define __syscall3      __syscall_sysenter
    46 #define __syscall4      __syscall_sysenter
    47 #define __syscall5      __syscall_int
    48 #define __syscall6      __syscall_int
     42#define __syscall0      __syscall_fast_func
     43#define __syscall1      __syscall_fast_func
     44#define __syscall2      __syscall_fast_func
     45#define __syscall3      __syscall_fast_func
     46#define __syscall4      __syscall_fast_func
     47#define __syscall5      __syscall_slow
     48#define __syscall6      __syscall_slow
    4949
    5050extern sysarg_t
    51 __syscall_sysenter(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
    52     const sysarg_t, const sysarg_t, const syscall_t);
     51(* __syscall_fast_func)(const sysarg_t, const sysarg_t, const sysarg_t,
     52    const sysarg_t, const sysarg_t, const sysarg_t, const syscall_t);
    5353
    5454extern sysarg_t
    55 __syscall_int(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
    56      const sysarg_t, const sysarg_t, const syscall_t);
     55__syscall_slow(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
     56    const sysarg_t, const sysarg_t, const syscall_t);
    5757
    5858#endif
  • uspace/lib/libc/arch/ia32/src/entry.s

    r5f678b1c r5a4fef9  
    2727#
    2828
     29INTEL_CPUID_STANDARD = 1
     30INTEL_SEP = 11
     31
    2932.section .init, "ax"
    3033
     
    3538## User-space task entry point
    3639#
    37 # %ebx contains the PCB pointer
     40# %edi contains the PCB pointer
    3841#
    3942__entry:
     
    4447        # Do not set %gs, it contains descriptor that can see TLS
    4548
     49        # Detect the mechanism used for making syscalls
     50        movl $(INTEL_CPUID_STANDARD), %eax
     51        cpuid
     52        bt $(INTEL_SEP), %edx
     53        jnc 0f
     54        leal __syscall_fast_func, %eax
     55        movl $__syscall_fast, (%eax)
     560:
     57
    4658        # Pass the PCB pointer to __main as the first argument
    47         pushl %ebx
     59        pushl %edi
    4860        call __main
    4961
  • uspace/lib/libc/arch/ia32/src/syscall.S

    r5f678b1c r5a4fef9  
    2727#
    2828
     29.data
     30
     31.global __syscall_fast_func
     32__syscall_fast_func:
     33        .long __syscall_slow
     34
    2935.text
    3036
     
    3541 * could benefit from this and not save unused registers on the stack.
    3642 */
    37 .global __syscall_int
    38 __syscall_int:
     43.global __syscall_slow
     44__syscall_slow:
    3945        pushl %ebx
    4046        pushl %esi
     
    6470 * segment, otherwise the SYSENTER wouldn't work in the first place).
    6571 */
    66 .global __syscall_sysenter
    67 __syscall_sysenter:
     72.global __syscall_fast
     73__syscall_fast:
    6874        pushl %ebx
    6975        pushl %esi
  • uspace/lib/libc/generic/io/klog.c

    r5f678b1c r5a4fef9  
    4242size_t klog_write(const void *buf, size_t size)
    4343{
    44         return (size_t) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, size);
     44        ssize_t ret = (ssize_t) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, size);
     45       
     46        if (ret >= 0)
     47                return (size_t) ret;
     48       
     49        return 0;
    4550}
    4651
  • uspace/lib/libc/generic/libc.c

    r5f678b1c r5a4fef9  
    8383                argv = __pcb->argv;
    8484                __stdio_init(__pcb->filc, __pcb->filv);
     85                (void) chdir(__pcb->cwd);
    8586        }
    8687       
  • uspace/lib/libc/generic/loader.c

    r5f678b1c r5a4fef9  
    101101}
    102102
     103/** Set current working directory for the loaded task.
     104 *
     105 * Sets the current working directory for the loaded task.
     106 *
     107 * @param ldr  Loader connection structure.
     108 *
     109 * @return Zero on success or negative error code.
     110 *
     111 */
     112int loader_set_cwd(loader_t *ldr)
     113{
     114        char *cwd;
     115        size_t len;
     116
     117        cwd = (char *) malloc(MAX_PATH_LEN + 1);
     118        if (!cwd)
     119                return ENOMEM;
     120        if (!getcwd(cwd, MAX_PATH_LEN + 1))
     121                str_cpy(cwd, MAX_PATH_LEN + 1, "/");
     122        len = str_length(cwd);
     123       
     124        ipc_call_t answer;
     125        aid_t req = async_send_0(ldr->phone_id, LOADER_SET_CWD, &answer);
     126        int rc = async_data_write_start(ldr->phone_id, cwd, len);
     127        free(cwd);
     128        if (rc != EOK) {
     129                async_wait_for(req, NULL);
     130                return rc;
     131        }
     132       
     133        ipcarg_t retval;
     134        async_wait_for(req, &retval);
     135        return (int) retval;
     136}
     137
    103138/** Set pathname of the program to load.
    104139 *
  • uspace/lib/libc/generic/malloc.c

    r5f678b1c r5a4fef9  
    353353}
    354354
     355void *calloc(const size_t nmemb, const size_t size)
     356{
     357        void *block = malloc(nmemb * size);
     358        if (block == NULL)
     359                return NULL;
     360
     361        memset(block, 0, nmemb * size);
     362        return block;
     363}
     364
    355365void *malloc(const size_t size)
    356366{
  • uspace/lib/libc/generic/task.c

    r5f678b1c r5a4fef9  
    8989                goto error;
    9090       
     91        /* Send spawner's current working directory. */
     92        rc = loader_set_cwd(ldr);
     93        if (rc != EOK)
     94                goto error;
     95       
    9196        /* Send program pathname. */
    9297        rc = loader_set_pathname(ldr, path);
     
    98103        if (rc != EOK)
    99104                goto error;
    100        
    101105       
    102106        /* Send default files */
  • uspace/lib/libc/generic/vfs/vfs.c

    r5f678b1c r5a4fef9  
    5757static futex_t cwd_futex = FUTEX_INITIALIZER;
    5858
    59 DIR *cwd_dir = NULL;
    60 char *cwd_path = NULL;
    61 size_t cwd_size = 0;
     59static int cwd_fd = -1;
     60static char *cwd_path = NULL;
     61static size_t cwd_size = 0;
    6262
    6363char *absolutize(const char *path, size_t *retlen)
     
    197197}
    198198
    199 static int _open(const char *path, int lflag, int oflag, ...)
    200 {
    201         ipcarg_t rc;
     199static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag)
     200{
     201        futex_down(&vfs_phone_futex);
     202        async_serialize_start();
     203        vfs_connect();
     204       
    202205        ipc_call_t answer;
    203         aid_t req;
    204        
    205         size_t pa_size;
    206         char *pa = absolutize(path, &pa_size);
    207         if (!pa)
    208                 return ENOMEM;
    209        
    210         futex_down(&vfs_phone_futex);
    211         async_serialize_start();
    212         vfs_connect();
    213        
    214         req = async_send_3(vfs_phone, VFS_IN_OPEN, lflag, oflag, 0, &answer);
    215         rc = async_data_write_start(vfs_phone, pa, pa_size);
     206        aid_t req = async_send_3(vfs_phone, VFS_IN_OPEN, lflag, oflag, 0, &answer);
     207        ipcarg_t rc = async_data_write_start(vfs_phone, abs, abs_size);
     208       
    216209        if (rc != EOK) {
    217210                ipcarg_t rc_orig;
    218        
    219                 async_wait_for(req, &rc_orig);
    220                 async_serialize_end();
    221                 futex_up(&vfs_phone_futex);
    222                 free(pa);
    223                 if (rc_orig == EOK)
    224                         return (int) rc;
    225                 else
    226                         return (int) rc_orig;
    227         }
    228         async_wait_for(req, &rc);
    229         async_serialize_end();
    230         futex_up(&vfs_phone_futex);
    231         free(pa);
     211                async_wait_for(req, &rc_orig);
     212               
     213                async_serialize_end();
     214                futex_up(&vfs_phone_futex);
     215               
     216                if (rc_orig == EOK)
     217                        return (int) rc;
     218                else
     219                        return (int) rc_orig;
     220        }
     221       
     222        async_wait_for(req, &rc);
     223        async_serialize_end();
     224        futex_up(&vfs_phone_futex);
    232225       
    233226        if (rc != EOK)
     
    239232int open(const char *path, int oflag, ...)
    240233{
    241         return _open(path, L_FILE, oflag);
     234        size_t abs_size;
     235        char *abs = absolutize(path, &abs_size);
     236        if (!abs)
     237                return ENOMEM;
     238       
     239        int ret = open_internal(abs, abs_size, L_FILE, oflag);
     240        free(abs);
     241       
     242        return ret;
    242243}
    243244
     
    471472        if (!dirp)
    472473                return NULL;
    473         dirp->fd = _open(dirname, L_DIRECTORY, 0);
    474         if (dirp->fd < 0) {
     474       
     475        size_t abs_size;
     476        char *abs = absolutize(dirname, &abs_size);
     477        if (!abs) {
     478                free(dirp);
     479                return ENOMEM;
     480        }
     481       
     482        int ret = open_internal(abs, abs_size, L_DIRECTORY, 0);
     483        free(abs);
     484       
     485        if (ret < 0) {
    475486                free(dirp);
    476487                return NULL;
    477488        }
     489       
     490        dirp->fd = ret;
    478491        return dirp;
    479492}
     
    636649int chdir(const char *path)
    637650{
    638         size_t pa_size;
    639         char *pa = absolutize(path, &pa_size);
    640         if (!pa)
    641                 return ENOMEM;
    642 
    643         DIR *d = opendir(pa);
    644         if (!d) {
    645                 free(pa);
     651        size_t abs_size;
     652        char *abs = absolutize(path, &abs_size);
     653        if (!abs)
     654                return ENOMEM;
     655       
     656        int fd = open_internal(abs, abs_size, L_DIRECTORY, O_DESC);
     657       
     658        if (fd < 0) {
     659                free(abs);
    646660                return ENOENT;
    647661        }
    648 
     662       
    649663        futex_down(&cwd_futex);
    650         if (cwd_dir) {
    651                 closedir(cwd_dir);
    652                 cwd_dir = NULL;
    653                 free(cwd_path);
    654                 cwd_path = NULL;
    655                 cwd_size = 0;
    656         }
    657         cwd_dir = d;
    658         cwd_path = pa;
    659         cwd_size = pa_size;
     664       
     665        if (cwd_fd >= 0)
     666                close(cwd_fd);
     667       
     668       
     669        if (cwd_path)
     670                free(cwd_path);
     671       
     672        cwd_fd = fd;
     673        cwd_path = abs;
     674        cwd_size = abs_size;
     675       
    660676        futex_up(&cwd_futex);
    661677        return EOK;
     
    664680char *getcwd(char *buf, size_t size)
    665681{
    666         if (!size)
     682        if (size == 0)
    667683                return NULL;
     684       
    668685        futex_down(&cwd_futex);
    669         if (size < cwd_size + 1) {
     686       
     687        if ((cwd_size == 0) || (size < cwd_size + 1)) {
    670688                futex_up(&cwd_futex);
    671689                return NULL;
    672690        }
     691       
    673692        str_cpy(buf, size, cwd_path);
    674693        futex_up(&cwd_futex);
     694       
    675695        return buf;
    676696}
     
    705725}
    706726
     727int dup2(int oldfd, int newfd)
     728{
     729        futex_down(&vfs_phone_futex);
     730        async_serialize_start();
     731        vfs_connect();
     732       
     733        ipcarg_t ret;
     734        ipcarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret);
     735       
     736        async_serialize_end();
     737        futex_up(&vfs_phone_futex);
     738       
     739        if (rc == EOK)
     740                return (int) ret;
     741       
     742        return (int) rc;
     743}
     744
    707745/** @}
    708746 */
  • uspace/lib/libc/include/fcntl.h

    r5f678b1c r5a4fef9  
    4343#define O_RDWR    32
    4444#define O_WRONLY  64
     45#define O_DESC    128
    4546
    4647extern int open(const char *, int, ...);
  • uspace/lib/libc/include/ipc/loader.h

    r5f678b1c r5a4fef9  
    4141        LOADER_HELLO = IPC_FIRST_USER_METHOD,
    4242        LOADER_GET_TASKID,
     43        LOADER_SET_CWD,
    4344        LOADER_SET_PATHNAME,
    4445        LOADER_SET_ARGS,
  • uspace/lib/libc/include/ipc/vfs.h

    r5f678b1c r5a4fef9  
    7373        VFS_IN_UNLINK,
    7474        VFS_IN_RENAME,
    75         VFS_IN_STAT
     75        VFS_IN_STAT,
     76        VFS_IN_DUP
    7677} vfs_in_request_t;
    7778
  • uspace/lib/libc/include/loader/loader.h

    r5f678b1c r5a4fef9  
    4949extern loader_t *loader_connect(void);
    5050extern int loader_get_task_id(loader_t *, task_id_t *);
     51extern int loader_set_cwd(loader_t *);
    5152extern int loader_set_pathname(loader_t *, const char *);
    5253extern int loader_set_args(loader_t *, char *const[]);
  • uspace/lib/libc/include/loader/pcb.h

    r5f678b1c r5a4fef9  
    5252        /** Program entry point. */
    5353        entry_point_t entry;
     54
     55        /** Current working directory. */
     56        char *cwd;
    5457       
    5558        /** Number of command-line arguments. */
  • uspace/lib/libc/include/malloc.h

    r5f678b1c r5a4fef9  
    4242
    4343extern void *malloc(const size_t size);
     44extern void *calloc(const size_t nmemb, const size_t size);
    4445extern void *memalign(const size_t align, const size_t size);
    4546extern void *realloc(const void *addr, const size_t size);
  • uspace/lib/libc/include/unistd.h

    r5f678b1c r5a4fef9  
    5151#endif
    5252
     53extern int dup2(int oldfd, int newfd);
     54
    5355extern ssize_t write(int, const void *, size_t);
    5456extern ssize_t read(int, void *, size_t);
  • uspace/lib/libfs/Makefile

    r5f678b1c r5a4fef9  
    2828#
    2929
    30 ## Common compiler flags
    31 #
     30include Makefile.common
    3231
    33 LIBC_PREFIX = ../libc
     32.PHONY: all clean
    3433
    35 ## Setup toolchain
    36 #
    37 
    38 include $(LIBC_PREFIX)/Makefile.toolchain
    39 
    40 CFLAGS += -Iinclude
    41 
    42 ## Sources
    43 #
    44 
    45 SOURCES = \
    46         libfs.c
    47 
    48 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    49 
    50 .PHONY: all clean depend
    51 
    52 all: libfs.a
    53 
    54 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5537
    5638clean:
    57         -rm -f libfs.a Makefile.depend
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(LIBFS)
    5840        find . -name '*.o' -follow -exec rm \{\} \;
    59 
    60 depend:
    61         -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
    62 
    63 libfs.a: depend $(OBJECTS)
    64         $(AR) rc libfs.a $(OBJECTS)
    65 
    66 %.o: %.c
    67         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
  • uspace/lib/libfs/libfs.c

    r5f678b1c r5a4fef9  
    531531        }
    532532       
    533         ipc_answer_5(rid, EOK, fs_handle, dev_handle, index, ops->size_get(fn),
    534             ops->lnkcnt_get(fn));
     533        ipc_answer_3(rid, EOK, ops->size_get(fn), ops->lnkcnt_get(fn),
     534            (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    535535       
    536536        (void) ops->node_put(fn);
  • uspace/lib/softfloat/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Common compiler flags
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../libc
     32.PHONY: all clean
    3333
    34 ## Setup toolchain
    35 #
    36 
    37 include $(LIBC_PREFIX)/Makefile.toolchain
    38 
    39 CFLAGS += -Iinclude -Iarch/$(UARCH)/include/
    40 
    41 ## Sources
    42 #
    43 
    44 GENERIC_SOURCES = \
    45         generic/add.c \
    46         generic/common.c \
    47         generic/comparison.c \
    48         generic/conversion.c \
    49         generic/div.c \
    50         generic/mul.c \
    51         generic/other.c \
    52         generic/softfloat.c \
    53         generic/sub.c
    54 
    55 ARCH_SOURCES =
    56 
    57 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
    58 
    59 .PHONY: all clean depend
    60 
    61 all: libsoftfloat.a
    62 
    63 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    6437
    6538clean:
    66         -rm -f libsoftfloat.a Makefile.depend
    67         find generic/ -name '*.o' -follow -exec rm \{\} \;
    68 
    69 depend:
    70         -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
    71 
    72 libsoftfloat.a: depend $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    73         $(AR) rc libsoftfloat.a $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    74 
    75 %.o: %.S
    76         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    77 
    78 %.o: %.s
    79         $(AS) $(AFLAGS) $< -o $@
    80 
    81 %.o: %.c
    82         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(LIBSOFTFLOAT)
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/lib/softint/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Common compiler flags
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../libc
     32.PHONY: all clean
    3333
    34 ## Setup toolchain
    35 #
    36 
    37 include $(LIBC_PREFIX)/Makefile.toolchain
    38 
    39 CFLAGS += -Iinclude
    40 
    41 ## Sources
    42 #
    43 
    44 ARCH_SOURCES =
    45 
    46 GENERIC_SOURCES = \
    47         generic/division.c\
    48         generic/multiplication.c
    49 
    50 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
    51 
    52 .PHONY: all clean depend
    53 
    54 all: libsoftint.a
    55 
    56 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5737
    5838clean:
    59         -rm -f libsoftint.a Makefile.depend
    60         find generic/ -name '*.o' -follow -exec rm \{\} \;
    61 
    62 depend:
    63         -makedepend -f - -- $(DEPEMD_DEFS) $(CFLAGS) -- $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
    64 
    65 libsoftint.a: depend $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    66         $(AR) rc libsoftint.a $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    67 
    68 %.o: %.S
    69         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    70 
    71 %.o: %.s
    72         $(AS) $(AFLAGS) $< -o $@
    73 
    74 %.o: %.c
    75         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(LIBSOFTINT)
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/bd/ata_bd/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = ata_bd
    44 SOURCES = \
    45         ata_bd.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/bd/file_bd/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = file_bd
    44 SOURCES = \
    45         file_bd.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/bd/gxe_bd/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = gxe_bd
    44 SOURCES = \
    45         gxe_bd.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/bd/rd/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = rd
    44 SOURCES = \
    45         rd.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/cir/fhc/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = fhc
    44 SOURCES = \
    45         fhc.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/cir/obio/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = obio
    44 SOURCES = \
    45         obio.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5437
    5538clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    57 
    58 depend:
    59         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    60 
    61 $(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    63 
    64 $(OUTPUT).disasm: $(OUTPUT)
    65         $(OBJDUMP) -d $< > $@
    66 
    67 %.o: %.S
    68         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    69 
    70 %.o: %.s
    71         $(AS) $(AFLAGS) $< -o $@
    72 
    73 %.o: %.c
    74         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/console/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 CFLAGS += -I.
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    40 
    41 ## Sources
    42 #
    43 
    44 OUTPUT = console
    45 
    46 GENERIC_SOURCES = \
    47         console.c \
    48         screenbuffer.c \
    49         keybuffer.c \
    50         gcons.c
    51 
    52 IMAGES = \
    53         gfx/helenos.ppm \
    54         gfx/nameic.ppm \
    55         gfx/cons_selected.ppm \
    56         gfx/cons_idle.ppm \
    57         gfx/cons_has_data.ppm \
    58         gfx/cons_kernel.ppm \
    59         gfx/anim_1.ppm \
    60         gfx/anim_2.ppm \
    61         gfx/anim_3.ppm \
    62         gfx/anim_4.ppm
    63 
    64 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) \
    65         $(addsuffix .o,$(basename $(IMAGES)))
    66 
    67 OBJECTS := $(GENERIC_OBJECTS)
    68 
    69 .PHONY: all clean depend
    70 
    71 all: $(OUTPUT) $(OUTPUT).disasm
    72 
    73 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    7437
    7538clean:
    76         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    77 
    78 depend:
    79         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    80 
    81 $(OUTPUT): $(OBJECTS) $(LIBS)
    82         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    83 
    84 $(OUTPUT).disasm: $(OUTPUT)
    85         $(OBJDUMP) -d $< > $@
    86 
    87 %.o: %.S
    88         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    89 
    90 %.o: %.s
    91         $(AS) $(AFLAGS) $< -o $@
    92 
    93 %.o: %.c
    94         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
    95 
    96 %.o: %.ppm
    97         $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/console/console.c

    r5f678b1c r5a4fef9  
    4040#include <ipc/services.h>
    4141#include <errno.h>
    42 #include <keybuffer.h>
    4342#include <ipc/console.h>
    4443#include <unistd.h>
     
    5554#include "console.h"
    5655#include "gcons.h"
     56#include "keybuffer.h"
    5757#include "screenbuffer.h"
    5858
  • uspace/srv/console/keybuffer.c

    r5f678b1c r5a4fef9  
    3535 */
    3636
    37 #include <keybuffer.h>
    3837#include <futex.h>
     38#include "keybuffer.h"
    3939
    4040atomic_t keybuffer_futex = FUTEX_INITIALIZER;
  • uspace/srv/console/screenbuffer.c

    r5f678b1c r5a4fef9  
    3333 */
    3434
    35 #include <screenbuffer.h>
    3635#include <io/style.h>
    3736#include <malloc.h>
    3837#include <unistd.h>
     38#include "screenbuffer.h"
    3939
    4040/** Store one character to screenbuffer.
  • uspace/srv/devmap/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 LIBS = $(LIBC_PREFIX)/libc.a
    38 
    39 ## Sources
    40 #
    41 
    42 OUTPUT = devmap
    43 SOURCES = \
    44         devmap.c
    45 
    46 CFLAGS += -D$(UARCH)
    47 
    48 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    49 
    50 .PHONY: all clean depend
    51 
    52 all: $(OUTPUT) $(OUTPUT).disasm
    53 
    54 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5537
    5638clean:
    57         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    58 
    59 depend:
    60         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    61 
    62 $(OUTPUT): $(OBJECTS) $(LIBS)
    63         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    64 
    65 $(OUTPUT).disasm: $(OUTPUT)
    66         $(OBJDUMP) -d $< > $@
    67 
    68 %.o: %.S
    69         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    70 
    71 %.o: %.s
    72         $(AS) $(AFLAGS) $< -o $@
    73 
    74 %.o: %.c
    75         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/fb/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 LIBS = $(LIBC_PREFIX)/libc.a
    38 
    39 ## Sources
    40 #
    41 
    42 OUTPUT = fb
    43 SOURCES = \
    44         main.c \
    45         ppm.c
    46 
    47 ifneq ($(UARCH),ia64)
    48         SOURCES += fb.c \
    49                 font-8x16.c
    50         CFLAGS += -DFB_ENABLED
    51 endif
    52 
    53 ifeq ($(UARCH),ia32)
    54         SOURCES += ega.c
    55         CFLAGS += -DEGA_ENABLED
    56 endif
    57 
    58 ifeq ($(UARCH),ia64)
    59         SOURCES += ega.c \
    60                 ski.c \
    61                 serial_console.c
    62         CFLAGS += -DSKI_ENABLED
    63         CFLAGS += -DEGA_ENABLED
    64 endif
    65 
    66 ifeq ($(UARCH),amd64)
    67         SOURCES += ega.c
    68         CFLAGS += -DEGA_ENABLED
    69 endif
    70 
    71 ifeq ($(UARCH),mips32)
    72         SOURCES += msim.c \
    73                 serial_console.c
    74         CFLAGS += -DMSIM_ENABLED
    75 endif
    76 
    77 ifeq ($(UARCH),sparc64)
    78         SOURCES += sgcn.c \
    79                 serial_console.c
    80         CFLAGS += -DSGCN_ENABLED
    81 endif
    82 
    83 CFLAGS += -D$(UARCH)
    84 
    85 
    86 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    87 
    88 .PHONY: all clean depend
    89 
    90 all: $(OUTPUT) $(OUTPUT).disasm
    91 
    92 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    9337
    9438clean:
    95         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    96 
    97 depend:
    98         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    99 
    100 $(OUTPUT): $(OBJECTS) $(LIBS)
    101         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    102 
    103 $(OUTPUT).disasm: $(OUTPUT)
    104         $(OBJDUMP) -d $< > $@
    105 
    106 %.o: %.S
    107         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    108 
    109 %.o: %.s
    110         $(AS) $(AFLAGS) $< -o $@
    111 
    112 %.o: %.c
    113         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/fs/devfs/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../../lib/libc
    33 LIBFS_PREFIX = ../../../lib/libfs
    34 SOFTINT_PREFIX = ../../../lib/softint
     32.PHONY: all clean
    3533
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 CFLAGS += -I $(LIBFS_PREFIX)
    39 
    40 LIBS = \
    41         $(LIBFS_PREFIX)/libfs.a \
    42         $(LIBC_PREFIX)/libc.a
    43 
    44 ## Sources
    45 #
    46 
    47 OUTPUT = devfs
    48 SOURCES = \
    49         devfs.c \
    50         devfs_ops.c
    51 
    52 
    53 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    54 
    55 .PHONY: all clean depend
    56 
    57 all: $(OUTPUT) $(OUTPUT).disasm
    58 
    59 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    6037
    6138clean:
    62         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    63 
    64 depend:
    65         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    66 
    67 $(OUTPUT): $(OBJECTS) $(LIBS)
    68         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    69 
    70 $(OUTPUT).disasm: $(OUTPUT)
    71         $(OBJDUMP) -d $< > $@
    72 
    73 %.o: %.S
    74         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    75 
    76 %.o: %.s
    77         $(AS) $(AFLAGS) $< -o $@
    78 
    79 %.o: %.c
    80         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/fs/fat/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../../lib/libc
    33 LIBFS_PREFIX = ../../../lib/libfs
    34 LIBBLOCK_PREFIX = ../../../lib/libblock
    35 SOFTINT_PREFIX = ../../../lib/softint
     32.PHONY: all clean
    3633
    37 include $(LIBC_PREFIX)/Makefile.toolchain
    38 
    39 CFLAGS += -I $(LIBFS_PREFIX) -I $(LIBBLOCK_PREFIX)
    40 
    41 LIBS = \
    42         $(LIBFS_PREFIX)/libfs.a \
    43         $(LIBBLOCK_PREFIX)/libblock.a \
    44         $(LIBC_PREFIX)/libc.a
    45 
    46 ## Sources
    47 #
    48 
    49 OUTPUT = fat
    50 SOURCES = \
    51         fat.c \
    52         fat_ops.c \
    53         fat_idx.c \
    54         fat_dentry.c \
    55         fat_fat.c
    56 
    57 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    58 
    59 .PHONY: all clean depend
    60 
    61 all: $(OUTPUT) $(OUTPUT).disasm
    62 
    63 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    6437
    6538clean:
    66         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    67 
    68 depend:
    69         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    70 
    71 $(OUTPUT): $(OBJECTS) $(LIBS)
    72         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    73 
    74 $(OUTPUT).disasm: $(OUTPUT)
    75         $(OBJDUMP) -d $< > $@
    76 
    77 %.o: %.S
    78         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    79 
    80 %.o: %.s
    81         $(AS) $(AFLAGS) $< -o $@
    82 
    83 %.o: %.c
    84         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/fs/fat/fat_ops.c

    r5f678b1c r5a4fef9  
    363363                                }
    364364                                rc = fat_node_get_core(&nodep, idx);
    365                                 assert(rc == EOK);
    366365                                fibril_mutex_unlock(&idx->lock);
    367                                 (void) block_put(b);
     366                                if (rc != EOK) {
     367                                        (void) block_put(b);
     368                                        return rc;
     369                                }
    368370                                *rfn = FS_NODE(nodep);
    369                                 return EOK;
     371                                rc = block_put(b);
     372                                if (rc != EOK)
     373                                        (void) fat_node_put(*rfn);
     374                                return rc;
    370375                        }
    371376                }
     
    10721077                        rc = fat_block_get(&b, bs, nodep, pos / bps,
    10731078                            BLOCK_FLAGS_NONE);
    1074                         assert(rc == EOK);
     1079                        if (rc != EOK) {
     1080                                fat_node_put(fn);
     1081                                ipc_answer_0(callid, rc);
     1082                                ipc_answer_0(rid, rc);
     1083                                return;
     1084                        }
    10751085                        (void) async_data_read_finalize(callid, b->data + pos % bps,
    10761086                            bytes);
    10771087                        rc = block_put(b);
    1078                         assert(rc == EOK);
     1088                        if (rc != EOK) {
     1089                                fat_node_put(fn);
     1090                                ipc_answer_0(rid, rc);
     1091                                return;
     1092                        }
    10791093                }
    10801094        } else {
     
    11001114                        rc = fat_block_get(&b, bs, nodep, bnum,
    11011115                            BLOCK_FLAGS_NONE);
    1102                         assert(rc == EOK);
     1116                        if (rc != EOK)
     1117                                goto err;
    11031118                        for (o = pos % (bps / sizeof(fat_dentry_t));
    11041119                            o < bps / sizeof(fat_dentry_t);
     
    11111126                                case FAT_DENTRY_LAST:
    11121127                                        rc = block_put(b);
    1113                                         assert(rc == EOK);
     1128                                        if (rc != EOK)
     1129                                                goto err;
    11141130                                        goto miss;
    11151131                                default:
     
    11171133                                        fat_dentry_name_get(d, name);
    11181134                                        rc = block_put(b);
    1119                                         assert(rc == EOK);
     1135                                        if (rc != EOK)
     1136                                                goto err;
    11201137                                        goto hit;
    11211138                                }
    11221139                        }
    11231140                        rc = block_put(b);
    1124                         assert(rc == EOK);
     1141                        if (rc != EOK)
     1142                                goto err;
    11251143                        bnum++;
    11261144                }
    11271145miss:
    1128                 fat_node_put(fn);
    1129                 ipc_answer_0(callid, ENOENT);
    1130                 ipc_answer_1(rid, ENOENT, 0);
    1131                 return;
     1146                rc = fat_node_put(fn);
     1147                ipc_answer_0(callid, rc != EOK ? rc : ENOENT);
     1148                ipc_answer_1(rid, rc != EOK ? rc : ENOENT, 0);
     1149                return;
     1150
     1151err:
     1152                (void) fat_node_put(fn);
     1153                ipc_answer_0(callid, rc);
     1154                ipc_answer_0(rid, rc);
     1155                return;
     1156
    11321157hit:
    11331158                (void) async_data_read_finalize(callid, name, str_size(name) + 1);
     
    11351160        }
    11361161
    1137         fat_node_put(fn);
    1138         ipc_answer_1(rid, EOK, (ipcarg_t)bytes);
     1162        rc = fat_node_put(fn);
     1163        ipc_answer_1(rid, rc, (ipcarg_t)bytes);
    11391164}
    11401165
     
    11471172        fat_node_t *nodep;
    11481173        fat_bs_t *bs;
    1149         size_t bytes;
     1174        size_t bytes, size;
    11501175        block_t *b;
    11511176        uint16_t bps;
     
    11701195        size_t len;
    11711196        if (!async_data_write_receive(&callid, &len)) {
    1172                 fat_node_put(fn);
     1197                (void) fat_node_put(fn);
    11731198                ipc_answer_0(callid, EINVAL);
    11741199                ipc_answer_0(rid, EINVAL);
     
    12011226                 */
    12021227                rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos);
    1203                 assert(rc == EOK);
     1228                if (rc != EOK) {
     1229                        (void) fat_node_put(fn);
     1230                        ipc_answer_0(callid, rc);
     1231                        ipc_answer_0(rid, rc);
     1232                        return;
     1233                }
    12041234                rc = fat_block_get(&b, bs, nodep, pos / bps, flags);
    1205                 assert(rc == EOK);
     1235                if (rc != EOK) {
     1236                        (void) fat_node_put(fn);
     1237                        ipc_answer_0(callid, rc);
     1238                        ipc_answer_0(rid, rc);
     1239                        return;
     1240                }
    12061241                (void) async_data_write_finalize(callid, b->data + pos % bps,
    12071242                    bytes);
    12081243                b->dirty = true;                /* need to sync block */
    12091244                rc = block_put(b);
    1210                 assert(rc == EOK);
     1245                if (rc != EOK) {
     1246                        (void) fat_node_put(fn);
     1247                        ipc_answer_0(rid, rc);
     1248                        return;
     1249                }
    12111250                if (pos + bytes > nodep->size) {
    12121251                        nodep->size = pos + bytes;
    12131252                        nodep->dirty = true;    /* need to sync node */
    12141253                }
    1215                 ipc_answer_2(rid, EOK, bytes, nodep->size);     
    1216                 fat_node_put(fn);
     1254                size = nodep->size;
     1255                rc = fat_node_put(fn);
     1256                ipc_answer_2(rid, rc, bytes, nodep->size);
    12171257                return;
    12181258        } else {
     
    12211261                 * clusters for the node and zero them out.
    12221262                 */
    1223                 int status;
    12241263                unsigned nclsts;
    12251264                fat_cluster_t mcl, lcl;
     
    12271266                nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc;
    12281267                /* create an independent chain of nclsts clusters in all FATs */
    1229                 status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
    1230                 if (status != EOK) {
     1268                rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
     1269                if (rc != EOK) {
    12311270                        /* could not allocate a chain of nclsts clusters */
    1232                         fat_node_put(fn);
    1233                         ipc_answer_0(callid, status);
    1234                         ipc_answer_0(rid, status);
     1271                        (void) fat_node_put(fn);
     1272                        ipc_answer_0(callid, rc);
     1273                        ipc_answer_0(rid, rc);
    12351274                        return;
    12361275                }
    12371276                /* zero fill any gaps */
    12381277                rc = fat_fill_gap(bs, nodep, mcl, pos);
    1239                 assert(rc == EOK);
     1278                if (rc != EOK) {
     1279                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1280                        (void) fat_node_put(fn);
     1281                        ipc_answer_0(callid, rc);
     1282                        ipc_answer_0(rid, rc);
     1283                        return;
     1284                }
    12401285                rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc,
    12411286                    flags);
    1242                 assert(rc == EOK);
     1287                if (rc != EOK) {
     1288                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1289                        (void) fat_node_put(fn);
     1290                        ipc_answer_0(callid, rc);
     1291                        ipc_answer_0(rid, rc);
     1292                        return;
     1293                }
    12431294                (void) async_data_write_finalize(callid, b->data + pos % bps,
    12441295                    bytes);
    12451296                b->dirty = true;                /* need to sync block */
    12461297                rc = block_put(b);
    1247                 assert(rc == EOK);
     1298                if (rc != EOK) {
     1299                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1300                        (void) fat_node_put(fn);
     1301                        ipc_answer_0(rid, rc);
     1302                        return;
     1303                }
    12481304                /*
    12491305                 * Append the cluster chain starting in mcl to the end of the
     
    12511307                 */
    12521308                rc = fat_append_clusters(bs, nodep, mcl);
    1253                 assert(rc == EOK);
    1254                 nodep->size = pos + bytes;
     1309                if (rc != EOK) {
     1310                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1311                        (void) fat_node_put(fn);
     1312                        ipc_answer_0(rid, rc);
     1313                        return;
     1314                }
     1315                nodep->size = size = pos + bytes;
    12551316                nodep->dirty = true;            /* need to sync node */
    1256                 ipc_answer_2(rid, EOK, bytes, nodep->size);
    1257                 fat_node_put(fn);
     1317                rc = fat_node_put(fn);
     1318                ipc_answer_2(rid, rc, bytes, size);
    12581319                return;
    12591320        }
  • uspace/srv/fs/tmpfs/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../../lib/libc
    33 LIBFS_PREFIX = ../../../lib/libfs
    34 LIBBLOCK_PREFIX = ../../../lib/libblock
    35 SOFTINT_PREFIX = ../../../lib/softint
     32.PHONY: all clean
    3633
    37 include $(LIBC_PREFIX)/Makefile.toolchain
    38 
    39 CFLAGS += -I $(LIBFS_PREFIX) -I $(LIBBLOCK_PREFIX)
    40 
    41 LIBS = \
    42         $(LIBFS_PREFIX)/libfs.a \
    43         $(LIBBLOCK_PREFIX)/libblock.a \
    44         $(LIBC_PREFIX)/libc.a
    45 
    46 ## Sources
    47 #
    48 
    49 OUTPUT = tmpfs
    50 SOURCES = \
    51         tmpfs.c \
    52         tmpfs_ops.c \
    53         tmpfs_dump.c
    54 
    55 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    56 
    57 .PHONY: all clean depend
    58 
    59 all: $(OUTPUT) $(OUTPUT).disasm
    60 
    61 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    6237
    6338clean:
    64         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    65 
    66 depend:
    67         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    68 
    69 $(OUTPUT): $(OBJECTS) $(LIBS)
    70         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    71 
    72 $(OUTPUT).disasm: $(OUTPUT)
    73         $(OBJDUMP) -d $< > $@
    74 
    75 %.o: %.S
    76         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    77 
    78 %.o: %.s
    79         $(AS) $(AFLAGS) $< -o $@
    80 
    81 %.o: %.c
    82         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/kbd/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 CFLAGS += -Iinclude
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    40 
    41 ## Sources
    42 #
    43 
    44 OUTPUT = kbd
    45 GENERIC_SOURCES = \
    46         generic/kbd.c \
    47         genarch/gsp.c \
    48         genarch/stroke.c
    49 
    50 ARCH_SOURCES =
    51 GENARCH_SOURCES = \
    52         layout/cz.c \
    53         layout/us_qwerty.c \
    54         layout/us_dvorak.c
    55 
    56 ifeq ($(UARCH), amd64)
    57         GENARCH_SOURCES += \
    58                 port/i8042.c \
    59                 ctl/pc.c
    60 endif
    61 
    62 ifeq ($(UARCH), arm32)
    63 ifeq ($(MACHINE), testarm)
    64         GENARCH_SOURCES += \
    65                 port/gxemul.c
    66        
    67         ifeq ($(CONFIG_FB), y)
    68                 GENARCH_SOURCES += \
    69                         ctl/gxe_fb.c
    70         else
    71                 GENARCH_SOURCES += \
    72                         ctl/stty.c
    73         endif
    74 endif
    75 ifeq ($(MACHINE), integratorcp)
    76          GENARCH_SOURCES += \
    77                 port/pl050.c \
    78                 ctl/pl050.c
    79 endif
    80 endif
    81 
    82 ifeq ($(UARCH), ia32)
    83         GENARCH_SOURCES += \
    84                 port/i8042.c \
    85                 ctl/pc.c
    86 endif
    87 
    88 ifeq ($(MACHINE), i460GX)
    89         GENARCH_SOURCES += \
    90                 port/i8042.c \
    91                 ctl/pc.c
    92 endif
    93 
    94 ifeq ($(MACHINE), ski)
    95         GENARCH_SOURCES += \
    96                 port/ski.c \
    97                 ctl/stty.c
    98 endif
    99 
    100 ifeq ($(MACHINE), msim)
    101         GENARCH_SOURCES += \
    102                 port/msim.c \
    103                 ctl/stty.c
    104 endif
    105 
    106 ifeq ($(MACHINE), lgxemul)
    107         GENARCH_SOURCES += \
    108                 port/gxemul.c
    109        
    110         ifeq ($(CONFIG_FB), y)
    111                 GENARCH_SOURCES += \
    112                         ctl/gxe_fb.c
    113         else
    114                 GENARCH_SOURCES += \
    115                         ctl/stty.c
    116         endif
    117 endif
    118 
    119 ifeq ($(MACHINE), bgxemul)
    120         GENARCH_SOURCES += \
    121                 port/gxemul.c
    122        
    123         ifeq ($(CONFIG_FB), y)
    124                 GENARCH_SOURCES += \
    125                         ctl/gxe_fb.c
    126         else
    127                 GENARCH_SOURCES += \
    128                         ctl/stty.c
    129         endif
    130 endif
    131 
    132 ifeq ($(UARCH), ppc32)
    133         GENARCH_SOURCES += \
    134                 port/dummy.c \
    135                 ctl/stty.c
    136 endif
    137 
    138 ifeq ($(UARCH), sparc64)
    139         ifeq ($(MACHINE),serengeti)
    140                 GENARCH_SOURCES += \
    141                         port/sgcn.c \
    142                         ctl/stty.c
    143         else
    144                 GENARCH_SOURCES += \
    145                         port/sun.c \
    146                         port/z8530.c \
    147                         port/ns16550.c \
    148                         ctl/sun.c
    149         endif
    150 endif
    151 
    152 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
    153 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
    154 GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
    155 
    156 OBJECTS := $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(GENARCH_OBJECTS)
    157 
    158 .PHONY: all clean depend
    159 
    160 all: $(OUTPUT) $(OUTPUT).disasm
    161 
    162 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    16337
    16438clean:
    165         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    166 
    167 depend:
    168         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    169 
    170 $(OUTPUT): $(OBJECTS) $(LIBS)
    171         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    172 
    173 $(OUTPUT).disasm: $(OUTPUT)
    174         $(OBJDUMP) -d $< > $@
    175 
    176 %.o: %.S
    177         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    178 
    179 %.o: %.s
    180         $(AS) $(AFLAGS) $< -o $@
    181 
    182 %.o: %.c
    183         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/loader/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2008 Jiri Svoboda
     3# Copyright (c) 2007 Jakub Jermar
    44# All rights reserved.
    55#
     
    2828#
    2929
    30 ## Setup toolchain
    31 #
     30include Makefile.common
    3231
    33 LIBC_PREFIX = ../../lib/libc
    34 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3533
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 include arch/$(UARCH)/Makefile.inc
    38 
    39 CFLAGS += -Iinclude
    40 
    41 LIBS = $(LIBC_PREFIX)/libc.a $(SOFTINT_PREFIX)/libsoftint.a
    42 
    43 ## Sources
    44 #
    45 
    46 OUTPUT = loader
    47 GENERIC_SOURCES = \
    48         main.c \
    49         elf_load.c \
    50         interp.s
    51 
    52 SOURCES := $(GENERIC_SOURCES) $(ARCH_SOURCES)
    53 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    54 
    55 .PHONY: all clean depend
    56 
    57 all: $(OUTPUT) $(OUTPUT).disasm
    58 
    59 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    6037
    6138clean:
    62         -rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm arch/$(UARCH)/_link.ld Makefile.depend
    63 
    64 depend:
    65         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    66 
    67 $(OUTPUT): $(OBJECTS) $(LIBS) arch/$(UARCH)/_link.ld
    68         $(LD) -T arch/$(UARCH)/_link.ld $(LFLAGS) $(OBJECTS) $(LIBS) -o $@ -Map $(OUTPUT).map
    69 
    70 $(OUTPUT).disasm: $(OUTPUT)
    71         $(OBJDUMP) -d $< > $@
    72 
    73 arch/$(UARCH)/_link.ld: arch/$(UARCH)/_link.ld.in
    74         $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
    75 
    76 %.o: %.S
    77         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    78 
    79 %.o: %.s
    80         $(AS) $(AFLAGS) $< -o $@
    81 
    82 %.o: %.c
    83         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm arch/*/_link.ld
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/loader/arch/ia32/ia32.s

    r5f678b1c r5a4fef9  
    4040        movl 0x8(%ebp), %eax
    4141
    42         # %ebx := pcb
    43         # pcb is passed to the entry point int %ebx
    44         mov 0xc(%ebp), %ebx
     42        # %edi := pcb
     43        # pcb is passed to the entry point in %edi
     44        mov 0xc(%ebp), %edi
    4545
    4646        # Save a tiny bit of stack space
  • uspace/srv/loader/main.c

    r5f678b1c r5a4fef9  
    7272static pcb_t pcb;
    7373
     74/** Current working directory */
     75static char *cwd = NULL;
     76
    7477/** Number of arguments */
    7578static int argc = 0;
     
    115118}
    116119
     120/** Receive a call setting the current working directory.
     121 *
     122 * @param rid
     123 * @param request
     124 */
     125static void ldr_set_cwd(ipc_callid_t rid, ipc_call_t *request)
     126{
     127        ipc_callid_t callid;
     128        size_t len;
     129       
     130        if (!async_data_write_receive(&callid, &len)) {
     131                ipc_answer_0(callid, EINVAL);
     132                ipc_answer_0(rid, EINVAL);
     133                return;
     134        }
     135       
     136        cwd = malloc(len + 1);
     137        if (!cwd) {
     138                ipc_answer_0(callid, ENOMEM);
     139                ipc_answer_0(rid, ENOMEM);
     140                return;
     141        }
     142       
     143        async_data_write_finalize(callid, cwd, len);
     144        cwd[len] = '\0';
     145       
     146        ipc_answer_0(rid, EOK);
     147}
    117148
    118149/** Receive a call setting pathname of the program to execute.
     
    313344        elf_create_pcb(&prog_info, &pcb);
    314345       
     346        pcb.cwd = cwd;
     347       
    315348        pcb.argc = argc;
    316349        pcb.argv = argv;
     
    406439                case LOADER_GET_TASKID:
    407440                        ldr_get_taskid(callid, &call);
     441                        continue;
     442                case LOADER_SET_CWD:
     443                        ldr_set_cwd(callid, &call);
    408444                        continue;
    409445                case LOADER_SET_PATHNAME:
  • uspace/srv/ns/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 LIBS = $(LIBC_PREFIX)/libc.a
    38 
    39 ## Sources
    40 #
    41 
    42 OUTPUT = ns
    43 SOURCES = \
    44         ns.c \
    45         service.c \
    46         clonable.c \
    47         task.c
    48 
    49 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    50 
    51 .PHONY: all clean depend
    52 
    53 all: $(OUTPUT) $(OUTPUT).disasm
    54 
    55 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5637
    5738clean:
    58         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    59 
    60 depend:
    61         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    62 
    63 $(OUTPUT): $(OBJECTS) $(LIBS)
    64         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    65 
    66 $(OUTPUT).disasm: $(OUTPUT)
    67         $(OBJDUMP) -d $< > $@
    68 
    69 %.o: %.S
    70         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    71 
    72 %.o: %.s
    73         $(AS) $(AFLAGS) $< -o $@
    74 
    75 %.o: %.c
    76         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/ns/service.c

    r5f678b1c r5a4fef9  
    156156               
    157157                hashed_service_t *hs = hash_table_get_instance(link, hashed_service_t, link);
    158                 ipcarg_t retval = ipc_forward_fast(pr->callid, hs->phone,
    159                     pr->arg2, pr->arg3, 0, IPC_FF_NONE);
    160                
    161                 if (!(pr->callid & IPC_CALLID_NOTIFICATION))
    162                         ipc_answer_0(pr->callid, retval);
     158                (void) ipc_forward_fast(pr->callid, hs->phone, pr->arg2,
     159                    pr->arg3, 0, IPC_FF_NONE);
    163160               
    164161                list_remove(cur);
     
    242239       
    243240        hashed_service_t *hs = hash_table_get_instance(link, hashed_service_t, link);
    244         retval = ipc_forward_fast(callid, hs->phone, IPC_GET_ARG2(*call),
     241        (void) ipc_forward_fast(callid, hs->phone, IPC_GET_ARG2(*call),
    245242            IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
     243        return;
    246244       
    247245out:
  • uspace/srv/part/mbr_part/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
     32.PHONY: all clean
    3233
    33 LIBC_PREFIX = ../../../lib/libc
    34 SOFTINT_PREFIX = ../../../lib/softint
    35 LIBBLOCK_PREFIX = ../../../lib/libblock
    36 
    37 include $(LIBC_PREFIX)/Makefile.toolchain
    38 
    39 CFLAGS += -I$(LIBBLOCK_PREFIX)
    40 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a
    41 
    42 ## Sources
    43 #
    44 
    45 OUTPUT = mbr_part
    46 SOURCES = \
    47         mbr_part.c
    48 
    49 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    50 
    51 .PHONY: all clean depend
    52 
    53 all: $(OUTPUT) $(OUTPUT).disasm
    54 
    55 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5637
    5738clean:
    58         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    59 
    60 depend:
    61         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    62 
    63 $(OUTPUT): $(OBJECTS) $(LIBS)
    64         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    65 
    66 $(OUTPUT).disasm: $(OUTPUT)
    67         $(OBJDUMP) -d $< > $@
    68 
    69 %.o: %.S
    70         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    71 
    72 %.o: %.s
    73         $(AS) $(AFLAGS) $< -o $@
    74 
    75 %.o: %.c
    76         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/pci/Makefile

    r5f678b1c r5a4fef9  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ## Setup toolchain
    30 #
     30include Makefile.common
    3131
    32 LIBC_PREFIX = ../../lib/libc
    33 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3433
    35 include $(LIBC_PREFIX)/Makefile.toolchain
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    3637
    37 
    38 LIBS = libpci/libpci.a $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = pci
    44 SOURCES = \
    45         pci.c
    46 
    47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    48 
    49 .PHONY: all clean depend
    50 
    51 all: $(OUTPUT) $(OUTPUT).disasm
    52 
    53 -include Makefile.depend
     38$(LIBPCI):
     39        $(MAKE) -C libpci
    5440
    5541clean:
    56         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    5742        $(MAKE) -C libpci clean
    58 
    59 depend:
    60         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    61 
    62 $(OUTPUT): $(OBJECTS) $(LIBS)
    63         $(MAKE) -C libpci
    64         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    65 
    66 $(OUTPUT).disasm: $(OUTPUT)
    67         $(OBJDUMP) -d $< > $@
    68 
    69 %.o: %.S
    70         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    71 
    72 %.o: %.s
    73         $(AS) $(AFLAGS) $< -o $@
    74 
    75 %.o: %.c
    76         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
    77 
    78 libpci/libpci.a:
    79         $(MAKE) -C libpci
     43        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     44        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/pci/libpci/Makefile

    r5f678b1c r5a4fef9  
    1 # Makefile for The PCI Library
    2 # (c) 1999 Martin Mares <mj@ucw.cz>
     1#
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
     4# All rights reserved.
     5#
     6# Redistribution and use in source and binary forms, with or without
     7# modification, are permitted provided that the following conditions
     8# are met:
     9#
     10# - Redistributions of source code must retain the above copyright
     11#   notice, this list of conditions and the following disclaimer.
     12# - Redistributions in binary form must reproduce the above copyright
     13#   notice, this list of conditions and the following disclaimer in the
     14#   documentation and/or other materials provided with the distribution.
     15# - The name of the author may not be used to endorse or promote products
     16#   derived from this software without specific prior written permission.
     17#
     18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28#
    329
    4 # Modified and ported to HelenOS by Jakub Jermar
     30include Makefile.common
    531
    6 LIBC_PREFIX=$(shell cd ../../../lib/libc; pwd)
     32.PHONY: all clean
    733
    8 include $(LIBC_PREFIX)/Makefile.toolchain
    9 
    10 LIBS = $(LIBC_PREFIX)/libc.a
    11 CFLAGS += -I$(LIBC_PREFIX)/include -trigraphs
    12 
    13 OBJS=access.o generic.o names.o
    14 INCL=internal.h pci.h header.h sysdep.h types.h pci_ids.h
    15 
    16 PCILIB=libpci.a
    17 
    18 OBJS += i386-ports.o
    19 
    20 all: $(PCILIB)
    21 
    22 $(PCILIB): $(OBJS)
    23         $(AR) rc $@ $(OBJS)
    24 
    25 %.o: %.c $(INCL)
    26         $(CC) $(CFLAGS) -c $< -o $@
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    2737
    2838clean:
    29         -rm *.o libpci.a
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(LIBPCI)
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/vfs/Makefile

    r5f678b1c r5a4fef9  
    11#
    2 # Copyright (c) 2006 Martin Decky
    3 # Copyright (c) 2008 Jakub Jermar
     2# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    44# All rights reserved.
    55#
     
    2828#
    2929
    30 ## Setup toolchain
    31 #
     30include Makefile.common
    3231
    33 LIBC_PREFIX = ../../lib/libc
    34 SOFTINT_PREFIX = ../../lib/softint
     32.PHONY: all clean
    3533
    36 include $(LIBC_PREFIX)/Makefile.toolchain
    37 
    38 LIBS = $(LIBC_PREFIX)/libc.a
    39 
    40 ## Sources
    41 #
    42 
    43 OUTPUT = vfs
    44 SOURCES = \
    45         vfs.c \
    46         vfs_node.c \
    47         vfs_file.c \
    48         vfs_ops.c \
    49         vfs_lookup.c \
    50         vfs_register.c
    51 
    52 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    53 
    54 .PHONY: all clean depend
    55 
    56 all: $(OUTPUT) $(OUTPUT).disasm
    57 
    58 -include Makefile.depend
     34all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
     35        -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
     36        $(MAKE) -f Makefile.build
    5937
    6038clean:
    61         -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS)
    62 
    63 depend:
    64         $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
    65 
    66 $(OUTPUT): $(OBJECTS) $(LIBS)
    67         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    68 
    69 $(OUTPUT).disasm: $(OUTPUT)
    70         $(OBJDUMP) -d $< > $@
    71 
    72 %.o: %.S
    73         $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
    74 
    75 %.o: %.s
    76         $(AS) $(AFLAGS) $< -o $@
    77 
    78 %.o: %.c
    79         $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     39        rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
     40        find . -name '*.o' -follow -exec rm \{\} \;
  • uspace/srv/vfs/vfs.c

    r5f678b1c r5a4fef9  
    126126                        vfs_sync(callid, &call);
    127127                        break;
     128                case VFS_IN_DUP:
     129                        vfs_dup(callid, &call);
    128130                default:
    129131                        ipc_answer_0(callid, ENOTSUP);
  • uspace/srv/vfs/vfs.h

    r5f678b1c r5a4fef9  
    186186extern bool vfs_files_init(void);
    187187extern vfs_file_t *vfs_file_get(int);
    188 extern int vfs_fd_alloc(void);
     188extern int vfs_fd_assign(vfs_file_t *file, int fd);
     189extern int vfs_fd_alloc(bool desc);
    189190extern int vfs_fd_free(int);
    190191
     
    200201extern void vfs_open_node(ipc_callid_t, ipc_call_t *);
    201202extern void vfs_sync(ipc_callid_t, ipc_call_t *);
     203extern void vfs_dup(ipc_callid_t, ipc_call_t *);
    202204extern void vfs_close(ipc_callid_t, ipc_call_t *);
    203205extern void vfs_read(ipc_callid_t, ipc_call_t *);
  • uspace/srv/vfs/vfs_file.c

    r5f678b1c r5a4fef9  
    7676/** Allocate a file descriptor.
    7777 *
    78  * @return              First available file descriptor or a negative error
    79  *                      code.
    80  */
    81 int vfs_fd_alloc(void)
     78 * @param desc If true, look for an available file descriptor
     79 *             in a descending order.
     80 *
     81 * @return First available file descriptor or a negative error
     82 *         code.
     83 */
     84int vfs_fd_alloc(bool desc)
    8285{
    8386        if (!vfs_files_init())
     
    8588       
    8689        unsigned int i;
    87         for (i = 0; i < MAX_OPEN_FILES; i++) {
     90        if (desc)
     91                i = MAX_OPEN_FILES - 1;
     92        else
     93                i = 0;
     94       
     95        while (true) {
    8896                if (!files[i]) {
    8997                        files[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t));
     
    96104                        return (int) i;
    97105                }
     106               
     107                if (desc) {
     108                        if (i == 0)
     109                                break;
     110                       
     111                        i--;
     112                } else {
     113                        if (i == MAX_OPEN_FILES - 1)
     114                                break;
     115                       
     116                        i++;
     117                }
    98118        }
    99119       
     
    118138        vfs_file_delref(files[fd]);
    119139        files[fd] = NULL;
     140       
     141        return EOK;
     142}
     143
     144/** Assign a file to a file descriptor.
     145 *
     146 * @param file File to assign.
     147 * @param fd   File descriptor to assign to.
     148 *
     149 * @return EOK on success or EINVAL if fd is an invalid or already
     150 *         used file descriptor.
     151 *
     152 */
     153int vfs_fd_assign(vfs_file_t *file, int fd)
     154{
     155        if (!vfs_files_init())
     156                return ENOMEM;
     157       
     158        if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] != NULL))
     159                return EINVAL;
     160       
     161        files[fd] = file;
     162        vfs_file_addref(files[fd]);
    120163       
    121164        return EOK;
  • uspace/srv/vfs/vfs_lookup.c

    r5f678b1c r5a4fef9  
    209209            (ipcarg_t) result->triplet.index, &answer);
    210210       
    211        
    212211        ipcarg_t rc;
    213212        async_wait_for(req, &rc);
  • uspace/srv/vfs/vfs_ops.c

    r5f678b1c r5a4fef9  
    543543         * structure.
    544544         */
    545         int fd = vfs_fd_alloc();
     545        int fd = vfs_fd_alloc((oflag & O_DESC) != 0);
    546546        if (fd < 0) {
    547547                vfs_node_put(node);
     
    620620         * structure.
    621621         */
    622         int fd = vfs_fd_alloc();
     622        int fd = vfs_fd_alloc((oflag & O_DESC) != 0);
    623623        if (fd < 0) {
    624624                vfs_node_put(node);
     
    679679}
    680680
     681static int vfs_close_internal(vfs_file_t *file)
     682{
     683        /*
     684         * Lock the open file structure so that no other thread can manipulate
     685         * the same open file at a time.
     686         */
     687        fibril_mutex_lock(&file->lock);
     688       
     689        if (file->refcnt <= 1) {
     690                /* Only close the file on the destination FS server
     691                   if there are no more file descriptors (except the
     692                   present one) pointing to this file. */
     693               
     694                int fs_phone = vfs_grab_phone(file->node->fs_handle);
     695               
     696                /* Make a VFS_OUT_CLOSE request at the destination FS server. */
     697                aid_t msg;
     698                ipc_call_t answer;
     699                msg = async_send_2(fs_phone, VFS_OUT_CLOSE, file->node->dev_handle,
     700                    file->node->index, &answer);
     701               
     702                /* Wait for reply from the FS server. */
     703                ipcarg_t rc;
     704                async_wait_for(msg, &rc);
     705               
     706                vfs_release_phone(fs_phone);
     707                fibril_mutex_unlock(&file->lock);
     708               
     709                return IPC_GET_ARG1(answer);
     710        }
     711       
     712        fibril_mutex_unlock(&file->lock);
     713        return EOK;
     714}
     715
    681716void vfs_close(ipc_callid_t rid, ipc_call_t *request)
    682717{
     
    690725        }
    691726       
    692         /*
    693          * Lock the open file structure so that no other thread can manipulate
    694          * the same open file at a time.
    695          */
    696         fibril_mutex_lock(&file->lock);
    697         int fs_phone = vfs_grab_phone(file->node->fs_handle);
    698        
    699         /* Make a VFS_OUT_CLOSE request at the destination FS server. */
    700         aid_t msg;
    701         ipc_call_t answer;
    702         msg = async_send_2(fs_phone, VFS_OUT_CLOSE, file->node->dev_handle,
    703             file->node->index, &answer);
    704 
    705         /* Wait for reply from the FS server. */
    706         ipcarg_t rc;
    707         async_wait_for(msg, &rc);
    708 
    709         vfs_release_phone(fs_phone);
    710         fibril_mutex_unlock(&file->lock);
    711        
    712         int retval = IPC_GET_ARG1(answer);
    713         if (retval != EOK)
    714                 ipc_answer_0(rid, retval);
    715        
    716         retval = vfs_fd_free(fd);
    717         ipc_answer_0(rid, retval);
     727        int ret = vfs_close_internal(file);
     728        if (ret != EOK)
     729                ipc_answer_0(rid, ret);
     730       
     731        ret = vfs_fd_free(fd);
     732        ipc_answer_0(rid, ret);
    718733}
    719734
     
    13101325}
    13111326
     1327void vfs_dup(ipc_callid_t rid, ipc_call_t *request)
     1328{
     1329        int oldfd = IPC_GET_ARG1(*request);
     1330        int newfd = IPC_GET_ARG2(*request);
     1331       
     1332        /* Lookup the file structure corresponding to oldfd. */
     1333        vfs_file_t *oldfile = vfs_file_get(oldfd);
     1334        if (!oldfile) {
     1335                ipc_answer_0(rid, EBADF);
     1336                return;
     1337        }
     1338       
     1339        /* If the file descriptors are the same, do nothing. */
     1340        if (oldfd == newfd) {
     1341                ipc_answer_1(rid, EOK, newfd);
     1342                return;
     1343        }
     1344       
     1345        /*
     1346         * Lock the open file structure so that no other thread can manipulate
     1347         * the same open file at a time.
     1348         */
     1349        fibril_mutex_lock(&oldfile->lock);
     1350       
     1351        /* Lookup an open file structure possibly corresponding to newfd. */
     1352        vfs_file_t *newfile = vfs_file_get(newfd);
     1353        if (newfile) {
     1354                /* Close the originally opened file. */
     1355                int ret = vfs_close_internal(newfile);
     1356                if (ret != EOK) {
     1357                        ipc_answer_0(rid, ret);
     1358                        return;
     1359                }
     1360               
     1361                ret = vfs_fd_free(newfd);
     1362                if (ret != EOK) {
     1363                        ipc_answer_0(rid, ret);
     1364                        return;
     1365                }
     1366        }
     1367       
     1368        /* Assign the old file to newfd. */
     1369        int ret = vfs_fd_assign(oldfile, newfd);
     1370        fibril_mutex_unlock(&oldfile->lock);
     1371       
     1372        if (ret != EOK)
     1373                ipc_answer_0(rid, ret);
     1374        else
     1375                ipc_answer_1(rid, EOK, newfd);
     1376}
     1377
    13121378/**
    13131379 * @}
Note: See TracChangeset for help on using the changeset viewer.