diff --git a/apps/sh/shell.c b/apps/sh/shell.c index 89fc6b8..a025ea4 100644 --- a/apps/sh/shell.c +++ b/apps/sh/shell.c @@ -34,7 +34,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -71,7 +72,8 @@ struct cmd_t *cmds[] = &cmd_boneshell, &cmd_exit, &cmd_pwd, - &cmd_logname + &cmd_logname, + &cmd_uname ,0 }; @@ -79,7 +81,8 @@ void init_terminal() { assertkm(device_initalized(KBD_DRIVER_INDEX) , "Keyboard not intalized for starting shell!"); TERMINAL_MODE=true; - cmds[CMD_BONEOS_LOGO_INDEX]->handler("boneos_logo"); + //cmds[CMD_BONEOS_LOGO_INDEX]->handler("boneos_logo"); + printk ("%s release %s started.\n", VAR_OSNAME, VAR_RELEASE); cmds[CMD_BONESHELL_INDEX]->handler("boneshell"); TERMINAL_MODE=false; } diff --git a/apps/sh/values.c b/apps/sh/values.c index c72f73f..81d2fba 100644 --- a/apps/sh/values.c +++ b/apps/sh/values.c @@ -15,16 +15,19 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ - + **/ + #include -#include +#include char* VAR_USER = "root"; -char* VAR_PWD = "/"; +char* VAR_PWD = "/"; +char* VAR_RELEASE = "0.0.1"; +char* VAR_OSNAME = "BoneOS"; +char* VAR_PLATFORM = "x86_32"; diff --git a/bin/Makefile b/bin/Makefile index d4ea1a8..e8dbfd5 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -20,6 +20,8 @@ CSRCS = \ pwd/opts/main_pwd.c \ logname/logname.c \ logname/opts/main_logname.c \ + uname/uname.c \ + uname/opts/main_uname.c \ boneshell/boneshell.c LIBNAME := bin diff --git a/bin/boneshell/boneshell.c b/bin/boneshell/boneshell.c index d25861d..de1c65a 100644 --- a/bin/boneshell/boneshell.c +++ b/bin/boneshell/boneshell.c @@ -67,7 +67,10 @@ void removeSpaces(char* source) void loop_terminal() { shell_instance_cnt+=1; - printk("SHELL INSTANCE #%d\n",shell_instance_cnt); + if (shell_instance_cnt != 1) + { + printk("New shell instance #%d\n",shell_instance_cnt); + } while(1) { start_shell:; @@ -110,7 +113,7 @@ void loop_terminal() if(strcmp(cmd_active.value, "exit")==0) { shell_instance_cnt-=1; - printk("EXITED SHELL INSTANCE #%d\n",shell_instance_cnt+1); + printk("Exited shell instance #%d\n",shell_instance_cnt+1); goto end_shell; } @@ -121,7 +124,6 @@ void loop_terminal() if(executed_internally==true) { executed_internally=false; - printk("EXECUTED INTERNALLY\n"); } cmds[i]->handler(cmd_active.value); __found = 1; diff --git a/bin/uname/opts/main_uname.c b/bin/uname/opts/main_uname.c new file mode 100644 index 0000000..77665db --- /dev/null +++ b/bin/uname/opts/main_uname.c @@ -0,0 +1,80 @@ +/** + ** This file is part of BoneOS. + ** + ** BoneOS is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + + ** BoneOS is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + + ** You should have received a copy of the GNU General Public License + ** along with BoneOS. If not, see . + ** + ** @main_author : Ashish Ahuja + ** + ** @contributors: + + ** Ashish Ahuja: start + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main_uname_opt_handler (char *cmd) +{ + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd,opts); + + if (num_opts == 1) + { + printk ("%s\n", VAR_OSNAME); + return STATUS_OK; + } + else if (num_opts > 1) + { + if (strcmp (opts [1].str, "--help") == 0) + { + printk (cmd_uname.help); + return STATUS_OK; + } + else if (strcmp (opts [1].str, "-a") == 0) + { + printk ("%s %s %s\n", VAR_OSNAME, VAR_RELEASE, VAR_PLATFORM); + return STATUS_OK; + } + else if (strcmp (opts [1].str, "-p") == 0) + { + printk ("%s\n", VAR_PLATFORM); + return STATUS_OK; + } + else if (strcmp (opts [1].str, "-r") == 0) + { + printk ("%s\n", VAR_RELEASE); + return STATUS_OK; + } + else if (strcmp (opts [1].str, "-n") == 0) + { + printk ("%s\n", VAR_OSNAME); + return STATUS_OK; + } + else + { + printk (cmd_uname.invalid_use_msg); + return STATUS_OK; + } + } + + return STATUS_OK; +} diff --git a/bin/uname/uname.c b/bin/uname/uname.c index e69de29..1613684 100644 --- a/bin/uname/uname.c +++ b/bin/uname/uname.c @@ -0,0 +1,67 @@ +/** + ** This file is part of BoneOS. + ** + ** BoneOS is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + + ** BoneOS is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + + ** You should have received a copy of the GNU General Public License + ** along with BoneOS. If not, see . + ** + ** @main_author : Ashish Ahuja + ** + ** @contributors: + + ** Ashish Ahuja: start + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct cmd_opt_t* cmd_uname_opts[] = +{ + 0 +}; + +int cmd_uname_handler (char *cmd) +{ + main_uname_opt_handler (cmd); + return STATUS_OK; +} + +struct cmd_t cmd_uname = +{ + .name = "uname", + .usage ="uname", + .help = "uname(1) \t\t\t\t BoneOS Terminal Manual \n" + "NAME : \n " + "\tuname\n" + "SYNOPSIS : \n " + "\tuname [option]\n" + "DESCRIPTION : \n " + "\tPrints out information about the OS.\n" + "OPTIONS : \n " + "\t Option Summary \n " + "\t\t [-n] : prints the OS name\n " + "\t\t [-a] : prints all the options\n " + "\t\t [-r] : prints the current release\n " + "\t\t [-p] : prints the current hardware platform\n", + .cmd_opts = cmd_uname_opts, + .handler = &cmd_uname_handler, + .invalid_use_msg = "Invalid use of uname command.\n" + "Type in uname --help for more help.\n", + .privilege = USER +}; diff --git a/include/apps/sh/values.h b/include/apps/sh/values.h index 08eddaa..7dd5117 100644 --- a/include/apps/sh/values.h +++ b/include/apps/sh/values.h @@ -1,11 +1,14 @@ #ifndef _APPS_TERM_VALUES_H_ #define _APPS_TERM_VALUES_H_ -#include +#include extern char* VAR_USER; -extern char* VAR_PWD; +extern char* VAR_PWD; +extern char* VAR_RELEASE; +extern char* VAR_OSNAME; +extern char* VAR_PLATFORM; extern struct values __values; diff --git a/include/bin/uname/opts/main_uname.h b/include/bin/uname/opts/main_uname.h new file mode 100644 index 0000000..5c825bc --- /dev/null +++ b/include/bin/uname/opts/main_uname.h @@ -0,0 +1,6 @@ +#ifndef _BIN_UNAME_MAINOPT_H_ +#define _BIN_UNAME_MAINOPT_H_ + +int main_uname_opt_handler (char *cmd); + +#endif diff --git a/include/bin/uname/uname.h b/include/bin/uname/uname.h new file mode 100644 index 0000000..4dbe4bb --- /dev/null +++ b/include/bin/uname/uname.h @@ -0,0 +1,6 @@ +#ifndef _BIN_UNAME_H_ +#define _BIN_UNAME_H_ + +extern struct cmd_t cmd_uname; + +#endif