summaryrefslogtreecommitdiff
path: root/include/fuse-lite/fuse_common.h (plain)
blob: 69d3c973f8c4e1fbcf87330b0be0661696cbede8
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/* This interface uses 64 bit off_t */
36#if defined(__SOLARIS__) && !defined(__x86_64__) && (_FILE_OFFSET_BITS != 64)
37#error Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#ifdef POSIXACLS
45/*
46 * FUSE_CAP_DONT_MASK: don't apply umask to file mode on create operations
47 */
48#define FUSE_CAP_DONT_MASK (1 << 6)
49#endif
50
51#define FUSE_CAP_BIG_WRITES (1 << 5)
52
53/**
54 * Information about open files
55 *
56 * Changed in version 2.5
57 */
58struct fuse_file_info {
59 /** Open flags. Available in open() and release() */
60 int flags;
61
62 /** Old file handle, don't use */
63 unsigned long fh_old;
64
65 /** In case of a write operation indicates if this was caused by a
66 writepage */
67 int writepage;
68
69 /** Can be filled in by open, to use direct I/O on this file.
70 Introduced in version 2.4 */
71 unsigned int direct_io : 1;
72
73 /** Can be filled in by open, to indicate, that cached file data
74 need not be invalidated. Introduced in version 2.4 */
75 unsigned int keep_cache : 1;
76
77 /** Indicates a flush operation. Set in flush operation, also
78 maybe set in highlevel lock operation and lowlevel release
79 operation. Introduced in version 2.6 */
80 unsigned int flush : 1;
81
82 /** Padding. Do not use*/
83 unsigned int padding : 29;
84
85 /** File handle. May be filled in by filesystem in open().
86 Available in all other file operations */
87 uint64_t fh;
88
89 /** Lock owner id. Available in locking operations and flush */
90 uint64_t lock_owner;
91};
92
93/**
94 * Connection information, passed to the ->init() method
95 *
96 * Some of the elements are read-write, these can be changed to
97 * indicate the value requested by the filesystem. The requested
98 * value must usually be smaller than the indicated value.
99 */
100struct fuse_conn_info {
101 /**
102 * Major version of the protocol (read-only)
103 */
104 unsigned proto_major;
105
106 /**
107 * Minor version of the protocol (read-only)
108 */
109 unsigned proto_minor;
110
111 /**
112 * Is asynchronous read supported (read-write)
113 */
114 unsigned async_read;
115
116 /**
117 * Maximum size of the write buffer
118 */
119 unsigned max_write;
120
121 /**
122 * Maximum readahead
123 */
124 unsigned max_readahead;
125
126 unsigned capable;
127 unsigned want;
128 /**
129 * For future use.
130 */
131 unsigned reserved[25];
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#ifdef __SOLARIS__
158/**
159 * Parse common options
160 *
161 * The following options are parsed:
162 *
163 * '-f' foreground
164 * '-d' '-odebug' foreground, but keep the debug option
165 * '-s' single threaded
166 * '-h' '--help' help
167 * '-ho' help without header
168 * '-ofsname=..' file system name, if not present, then set to the program
169 * name
170 *
171 * All parameters may be NULL
172 *
173 * @param args argument vector
174 * @param mountpoint the returned mountpoint, should be freed after use
175 * @param multithreaded set to 1 unless the '-s' option is present
176 * @param foreground set to 1 if one of the relevant options is present
177 * @return 0 on success, -1 on failure
178 */
179int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
180 int *multithreaded, int *foreground);
181
182/**
183 * Go into the background
184 *
185 * @param foreground if true, stay in the foreground
186 * @return 0 on success, -1 on failure
187 */
188int fuse_daemonize(int foreground);
189
190#endif /* __SOLARIS__ */
191
192/**
193 * Get the version of the library
194 *
195 * @return the version
196 */
197int fuse_version(void);
198
199/* ----------------------------------------------------------- *
200 * Signal handling *
201 * ----------------------------------------------------------- */
202
203/**
204 * Exit session on HUP, TERM and INT signals and ignore PIPE signal
205 *
206 * Stores session in a global variable. May only be called once per
207 * process until fuse_remove_signal_handlers() is called.
208 *
209 * @param se the session to exit
210 * @return 0 on success, -1 on failure
211 */
212int fuse_set_signal_handlers(struct fuse_session *se);
213
214/**
215 * Restore default signal handlers
216 *
217 * Resets global session. After this fuse_set_signal_handlers() may
218 * be called again.
219 *
220 * @param se the same session as given in fuse_set_signal_handlers()
221 */
222void fuse_remove_signal_handlers(struct fuse_session *se);
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif /* _FUSE_COMMON_H_ */
229