Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 12028
b: refs/heads/master
c: b92327f
h: refs/heads/master
v: v3
  • Loading branch information
Steve French committed Aug 23, 2005
1 parent 1fe93e7 commit 83c1c46
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a5a2b489bae8f66559a531df99a26eb16b42299e
refs/heads/master: b92327fe6b25d60004b79df9e3c19091c03118ba
1 change: 1 addition & 0 deletions trunk/fs/cifs/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern int cifs_dir_notify(struct file *, unsigned long arg);

/* Functions related to dir entries */
extern struct dentry_operations cifs_dentry_ops;
extern struct dentry_operations cifs_ci_dentry_ops;

/* Functions related to symlinks */
extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd);
Expand Down
54 changes: 51 additions & 3 deletions trunk/fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
("Create worked but get_inode_info failed rc = %d",
rc));
} else {
direntry->d_op = &cifs_dentry_ops;
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
else
direntry->d_op = &cifs_dentry_ops;
d_instantiate(direntry, newinode);
}
if((nd->flags & LOOKUP_OPEN) == FALSE) {
Expand Down Expand Up @@ -322,7 +325,10 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t dev
if(!rc) {
rc = cifs_get_inode_info_unix(&newinode, full_path,
inode->i_sb,xid);
direntry->d_op = &cifs_dentry_ops;
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
else
direntry->d_op = &cifs_dentry_ops;
if(rc == 0)
d_instantiate(direntry, newinode);
}
Expand Down Expand Up @@ -418,7 +424,10 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
parent_dir_inode->i_sb,xid);

if ((rc == 0) && (newInode != NULL)) {
direntry->d_op = &cifs_dentry_ops;
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
else
direntry->d_op = &cifs_dentry_ops;
d_add(direntry, newInode);

/* since paths are not looked up by component - the parent directories are presumed to be good here */
Expand Down Expand Up @@ -477,3 +486,42 @@ struct dentry_operations cifs_dentry_ops = {
/* d_delete: cifs_d_delete, *//* not needed except for debugging */
/* no need for d_hash, d_compare, d_release, d_iput ... yet. BB confirm this BB */
};

static int cifs_ci_hash(struct dentry *dentry, struct qstr *q)
{
struct nls_table *codepage = CIFS_SB(dentry->d_inode->i_sb)->local_nls;
unsigned long hash;
int i;

hash = init_name_hash();
for (i = 0; i < q->len; i++)
hash = partial_name_hash(nls_tolower(codepage, q->name[i]),
hash);
q->hash = end_name_hash(hash);

return 0;
}

static int cifs_ci_compare(struct dentry *dentry, struct qstr *a,
struct qstr *b)
{
struct nls_table *codepage = CIFS_SB(dentry->d_inode->i_sb)->local_nls;

if ((a->len == b->len) &&
(nls_strnicmp(codepage, a->name, b->name, a->len) == 0)) {
/*
* To preserve case, don't let an existing negative dentry's
* case take precedence. If a is not a negative dentry, this
* should have no side effects
*/
memcpy((unsigned char *)a->name, b->name, a->len);
return 0;
}
return 1;
}

struct dentry_operations cifs_ci_dentry_ops = {
.d_revalidate = cifs_d_revalidate,
.d_hash = cifs_ci_hash,
.d_compare = cifs_ci_compare,
};
5 changes: 4 additions & 1 deletion trunk/fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,10 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
rc = cifs_get_inode_info(&newinode, full_path, NULL,
inode->i_sb,xid);

direntry->d_op = &cifs_dentry_ops;
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
else
direntry->d_op = &cifs_dentry_ops;
d_instantiate(direntry, newinode);
if (direntry->d_inode)
direntry->d_inode->i_nlink = 2;
Expand Down
5 changes: 4 additions & 1 deletion trunk/fs/cifs/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
("Create symlink worked but get_inode_info failed with rc = %d ",
rc));
} else {
direntry->d_op = &cifs_dentry_ops;
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
else
direntry->d_op = &cifs_dentry_ops;
d_instantiate(direntry, newinode);
}
}
Expand Down
5 changes: 4 additions & 1 deletion trunk/fs/cifs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
}

*ptmp_inode = new_inode(file->f_dentry->d_sb);
tmp_dentry->d_op = &cifs_dentry_ops;
if (pTcon->nocase)
tmp_dentry->d_op = &cifs_ci_dentry_ops;
else
tmp_dentry->d_op = &cifs_dentry_ops;
if(*ptmp_inode == NULL)
return rc;
rc = 1;
Expand Down

0 comments on commit 83c1c46

Please sign in to comment.