6bb503e82aa446d3f344f044eaa65d721a2d9abe
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 "../fs-state.h"
20 #include "../driver/volume.h"
23 backend_mount(char *name
)
25 struct backend
*b
= find_backend(name
);
34 backend_info(char *name
)
36 struct backend
*b
= find_backend(name
);
45 start(int argc
, char **argv
)
47 struct volume
*v
= volume_find("rootfs_data");
49 if (!getenv("PREINIT"))
53 v
= volume_find("rootfs");
55 fprintf(stderr
, "mounting /dev/root\n");
56 mount("/dev/root", "/", NULL
, MS_NOATIME
| MS_REMOUNT
, 0);
61 if (!backend_mount("extroot")) {
62 fprintf(stderr
, "fs-state: switched to extroot\n");
66 switch (volume_identify(v
)) {
72 backend_mount("overlay");
76 backend_mount("snapshot");
84 stop(int argc
, char **argv
)
86 if (!getenv("SHUTDOWN"))
93 done(int argc
, char **argv
)
95 struct volume
*v
= volume_find("rootfs_data");
100 switch (volume_identify(v
)) {
103 return jffs2_switch(argc
, argv
);
110 info(int argc
, char **argv
)
112 struct volume
*v
= volume_find("rootfs_data");
117 switch (volume_identify(v
)) {
119 backend_info("snapshot");
126 static struct backend start_backend
= {
130 BACKEND(start_backend
);
132 static struct backend stop_backend
= {
136 BACKEND(stop_backend
);
138 static struct backend done_backend
= {
142 BACKEND(done_backend
);
144 static struct backend info_backend
= {
148 BACKEND(info_backend
);