xref: /nrf52832-nimble/rt-thread/components/dfs/filesystems/uffs/src/inc/uffs/uffs_mtb.h (revision 104654410c56c573564690304ae786df310c91fc)
1 /*
2   This file is part of UFFS, the Ultra-low-cost Flash File System.
3 
4   Copyright (C) 2005-2009 Ricky Zheng <[email protected]>
5 
6   UFFS is free software; you can redistribute it and/or modify it under
7   the GNU Library General Public License as published by the Free Software
8   Foundation; either version 2 of the License, or (at your option) any
9   later version.
10 
11   UFFS is distributed in the hope that it will be useful, but WITHOUT
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   or GNU Library General Public License, as applicable, for more details.
15 
16   You should have received a copy of the GNU General Public License
17   and GNU Library General Public License along with UFFS; if not, write
18   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19   Boston, MA  02110-1301, USA.
20 
21   As a special exception, if other files instantiate templates or use
22   macros or inline functions from this file, or you compile this file
23   and link it with other works to produce a work based on this file,
24   this file does not by itself cause the resulting work to be covered
25   by the GNU General Public License. However the source code for this
26   file must still be made available in accordance with section (3) of
27   the GNU General Public License v2.
28 
29   This exception does not invalidate any other reasons why a work based
30   on this file might be covered by the GNU General Public License.
31 */
32 
33 /**
34  * \file uffs_mtb.h
35  * \brief mount table related stuff
36  * \author Ricky Zheng
37  */
38 
39 #ifndef _UFFS_MTB_H_
40 #define _UFFS_MTB_H_
41 
42 #include "uffs/uffs_types.h"
43 #include "uffs/uffs_core.h"
44 #include "uffs/uffs.h"
45 
46 #ifdef __cplusplus
47 extern "C"{
48 #endif
49 
50 
51 typedef struct uffs_MountTableEntrySt {
52 	uffs_Device *dev;		// UFFS 'device' - core internal data structure for partition
53 	int start_block;		// partition start block
54 	int end_block;			// partition end block ( if < 0, reserve space form the end of storage)
55 	const char *mount;		// mount point
56 	struct uffs_MountTableEntrySt *prev;
57 	struct uffs_MountTableEntrySt *next;
58 } uffs_MountTable;
59 
60 /** Register mount entry, will be put at 'unmounted' list */
61 int uffs_RegisterMountTable(uffs_MountTable *mtb);
62 
63 /** Remove mount entry from the list */
64 int uffs_UnRegisterMountTable(uffs_MountTable *mtb);
65 
66 /** mount partition */
67 int uffs_Mount(const char *mount);
68 
69 /** unmount parttion */
70 int uffs_UnMount(const char *mount);
71 
72 /** get mounted entry list */
73 uffs_MountTable * uffs_MtbGetMounted(void);
74 
75 /** get unmounted entry list */
76 uffs_MountTable * uffs_MtbGetUnMounted(void);
77 
78 /** get matched mount point from absolute path */
79 int uffs_GetMatchedMountPointSize(const char *path);
80 
81 /** get uffs device from mount point */
82 uffs_Device * uffs_GetDeviceFromMountPoint(const char *mount);
83 
84 /** get uffs device from mount point */
85 uffs_Device * uffs_GetDeviceFromMountPointEx(const char *mount, int len);
86 
87 /** get mount point name from uffs device */
88 const char * uffs_GetDeviceMountPoint(uffs_Device *dev);
89 
90 /** down crease uffs device references by uffs_GetDeviceXXX() */
91 void uffs_PutDevice(uffs_Device *dev);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 #endif
97