aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@austin.ibm.com>2004-07-12 03:31:38 -0500
committerDave Kleikamp <jfs.adm@hostme.bitkeeper.com>2004-07-12 03:31:38 -0500
commit6e50a7fe01bb676b2bddc1c5a01ea1a1dbfc3fbf (patch)
tree53cc7591116508eedfeb9acf5f9ac8b915d69c2c /fs
parent8a6a07e850bd3385259f0a393646eb722b6a4032 (diff)
downloadhistory-6e50a7fe01bb676b2bddc1c5a01ea1a1dbfc3fbf.tar.gz
JFS: Add d_hash and d_compare operations for case-insensitive names
JFS supports OS/2-compatibility with case-insensitive file names. To avoid multiple dentries for these names, jfs needs to provide the d_hash and d_compare dentry_operations. The operations are only used when the volume was created in OS/2 or with the -O flag.
Diffstat (limited to 'fs')
-rw-r--r--fs/jfs/namei.c57
-rw-r--r--fs/jfs/super.c5
2 files changed, 60 insertions, 2 deletions
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 871371d5a1aa32..8c3a8e78d0f8ce 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) International Business Machines Corp., 2000-2003
+ * Copyright (C) International Business Machines Corp., 2000-2004
* Portions Copyright (C) Christoph Hellwig, 2001-2002
*
* This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,7 @@
*/
#include <linux/fs.h>
+#include <linux/ctype.h>
#include "jfs_incore.h"
#include "jfs_superblock.h"
#include "jfs_inode.h"
@@ -43,6 +44,7 @@ extern int jfs_init_acl(struct inode *, struct inode *);
*/
struct inode_operations jfs_dir_inode_operations;
struct file_operations jfs_dir_operations;
+struct dentry_operations jfs_ci_dentry_operations;
static s64 commitZeroLink(tid_t, struct inode *);
@@ -1422,7 +1424,15 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
return ERR_PTR(-EACCES);
}
- return d_splice_alias(ip, dentry);
+ if (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2)
+ dentry->d_op = &jfs_ci_dentry_operations;
+
+ dentry = d_splice_alias(ip, dentry);
+
+ if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
+ dentry->d_op = &jfs_ci_dentry_operations;
+
+ return dentry;
}
struct dentry *jfs_get_parent(struct dentry *dentry)
@@ -1476,3 +1486,46 @@ struct file_operations jfs_dir_operations = {
.readdir = jfs_readdir,
.fsync = jfs_fsync,
};
+
+static int jfs_ci_hash(struct dentry *dir, struct qstr *this)
+{
+ unsigned long hash;
+ int i;
+
+ hash = init_name_hash();
+ for (i=0; i < this->len; i++)
+ hash = partial_name_hash(tolower(this->name[i]), hash);
+ this->hash = end_name_hash(hash);
+
+ return 0;
+}
+
+static int jfs_ci_compare(struct dentry *dir, struct qstr *a, struct qstr *b)
+{
+ int i, result = 1;
+
+ if (a->len != b->len)
+ goto out;
+ for (i=0; i < a->len; i++) {
+ if (tolower(a->name[i]) != tolower(b->name[i]))
+ goto out;
+ }
+ result = 0;
+
+ /*
+ * We want creates to preserve case. A negative dentry, a, that
+ * has a different case than b may cause a new entry to be created
+ * with the wrong case. Since we can't tell if a comes from a negative
+ * dentry, we blindly replace it with b. This should be harmless if
+ * a is not a negative dentry.
+ */
+ memcpy((unsigned char *)a->name, b->name, a->len);
+out:
+ return result;
+}
+
+struct dentry_operations jfs_ci_dentry_operations =
+{
+ .d_hash = jfs_ci_hash,
+ .d_compare = jfs_ci_compare,
+};
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index bbe21d1d28647d..9615a83d7ef016 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -82,6 +82,8 @@ extern void jfs_write_inode(struct inode *inode, int wait);
extern struct dentry *jfs_get_parent(struct dentry *dentry);
extern int jfs_extendfs(struct super_block *, s64, int);
+extern struct dentry_operations jfs_ci_dentry_operations;
+
#ifdef PROC_FS_JFS /* see jfs_debug.h */
extern void jfs_proc_init(void);
extern void jfs_proc_clean(void);
@@ -446,6 +448,9 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
if (!sb->s_root)
goto out_no_root;
+ if (sbi->mntflag & JFS_OS2)
+ sb->s_root->d_op = &jfs_ci_dentry_operations;
+
/* logical blocks are represented by 40 bits in pxd_t, etc. */
sb->s_maxbytes = ((u64) sb->s_blocksize) << 40;
#if BITS_PER_LONG == 32