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