patch for 2.1.76 ncpfs

Bill Hawes (whawes@star.net)
Wed, 31 Dec 1997 11:26:24 -0500


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

The attached patch has some bug fixes and minor improvements for 2.1.76
ncpfs. It should fix a reported problem with files being left open on
the server.

If you're using ncpfs, please give this patch a test and let me know of
any problems.

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

--- linux-2.1.76/fs/ncpfs/dir.c.old Sun Nov 30 11:26:13 1997
+++ linux-2.1.76/fs/ncpfs/dir.c Tue Dec 30 16:49:23 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,42 +206,14 @@
*/
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;
-}
-
-/*
- * Check whether a dentry already exists for the given name,
- * and return the inode number if it has an inode. This is
- * needed to keep getcwd() working.
- */
-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);
-
- dentry = d_lookup(dir, name);
- if (dentry)
- {
- if (dentry->d_inode)
- ino = dentry->d_inode->i_ino;
- dput(dentry);
- }
return ino;
}

--- linux-2.1.76/fs/ncpfs/inode.c.old Sun Nov 30 11:26:00 1997
+++ linux-2.1.76/fs/ncpfs/inode.c Tue Dec 30 16:49:23 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;
}

@@ -354,7 +354,7 @@
ncp_unlock_server(server);

close_fp(server->ncp_filp);
- kill_proc(server->m.wdog_pid, SIGTERM, 0);
+ kill_proc(server->m.wdog_pid, SIGTERM, 1);

ncp_kfree_s(server->packet, server->packet_size);

--- linux-2.1.76/fs/ncpfs/file.c.old Sun Nov 30 11:26:00 1997
+++ linux-2.1.76/fs/ncpfs/file.c Tue Dec 30 16:49:23 1997
@@ -15,11 +15,12 @@
#include <linux/fcntl.h>
#include <linux/stat.h>
#include <linux/mm.h>
-#include <linux/ncp_fs.h>
#include <linux/locks.h>
-#include "ncplib_kernel.h"
#include <linux/malloc.h>

+#include <linux/ncp_fs.h>
+#include "ncplib_kernel.h"
+
static inline int min(int a, int b)
{
return a < b ? a : b;
@@ -65,7 +66,7 @@
result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
NULL, NULL, OC_MODE_OPEN,
0, AR_READ, &finfo);
- if (!result) {
+ if (result) {
#ifdef NCPFS_PARANOIA
printk(KERN_DEBUG "ncp_make_open: failed, result=%d\n", result);
#endif
@@ -82,11 +83,7 @@
#ifdef NCPFS_PARANOIA
printk(KERN_DEBUG "ncp_make_open: file open, access=%x\n", access);
#endif
- if (((right == O_RDONLY) && ((access == O_RDONLY)
- || (access == O_RDWR)))
- || ((right == O_WRONLY) && ((access == O_WRONLY)
- || (access == O_RDWR)))
- || ((right == O_RDWR) && (access == O_RDWR)))
+ if (access == right || access == O_RDWR)
error = 0;

out_unlock:
@@ -231,7 +228,7 @@
}
}

- inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+ inode->i_mtime = inode->i_atime = CURRENT_TIME;

file->f_pos = pos;

--------------DBA51C255B11304C6F2CD072--