patch-1.3.68 linux/fs/ncpfs/inode.c
Next file: linux/fs/ncpfs/mmap.c
Previous file: linux/fs/ncpfs/file.c
Back to the patch index
Back to the overall index
- Lines: 167
- Date:
Thu Feb 22 15:35:35 1996
- Orig file:
v1.3.67/linux/fs/ncpfs/inode.c
- Orig date:
Tue Jan 23 21:15:51 1996
diff -u --recursive --new-file v1.3.67/linux/fs/ncpfs/inode.c linux/fs/ncpfs/inode.c
@@ -6,6 +6,7 @@
*/
#include <linux/module.h>
+#include <linux/config.h>
#include <asm/system.h>
#include <asm/segment.h>
@@ -20,6 +21,9 @@
#include <linux/locks.h>
#include <linux/fcntl.h>
#include <linux/malloc.h>
+#ifdef CONFIG_KERNELD
+#include <linux/kerneld.h>
+#endif
#include "ncplib_kernel.h"
extern int close_fp(struct file *filp);
@@ -182,6 +186,7 @@
struct ncp_server *server;
struct file *ncp_filp;
struct file *wdog_filp;
+ struct file *msg_filp;
kdev_t dev = sb->s_dev;
int error;
@@ -197,6 +202,8 @@
printk("ncp warning: mount version %s than kernel\n",
(data->version < NCP_MOUNT_VERSION) ?
"older" : "newer");
+ sb->s_dev = 0;
+ return NULL;
}
if ( (data->ncp_fd >= NR_OPEN)
@@ -217,6 +224,15 @@
return NULL;
}
+ if ( (data->message_fd >= NR_OPEN)
+ || ((msg_filp = current->files->fd[data->message_fd]) == NULL)
+ || (!S_ISSOCK(msg_filp->f_inode->i_mode)))
+ {
+ printk("ncp_read_super: invalid wdog socket\n");
+ sb->s_dev = 0;
+ return NULL;
+ }
+
/* We must malloc our own super-block info */
server = (struct ncp_server *)ncp_kmalloc(sizeof(struct ncp_server),
GFP_KERNEL);
@@ -229,6 +245,7 @@
ncp_filp->f_count += 1;
wdog_filp->f_count += 1;
+ msg_filp->f_count += 1;
lock_super(sb);
@@ -242,10 +259,12 @@
server->ncp_filp = ncp_filp;
server->wdog_filp = wdog_filp;
+ server->msg_filp = msg_filp;
server->lock = 0;
server->wait = NULL;
server->packet = NULL;
server->buffer_size = 0;
+ server->conn_status = 0;
server->m = *data;
server->m.file_mode = (server->m.file_mode &
@@ -253,6 +272,9 @@
server->m.dir_mode = (server->m.dir_mode &
(S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFDIR;
+ /* protect against invalid mount points */
+ server->m.mount_point[sizeof(server->m.mount_point)-1] = '\0';
+
server->packet_size = NCP_PACKET_SIZE;
server->packet = ncp_kmalloc(NCP_PACKET_SIZE, GFP_KERNEL);
@@ -278,6 +300,15 @@
goto fail;
}
+ if (ncp_catch_message(server) != 0)
+ {
+ printk("ncp_read_super: Could not catch messages\n");
+ ncp_dont_catch_watchdog(server);
+ error = -EINVAL;
+ unlock_super(sb);
+ goto fail;
+ }
+
ncp_lock_server(server);
error = ncp_connect(server);
ncp_unlock_server(server);
@@ -324,6 +355,7 @@
fail:
ncp_filp->f_count -= 1;
wdog_filp->f_count -= 1;
+ msg_filp->f_count -= 1;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
return NULL;
}
@@ -343,6 +375,7 @@
ncp_dont_catch_watchdog(server);
close_fp(server->wdog_filp);
+ close_fp(server->msg_filp);
ncp_free_all_inodes(server);
@@ -357,6 +390,32 @@
MOD_DEC_USE_COUNT;
}
+/* This routine is called from an interrupt in ncp_msg_data_ready. So
+ * we have to be careful NOT to sleep here! */
+void
+ncp_trigger_message(struct ncp_server *server)
+{
+ char command[ sizeof(server->m.mount_point)
+ + sizeof(NCP_MSG_COMMAND) + 2];
+
+ if (server == NULL)
+ {
+ printk("ncp_trigger_message: invalid server!\n");
+ return;
+ }
+
+ DPRINTK("ncp_trigger_message: on %s\n",
+ server->m.mount_point);
+
+#ifdef CONFIG_KERNELD
+ strcpy(command, NCP_MSG_COMMAND);
+ strcat(command, " ");
+ strcat(command, server->m.mount_point);
+ DPRINTK("ksystem: %s\n", command);
+ ksystem(command, KERNELD_NOWAIT);
+#endif
+}
+
static void
ncp_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
{
@@ -386,6 +445,11 @@
int info_mask;
struct nw_modify_dos_info info;
+ if (!ncp_conn_valid(NCP_SERVER(inode)))
+ {
+ return -EIO;
+ }
+
if ((result = inode_change_ok(inode, attr)) < 0)
return result;
@@ -493,6 +557,7 @@
}
#ifdef MODULE
+int
init_module( void)
{
int status;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this