/core/10.4/fusefs/fuse_kludges.c

http://macfuse.googlecode.com/ · C · 54 lines · 23 code · 8 blank · 23 comment · 0 complexity · 3dffad44844a00bbf07e8a8b59e8cf65 MD5 · raw file

  1. /*
  2. * Copyright (C) 2006-2008 Google. All Rights Reserved.
  3. * Amit Singh <singh@>
  4. */
  5. #include "fuse_kludges.h"
  6. #if M_MACFUSE_ENABLE_EXCHANGE
  7. extern void
  8. fuse_kludge_exchange(vnode_t v1, vnode_t v2)
  9. {
  10. char *tmp_v_name = ((struct fuse_kludge_vnode *)v1)->v_name;
  11. ((struct fuse_kludge_vnode *)v1)->v_name =
  12. ((struct fuse_kludge_vnode *)v2)->v_name;
  13. ((struct fuse_kludge_vnode *)v2)->v_name = tmp_v_name;
  14. vnode_t tmp_v_parent = ((struct fuse_kludge_vnode *)v1)->v_parent;
  15. ((struct fuse_kludge_vnode *)v1)->v_parent =
  16. ((struct fuse_kludge_vnode *)v2)->v_parent;
  17. ((struct fuse_kludge_vnode *)v2)->v_parent = tmp_v_parent;
  18. }
  19. #endif /* M_MACFUSE_ENABLE_EXCHANGE */
  20. #define MNT_KERN_FLAG_OFFSET 64
  21. #define MNTK_LOCK_LOCAL 0x00100000
  22. #define MNTK_UNMOUNT 0x01000000
  23. void
  24. vfs_setlocklocal(mount_t mp)
  25. {
  26. /*
  27. * Horrible, horrible kludge. Dangerous to boot. "Boot", heh.
  28. * The issue is that we really need to do vfs_setlocklocal(mp),
  29. * otherwise we won't have VFS-provided advisory file locking.
  30. * Since the kernel's extended attributes needs to create files
  31. * with O_EXLOCK set, we need advisory locking for extended
  32. * attributes to work properly. Since ACLs depend on extended
  33. * attributes, vfs_setlocklocal(mp) keeps becoming critical.
  34. *
  35. * The kludge is, well, just setting the flag "by hand". This
  36. * means I'm hardcoding the offset of the flag word field in the
  37. * mount structure, which is internal to the kernel (not exposed
  38. * through the KPIs).
  39. *
  40. * If the field offset changes in future (not likely, but not
  41. * guaranteed to remain the same either), the following operation
  42. * could result in weird behavior, including a kernel panic.
  43. *
  44. */
  45. *(int *)((char *)mp + MNT_KERN_FLAG_OFFSET) |= MNTK_LOCK_LOCAL;
  46. }