patch for 2.1.72 ncpfs

Bill Hawes (whawes@star.net)
Sat, 13 Dec 1997 09:42:06 -0500


This is a multi-part message in MIME format.
--------------F5636C69809B24BE229D1E2C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The attached patch makes a couple of minor changes to the ncpfs dentry
operations routines. The find_inode_number() routine is now reasonably
generic and should work for any fs using synthetic inode numbers. (The
code in smbfs and ncpfs is now identical.) Also, the inode numbers now
start at 2 in keeping with the traditional unix convention.

I made a small change to the dentry hashing routine to leave the hash
code unchanged if you're in a case-sensitive directory -- this should
give slightly better hashing performance.

The patch includes Peter's previously-posted changes to sock.c.

Regards,
Bill
--------------F5636C69809B24BE229D1E2C
Content-Type: text/plain; charset=us-ascii; name="ncpfs_72-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="ncpfs_72-patch"

--- linux-2.1.72/fs/ncpfs/dir.c.old Sun Nov 30 11:26:13 1997
+++ linux-2.1.72/fs/ncpfs/dir.c Sat Dec 13 10:19:53 1997
@@ -105,10 +105,10 @@
/*
* Dentry operations routines
*/
-static int ncp_lookup_validate(struct dentry *);
-static void ncp_delete_dentry(struct dentry *);
+static int ncp_lookup_validate(struct dentry *);
static int ncp_hash_dentry(struct dentry *, struct qstr *);
static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *);
+static void ncp_delete_dentry(struct dentry *);

static struct dentry_operations ncp_dentry_operations =
{
@@ -125,19 +125,23 @@
*/
#define tolower(c) (((c) >= 'A' && (c) <= 'Z') ? (c)-('A'-'a') : (c))

-
+/*
+ * Note: leave the hash unchanged if the directory
+ * is case-sensitive.
+ */
static int
ncp_hash_dentry(struct dentry *dentry, struct qstr *this)
{
- unsigned long hash;
- int i;
+ 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;
+ if (!ncp_case_sensitive(dentry->d_inode)) {
+ 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
@@ -202,12 +206,12 @@
*/
ino_t ncp_invent_inos(unsigned long n)
{
- static ino_t ino = 1;
+ static ino_t ino = 2;

if (ino + 2*n < ino)
{
/* wrap around */
- ino += n;
+ ino = 2;
}
ino += n;
return ino;
@@ -221,16 +225,21 @@
static ino_t
find_inode_number(struct dentry *dir, struct qstr *name)
{
- unsigned long hash;
- int i;
struct dentry * dentry;
ino_t ino = 0;
-
- hash = init_name_hash();
- for (i=0; i<name->len ; i++)
- hash = partial_name_hash(tolower(name->name[i]),hash);
- name->hash = end_name_hash(hash);
-
+
+ /*
+ * Check for a fs-specific hash function. Note that we must
+ * calculate the standard hash first, as the d_op->d_hash()
+ * routine may choose to leave the hash value unchanged.
+ */
+ name->hash = full_name_hash(name->name, name->len);
+ if (dir->d_op && dir->d_op->d_hash)
+ {
+ if (dir->d_op->d_hash(dir, name) != 0)
+ goto out;
+ }
+
dentry = d_lookup(dir, name);
if (dentry)
{
@@ -238,6 +247,7 @@
ino = dentry->d_inode->i_ino;
dput(dentry);
}
+out:
return ino;
}

--- linux-2.1.72/fs/ncpfs/inode.c.old Sun Nov 30 11:26:00 1997
+++ linux-2.1.72/fs/ncpfs/inode.c Sat Dec 13 10:43:07 1997
@@ -210,7 +210,7 @@
i->entryName[0] = '\0';

root->finfo.opened= 0;
- info->ino = 1;
+ info->ino = 2; /* tradition */
info->nw_info = root->finfo;
}

--- linux-2.1.72/fs/ncpfs/sock.c.old Mon Dec 1 23:56:58 1997
+++ linux-2.1.72/fs/ncpfs/sock.c Sat Dec 13 09:43:27 1997
@@ -18,6 +18,7 @@
#include <linux/net.h>
#include <linux/mm.h>
#include <linux/netdevice.h>
+#include <linux/signal.h>
#include <net/scm.h>
#include <net/sock.h>
#include <linux/ipx.h>
@@ -124,12 +125,12 @@
What if we've blocked it ourselves? What about
alarms? Why, in fact, are we mucking with the
sigmask at all? -- r~ */
- if (current->sig->action[SIGINT - 1].sa_handler == SIG_DFL)
+ if (current->sig->action[SIGINT - 1].sa.sa_handler == SIG_DFL)
mask |= sigmask(SIGINT);
- if (current->sig->action[SIGQUIT - 1].sa_handler == SIG_DFL)
+ if (current->sig->action[SIGQUIT - 1].sa.sa_handler == SIG_DFL)
mask |= sigmask(SIGQUIT);
}
- siginitmaskinv(&current->blocked, mask);
+ siginitsetinv(&current->blocked, mask);
recalc_sigpending(current);
spin_unlock_irqrestore(&current->sigmask_lock, flags);

@@ -278,7 +279,7 @@
}

spin_lock_irqsave(&current->sigmask_lock, flags);
- current->blocked = old_mask;
+ current->blocked = old_set;
recalc_sigpending(current);
spin_unlock_irqrestore(&current->sigmask_lock, flags);

--------------F5636C69809B24BE229D1E2C--