Permalink
Browse files

Move exchange function implementation from kludge.c to compat dir

"kludge" term is misleading. compat is more widely used term for
reimplemented stuff. Move the code to compat/exchange.c
  • Loading branch information...
1 parent d405515 commit 8fdbaec7a35ff4f79deea94d395e6e4e417209f4 @anatol anatol committed May 22, 2012
Showing with 64 additions and 69 deletions.
  1. +1 −0 compat/README
  2. +31 −30 fuse_kludges.c → compat/exchange.c
  3. +19 −0 compat/exchange.h
  4. +0 −1 fuse_biglock_vnops.c
  5. +0 −1 fuse_device.c
  6. +5 −2 fuse_internal.c
  7. +0 −1 fuse_internal.h
  8. +0 −1 fuse_ipc.h
  9. +0 −23 fuse_kludges.h
  10. +0 −1 fuse_vfsops.c
  11. +0 −1 fuse_vnops.c
  12. +8 −8 kext.xcodeproj/project.pbxproj
View
@@ -2,3 +2,4 @@
are unavailable or differ across MacOSX versions:
* tree.h - rbtree implementation copied from OpenBSD. SDK has this header only starting from version 10.7.
+ * exchange - exchange vnop is not a part of public kernel API, so we mimic its implementation
@@ -3,7 +3,8 @@
*/
-#include "fuse_kludges.h"
+#include "exchange.h"
+
#include <libkern/version.h>
#ifdef FUSE4X_ENABLE_EXCHANGE
@@ -26,7 +27,7 @@
* 116 120 192 116 184
*/
-struct fuse_kludge_vnode_9 {
+struct fuse_compat_vnode_9 {
char v_lock[12];
char dummy0[36];
uint16_t v_lflag;
@@ -37,7 +38,7 @@ struct fuse_kludge_vnode_9 {
} __attribute__ ((packed));
#if __LP64__
-struct fuse_kludge_vnode_10 {
+struct fuse_compat_vnode_10 {
char v_lock[24];
char dummy0[64];
uint16_t v_lflag;
@@ -47,7 +48,7 @@ struct fuse_kludge_vnode_10 {
char dummy2[48];
} __attribute__ ((packed));
#else
-struct fuse_kludge_vnode_10 {
+struct fuse_compat_vnode_10 {
char v_lock[12];
char dummy0[36];
uint16_t v_lflag;
@@ -58,7 +59,7 @@ struct fuse_kludge_vnode_10 {
} __attribute__ ((packed));
#endif
-struct fuse_kludge_vnode_11 {
+struct fuse_compat_vnode_11 {
void *v_lock[2];
void *dummy0[7];
char dummy1[8];
@@ -71,39 +72,39 @@ struct fuse_kludge_vnode_11 {
} __attribute__ ((packed));
void
-fuse_kludge_exchange(vnode_t v1, vnode_t v2)
+fuse_compat_exchange(vnode_t v1, vnode_t v2)
{
if (version_major > 10) {
- char *tmp_v_name = ((struct fuse_kludge_vnode_11 *)v1)->v_name;
- ((struct fuse_kludge_vnode_11 *)v1)->v_name =
- ((struct fuse_kludge_vnode_11 *)v2)->v_name;
- ((struct fuse_kludge_vnode_11 *)v2)->v_name = tmp_v_name;
+ char *tmp_v_name = ((struct fuse_compat_vnode_11 *)v1)->v_name;
+ ((struct fuse_compat_vnode_11 *)v1)->v_name =
+ ((struct fuse_compat_vnode_11 *)v2)->v_name;
+ ((struct fuse_compat_vnode_11 *)v2)->v_name = tmp_v_name;
- vnode_t tmp_v_parent = ((struct fuse_kludge_vnode_11 *)v1)->v_parent;
- ((struct fuse_kludge_vnode_11 *)v1)->v_parent =
- ((struct fuse_kludge_vnode_11 *)v2)->v_parent;
- ((struct fuse_kludge_vnode_11 *)v2)->v_parent = tmp_v_parent;
+ vnode_t tmp_v_parent = ((struct fuse_compat_vnode_11 *)v1)->v_parent;
+ ((struct fuse_compat_vnode_11 *)v1)->v_parent =
+ ((struct fuse_compat_vnode_11 *)v2)->v_parent;
+ ((struct fuse_compat_vnode_11 *)v2)->v_parent = tmp_v_parent;
}
else if (version_major > 9) {
- char *tmp_v_name = ((struct fuse_kludge_vnode_10 *)v1)->v_name;
- ((struct fuse_kludge_vnode_10 *)v1)->v_name =
- ((struct fuse_kludge_vnode_10 *)v2)->v_name;
- ((struct fuse_kludge_vnode_10 *)v2)->v_name = tmp_v_name;
+ char *tmp_v_name = ((struct fuse_compat_vnode_10 *)v1)->v_name;
+ ((struct fuse_compat_vnode_10 *)v1)->v_name =
+ ((struct fuse_compat_vnode_10 *)v2)->v_name;
+ ((struct fuse_compat_vnode_10 *)v2)->v_name = tmp_v_name;
- vnode_t tmp_v_parent = ((struct fuse_kludge_vnode_10 *)v1)->v_parent;
- ((struct fuse_kludge_vnode_10 *)v1)->v_parent =
- ((struct fuse_kludge_vnode_10 *)v2)->v_parent;
- ((struct fuse_kludge_vnode_10 *)v2)->v_parent = tmp_v_parent;
+ vnode_t tmp_v_parent = ((struct fuse_compat_vnode_10 *)v1)->v_parent;
+ ((struct fuse_compat_vnode_10 *)v1)->v_parent =
+ ((struct fuse_compat_vnode_10 *)v2)->v_parent;
+ ((struct fuse_compat_vnode_10 *)v2)->v_parent = tmp_v_parent;
} else {
- char *tmp_v_name = ((struct fuse_kludge_vnode_9 *)v1)->v_name;
- ((struct fuse_kludge_vnode_9 *)v1)->v_name =
- ((struct fuse_kludge_vnode_9 *)v2)->v_name;
- ((struct fuse_kludge_vnode_9 *)v2)->v_name = tmp_v_name;
+ char *tmp_v_name = ((struct fuse_compat_vnode_9 *)v1)->v_name;
+ ((struct fuse_compat_vnode_9 *)v1)->v_name =
+ ((struct fuse_compat_vnode_9 *)v2)->v_name;
+ ((struct fuse_compat_vnode_9 *)v2)->v_name = tmp_v_name;
- vnode_t tmp_v_parent = ((struct fuse_kludge_vnode_9 *)v1)->v_parent;
- ((struct fuse_kludge_vnode_9 *)v1)->v_parent =
- ((struct fuse_kludge_vnode_9 *)v2)->v_parent;
- ((struct fuse_kludge_vnode_9 *)v2)->v_parent = tmp_v_parent;
+ vnode_t tmp_v_parent = ((struct fuse_compat_vnode_9 *)v1)->v_parent;
+ ((struct fuse_compat_vnode_9 *)v1)->v_parent =
+ ((struct fuse_compat_vnode_9 *)v2)->v_parent;
+ ((struct fuse_compat_vnode_9 *)v2)->v_parent = tmp_v_parent;
}
}
View
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2012 Anatol Pomozov. All Rights Reserved.
+ */
+
+
+#ifndef _FUSE_COMPAT_EXCHANGE_H_
+#define _FUSE_COMPAT_EXCHANGE_H_
+
+#include "fuse.h"
+
+#include <sys/kernel_types.h>
+
+#ifdef FUSE4X_ENABLE_EXCHANGE
+
+void fuse_compat_exchange(vnode_t v1, vnode_t v2);
+
+#endif /* FUSE4X_ENABLE_EXCHANGE */
+
+#endif /* _FUSE_COMPAT_EXCHANGE_H_ */
View
@@ -5,7 +5,6 @@
*/
#include "fuse.h"
-#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "fuse_node.h"
#include "fuse_biglock_vnops.h"
View
@@ -9,7 +9,6 @@
#include "fuse_ipc.h"
#include "fuse_internal.h"
#include "fuse_kernel.h"
-#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "fuse_sysctl.h"
View
@@ -12,7 +12,6 @@
#include "fuse_node.h"
#include "fuse_file.h"
#include "fuse_sysctl.h"
-#include "fuse_kludges.h"
#include <AvailabilityMacros.h>
#include <kern/assert.h>
@@ -42,6 +41,10 @@
#include "fuse_biglock_vnops.h"
#endif
+#ifdef FUSE4X_ENABLE_EXCHANGE
+# include "compat/exchange.h"
+#endif
+
/* access */
__private_extern__
@@ -234,7 +237,7 @@ fuse_internal_exchange(vnode_t fvp,
ubc_setsize(fvp, (off_t)ffud->filesize);
ubc_setsize(tvp, (off_t)tfud->filesize);
- fuse_kludge_exchange(fvp, tvp);
+ fuse_compat_exchange(fvp, tvp);
/*
* Another approach (will need additional kernel support to work):
View
@@ -10,7 +10,6 @@
#include "fuse.h"
#include "fuse_ipc.h"
-#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "fuse_node.h"
#include "fuse_kernel.h"
View
@@ -10,7 +10,6 @@
#include "fuse.h"
#include "fuse_kernel.h"
#include "fuse_device.h"
-#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "compat/tree.h"
View
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2006-2008 Google. All Rights Reserved.
- */
-
-
-#ifndef _FUSE_KLUDGES_H_
-#define _FUSE_KLUDGES_H_
-
-#include "fuse.h"
-#include "fuse_sysctl.h"
-
-#include <sys/cdefs.h>
-#include <sys/mount.h>
-#include <sys/types.h>
-#include <sys/vnode.h>
-
-#ifdef FUSE4X_ENABLE_EXCHANGE
-
-extern void fuse_kludge_exchange(vnode_t v1, vnode_t v2);
-
-#endif /* FUSE4X_ENABLE_EXCHANGE */
-
-#endif /* _FUSE_KLUDGES_H_ */
View
@@ -8,7 +8,6 @@
#include "fuse_device.h"
#include "fuse_internal.h"
#include "fuse_ipc.h"
-#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "fuse_node.h"
#include "fuse_sysctl.h"
View
@@ -8,7 +8,6 @@
#include "fuse_file.h"
#include "fuse_internal.h"
#include "fuse_ipc.h"
-#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "fuse_node.h"
#include <fuse_param.h>
@@ -15,6 +15,8 @@
DE134B0113BE3A8F00113A90 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE134B0013BE3A8F00113A90 /* CoreFoundation.framework */; };
DE3C8BF0151D368F0038F90D /* README in Resources */ = {isa = PBXBuildFile; fileRef = DE3C8BEE151D368F0038F90D /* README */; };
DE3C8BF1151D368F0038F90D /* tree.h in Headers */ = {isa = PBXBuildFile; fileRef = DE3C8BEF151D368F0038F90D /* tree.h */; };
+ DE8F792215226DD70025FDF1 /* exchange.c in Sources */ = {isa = PBXBuildFile; fileRef = DE8F792015226DD70025FDF1 /* exchange.c */; };
+ DE8F792315226DD70025FDF1 /* exchange.h in Headers */ = {isa = PBXBuildFile; fileRef = DE8F792115226DD70025FDF1 /* exchange.h */; };
DEBF0B1313886AAC00A1755B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DEBF0B1113886AAC00A1755B /* InfoPlist.strings */; };
DEE25D27138874AF009DC919 /* fuse_biglock_vnops.c in Sources */ = {isa = PBXBuildFile; fileRef = DEE25D0A138874AF009DC919 /* fuse_biglock_vnops.c */; };
DEE25D28138874AF009DC919 /* fuse_biglock_vnops.h in Headers */ = {isa = PBXBuildFile; fileRef = DEE25D0B138874AF009DC919 /* fuse_biglock_vnops.h */; };
@@ -27,8 +29,6 @@
DEE25D2F138874AF009DC919 /* fuse_ipc.c in Sources */ = {isa = PBXBuildFile; fileRef = DEE25D12138874AF009DC919 /* fuse_ipc.c */; };
DEE25D30138874AF009DC919 /* fuse_ipc.h in Headers */ = {isa = PBXBuildFile; fileRef = DEE25D13138874AF009DC919 /* fuse_ipc.h */; };
DEE25D31138874AF009DC919 /* fuse_kernel.h in Headers */ = {isa = PBXBuildFile; fileRef = DEE25D14138874AF009DC919 /* fuse_kernel.h */; };
- DEE25D32138874AF009DC919 /* fuse_kludges.c in Sources */ = {isa = PBXBuildFile; fileRef = DEE25D15138874AF009DC919 /* fuse_kludges.c */; };
- DEE25D33138874AF009DC919 /* fuse_kludges.h in Headers */ = {isa = PBXBuildFile; fileRef = DEE25D16138874AF009DC919 /* fuse_kludges.h */; };
DEE25D36138874AF009DC919 /* fuse_locking.c in Sources */ = {isa = PBXBuildFile; fileRef = DEE25D19138874AF009DC919 /* fuse_locking.c */; };
DEE25D37138874AF009DC919 /* fuse_locking.h in Headers */ = {isa = PBXBuildFile; fileRef = DEE25D1A138874AF009DC919 /* fuse_locking.h */; };
DEE25D38138874AF009DC919 /* fuse_main.c in Sources */ = {isa = PBXBuildFile; fileRef = DEE25D1B138874AF009DC919 /* fuse_main.c */; };
@@ -66,6 +66,8 @@
DE3C8BEE151D368F0038F90D /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README; path = compat/README; sourceTree = "<group>"; };
DE3C8BEF151D368F0038F90D /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tree.h; path = compat/tree.h; sourceTree = "<group>"; };
DE3ED530149F1D51007E2A7C /* kext.exports */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = kext.exports; sourceTree = "<group>"; };
+ DE8F792015226DD70025FDF1 /* exchange.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = exchange.c; path = compat/exchange.c; sourceTree = "<group>"; };
+ DE8F792115226DD70025FDF1 /* exchange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = exchange.h; path = compat/exchange.h; sourceTree = "<group>"; };
DEBF0B0913886AAC00A1755B /* fuse4x.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = fuse4x.kext; sourceTree = BUILT_PRODUCTS_DIR; };
DEBF0B0D13886AAC00A1755B /* Kernel.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kernel.framework; path = System/Library/Frameworks/Kernel.framework; sourceTree = SDKROOT; };
DEBF0B1013886AAC00A1755B /* kext-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "kext-Info.plist"; sourceTree = "<group>"; };
@@ -82,8 +84,6 @@
DEE25D12138874AF009DC919 /* fuse_ipc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fuse_ipc.c; sourceTree = "<group>"; };
DEE25D13138874AF009DC919 /* fuse_ipc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fuse_ipc.h; sourceTree = "<group>"; };
DEE25D14138874AF009DC919 /* fuse_kernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fuse_kernel.h; sourceTree = "<group>"; };
- DEE25D15138874AF009DC919 /* fuse_kludges.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fuse_kludges.c; sourceTree = "<group>"; };
- DEE25D16138874AF009DC919 /* fuse_kludges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fuse_kludges.h; sourceTree = "<group>"; };
DEE25D19138874AF009DC919 /* fuse_locking.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fuse_locking.c; sourceTree = "<group>"; };
DEE25D1A138874AF009DC919 /* fuse_locking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fuse_locking.h; sourceTree = "<group>"; };
DEE25D1B138874AF009DC919 /* fuse_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fuse_main.c; sourceTree = "<group>"; };
@@ -133,6 +133,8 @@
isa = PBXGroup;
children = (
DE3C8BEE151D368F0038F90D /* README */,
+ DE8F792015226DD70025FDF1 /* exchange.c */,
+ DE8F792115226DD70025FDF1 /* exchange.h */,
DE3C8BEF151D368F0038F90D /* tree.h */,
);
name = compat;
@@ -155,8 +157,6 @@
DEE25D11138874AF009DC919 /* fuse_internal.h */,
DEE25D12138874AF009DC919 /* fuse_ipc.c */,
DEE25D13138874AF009DC919 /* fuse_ipc.h */,
- DEE25D15138874AF009DC919 /* fuse_kludges.c */,
- DEE25D16138874AF009DC919 /* fuse_kludges.h */,
DEE25D19138874AF009DC919 /* fuse_locking.c */,
DEE25D1A138874AF009DC919 /* fuse_locking.h */,
DEE25D1B138874AF009DC919 /* fuse_main.c */,
@@ -238,7 +238,6 @@
DEE25D2E138874AF009DC919 /* fuse_internal.h in Headers */,
DEE25D30138874AF009DC919 /* fuse_ipc.h in Headers */,
DEE25D31138874AF009DC919 /* fuse_kernel.h in Headers */,
- DEE25D33138874AF009DC919 /* fuse_kludges.h in Headers */,
DEE25D37138874AF009DC919 /* fuse_locking.h in Headers */,
DEE25D3A138874AF009DC919 /* fuse_node.h in Headers */,
DEE25D3E138874AF009DC919 /* fuse_sysctl.h in Headers */,
@@ -249,6 +248,7 @@
DEE25D571388751A009DC919 /* fuse_param.h in Headers */,
DEE25D581388751A009DC919 /* fuse_version.h in Headers */,
DE3C8BF1151D368F0038F90D /* tree.h in Headers */,
+ DE8F792315226DD70025FDF1 /* exchange.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -355,13 +355,13 @@
DEE25D2B138874AF009DC919 /* fuse_file.c in Sources */,
DEE25D2D138874AF009DC919 /* fuse_internal.c in Sources */,
DEE25D2F138874AF009DC919 /* fuse_ipc.c in Sources */,
- DEE25D32138874AF009DC919 /* fuse_kludges.c in Sources */,
DEE25D36138874AF009DC919 /* fuse_locking.c in Sources */,
DEE25D38138874AF009DC919 /* fuse_main.c in Sources */,
DEE25D39138874AF009DC919 /* fuse_node.c in Sources */,
DEE25D3D138874AF009DC919 /* fuse_sysctl.c in Sources */,
DEE25D3F138874AF009DC919 /* fuse_vfsops.c in Sources */,
DEE25D41138874AF009DC919 /* fuse_vnops.c in Sources */,
+ DE8F792215226DD70025FDF1 /* exchange.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 8fdbaec

Please sign in to comment.