e281c0b9ee978810612dfef2ba8a3718f13f98cc
2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <sys/mount.h>
18 #include "libfstools/libfstools.h"
19 #include "libfstools/volume.h"
22 start(int argc
, char *argv
[1])
24 struct volume
*v
= volume_find("rootfs_data");
26 if (!getenv("PREINIT"))
30 v
= volume_find("rootfs");
32 fprintf(stderr
, "mounting /dev/root\n");
33 mount("/dev/root", "/", NULL
, MS_NOATIME
| MS_REMOUNT
, 0);
38 if (!mount_extroot()) {
39 fprintf(stderr
, "fs-state: switched to extroot\n");
43 switch (volume_identify(v
)) {
61 stop(int argc
, char *argv
[1])
63 if (!getenv("SHUTDOWN"))
70 done(int argc
, char *argv
[1])
72 struct volume
*v
= volume_find("rootfs_data");
77 switch (volume_identify(v
)) {
80 return jffs2_switch(argc
, argv
);
86 int main(int argc
, char **argv
)
89 return start(argc
, argv
);
90 if (!strcmp(argv
[1], "stop"))
91 return stop(argc
, argv
);
92 if (!strcmp(argv
[1], "done"))
93 return done(argc
, argv
);