summaryrefslogtreecommitdiff
path: root/src/libs/uio/physical.h
blob: 71bc8e6aaf4a2400d3f1c73907575c54c9739c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright (C) 2003  Serge van den Boom
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 * Nota bene: later versions of the GNU General Public License do not apply
 * to this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef LIBS_UIO_PHYSICAL_H_
#define LIBS_UIO_PHYSICAL_H_

#ifndef uio_INTERNAL_PHYSICAL
typedef void *uio_PRootExtra;
typedef void *uio_NativeEntriesContext;
#endif

// 'forward' declarations
typedef struct uio_PRoot uio_PRoot;
typedef struct uio_PRoot_CloseHandler uio_PRoot_CloseHandler;


#include "iointrn.h"
#include "uioport.h"
#include "fstypes.h"


/*
 * Represents the root of a physical directory structure.
 */
struct uio_PRoot {
	int mountRef;
			/* Number of times this structure is referenced from
			 * mount trees. */
	int handleRef;
			/* Number of file or directory handles that point inside the
			 * physical directory strucure of this pRoot.
			 */
	struct uio_PDirHandle *rootDir;
	struct uio_FileSystemHandler *handler;
			/* How to handle files in this PRoot tree */
	int flags;
#		define uio_PRoot_NOCACHE 0x0002
	struct uio_Handle *handle;
			/* The handle through which this PRoot is opened,
			 * this is NULL for the top PRoot */
			// TODO: move this to extra?
#ifdef uio_PROOT_HAVE_CLOSE_HANDLERS
	int numCloseHandlers;
	uio_PRoot_CloseHandler *closeHandlers;
#endif
	uio_PRootExtra extra;
			/* extra internal data for some filesystem types */
};

#ifdef uio_PROOT_HAVE_CLOSE_HANDLERS
struct uio_PRoot_CloseHandler {
	void (*fun)(void *);
	void *arg;
};
#endif

void uio_PRoot_deletePRootExtra(uio_PRoot *pRoot);
uio_PRoot *uio_PRoot_new(uio_PDirHandle *topDirHandle,
		uio_FileSystemHandler *handler, uio_Handle *handle,
		uio_PRootExtra extra, int flags);
#ifdef uio_PROOT_HAVE_CLOSE_HANDLERS
void uio_PRoot_addCloseHandler(uio_PRoot *pRoot, void (*fun)(void *),
		void *arg);
void uio_PRoot_callCloseHandlers(uio_PRoot *pRoot);
void uio_PRoot_removeCloseHandlers(uio_PRoot *pRoot);
#endif
uio_PDirHandle *uio_PRoot_getRootDirHandle(uio_PRoot *pRoot);
void uio_PRoot_refHandle(uio_PRoot *pRoot);
void uio_PRoot_unrefHandle(uio_PRoot *pRoot);
void uio_PRoot_refMount(uio_PRoot *pRoot);
void uio_PRoot_unrefMount(uio_PRoot *pRoot);

#endif  /* LIBS_UIO_PHYSICAL_H_  */