940c504dc8341a3de6ce6e542b9732a28200ec87
[project/fstools.git] / libfstools / libfstools.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 #include <libubox/ulog.h>
20
21 struct volume;
22
23 enum {
24         FS_NONE,
25         FS_SNAPSHOT,
26         FS_JFFS2,
27         FS_DEADCODE,
28         FS_UBIFS,
29         FS_EXT4FS,
30 };
31
32 enum fs_state {
33         FS_STATE_UNKNOWN,
34         FS_STATE_PENDING,
35         FS_STATE_READY,
36         __FS_STATE_LAST = FS_STATE_READY,
37 };
38
39 extern char const *extroot_prefix;
40 extern int mount_extroot(void);
41 extern int mount_snapshot(struct volume *v);
42 extern int mount_overlay(struct volume *v);
43
44 extern int mount_move(char *oldroot, char *newroot, char *dir);
45 extern int pivot(char *new, char *old);
46 extern int fopivot(char *rw_root, char *ro_root);
47 extern int ramoverlay(void);
48
49 extern int find_overlay_mount(char *overlay);
50 extern char* find_mount(char *mp);
51 extern char* find_mount_point(char *block, int mtd_only);
52 extern int find_filesystem(char *fs);
53
54 extern int jffs2_switch(struct volume *v);
55
56 extern int handle_whiteout(const char *dir);
57 extern void foreachdir(const char *dir, int (*cb)(const char*));
58
59 extern void overlay_delete(const char *dir, bool keep_sysupgrade);
60
61 enum fs_state fs_state_get(const char *dir);
62 int fs_state_set(const char *dir, enum fs_state state);
63
64 #endif