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)) {
62 stop(int argc, char *argv[1])
64 if (!getenv("SHUTDOWN"))
71 done(int argc, char *argv[1])
73 struct volume *v = volume_find("rootfs_data");
78 switch (volume_identify(v)) {
81 return jffs2_switch(v);
87 int main(int argc, char **argv)
90 return start(argc, argv);
91 if (!strcmp(argv[1], "stop"))
92 return stop(argc, argv);
93 if (!strcmp(argv[1], "done"))
94 return done(argc, argv);