我正在尝试设计一个文件系统并在Linux下为它编写驱动程序。源代码是公开的,源代码的URL是http://sourceforge.net/projects/pfspfs。
我发现了一个奇怪的问题,Linux内核将始终调用tmpfile /并查找sni-qt_sogou-qimpanel_2162-u9AQ7h。我不知道为什么,很多块和inode被奇怪地分配。
以下是我用来挂载文件系统并使用pr_warn
生成一些调试信息的步骤:
我使用pr_warn
打印一些调试信息。这是调试信息:
1. [ 326.781181] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
2. [ 334.253616] pfs: device loop0: pfs_lookup: lookup 1
3. [ 334.253625] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
4. [ 334.253633] pfs: device loop0: pfs_create: create 1
5. [ 334.253636] pfs: device loop0: pfs_mknod: mknod 1
6. [ 334.253648] pfs: device loop0: pfs_alloc0: 0: left 6
7. [ 334.253651] pfs: device loop0: pfs_alloc0: 0: alloc 15, cnt = 5
8. [ 334.253656] pfs: device loop0: pfs_new_inode: alloc inode 15
9. [ 334.253660] pfs: device loop0: pfs_mknod: mknod 1: pfs_new_inode end
10. [ 334.253662] pfs: device loop0: pfs_add_nondir: add nondir 1
11. [ 334.253665] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
12. [ 334.253669] pfs: device loop0: pfs_add_link: add link 1: left = 0, reclen = 24
13. [ 334.253671] pfs: device loop0: pfs_get_block_number: get block numberof 1: 1
14. [ 334.253674] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
15. [ 334.253676] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
16. [ 334.253679] pfs: device loop0: pfs_alloc0: 1: left 512
17. [ 334.253682] pfs: device loop0: pfs_alloc0: 1: alloc 96, cnt = 511
18. [ 334.253856] pfs: device loop0: pfs_add_nondir: add nondir 1 end
19. [ 337.874792] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
20. [ 337.874802] pfs: device loop0: pfs_get_block_number: get block numberof 1: 0
21. [ 339.498179] pfs: device loop0: pfs_lookup: lookup sni-qt_sogou-qimpanel_2162-u9AQ7h
22. [ 339.498187] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
23. [ 340.897097] pfs: device loop0: pfs_tmpfile: tmpfile /
24. [ 340.897114] pfs: device loop0: pfs_alloc0: 0: left 5
25. [ 340.897118] pfs: device loop0: pfs_alloc0: 0: alloc 14, cnt = 4
26. [ 340.897122] pfs: device loop0: pfs_new_inode: alloc inode 14
27. [ 340.897126] pfs: device loop0: pfs_tmpfile: tmpfile end
28. [ 340.897168] pfs: device loop0: pfs_tmpfile: tmpfile /
29. [ 340.897171] pfs: device loop0: pfs_alloc0: 0: left 4
30. [ 340.897174] pfs: device loop0: pfs_alloc0: 0: alloc 13, cnt = 3
31. [ 340.897176] pfs: device loop0: pfs_new_inode: alloc inode 13
32. [ 340.897179] pfs: device loop0: pfs_tmpfile: tmpfile end
33. [ 340.898339] pfs: device loop0: pfs_get_block: get_block 0
34. [ 340.898342] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
35. [ 340.898345] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
36. [ 340.898347] pfs: device loop0: pfs_alloc0: 1: left 511
37. [ 340.898350] pfs: device loop0: pfs_alloc0: 1: alloc 104, cnt = 510
38. [ 340.926458] pfs: device loop0: pfs_get_block: get_block 1
39. [ 340.926465] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
40. [ 340.926468] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
41. [ 340.926472] pfs: device loop0: pfs_alloc0: 1: left 510
42. [ 340.926475] pfs: device loop0: pfs_alloc0: 1: alloc 112, cnt = 509
43. [ 340.927868] pfs: device loop0: pfs_get_block: get_block 2
44. [ 340.927871] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
45. [ 340.927874] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
46. [ 340.927876] pfs: device loop0: pfs_alloc0: 1: left 509
47. [ 340.927879] pfs: device loop0: pfs_alloc0: 1: alloc 120, cnt = 508
48. [ 340.928983] pfs: device loop0: pfs_get_block: get_block 3
49. [ 340.928985] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
50. [ 340.928988] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
51. [ 340.928990] pfs: device loop0: pfs_alloc0: 1: left 508
52. [ 340.928993] pfs: device loop0: pfs_alloc0: 1: alloc 128, cnt = 507
53. [ 340.956804] pfs: device loop0: pfs_get_block: get_block 4
54. [ 340.956809] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
55. [ 340.956811] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
56. [ 340.956814] pfs: device loop0: pfs_alloc0: 1: left 507
57. [ 340.956816] pfs: device loop0: pfs_alloc0: 1: alloc 136, cnt = 506
58. [ 340.957638] pfs: device loop0: pfs_get_block: get_block 5
59. [ 340.957639] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
60. [ 340.957641] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
61. [ 340.957642] pfs: device loop0: pfs_alloc0: 1: left 506
62. [ 340.957644] pfs: device loop0: pfs_alloc0: 1: alloc 144, cnt = 505
63. [ 369.741734] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
64. [ 369.741744] pfs: device loop0: pfs_get_block_number: get block numberof 1: 0
65. [ 372.412704] pfs: device loop0: pfs_lookup: lookup 2
66. [ 372.412712] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
67. [ 372.412720] pfs: device loop0: pfs_create: create 2
68. [ 372.412723] pfs: device loop0: pfs_mknod: mknod 2
69. [ 372.412727] pfs: device loop0: pfs_alloc0: 0: left 3
70. [ 372.412730] pfs: device loop0: pfs_alloc0: 0: alloc 12, cnt = 2
71. [ 372.412735] pfs: device loop0: pfs_new_inode: alloc inode 12
72. [ 372.412739] pfs: device loop0: pfs_mknod: mknod 2: pfs_new_inode end
73. [ 372.412742] pfs: device loop0: pfs_add_nondir: add nondir 2
74. [ 372.412745] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
75. [ 372.412748] pfs: device loop0: pfs_add_link: add link 2: left = 4072, reclen = 24
76. [ 372.412751] pfs: device loop0: pfs_get_block_number: get block numberof 1: 0
77. [ 372.412756] pfs: device loop0: pfs_add_nondir: add nondir 2 end
78. [ 375.500996] pfs: device loop0: pfs_get_block: get_block 6
79. [ 375.501003] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
80. [ 375.501006] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
81. [ 375.501010] pfs: device loop0: pfs_alloc0: 1: left 505
82. [ 375.501013] pfs: device loop0: pfs_alloc0: 1: alloc 152, cnt = 504
83. [ 375.501054] pfs: device loop0: pfs_get_block: get_block 0
84. [ 375.501056] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
85. [ 375.501058] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
86. [ 375.501061] pfs: device loop0: pfs_alloc0: 1: left 511
87. [ 375.501063] pfs: device loop0: pfs_alloc0: 1: alloc 152, cnt = 510
88. [ 375.536722] pfs: device loop0: pfs_get_block: get_block 0
89. [ 375.536728] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
90. [ 375.536731] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
91. [ 375.536735] pfs: device loop0: pfs_alloc0: 1: left 511
92. [ 375.536738] pfs: device loop0: pfs_alloc0: 1: alloc 152, cnt = 510
93. [ 375.537954] pfs: device loop0: pfs_get_block: get_block 1
94. [ 375.537958] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
95. [ 375.537960] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
96. [ 375.537963] pfs: device loop0: pfs_alloc0: 1: left 510
97. [ 375.537965] pfs: device loop0: pfs_alloc0: 1: alloc 144, cnt = 509
98. [ 375.539114] pfs: device loop0: pfs_get_block: get_block 2
99. [ 375.539116] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
100. [ 375.539118] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
101. [ 375.539121] pfs: device loop0: pfs_alloc0: 1: left 509
102. [ 375.539123] pfs: device loop0: pfs_alloc0: 1: alloc 136, cnt = 508
103. [ 375.567196] pfs: device loop0: pfs_get_block: get_block 3
104. [ 375.567202] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
105. [ 375.567205] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
106. [ 375.567209] pfs: device loop0: pfs_alloc0: 1: left 508
107. [ 375.567212] pfs: device loop0: pfs_alloc0: 1: alloc 128, cnt = 507
108. [ 375.568462] pfs: device loop0: pfs_get_block: get_block 4
109. [ 375.568465] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
110. [ 375.568467] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
111. [ 375.568469] pfs: device loop0: pfs_alloc0: 1: left 507
112. [ 375.568472] pfs: device loop0: pfs_alloc0: 1: alloc 120, cnt = 506
113. [ 375.569630] pfs: device loop0: pfs_get_block: get_block 5
114. [ 375.569633] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
115. [ 375.569635] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
116. [ 375.569638] pfs: device loop0: pfs_alloc0: 1: left 506
117. [ 375.569640] pfs: device loop0: pfs_alloc0: 1: alloc 112, cnt = 505
118. [ 375.596953] pfs: device loop0: pfs_get_block: get_block 6
119. [ 375.596957] pfs: device loop0: pfs_bmap_alloc: bmap_alloc
120. [ 375.596959] pfs: device loop0: pfs_atomic_alloc: pfs atomic alloc
121. [ 375.596961] pfs: device loop0: pfs_alloc0: 1: left 505
122. [ 375.596963] pfs: device loop0: pfs_alloc0: 1: alloc 104, cnt = 504
123. [ 386.356847] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
124. [ 386.356854] pfs: device loop0: pfs_get_block_number: get block numberof 1: 0
125. [ 389.444478] pfs: device loop0: pfs_lookup: lookup 3
126. [ 389.444487] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
127. [ 389.444495] pfs: device loop0: pfs_create: create 3
128. [ 389.444498] pfs: device loop0: pfs_mknod: mknod 3
129. [ 389.444503] pfs: device loop0: pfs_alloc0: 0: left 2
130. [ 389.444506] pfs: device loop0: pfs_alloc0: 0: alloc 11, cnt = 1
131. [ 389.444508] pfs: device loop0: pfs_new_inode: alloc inode 11
132. [ 389.444513] pfs: device loop0: pfs_mknod: mknod 3: pfs_new_inode end
133. [ 389.444515] pfs: device loop0: pfs_add_nondir: add nondir 3
134. [ 389.444518] pfs: device loop0: pfs_get_block_number: get block numberof 0: 0
135. [ 389.444521] pfs: device loop0: pfs_add_link: add link 3: left = 4048, reclen = 24
136. [ 389.444524] pfs: device loop0: pfs_get_block_number: get block numberof 1: 0
137. [ 389.444529] pfs: device loop0: pfs_add_nondir: add nondir 3 end