Commit 2804eb00 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] UDF: directory reading fix

From: Ben Fennema <bfennema@falcon.csc.calpoly.edu>

The problem occured when files were stored on the disc in 16-bit per
character mode when all the upper bits were 0.  The fs module
converted the file name given by the user to a 8-bit per character
string to compare, so the comparison always failed.

The patch maps the file from disc into the current locale and then
compares it directly to the file name given by the user.
parent 8c04bc34
...@@ -154,8 +154,8 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, ...@@ -154,8 +154,8 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
{ {
struct fileIdentDesc *fi=NULL; struct fileIdentDesc *fi=NULL;
loff_t f_pos; loff_t f_pos;
int block, namelen; int block, flen;
char name[UDF_NAME_LEN], fname[UDF_NAME_LEN]; char fname[UDF_NAME_LEN];
char *nameptr; char *nameptr;
uint8_t lfi; uint8_t lfi;
uint16_t liu; uint16_t liu;
...@@ -167,9 +167,6 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, ...@@ -167,9 +167,6 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
if (!dir) if (!dir)
return NULL; return NULL;
if ( !(namelen = udf_put_filename(dir->i_sb, dentry->d_name.name, name, dentry->d_name.len)))
return NULL;
f_pos = (udf_ext0_offset(dir) >> 2); f_pos = (udf_ext0_offset(dir) >> 2);
fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
...@@ -253,10 +250,13 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, ...@@ -253,10 +250,13 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
if (!lfi) if (!lfi)
continue; continue;
if (udf_match(namelen, name, lfi, nameptr)) if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)))
{ {
udf_release_data(bh); if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name))
return fi; {
udf_release_data(bh);
return fi;
}
} }
} }
if (fibh->sbh != fibh->ebh) if (fibh->sbh != fibh->ebh)
...@@ -353,6 +353,7 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, ...@@ -353,6 +353,7 @@ udf_add_entry(struct inode *dir, struct dentry *dentry,
char name[UDF_NAME_LEN], fname[UDF_NAME_LEN]; char name[UDF_NAME_LEN], fname[UDF_NAME_LEN];
int namelen; int namelen;
loff_t f_pos; loff_t f_pos;
int flen;
char *nameptr; char *nameptr;
loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2; loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
int nfidlen; int nfidlen;
...@@ -480,7 +481,8 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, ...@@ -480,7 +481,8 @@ udf_add_entry(struct inode *dir, struct dentry *dentry,
if (!lfi || !dentry) if (!lfi || !dentry)
continue; continue;
if (udf_match(namelen, name, lfi, nameptr)) if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) &&
udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name))
{ {
if (fibh->sbh != fibh->ebh) if (fibh->sbh != fibh->ebh)
udf_release_data(fibh->ebh); udf_release_data(fibh->ebh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment