You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
  4. This program can be distributed under the terms of the GNU LGPLv2.
  5. See the file COPYING.LIB
  6. */
  7. #include "fuse_chan.h"
  8. #include "fuse_common_compat.h"
  9. #include "fuse_i.h"
  10. #include "fuse_kernel.h"
  11. #include "fuse_lowlevel_compat.h"
  12. #include "fuse_misc.h"
  13. #include <assert.h>
  14. #include <errno.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <sys/ioctl.h>
  19. #include <unistd.h>
  20. struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data)
  21. {
  22. struct fuse_session *se = (struct fuse_session *) malloc(sizeof(*se));
  23. if (se == NULL) {
  24. fprintf(stderr, "fuse: failed to allocate session\n");
  25. return NULL;
  26. }
  27. memset(se, 0, sizeof(*se));
  28. se->op = *op;
  29. se->data = data;
  30. return se;
  31. }
  32. void fuse_session_destroy(struct fuse_session *se)
  33. {
  34. if (se->op.destroy)
  35. se->op.destroy(se->data);
  36. free(se);
  37. }
  38. void fuse_session_exit(struct fuse_session *se)
  39. {
  40. if (se->op.exit)
  41. se->op.exit(se->data, 1);
  42. se->exited = 1;
  43. }
  44. void fuse_session_reset(struct fuse_session *se)
  45. {
  46. if (se->op.exit)
  47. se->op.exit(se->data, 0);
  48. se->exited = 0;
  49. }
  50. int fuse_session_exited(struct fuse_session *se)
  51. {
  52. if (se->op.exited)
  53. return se->op.exited(se->data);
  54. else
  55. return se->exited;
  56. }
  57. void *fuse_session_data(struct fuse_session *se)
  58. {
  59. return se->data;
  60. }