/filesystems/unixfs/minixfs/minixfs_mainx.c

http://macfuse.googlecode.com/ · C · 82 lines · 66 code · 11 blank · 5 comment · 7 complexity · d04ae21f619c4ff71ee5001fc29b0a2f MD5 · raw file

  1. /*
  2. * Minix File System Famiy for MacFUSE
  3. * Copyright (c) 2008 Amit Singh
  4. * http://osxbook.com
  5. */
  6. #include "unixfs.h"
  7. #include <errno.h>
  8. #include <stddef.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <unistd.h>
  13. #include <ctype.h>
  14. #include <dlfcn.h>
  15. static const char* PROGNAME = "minixfs";
  16. static const char* PROGVERS = "1.0";
  17. static struct filesystems {
  18. int isalias;
  19. char* fstypename;
  20. char* fstypename_canonical;
  21. } filesystems[] = {
  22. { 1, "Minix", "minix" },
  23. { 0, NULL, NULL },
  24. };
  25. __private_extern__
  26. void
  27. unixfs_usage(void)
  28. {
  29. fprintf(stderr,
  30. "%s (version %s): Minix File System for MacFUSE\n"
  31. "Amit Singh <http://osxbook.com>\n"
  32. "usage:\n"
  33. " %s [--force] --dmg DMG MOUNTPOINT [MacFUSE args...]\n"
  34. "where:\n"
  35. " . DMG must point to a Minix disk image\n"
  36. " . --force attempts mounting even if there are warnings or errors\n",
  37. PROGNAME, PROGVERS, PROGNAME);
  38. }
  39. __private_extern__
  40. struct unixfs*
  41. unixfs_preflight(char* dmg, char** type, struct unixfs** unixfsp)
  42. {
  43. int i;
  44. *unixfsp = NULL;
  45. if (!type)
  46. goto out;
  47. *type = "minix"; /* quick fix */
  48. for (i = 0; filesystems[i].fstypename != NULL; i++) {
  49. if (strcasecmp(*type, filesystems[i].fstypename) == 0) {
  50. char symb[255];
  51. snprintf(symb, 255, "%s_%s", "unixfs",
  52. filesystems[i].fstypename_canonical);
  53. void* impl = dlsym(RTLD_DEFAULT, symb);
  54. if (impl != NULL) {
  55. *unixfsp = (struct unixfs*)impl;
  56. break;
  57. }
  58. }
  59. }
  60. out:
  61. return *unixfsp;
  62. }
  63. __private_extern__
  64. void
  65. unixfs_postflight(char* fsname, char* volname, char* extra_args)
  66. {
  67. snprintf(extra_args, UNIXFS_ARGLEN,
  68. "-oro,sparse,defer_permissions,daemon_timeout=5,"
  69. "volname=%s,fsname=%s File System",
  70. volname, fsname);
  71. }