vfs_init.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* $OpenBSD: vfs_init.c,v 1.36 2015/03/14 03:38:51 jsg Exp $ */
  2. /* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */
  3. /*
  4. * Copyright (c) 1989, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * This code is derived from software contributed
  8. * to Berkeley by John Heidemann of the UCLA Ficus project.
  9. *
  10. * Source: * @(#)i405_init.c 2.10 92/04/27 UCLA Ficus project
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. * 3. Neither the name of the University nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. * SUCH DAMAGE.
  35. *
  36. * @(#)vfs_init.c 8.3 (Berkeley) 1/4/94
  37. */
  38. #include <sys/param.h>
  39. #include <sys/mount.h>
  40. #include <sys/namei.h>
  41. #include <sys/vnode.h>
  42. #include <sys/pool.h>
  43. struct pool namei_pool;
  44. /* This defines the root filesystem. */
  45. struct vnode *rootvnode;
  46. /* Set up the filesystem operations for vnodes. */
  47. #ifdef FFS
  48. extern const struct vfsops ffs_vfsops;
  49. #endif
  50. #ifdef MFS
  51. extern const struct vfsops mfs_vfsops;
  52. #endif
  53. #ifdef MSDOSFS
  54. extern const struct vfsops msdosfs_vfsops;
  55. #endif
  56. #ifdef NFSCLIENT
  57. extern const struct vfsops nfs_vfsops;
  58. #endif
  59. #ifdef CD9660
  60. extern const struct vfsops cd9660_vfsops;
  61. #endif
  62. #ifdef EXT2FS
  63. extern const struct vfsops ext2fs_vfsops;
  64. #endif
  65. #ifdef NTFS
  66. extern const struct vfsops ntfs_vfsops;
  67. #endif
  68. #ifdef UDF
  69. extern const struct vfsops udf_vfsops;
  70. #endif
  71. #ifdef FUSE
  72. extern const struct vfsops fusefs_vfsops;
  73. #endif
  74. #ifdef TMPFS
  75. extern const struct vfsops tmpfs_vfsops;
  76. #endif
  77. /* Set up the filesystem operations for vnodes. */
  78. static struct vfsconf vfsconflist[] = {
  79. #ifdef FFS
  80. { &ffs_vfsops, MOUNT_FFS, 1, 0, MNT_LOCAL, NULL },
  81. #endif
  82. #ifdef MFS
  83. { &mfs_vfsops, MOUNT_MFS, 3, 0, MNT_LOCAL, NULL },
  84. #endif
  85. #ifdef EXT2FS
  86. { &ext2fs_vfsops, MOUNT_EXT2FS, 17, 0, MNT_LOCAL, NULL },
  87. #endif
  88. #ifdef CD9660
  89. { &cd9660_vfsops, MOUNT_CD9660, 14, 0, MNT_LOCAL, NULL },
  90. #endif
  91. #ifdef MSDOSFS
  92. { &msdosfs_vfsops, MOUNT_MSDOS, 4, 0, MNT_LOCAL, NULL },
  93. #endif
  94. #ifdef NFSCLIENT
  95. { &nfs_vfsops, MOUNT_NFS, 2, 0, 0, NULL },
  96. #endif
  97. #ifdef NTFS
  98. { &ntfs_vfsops, MOUNT_NTFS, 6, 0, MNT_LOCAL, NULL },
  99. #endif
  100. #ifdef UDF
  101. { &udf_vfsops, MOUNT_UDF, 13, 0, MNT_LOCAL, NULL },
  102. #endif
  103. #ifdef FUSE
  104. { &fusefs_vfsops, MOUNT_FUSEFS, 18, 0, MNT_LOCAL, NULL },
  105. #endif
  106. #ifdef TMPFS
  107. { &tmpfs_vfsops, MOUNT_TMPFS, 19, 0, MNT_LOCAL, NULL },
  108. #endif
  109. };
  110. /*
  111. * Initially the size of the list, vfsinit will set maxvfsconf
  112. * to the highest defined type number.
  113. */
  114. int maxvfsconf = sizeof(vfsconflist) / sizeof(struct vfsconf);
  115. struct vfsconf *vfsconf = vfsconflist;
  116. /* Initialize the vnode structures and initialize each file system type. */
  117. void
  118. vfsinit(void)
  119. {
  120. int i;
  121. struct vfsconf *vfsconflist;
  122. int vfsconflistlen;
  123. pool_init(&namei_pool, MAXPATHLEN, 0, 0, PR_WAITOK, "namei", NULL);
  124. /* Initialize the vnode table. */
  125. vntblinit();
  126. /* Initialize the vnode name cache. */
  127. nchinit();
  128. /*
  129. * Stop using vfsconf and maxvfsconf as a temporary storage,
  130. * set them to their correct values now.
  131. */
  132. vfsconflist = vfsconf;
  133. vfsconflistlen = maxvfsconf;
  134. vfsconf = NULL;
  135. maxvfsconf = 0;
  136. for (i = 0; i < vfsconflistlen; i++)
  137. vfs_register(&vfsconflist[i]);
  138. }