Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

10.5: Until I overhaul session management, prevent multiple concurren…

…t file systems from a single process.

git-svn-id: http://macfuse.googlecode.com/svn/trunk@921 febdc8c4-1326-0410-abd6-27cb15717650
  • Loading branch information...
commit 9fe8fb92011b951b0b6101243f79e4e2869eb667 1 parent 4173046
authored May 01, 2008
4  include/Makefile.am
@@ -4,8 +4,10 @@ fuseincludedir=$(includedir)/fuse
4 4
 
5 5
 if DARWIN
6 6
 darwin_headers = fuse_darwin.h
  7
+darwin_headers_private = fuse_darwin_private.h
7 8
 else
8 9
 darwin_headers =
  10
+darwin_headers_private =
9 11
 endif
10 12
 
11 13
 fuseinclude_HEADERS = \
@@ -20,4 +22,4 @@ fuseinclude_HEADERS = \
20 22
 
21 23
 include_HEADERS = old/fuse.h ulockmgr.h
22 24
 
23  
-noinst_HEADERS = fuse_kernel.h
  25
+noinst_HEADERS = fuse_kernel.h $(darwin_headers_private)
4  include/Makefile.in
@@ -183,7 +183,9 @@ top_builddir = @top_builddir@
183 183
 top_srcdir = @top_srcdir@
184 184
 fuseincludedir = $(includedir)/fuse
185 185
 @DARWIN_FALSE@darwin_headers = 
  186
+@DARWIN_FALSE@darwin_headers_private =
186 187
 @DARWIN_TRUE@darwin_headers = fuse_darwin.h
  188
+@DARWIN_TRUE@darwin_headers_private = fuse_darwin_private.h
187 189
 fuseinclude_HEADERS = \
188 190
 	$(darwin_headers)	\
189 191
 	fuse.h			\
@@ -195,7 +197,7 @@ fuseinclude_HEADERS = \
195 197
 	fuse_opt.h
196 198
 
197 199
 include_HEADERS = old/fuse.h ulockmgr.h
198  
-noinst_HEADERS = fuse_kernel.h
  200
+noinst_HEADERS = fuse_kernel.h $(darwin_headers_private)
199 201
 all: config.h
200 202
 	$(MAKE) $(AM_MAKEFLAGS) all-am
201 203
 
16  include/fuse_darwin.h
@@ -83,20 +83,10 @@ typedef fuse_sem_t sem_t;
83 83
 
84 84
 const char *macfuse_version(void);
85 85
 
86  
-/* Kernel */
  86
+/* Advanced */
87 87
 
88  
-#ifdef DARWIN_KERNEL_COMMON
89  
-
90  
-#include <fuse_param.h>
91  
-#include <fuse_ioctl.h>
92  
-#include <fuse_version.h>
93  
-
94  
-#endif /* DARWIN_KERNEL_COMMON */
95  
-
96  
-int  fuse_knote_path_np(const char *path, uint32_t note);
97  
-int  fuse_purge_path_np(const char *path);
98  
-int  fuse_purge_path_set_size_np(const char *path, off_t newsize);
99  
-long fuse_os_version_major(void);
  88
+int fuse_knote_path_np(const char *path, uint32_t note);
  89
+int fuse_purge_path_np(const char *path, off_t *newsize);
100 90
 
101 91
 #ifdef __cplusplus
102 92
 }
31  include/fuse_darwin_private.h
... ...
@@ -0,0 +1,31 @@
  1
+/*
  2
+ * Copyright (C) 2006-2008 Google. All Rights Reserved.
  3
+ * Amit Singh <singh@>
  4
+ */
  5
+
  6
+#if (__FreeBSD__ >= 10)
  7
+
  8
+#ifndef _FUSE_DARWIN_PRIVATE_H_
  9
+#define _FUSE_DARWIN_PRIVATE_H_
  10
+
  11
+#ifdef __cplusplus
  12
+extern "C" {
  13
+#endif
  14
+
  15
+#include "fuse_lowlevel.h"
  16
+#include "fuse_darwin.h"
  17
+
  18
+#include <fuse_param.h>
  19
+#include <fuse_ioctl.h>
  20
+#include <fuse_version.h>
  21
+
  22
+#ifdef __cplusplus
  23
+}
  24
+#endif
  25
+
  26
+fuse_ino_t fuse_lookup_inode_internal_np(const char *path);
  27
+int        fuse_resize_node_internal_np(const char *path, off_t newsize);
  28
+
  29
+#endif /* _FUSE_DARWIN_PRIVATE_H_ */
  30
+
  31
+#endif /* __FreeBSD__ >= 10 */
2  lib/Makefile.am
... ...
@@ -1,7 +1,7 @@
1 1
 ## Process this file with automake to produce Makefile.in
2 2
 
3 3
 if DARWIN
4  
-AM_CPPFLAGS_DARWIN = -D__FreeBSD__=10 -DDARWIN_KERNEL_COMMON=1
  4
+AM_CPPFLAGS_DARWIN = -D__FreeBSD__=10
5 5
 else
6 6
 AM_CPPFLAGS_DARWIN =
7 7
 endif
2  lib/Makefile.in
@@ -215,7 +215,7 @@ target_vendor = @target_vendor@
215 215
 top_builddir = @top_builddir@
216 216
 top_srcdir = @top_srcdir@
217 217
 @DARWIN_FALSE@AM_CPPFLAGS_DARWIN = 
218  
-@DARWIN_TRUE@AM_CPPFLAGS_DARWIN = -D__FreeBSD__=10 -DDARWIN_KERNEL_COMMON=1
  218
+@DARWIN_TRUE@AM_CPPFLAGS_DARWIN = -D__FreeBSD__=10
219 219
 AM_CPPFLAGS = -I$(top_srcdir)/include -DFUSERMOUNT_DIR=\"$(bindir)\" \
220 220
  -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26 $(AM_CPPFLAGS_DARWIN)
221 221
 
11  lib/fuse.c
@@ -3305,6 +3305,13 @@ struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
3305 3305
 	struct fuse_fs *fs;
3306 3306
 	struct fuse_lowlevel_ops llop = fuse_path_ops;
3307 3307
 
  3308
+#if (__FreeBSD__ >= 10)
  3309
+	if (the_fuse != NULL) {
  3310
+		fprintf(stderr, "fuse: multiple concurrent file systems not supported\n");
  3311
+		goto out;
  3312
+	}
  3313
+#endif /* __FreeBSD__ >= 10 */
  3314
+
3308 3315
 	if (fuse_create_context_key() == -1)
3309 3316
 		goto out;
3310 3317
 
@@ -3537,7 +3544,7 @@ void fuse_register_module(struct fuse_module *mod)
3537 3544
 #if (__FreeBSD__ >= 10)
3538 3545
 
3539 3546
 fuse_ino_t
3540  
-fuse_lookup_inode_by_path_np(const char *path)
  3547
+fuse_lookup_inode_internal_np(const char *path)
3541 3548
 {
3542 3549
 	fuse_ino_t ino = 0; /* invalid */
3543 3550
 	fuse_ino_t parent_ino = FUSE_ROOT_ID;
@@ -3592,7 +3599,7 @@ fuse_lookup_inode_by_path_np(const char *path)
3592 3599
 
3593 3600
 __private_extern__
3594 3601
 int
3595  
-fuse_resize_node_by_path_np(const char *path, off_t newsize)
  3602
+fuse_resize_node_internal_np(const char *path, off_t newsize)
3596 3603
 {
3597 3604
 	int ret = ENOENT;
3598 3605
 	fuse_ino_t parent_ino = FUSE_ROOT_ID;
44  lib/fuse_darwin.c
@@ -8,7 +8,7 @@
8 8
 #include <pthread.h>
9 9
 
10 10
 #include <fuse_lowlevel.h>
11  
-#include "fuse_darwin.h"
  11
+#include "fuse_darwin_private.h"
12 12
 
13 13
 /*
14 14
  * Semaphore implementation based on:
@@ -238,17 +238,17 @@ fuse_sem_wait(fuse_sem_t *sem)
238 238
     return res;
239 239
 }
240 240
 
241  
-extern int fuse_chan_fd_np(void);
242  
-extern fuse_ino_t fuse_lookup_inode_by_path_np(const char *path);
  241
+const char *
  242
+macfuse_version(void)
  243
+{
  244
+    return MACFUSE_VERSION;
  245
+}
243 246
 
244 247
 /* XXX: <sys/ubc.h> */
245 248
 #define UBC_INVALIDATE 0x04
246 249
 
247  
-static int fuse_purge_path_backend(const char *, off_t, int);
248  
-extern int fuse_resize_node_by_path_np(const char *path, off_t newsize);
249  
-
250  
-static int
251  
-fuse_purge_path_backend(const char *path, off_t newsize, int shouldsetsize)
  250
+int
  251
+fuse_purge_path_np(const char *path, off_t *newsize)
252 252
 {
253 253
     struct fuse_avfi_ioctl avfi;
254 254
     fuse_ino_t ino = 0;
@@ -258,7 +258,7 @@ fuse_purge_path_backend(const char *path, off_t newsize, int shouldsetsize)
258 258
         return EINVAL;
259 259
     }
260 260
 
261  
-    ino = fuse_lookup_inode_by_path_np(path);
  261
+    ino = fuse_lookup_inode_internal_np(path);
262 262
     if (ino == 0) { /* invalid */ 
263 263
         return ENOENT;
264 264
     }
@@ -272,32 +272,20 @@ fuse_purge_path_backend(const char *path, off_t newsize, int shouldsetsize)
272 272
     avfi.cmd = FUSE_AVFI_UBC | FUSE_AVFI_PURGEATTRCACHE;
273 273
     avfi.ubc_flags = UBC_INVALIDATE;
274 274
 
275  
-    if (shouldsetsize) {
  275
+    if (newsize) {
276 276
         avfi.cmd |= FUSE_AVFI_UBC_SETSIZE;
277  
-        avfi.size = newsize;
  277
+        avfi.size = *newsize;
278 278
     }
279 279
 
280 280
     int ret = ioctl(fd, FUSEDEVIOCALTERVNODEFORINODE, (void *)&avfi);
281  
-    if (ret == 0) {
282  
-        ret = fuse_resize_node_by_path_np(path, newsize);;
  281
+    if ((ret == 0) && newsize) {
  282
+        ret = fuse_resize_node_internal_np(path, *newsize);;
283 283
     }
284 284
 
285 285
     return ret;
286 286
 }
287 287
 
288 288
 int
289  
-fuse_purge_path_np(const char *path)
290  
-{
291  
-    return fuse_purge_path_backend(path, (off_t)0, 0);
292  
-}
293  
-
294  
-int
295  
-fuse_purge_path_set_size_np(const char *path, off_t newsize)
296  
-{
297  
-    return fuse_purge_path_backend(path, newsize, 1);
298  
-}
299  
-
300  
-int
301 289
 fuse_knote_path_np(const char *path, uint32_t note)
302 290
 {
303 291
     struct fuse_avfi_ioctl avfi;
@@ -326,9 +314,3 @@ fuse_knote_path_np(const char *path, uint32_t note)
326 314
 
327 315
     return ioctl(fd, FUSEDEVIOCALTERVNODEFORINODE, (void *)&avfi);
328 316
 }
329  
-
330  
-const char *
331  
-macfuse_version(void)
332  
-{
333  
-    return MACFUSE_VERSION;
334  
-}
2  lib/fuse_kern_chan.c
@@ -76,7 +76,7 @@ static int fuse_kern_chan_send(struct fuse_chan *ch, const struct iovec iov[],
76 76
 }
77 77
 
78 78
 #if (__FreeBSD__ >= 10)
79  
-#include "fuse_darwin.h"
  79
+#include "fuse_darwin_private.h"
80 80
 #endif
81 81
 
82 82
 static void fuse_kern_chan_destroy(struct fuse_chan *ch)
2  lib/fuse_loop_mt.c
@@ -17,7 +17,7 @@
17 17
 #include <signal.h>
18 18
 #if (__FreeBSD__ >= 10)
19 19
 #define DARWIN_SEMAPHORE_COMPAT 1
20  
-#include "fuse_darwin.h"
  20
+#include "fuse_darwin_private.h"
21 21
 #else
22 22
 #include <semaphore.h>
23 23
 #endif
2  lib/helper.c
@@ -13,7 +13,7 @@
13 13
 #include "fuse_lowlevel.h"
14 14
 #include "fuse_common_compat.h"
15 15
 #if (__FreeBSD__ >= 10)
16  
-#include "fuse_darwin.h"
  16
+#include "fuse_darwin_private.h"
17 17
 #endif
18 18
 
19 19
 #include <stdio.h>
12  lib/mount_darwin.c
@@ -36,11 +36,11 @@
36 36
 #include <sys/mount.h>
37 37
 #include <AssertMacros.h>
38 38
 
39  
-#include "fuse_darwin.h"
  39
+#include "fuse_darwin_private.h"
40 40
 
41 41
 static int quiet_mode = 0;
42 42
 
43  
-long
  43
+static long
44 44
 fuse_os_version_major(void)
45 45
 {
46 46
     int ret = 0;
@@ -431,7 +431,13 @@ fuse_kern_unmount(const char *mountpoint, int fd)
431 431
 void
432 432
 fuse_unmount_compat22(const char *mountpoint)
433 433
 {
434  
-    return fuse_kern_unmount(mountpoint, fuse_chan_fd_np());
  434
+    char resolved_path[PATH_MAX];
  435
+    char *rp = realpath(mountpoint, resolved_path);
  436
+    if (rp) {
  437
+        (void)unmount(resolved_path, 0);
  438
+    }
  439
+
  440
+    return;
435 441
 }
436 442
 
437 443
 static int

0 notes on commit 9fe8fb9

Please sign in to comment.
Something went wrong with that request. Please try again.