/branches/sparc/uspace/srv/fs/fat/fat_ops.c |
---|
737,7 → 737,6 |
rootp->type = FAT_DIRECTORY; |
rootp->firstc = FAT_CLST_ROOT; |
rootp->refcnt = 1; |
rootp->lnkcnt = 0; /* FS root is not linked */ |
rootp->size = rde * sizeof(fat_dentry_t); |
rootp->idx = ridxp; |
ridxp->nodep = rootp; |
744,7 → 743,7 |
futex_up(&ridxp->lock); |
ipc_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt); |
ipc_answer_0(rid, EOK); |
} |
void fat_mount(ipc_callid_t rid, ipc_call_t *request) |
/branches/sparc/uspace/srv/fs/tmpfs/tmpfs_ops.c |
---|
233,7 → 233,7 |
hash_table_destroy(&dentries); |
return false; |
} |
root->lnkcnt = 0; /* FS root is not linked */ |
root->lnkcnt = 1; |
return true; |
} |
405,12 → 405,11 |
if (dev_handle >= 0) { |
if (tmpfs_restore(dev_handle)) |
ipc_answer_3(rid, EOK, root->index, root->size, |
root->lnkcnt); |
ipc_answer_0(rid, EOK); |
else |
ipc_answer_0(rid, ELIMIT); |
} else { |
ipc_answer_3(rid, EOK, root->index, root->size, root->lnkcnt); |
ipc_answer_0(rid, EOK); |
} |
} |
/branches/sparc/uspace/srv/vfs/vfs_ops.c |
---|
205,12 → 205,6 |
} else { |
/* We still don't have the root file system mounted. */ |
if ((size == 1) && (buf[0] == '/')) { |
vfs_lookup_res_t mr_res; |
vfs_node_t *mr_node; |
ipcarg_t rindex; |
ipcarg_t rsize; |
ipcarg_t rlnkcnt; |
/* |
* For this simple, but important case, |
* we are almost done. |
219,30 → 213,16 |
/* Tell the mountee that it is being mounted. */ |
phone = vfs_grab_phone(fs_handle); |
rc = async_req_1_3(phone, VFS_MOUNTED, |
(ipcarg_t) dev_handle, &rindex, &rsize, &rlnkcnt); |
rc = async_req_1_0(phone, VFS_MOUNTED, |
(ipcarg_t) dev_handle); |
vfs_release_phone(phone); |
if (rc != EOK) { |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, rc); |
return; |
if (rc == EOK) { |
rootfs.fs_handle = fs_handle; |
rootfs.dev_handle = dev_handle; |
} |
mr_res.triplet.fs_handle = fs_handle; |
mr_res.triplet.dev_handle = dev_handle; |
mr_res.triplet.index = (fs_index_t) rindex; |
mr_res.size = (size_t) rsize; |
mr_res.lnkcnt = (unsigned) rlnkcnt; |
rootfs.fs_handle = fs_handle; |
rootfs.dev_handle = dev_handle; |
futex_up(&rootfs_futex); |
/* Add reference to the mounted root. */ |
mr_node = vfs_node_get(&mr_res); |
assert(mr_node); |
ipc_answer_0(rid, rc); |
return; |
} else { |
/branches/sparc/uspace/lib/libc/generic/getopt.c |
---|
File deleted |
/branches/sparc/uspace/lib/libc/generic/ipc.c |
---|
682,7 → 682,7 |
{ |
int res; |
sysarg_t tmp_flags; |
res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst, |
res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst, |
(ipcarg_t) size, arg, NULL, &tmp_flags); |
if (flags) |
*flags = tmp_flags; |
742,7 → 742,7 |
*/ |
int ipc_share_out_start(int phoneid, void *src, int flags) |
{ |
return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0, |
return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0, |
(ipcarg_t) flags); |
} |
/branches/sparc/uspace/lib/libc/generic/io/asprintf.c |
---|
File deleted |
/branches/sparc/uspace/lib/libc/generic/io/printf_core.c |
---|
94,9 → 94,12 |
if (str == NULL) |
return printf_putnchars("(NULL)", 6, ps); |
count = strlen(str); |
for (count = 0; str[count] != 0; count++); |
return ps->write((void *) str, count, ps->data); |
if (ps->write((void *) str, count, ps->data) == count) |
return 0; |
return EOF; |
} |
/** Print one character to output |
/branches/sparc/uspace/lib/libc/generic/io/vsnprintf.c |
---|
38,27 → 38,22 |
#include <io/printf_core.h> |
struct vsnprintf_data { |
size_t size; /* total space for string */ |
size_t len; /* count of currently used characters */ |
char *string; /* destination string */ |
size_t size; /* total space for string */ |
size_t len; /* count of currently used characters */ |
char *string; /* destination string */ |
}; |
/** Write string to given buffer. |
* Write at most data->size characters including trailing zero. According to C99 |
* has snprintf to return number of characters that would have been written if |
* enough space had been available. Hence the return value is not number of |
* really printed characters but size of input string. Number of really used |
* characters is stored in data->len. |
* |
* @param str Source string to print. |
* @param count Size of the source string. |
* @param data Structure with destination string, counter of used space |
* and total string size. |
* @return Number of characters to print (not characters really |
* printed!) |
* Write at most data->size characters including trailing zero. According to C99 has snprintf to return number |
* of characters that would have been written if enough space had been available. Hence the return value is not |
* number of really printed characters but size of input string. Number of really used characters |
* is stored in data->len. |
* @param str source string to print |
* @param count size of source string |
* @param data structure with destination string, counter of used space and total string size. |
* @return number of characters to print (not characters really printed!) |
*/ |
static int |
vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) |
static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) |
{ |
size_t i; |
i = data->size - data->len; |
68,10 → 63,7 |
} |
if (i == 1) { |
/* |
* We have only one free byte left in buffer => write there |
* trailing zero. |
*/ |
/* We have only one free byte left in buffer => write there trailing zero */ |
data->string[data->size - 1] = 0; |
data->len = data->size; |
return count; |
78,23 → 70,17 |
} |
if (i <= count) { |
/* |
* We have not enought space for whole string with the trailing |
* zero => print only a part of string. |
*/ |
memcpy((void *)(data->string + data->len), (void *)str, i - 1); |
data->string[data->size - 1] = 0; |
data->len = data->size; |
return count; |
/* We have not enought space for whole string with the trailing zero => print only a part of string */ |
memcpy((void *)(data->string + data->len), (void *)str, i - 1); |
data->string[data->size - 1] = 0; |
data->len = data->size; |
return count; |
} |
/* Buffer is big enought to print whole string */ |
memcpy((void *)(data->string + data->len), (void *)str, count); |
data->len += count; |
/* |
* Put trailing zero at end, but not count it into data->len so it could |
* be rewritten next time. |
*/ |
/* Put trailing zero at end, but not count it into data->len so it could be rewritten next time */ |
data->string[data->len] = 0; |
return count; |
101,22 → 87,17 |
} |
/** Print formatted to the given buffer with limited size. |
* @param str Buffer. |
* @param size Bffer size. |
* @param fmt Format string. |
* @param str buffer |
* @param size buffer size |
* @param fmt format string |
* \see For more details about format string see printf_core. |
*/ |
int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) |
{ |
struct vsnprintf_data data = {size, 0, str}; |
struct printf_spec ps = { |
(int(*)(void *, size_t, void *)) vsnprintf_write, |
&data |
}; |
struct printf_spec ps = {(int(*)(void *, size_t, void *)) vsnprintf_write, &data}; |
/* |
* Print 0 at end of string - fix the case that nothing will be printed. |
*/ |
/* Print 0 at end of string - fix the case that nothing will be printed */ |
if (size > 0) |
str[0] = 0; |
/branches/sparc/uspace/lib/libc/generic/io/sprintf.c |
---|
48,6 → 48,7 |
va_start(args, fmt); |
ret = vsprintf(str, fmt, args); |
va_end(args); |
return ret; |
/branches/sparc/uspace/lib/libc/include/getopt.h |
---|
File deleted |
/branches/sparc/uspace/lib/libc/include/stdio.h |
---|
54,17 → 54,16 |
extern int getchar(void); |
extern int puts(const char *); |
extern int putchar(int); |
extern int puts(const char * str); |
extern int putchar(int c); |
extern int printf(const char *, ...); |
extern int asprintf(char **, const char *, ...); |
extern int sprintf(char *, const char *fmt, ...); |
extern int snprintf(char *, size_t , const char *, ...); |
extern int printf(const char *fmt, ...); |
extern int sprintf(char *str, const char *fmt, ...); |
extern int snprintf(char *str, size_t size, const char *fmt, ...); |
extern int vprintf(const char *, va_list); |
extern int vsprintf(char *, const char *, va_list); |
extern int vsnprintf(char *, size_t, const char *, va_list); |
extern int vprintf(const char *fmt, va_list ap); |
extern int vsprintf(char *str, const char *fmt, va_list ap); |
extern int vsnprintf(char *str, size_t size, const char *fmt, va_list ap); |
#define fprintf(f, fmt, ...) printf(fmt, ##__VA_ARGS__) |
/branches/sparc/uspace/lib/libc/arch/sparc64/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = sparc64-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/sparc64/bin |
TOOLCHAIN_DIR = /usr/local/sparc64/bin |
ARCH_SOURCES += arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/tls.c |
/branches/sparc/uspace/lib/libc/arch/ia64/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = ia64-pc-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia64/bin |
TOOLCHAIN_DIR = /usr/local/ia64/bin |
CFLAGS += -fno-unwind-tables -DMALLOC_ALIGNMENT_16 |
LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a |
AFLAGS += |
/branches/sparc/uspace/lib/libc/arch/arm32/Makefile.inc |
---|
30,12 → 30,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = arm-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm/bin |
TOOLCHAIN_DIR = /usr/local/arm/bin |
CFLAGS += -ffixed-r9 -mtp=soft |
LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a |
AFLAGS += |
/branches/sparc/uspace/lib/libc/arch/ppc32/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = ppc-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/ppc/bin |
TOOLCHAIN_DIR = /usr/local/ppc/bin |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
/branches/sparc/uspace/lib/libc/arch/amd64/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = amd64-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64/bin |
TOOLCHAIN_DIR = /usr/local/amd64/bin |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \ |
arch/$(ARCH)/src/fibril.S \ |
/branches/sparc/uspace/lib/libc/arch/ppc64/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = ppc64-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/ppc64/bin |
TOOLCHAIN_DIR = /usr/local/ppc64/bin |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
/branches/sparc/uspace/lib/libc/arch/mips32/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = mipsel-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mipsel/bin |
TOOLCHAIN_DIR = /usr/local/mipsel/bin |
CFLAGS += -mips3 |
-include ../../Makefile.config |
/branches/sparc/uspace/lib/libc/arch/ia32/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = i686-pc-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/i686/bin |
TOOLCHAIN_DIR = /usr/local/i686/bin |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \ |
arch/$(ARCH)/src/fibril.S \ |
/branches/sparc/uspace/lib/libc/arch/mips32eb/Makefile.inc |
---|
29,12 → 29,8 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = mips-sgi-irix5 |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips/bin |
TOOLCHAIN_DIR = /usr/local/mips/bin |
CFLAGS += -mips3 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
/branches/sparc/uspace/lib/libc/Makefile |
---|
57,7 → 57,6 |
generic/tls.c \ |
generic/task.c \ |
generic/futex.c \ |
generic/io/asprintf.c \ |
generic/io/io.c \ |
generic/io/printf.c \ |
generic/io/stream.c \ |
71,7 → 70,6 |
generic/sysinfo.c \ |
generic/ipc.c \ |
generic/async.c \ |
generic/getopt.c \ |
generic/libadt/list.o \ |
generic/libadt/hash_table.o \ |
generic/time.c \ |
/branches/sparc/uspace/app/bdsh/errors.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/README |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/util.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/errors.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/util.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/TODO |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/exec.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/errstr.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/exec.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/scli.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/Makefile |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/scli.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/input.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/LICENSE |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/input.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/AUTHORS |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/mknewcmd |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/branches/sparc/uspace/app/bdsh/cmds/mod_cmds.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/pwd/pwd.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/pwd/pwd_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/pwd/pwd.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/pwd/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/module_aliases.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/README |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/modules.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/ls/ls_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/ls/ls.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/ls/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/ls/ls.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/rm/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/rm/rm.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/rm/rm_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/rm/rm.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/quit/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/quit/quit.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/quit/quit.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/quit/quit_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/touch/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/touch/touch.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/touch/touch.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/touch/touch_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/mkdir/mkdir.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/mkdir/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/mkdir/mkdir_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/mkdir/mkdir.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/cat/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/cat/cat.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/cat/cat_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/cat/cat.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/help/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/help/help.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/help/help_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/modules/help/help.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/README |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/builtin_aliases.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/builtins.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/cd/cd.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/cd/entry.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/cd/cd_def.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtins/cd/cd.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/cmds.h |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/cmds/builtin_cmds.c |
---|
File deleted |
/branches/sparc/uspace/app/bdsh/config.h |
---|
File deleted |
/branches/sparc/uspace/app/init/init.c |
---|
98,8 → 98,10 |
{ |
info_print(); |
sleep(5); // FIXME |
bool has_tmpfs = false; |
bool has_fat = false; |
if (!mount_fs("tmpfs") && !mount_fs("fat")) { |
if (!(has_tmpfs = mount_fs("tmpfs")) && !(has_fat = mount_fs("fat"))) { |
printf(NAME ": Exiting\n"); |
return -1; |
} |
112,7 → 114,18 |
console_wait(); |
version_print(); |
spawn("/sbin/bdsh"); |
/* |
* Spawn file system servers that were not loaded as init tasks. |
*/ |
if (!has_fat) |
spawn("/sbin/fat"); |
if (!has_tmpfs) |
spawn("/sbin/tmpfs"); |
spawn("/sbin/tetris"); |
spawn("/sbin/cli"); |
// FIXME: spawn("/sbin/tester"); |
spawn("/sbin/klog"); |
return 0; |
} |
/branches/sparc/uspace/app/cli/cli.c |
---|
0,0 → 1,125 |
/* |
* Copyright (c) 2008 Jiri Svoboda |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup cli cli |
* @brief Trivial command-line interface for running programs. |
* @{ |
*/ |
/** |
* @file |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <task.h> |
#define LINE_BUFFER_SIZE 128 |
static char line_buffer[LINE_BUFFER_SIZE]; |
#define MAX_ARGS 16 |
static char *argv_buf[MAX_ARGS + 1]; |
static void read_line(char *buffer, int n) |
{ |
char c; |
int chars; |
printf("> "); |
chars = 0; |
while (chars < n - 1) { |
c = getchar(); |
if (c < 0) exit(0); |
if (c == '\n') break; |
if (c == '\b') { |
if (chars > 0) { |
putchar('\b'); |
--chars; |
} |
continue; |
} |
putchar(c); |
buffer[chars++] = c; |
} |
putchar('\n'); |
buffer[chars] = '\0'; |
} |
static void program_run(void) |
{ |
char *p; |
int n; |
p = line_buffer; |
n = 0; |
while (n < MAX_ARGS) { |
argv_buf[n++] = p; |
p = strchr(p, ' '); |
if (p == NULL) break; |
*p++ = '\0'; |
} |
argv_buf[n] = NULL; |
printf("spawn task '%s' with %d args\n", argv_buf[0], n); |
printf("args:"); |
int i; |
for (i = 0; i < n; ++i) { |
printf(" '%s'", argv_buf[i]); |
} |
printf("\n"); |
task_spawn(argv_buf[0], argv_buf); |
} |
int main(int argc, char *argv[]) |
{ |
printf("This is CLI\n"); |
while (1) { |
read_line(line_buffer, LINE_BUFFER_SIZE); |
printf("'%s'\n", line_buffer); |
if (strcmp(line_buffer, "exit") == 0) |
break; |
if (line_buffer[0] != '\0') |
program_run(); |
} |
printf("Bye\n"); |
return 0; |
} |
/** @} |
*/ |
/branches/sparc/uspace/app/cli/Makefile |
---|
0,0 → 1,86 |
# |
# Copyright (c) 2005 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
include ../../../version |
include ../../Makefile.config |
## Setup toolchain |
# |
LIBC_PREFIX = ../../lib/libc |
SOFTINT_PREFIX = ../../lib/softint |
include $(LIBC_PREFIX)/Makefile.toolchain |
CFLAGS += -I../../srv/kbd/include |
LIBS = $(LIBC_PREFIX)/libc.a |
DEFS += -DRELEASE=\"$(RELEASE)\" |
ifdef REVISION |
DEFS += "-DREVISION=\"$(REVISION)\"" |
endif |
ifdef TIMESTAMP |
DEFS += "-DTIMESTAMP=\"$(TIMESTAMP)\"" |
endif |
## Sources |
# |
OUTPUT = cli |
SOURCES = \ |
cli.c |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
.PHONY: all clean depend disasm |
all: $(OUTPUT) disasm |
-include Makefile.depend |
clean: |
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend |
depend: |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
%.o: %.s |
$(AS) $(AFLAGS) $< -o $@ |
%.o: %.c |
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@ |
/branches/sparc/uspace/Makefile |
---|
48,9 → 48,9 |
srv/devmap \ |
app/tetris \ |
app/tester \ |
app/cli \ |
app/klog \ |
app/init \ |
app/bdsh |
app/init |
ifeq ($(ARCH), amd64) |
DIRS += srv/pci |