summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2011-01-18 17:37:41 -0800
committerKen Sumrall <ksumrall@android.com>2011-01-18 17:39:24 -0800
commit203bad597fb4e46ddda051add28400070b5c3a5a (patch)
tree9745cb1b6856fc88babaa9d60e348f4c3e3c83dd /init
parent108d3d74a805ad15d2cd2db47dad86f1082a59ba (diff)
downloadsystem_core-203bad597fb4e46ddda051add28400070b5c3a5a.zip
system_core-203bad597fb4e46ddda051add28400070b5c3a5a.tar.gz
system_core-203bad597fb4e46ddda051add28400070b5c3a5a.tar.bz2
Add the commands rm and rmdir to init.
rm only removes a single non-directory directory entry (no -r support) rmdir removes a single empty directory Change-Id: I49702b02ba98a177027b126268c2c2846f968195
Diffstat (limited to 'init')
-rw-r--r--init/builtins.c10
-rw-r--r--init/init_parser.c2
-rw-r--r--init/keywords.h4
3 files changed, 16 insertions, 0 deletions
diff --git a/init/builtins.c b/init/builtins.c
index 915c5aa..490ad48 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -485,6 +485,16 @@ int do_symlink(int nargs, char **args)
return symlink(args[1], args[2]);
}
+int do_rm(int nargs, char **args)
+{
+ return unlink(args[1]);
+}
+
+int do_rmdir(int nargs, char **args)
+{
+ return rmdir(args[1]);
+}
+
int do_sysclktz(int nargs, char **args)
{
struct timezone tz;
diff --git a/init/init_parser.c b/init/init_parser.c
index 00e6b9e..0898ae8 100644
--- a/init/init_parser.c
+++ b/init/init_parser.c
@@ -125,6 +125,8 @@ int lookup_keyword(const char *s)
break;
case 'r':
if (!strcmp(s, "estart")) return K_restart;
+ if (!strcmp(s, "mdir")) return K_rmdir;
+ if (!strcmp(s, "m")) return K_rm;
break;
case 's':
if (!strcmp(s, "ervice")) return K_service;
diff --git a/init/keywords.h b/init/keywords.h
index d15ad49..c977fd7 100644
--- a/init/keywords.h
+++ b/init/keywords.h
@@ -15,6 +15,8 @@ int do_import(int nargs, char **args);
int do_mkdir(int nargs, char **args);
int do_mount(int nargs, char **args);
int do_restart(int nargs, char **args);
+int do_rm(int nargs, char **args);
+int do_rmdir(int nargs, char **args);
int do_setkey(int nargs, char **args);
int do_setprop(int nargs, char **args);
int do_setrlimit(int nargs, char **args);
@@ -59,6 +61,8 @@ enum {
KEYWORD(oneshot, OPTION, 0, 0)
KEYWORD(onrestart, OPTION, 0, 0)
KEYWORD(restart, COMMAND, 1, do_restart)
+ KEYWORD(rm, COMMAND, 1, do_rm)
+ KEYWORD(rmdir, COMMAND, 1, do_rmdir)
KEYWORD(service, SECTION, 0, 0)
KEYWORD(setenv, OPTION, 2, 0)
KEYWORD(setkey, COMMAND, 0, do_setkey)