main.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* AFS client file system
  2. *
  3. * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/moduleparam.h>
  13. #include <linux/init.h>
  14. #include <linux/completion.h>
  15. #include "internal.h"
  16. MODULE_DESCRIPTION("AFS Client File System");
  17. MODULE_AUTHOR("Red Hat, Inc.");
  18. MODULE_LICENSE("GPL");
  19. unsigned afs_debug;
  20. module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO);
  21. MODULE_PARM_DESC(afs_debug, "AFS debugging mask");
  22. static char *rootcell;
  23. module_param(rootcell, charp, 0);
  24. MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
  25. #ifdef AFS_CACHING_SUPPORT
  26. static struct cachefs_netfs_operations afs_cache_ops = {
  27. .get_page_cookie = afs_cache_get_page_cookie,
  28. };
  29. struct cachefs_netfs afs_cache_netfs = {
  30. .name = "afs",
  31. .version = 0,
  32. .ops = &afs_cache_ops,
  33. };
  34. #endif
  35. /*
  36. * initialise the AFS client FS module
  37. */
  38. static int __init afs_init(void)
  39. {
  40. int ret;
  41. printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n");
  42. /* register the /proc stuff */
  43. ret = afs_proc_init();
  44. if (ret < 0)
  45. return ret;
  46. #ifdef AFS_CACHING_SUPPORT
  47. /* we want to be able to cache */
  48. ret = cachefs_register_netfs(&afs_cache_netfs,
  49. &afs_cache_cell_index_def);
  50. if (ret < 0)
  51. goto error_cache;
  52. #endif
  53. /* initialise the cell DB */
  54. ret = afs_cell_init(rootcell);
  55. if (ret < 0)
  56. goto error_cell_init;
  57. /* initialise the VL update process */
  58. ret = afs_vlocation_update_init();
  59. if (ret < 0)
  60. goto error_vl_update_init;
  61. /* initialise the callback update process */
  62. ret = afs_callback_update_init();
  63. /* create the RxRPC transport */
  64. ret = afs_open_socket();
  65. if (ret < 0)
  66. goto error_open_socket;
  67. /* register the filesystems */
  68. ret = afs_fs_init();
  69. if (ret < 0)
  70. goto error_fs;
  71. return ret;
  72. error_fs:
  73. afs_close_socket();
  74. error_open_socket:
  75. error_vl_update_init:
  76. error_cell_init:
  77. #ifdef AFS_CACHING_SUPPORT
  78. cachefs_unregister_netfs(&afs_cache_netfs);
  79. error_cache:
  80. #endif
  81. afs_callback_update_kill();
  82. afs_vlocation_purge();
  83. afs_cell_purge();
  84. afs_proc_cleanup();
  85. printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
  86. return ret;
  87. }
  88. /* XXX late_initcall is kludgy, but the only alternative seems to create
  89. * a transport upon the first mount, which is worse. Or is it?
  90. */
  91. late_initcall(afs_init); /* must be called after net/ to create socket */
  92. /*
  93. * clean up on module removal
  94. */
  95. static void __exit afs_exit(void)
  96. {
  97. printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n");
  98. afs_fs_exit();
  99. afs_close_socket();
  100. afs_purge_servers();
  101. afs_callback_update_kill();
  102. afs_vlocation_purge();
  103. flush_scheduled_work();
  104. afs_cell_purge();
  105. #ifdef AFS_CACHING_SUPPORT
  106. cachefs_unregister_netfs(&afs_cache_netfs);
  107. #endif
  108. afs_proc_cleanup();
  109. }
  110. module_exit(afs_exit);