Signed-off-by: John Crispin <blogic@openwrt.org>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libubox/ulog.h>
#include <fcntl.h>
#include <libubox/ulog.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libfstools/libfstools.h"
#include "libfstools/volume.h"
#include "libfstools/libfstools.h"
#include "libfstools/volume.h"
static int jffs2_mark(struct volume *v);
static int
static int jffs2_mark(struct volume *v);
static int
-ask_user(int argc, char **argv)
- if ((argc < 2) || strcmp(argv[1], "-y")) {
- ULOG_WARN("This will erase all settings and remove any installed packages. Are you sure? [N/y]\n");
- if (getchar() != 'y')
- return -1;
- }
+ ULOG_WARN("This will erase all settings and remove any installed packages. Are you sure? [N/y]\n");
+ if (getchar() != 'y')
+ return -1;
-static int jffs2_reset(struct volume *v)
+static int jffs2_reset(struct volume *v, int reset)
+ if (reset) {
+ sync();
+ sleep(2);
+ reboot(RB_AUTOBOOT);
+ while (1)
+ ;
+ }
+
int main(int argc, char **argv)
{
struct volume *v;
int main(int argc, char **argv)
{
struct volume *v;
+ int ch, yes = 0, reset = 0;
+ while ((ch = getopt(argc, argv, "yr")) != -1) {
+ switch(ch) {
+ case 'y':
+ yes = 1;
+ break;
+ case 'r':
+ reset = 1;
+ break;
+ }
+
+ }
- if (ask_user(argc, argv))
+ if (!yes && ask_user())
if (!strcmp(*argv, "jffs2mark"))
return jffs2_mark(v);
if (!strcmp(*argv, "jffs2mark"))
return jffs2_mark(v);
+ return jffs2_reset(v, reset);