2 * linux/fs/isofs/namei.c
4 * (C) 1992 Eric Youngdale Modified for ISO 9660 filesystem.
6 * (C) 1991 Linus Torvalds - minix filesystem
13 * ok, we cannot use strncmp, as the name is not in our data space.
14 * Thus we'll have to use isofs_match. No big problem. Match also makes
18 isofs_cmp(struct dentry
*dentry
, const char *compare
, int dlen
)
25 /* check special "." and ".." files */
28 if (compare
[0] == 0) {
29 if (!dentry
->d_name
.len
)
32 } else if (compare
[0] == 1) {
40 return dentry
->d_op
->d_compare(NULL
, NULL
, NULL
, NULL
,
41 dentry
->d_name
.len
, dentry
->d_name
.name
, &qstr
);
47 * finds an entry in the specified directory with the wanted name. It
48 * returns the inode number of the found entry, or 0 on error.
51 isofs_find_entry(struct inode
*dir
, struct dentry
*dentry
,
52 unsigned long *block_rv
, unsigned long *offset_rv
,
53 char *tmpname
, struct iso_directory_record
*tmpde
)
55 unsigned long bufsize
= ISOFS_BUFFER_SIZE(dir
);
56 unsigned char bufbits
= ISOFS_BUFFER_BITS(dir
);
57 unsigned long block
, f_pos
, offset
, block_saved
, offset_saved
;
58 struct buffer_head
*bh
= NULL
;
59 struct isofs_sb_info
*sbi
= ISOFS_SB(dir
->i_sb
);
61 if (!ISOFS_I(dir
)->i_first_extent
)
68 while (f_pos
< dir
->i_size
) {
69 struct iso_directory_record
*de
;
70 int de_len
, match
, i
, dlen
;
74 bh
= isofs_bread(dir
, block
);
79 de
= (struct iso_directory_record
*) (bh
->b_data
+ offset
);
81 de_len
= *(unsigned char *) de
;
85 f_pos
= (f_pos
+ ISOFS_BLOCK_SIZE
) & ~(ISOFS_BLOCK_SIZE
- 1);
86 block
= f_pos
>> bufbits
;
91 block_saved
= bh
->b_blocknr
;
92 offset_saved
= offset
;
96 /* Make sure we have a full directory entry */
97 if (offset
>= bufsize
) {
98 int slop
= bufsize
- offset
+ de_len
;
99 memcpy(tmpde
, de
, slop
);
100 offset
&= bufsize
- 1;
105 bh
= isofs_bread(dir
, block
);
108 memcpy((void *) tmpde
+ slop
, bh
->b_data
, offset
);
113 dlen
= de
->name_len
[0];
115 /* Basic sanity check, whether name doesn't exceed dir entry */
116 if (de_len
< dlen
+ sizeof(struct iso_directory_record
)) {
117 printk(KERN_NOTICE
"iso9660: Corrupted directory entry"
118 " in block %lu of inode %lu\n", block
,
124 ((i
= get_rock_ridge_filename(de
, tmpname
, dir
)))) {
125 dlen
= i
; /* possibly -1 */
128 } else if (sbi
->s_joliet_level
) {
129 dlen
= get_joliet_filename(de
, tmpname
, dir
);
132 } else if (sbi
->s_mapping
== 'a') {
133 dlen
= get_acorn_filename(de
, tmpname
, dir
);
135 } else if (sbi
->s_mapping
== 'n') {
136 dlen
= isofs_name_translate(de
, tmpname
, dir
);
141 * Skip hidden or associated files unless hide or showassoc,
142 * respectively, is set
147 (!(de
->flags
[-sbi
->s_high_sierra
] & 1))) &&
149 (!(de
->flags
[-sbi
->s_high_sierra
] & 4)))) {
150 match
= (isofs_cmp(dentry
, dpnt
, dlen
) == 0);
153 isofs_normalize_block_and_offset(de
,
156 *block_rv
= block_saved
;
157 *offset_rv
= offset_saved
;
166 struct dentry
*isofs_lookup(struct inode
*dir
, struct dentry
*dentry
, struct nameidata
*nd
)
169 unsigned long uninitialized_var(block
);
170 unsigned long uninitialized_var(offset
);
174 page
= alloc_page(GFP_USER
);
176 return ERR_PTR(-ENOMEM
);
178 found
= isofs_find_entry(dir
, dentry
,
181 1024 + page_address(page
));
184 inode
= found
? isofs_iget(dir
->i_sb
, block
, offset
) : NULL
;
186 return d_splice_alias(inode
, dentry
);
This page took 0.033791 seconds and 5 git commands to generate.