This source file includes following definitions.
- ufs_match
- ufs_lookup
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/fs.h>
14
15 extern unsigned int ufs_bmap(struct inode * inode, int block);
16
17
18
19
20
21 static int ufs_match (int len, const char * const name, struct direct * d)
22 {
23 if (!d || len > MAXNAMLEN)
24 return 0;
25
26
27
28 if (!len && (d->d_namlen == 1) && (d->d_name[0] == '.') &&
29 (d->d_name[1] == '\0'))
30 return 1;
31 if (len != d->d_namlen)
32 return 0;
33 return !memcmp(name, d->d_name, len);
34 }
35
36
37 int ufs_lookup (struct inode * dir, const char * name, int len,
38 struct inode ** result)
39 {
40 unsigned long int lfragno, fragno;
41 struct buffer_head * bh;
42 struct direct * d;
43
44
45
46
47 if ((len == 5) && !(memcmp(name, "xyzzy", len)) &&
48 (dir->i_ino == UFS_ROOTINO)) {
49 dir->i_sb->u.ufs_sb.s_flags ^= UFS_DEBUG;
50 printk("UFS debugging %s\n",
51 (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG) ?
52 "on": "off");
53 return(-ENOENT);
54 }
55
56
57
58
59 if ((len == 7) && !(memcmp(name, "xyzzy.i", len)) &&
60 (dir->i_ino == UFS_ROOTINO)) {
61 dir->i_sb->u.ufs_sb.s_flags ^= UFS_DEBUG_INODE;
62 printk("UFS inode debugging %s\n",
63 (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG_INODE) ?
64 "on": "off");
65 return(-ENOENT);
66 }
67
68 if ((len == 7) && !(memcmp(name, "xyzzy.n", len)) &&
69 (dir->i_ino == UFS_ROOTINO)) {
70 dir->i_sb->u.ufs_sb.s_flags ^= UFS_DEBUG_NAMEI;
71 printk("UFS namei debugging %s\n",
72 (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG_NAMEI) ?
73 "on": "off");
74 return(-ENOENT);
75 }
76
77 if ((len == 7) && !(memcmp(name, "xyzzy.l", len)) &&
78 (dir->i_ino == UFS_ROOTINO)) {
79 dir->i_sb->u.ufs_sb.s_flags ^= UFS_DEBUG_LINKS;
80 printk("UFS symlink debugging %s\n",
81 (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG_LINKS) ?
82 "on": "off");
83 return(-ENOENT);
84 }
85
86 if (dir->i_sb->u.ufs_sb.s_flags & (UFS_DEBUG|UFS_DEBUG_NAMEI)) {
87 printk("ufs_lookup: called for ino %lu name %s\n",
88 dir->i_ino, name);
89 }
90
91
92 for (lfragno = 0; lfragno < (dir->i_blocks)>>1; lfragno++) {
93 fragno = ufs_bmap(dir, lfragno);
94
95
96 if (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG) {
97 printk("ufs_lookup: ino %lu lfragno %lu fragno %lu\n",
98 dir->i_ino, lfragno, fragno);
99 }
100 if (fragno == 0) {
101
102 return(-ENOENT);
103 }
104 bh = bread(dir->i_dev, fragno, dir->i_sb->s_blocksize);
105 if (bh == NULL) {
106 printk("ufs_lookup: bread failed: ino %lu, lfragno %lu",
107 dir->i_ino, lfragno);
108 return(-EIO);
109 }
110 d = (struct direct *)(bh->b_data);
111 while (((char *)d - bh->b_data + d->d_reclen) <=
112 dir->i_sb->s_blocksize) {
113
114 if ((d->d_reclen == 0) || (d->d_namlen == 0)) {
115 if (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG) {
116 printk("ufs_lookup: skipped space in directory, ino %lu\n",
117 dir->i_ino);
118 }
119 break;
120 }
121 if (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG) {
122 printk("lfragno 0x%lx direct d 0x%x d_ino %u d_reclen %u d_namlen %u d_name `%s'\n",
123 lfragno, (unsigned int)d, d->d_ino, d->d_reclen, d->d_namlen, d->d_name);
124 }
125 if ((d->d_namlen == len) &&
126
127 (ufs_match(len, name, d))) {
128
129 *result = iget(dir->i_sb, d->d_ino);
130 brelse(bh);
131 return(0);
132 } else {
133
134 if (dir->i_sb->u.ufs_sb.s_flags & UFS_DEBUG) {
135 printk("ufs_lookup: wanted (%s,%d) got (%s,%d)\n",
136 name, len, d->d_name, d->d_namlen);
137 }
138 }
139 d = (struct direct *)((char *)d + d->d_reclen);
140 }
141 brelse(bh);
142 }
143 return(-ENOENT);
144 }
145
146
147
148
149
150
151
152
153
154