1/*
2  FUSE: Filesystem in Userspace
3  Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
4
5  This program can be distributed under the terms of the GNU LGPLv2.
6  See the file COPYING.LIB.
7*/
8
9/** @file */
10
11#if !defined(_FUSE_H_) && !defined(_FUSE_LOWLEVEL_H_)
12#error "Never include <fuse_common.h> directly; use <fuse.h> or <fuse_lowlevel.h> instead."
13#endif
14
15#ifndef _FUSE_COMMON_H_
16#define _FUSE_COMMON_H_
17
18#include "fuse_opt.h"
19#include <stdint.h>
20
21/** Major version of FUSE library interface */
22#define FUSE_MAJOR_VERSION 2
23
24/** Minor version of FUSE library interface */
25#define FUSE_MINOR_VERSION 7
26
27#define FUSE_MAKE_VERSION(maj, min)  ((maj) * 10 + (min))
28#define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * Information about open files
36 *
37 * Changed in version 2.5
38 */
39struct fuse_file_info {
40	/** Open flags.	 Available in open() and release() */
41	int flags;
42
43	/** Old file handle, don't use */
44	unsigned long fh_old;
45
46	/** In case of a write operation indicates if this was caused by a
47	    writepage */
48	int writepage;
49
50	/** Can be filled in by open, to use direct I/O on this file.
51	    Introduced in version 2.4 */
52	unsigned int direct_io : 1;
53
54	/** Can be filled in by open, to indicate, that cached file data
55	    need not be invalidated.  Introduced in version 2.4 */
56	unsigned int keep_cache : 1;
57
58	/** Indicates a flush operation.  Set in flush operation, also
59	    maybe set in highlevel lock operation and lowlevel release
60	    operation.	Introduced in version 2.6 */
61	unsigned int flush : 1;
62
63	/** Padding.  Do not use*/
64	unsigned int padding : 29;
65
66	/** File handle.  May be filled in by filesystem in open().
67	    Available in all other file operations */
68	uint64_t fh;
69
70	/** Lock owner id.  Available in locking operations and flush */
71	uint64_t lock_owner;
72};
73
74/**
75 * Connection information, passed to the ->init() method
76 *
77 * Some of the elements are read-write, these can be changed to
78 * indicate the value requested by the filesystem.  The requested
79 * value must usually be smaller than the indicated value.
80 */
81struct fuse_conn_info {
82	/**
83	 * Major version of the protocol (read-only)
84	 */
85	unsigned proto_major;
86
87	/**
88	 * Minor version of the protocol (read-only)
89	 */
90	unsigned proto_minor;
91
92	/**
93	 * Is asynchronous read supported (read-write)
94	 */
95	unsigned async_read;
96
97	/**
98	 * Maximum size of the write buffer
99	 */
100	unsigned max_write;
101
102	/**
103	 * Maximum readahead
104	 */
105	unsigned max_readahead;
106
107	/**
108	 * For future use.
109	 */
110	unsigned reserved[27];
111    };
112
113struct fuse_session;
114struct fuse_chan;
115
116/**
117 * Create a FUSE mountpoint
118 *
119 * Returns a control file descriptor suitable for passing to
120 * fuse_new()
121 *
122 * @param mountpoint the mount point path
123 * @param args argument vector
124 * @return the communication channel on success, NULL on failure
125 */
126struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
127
128/**
129 * Umount a FUSE mountpoint
130 *
131 * @param mountpoint the mount point path
132 * @param ch the communication channel
133 */
134void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
135
136/**
137 * Get the version of the library
138 *
139 * @return the version
140 */
141int fuse_version(void);
142
143/* ----------------------------------------------------------- *
144 * Signal handling					       *
145 * ----------------------------------------------------------- */
146
147/**
148 * Exit session on HUP, TERM and INT signals and ignore PIPE signal
149 *
150 * Stores session in a global variable.	 May only be called once per
151 * process until fuse_remove_signal_handlers() is called.
152 *
153 * @param se the session to exit
154 * @return 0 on success, -1 on failure
155 */
156int fuse_set_signal_handlers(struct fuse_session *se);
157
158/**
159 * Restore default signal handlers
160 *
161 * Resets global session.  After this fuse_set_signal_handlers() may
162 * be called again.
163 *
164 * @param se the same session as given in fuse_set_signal_handlers()
165 */
166void fuse_remove_signal_handlers(struct fuse_session *se);
167
168#ifdef __cplusplus
169}
170#endif
171
172#endif /* _FUSE_COMMON_H_ */
173