move files around
[project/fstools.git] / fs-state.h
1 /*
2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
3 *
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
7 *
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.
12 */
13
14 #ifndef _FS_STATE_H__
15 #define _FS_STATE_H__
16
17 #include <libubox/list.h>
18 #include <libubox/blob.h>
19
20 enum {
21 FS_NONE,
22 FS_SNAPSHOT,
23 FS_JFFS2,
24 FS_DEADCODE,
25 };
26
27 typedef int (*backend_cli_t)(int argc, char **argv);
28 typedef int (*backend_mount_t)(void);
29 typedef int (*backend_info_t)(void);
30
31 extern char const *extroot_prefix;
32
33 struct backend_handler
34 {
35 char *name;
36 char *desc;
37 backend_cli_t cli;
38 };
39
40 struct backend
41 {
42 struct list_head list;
43 char *name;
44 char *desc;
45 int num_handlers;
46 backend_cli_t cli;
47 backend_mount_t mount;
48 backend_info_t info;
49 struct backend_handler *handlers;
50 };
51
52 void register_backend(struct backend *);
53 struct backend* find_backend(char *);
54 int backend_mount(char *name);
55
56 #define BACKEND(x) \
57 static void __attribute__((constructor)) \
58 register_##x(void) { \
59 register_backend(&x); \
60 }
61
62 int mount_move(char *oldroot, char *newroot, char *dir);
63 int pivot(char *new, char *old);
64 int fopivot(char *rw_root, char *ro_root);
65 int ramoverlay(void);
66
67 int find_overlay_mount(char *overlay);
68 char* find_mount(char *mp);
69 char* find_mount_point(char *block, char *fs);
70 int find_filesystem(char *fs);
71 int find_mtd_block(char *name, char *part, int plen);
72 int find_mtd_char(char *name, char *part, int plen);
73
74 int jffs2_ready(char *mtd);
75 int jffs2_switch(int argc, char **argv);
76
77 int handle_whiteout(const char *dir);
78 void foreachdir(const char *dir, int (*cb)(const char*));
79
80 #endif