lkml.org 
[lkml]   [1997]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectpatch for 2.1.73 ncpfs
The attached patch for 2.1.73 updates the code a bit and fixes (I hope)
a couple of bugs.

Summary of Changes:
In file.c, a logic error was causing a successful read-only open to be
returned as an error, leaving the file open on the server. I've also
simplified the access test a bit.

Also in file.c, the i_ctime was being changed by writing to a file; this
should be i_atime instead.

The local find_inode_number() has been removed to use the new generic
function instead. The dentry_hash function now leaves the hash code
unchanged for case-sensitive directories.

At umount time the kill_proc() call now sets the priv flag, in case a
non-root user is unmounting.

Changes to sock.c as per Peter Waltenberg's earlier patch.

The patch compiles but is otherwise untested, so please test this out if
you're using ncpfs.

Regards,
Bill--- linux-2.1.73/fs/ncpfs/dir.c.old Sun Nov 30 11:26:13 1997
+++ linux-2.1.73/fs/ncpfs/dir.c Fri Dec 19 11:03:58 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.73/fs/ncpfs/inode.c.old Sun Nov 30 11:26:00 1997
+++ linux-2.1.73/fs/ncpfs/inode.c Fri Dec 19 12:55:38 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.73/fs/ncpfs/file.c.old Sun Nov 30 11:26:00 1997
+++ linux-2.1.73/fs/ncpfs/file.c Fri Dec 19 13:19:18 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;

--- linux-2.1.73/fs/ncpfs/sock.c.old Mon Dec 1 23:56:58 1997
+++ linux-2.1.73/fs/ncpfs/sock.c Fri Dec 19 09:47:43 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);
\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.062 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site