PageRenderTime 20ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/filesystems/unixfs/ufs/ufs_mainx.c

http://macfuse.googlecode.com/
C | 101 lines | 84 code | 12 blank | 5 comment | 11 complexity | acd6efdac4e3f5dad20b108a21086f86 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  1. /*
  2. * UFS 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 = "ufs";
  16. static const char* PROGVERS = "1.0";
  17. static struct filesystems {
  18. int isalias;
  19. char* fstypename;
  20. char* fstypename_canonical;
  21. } filesystems[] = {
  22. { 0, "old", "ufs" },
  23. { 0, "sunos", "ufs" },
  24. { 0, "sun", "ufs" },
  25. { 0, "sunx86", "ufs" },
  26. { 0, "hp", "ufs" },
  27. { 0, "nextstep", "ufs" },
  28. { 0, "nextstep-cd", "ufs" },
  29. { 0, "openstep", "ufs" },
  30. { 0, "44bsd", "ufs" },
  31. { 0, "5xbsd", "ufs" },
  32. { 0, "ufs2", "ufs" },
  33. { 0, NULL, NULL },
  34. };
  35. __private_extern__
  36. void
  37. unixfs_usage(void)
  38. {
  39. fprintf(stderr,
  40. "%s (version %s): UFS family of file systems for MacFUSE\n"
  41. "Amit Singh <http://osxbook.com>\n"
  42. "usage:\n"
  43. " %s [--force] --dmg DMG --type TYPE MOUNTPOINT [MacFUSE args...]\n"
  44. "where:\n"
  45. " . DMG must point to an ancient Unix disk image of a valid type\n"
  46. " . TYPE is one of:",
  47. PROGNAME, PROGVERS, PROGNAME);
  48. int i;
  49. for (i = 0; filesystems[i].fstypename != NULL; i++) {
  50. if (!filesystems[i].isalias)
  51. fprintf(stderr, " %s ", filesystems[i].fstypename);
  52. }
  53. fprintf(stderr, "\n");
  54. fprintf(stderr, "%s",
  55. " . --force attempts mounting even if there are warnings or errors\n"
  56. );
  57. }
  58. __private_extern__
  59. struct unixfs*
  60. unixfs_preflight(char* dmg, char** type, struct unixfs** unixfsp)
  61. {
  62. int i;
  63. *unixfsp = NULL;
  64. if (!type || !*type)
  65. goto out;
  66. for (i = 0; filesystems[i].fstypename != NULL; i++) {
  67. if (strcasecmp(*type, filesystems[i].fstypename) == 0) {
  68. char symb[255];
  69. snprintf(symb, 255, "%s_%s", "unixfs",
  70. filesystems[i].fstypename_canonical);
  71. void* impl = dlsym(RTLD_DEFAULT, symb);
  72. if (impl != NULL) {
  73. *unixfsp = (struct unixfs*)impl;
  74. break;
  75. }
  76. }
  77. }
  78. out:
  79. return *unixfsp;
  80. }
  81. __private_extern__
  82. void
  83. unixfs_postflight(char* fsname, char* volname, char* extra_args)
  84. {
  85. snprintf(extra_args, UNIXFS_ARGLEN,
  86. "-oro,sparse,defer_permissions,daemon_timeout=5,"
  87. "volname=%s,fsname=%s File System",
  88. volname, fsname);
  89. }