patch-2.2.17 linux/fs/smbfs/sock.c
Next file: linux/fs/ufs/acl.c
Previous file: linux/fs/smbfs/smb_debug.h
Back to the patch index
Back to the overall index
- Lines: 368
- Date:
Mon Sep 4 18:39:27 2000
- Orig file:
v2.2.16/fs/smbfs/sock.c
- Orig date:
Mon Sep 4 18:37:06 2000
diff -u --recursive --new-file v2.2.16/fs/smbfs/sock.c linux/fs/smbfs/sock.c
@@ -4,6 +4,7 @@
* Copyright (C) 1995, 1996 by Paal-Kr. Engstad and Volker Lendecke
* Copyright (C) 1997 by Volker Lendecke
*
+ * Please add a note about your changes to smbfs in the ChangeLog file.
*/
#include <linux/sched.h>
@@ -25,8 +26,7 @@
#include <asm/uaccess.h>
-#define SMBFS_PARANOIA 1
-/* #define SMBFS_DEBUG_VERBOSE 1 */
+#include "smb_debug.h"
static int
_recvfrom(struct socket *socket, unsigned char *ubuf, int size,
@@ -118,9 +118,7 @@
result = -EIO;
if (job->sk->dead)
{
-#ifdef SMBFS_PARANOIA
- printk(KERN_DEBUG "smb_data_callback: sock dead!\n");
-#endif
+ PARANOIA("sock dead!\n");
break;
}
@@ -135,7 +133,7 @@
result = _recvfrom(socket, (void *) peek_buf, 4,
MSG_DONTWAIT);
- pr_debug("smb_data_callback: got SESSION KEEPALIVE\n");
+ DEBUG1("got SESSION KEEPALIVE\n");
if (result == -EAGAIN)
break;
@@ -154,7 +152,7 @@
struct data_callback* job;
job = kmalloc(sizeof(struct data_callback),GFP_ATOMIC);
if(job == 0) {
- printk("smb_data_ready(): lost SESSION KEEPALIVE due to OOM.\n");
+ printk("smb_data_ready: lost SESSION KEEPALIVE due to OOM.\n");
found_data(sk);
return;
}
@@ -182,7 +180,7 @@
{
#ifdef SMBFS_PARANOIA
if (!smb_valid_socket(file->f_dentry->d_inode))
- printk(KERN_DEBUG "smb_server_sock: bad socket!\n");
+ PARANOIA("bad socket!\n");
#endif
return &file->f_dentry->d_inode->u.socket_i;
}
@@ -209,13 +207,13 @@
sk = socket->sk;
if (sk == NULL)
{
- pr_debug("smb_catch_keepalive: sk == NULL");
+ DEBUG1("sk == NULL");
server->data_ready = NULL;
goto out;
}
- pr_debug("smb_catch_keepalive.: sk->d_r = %x, server->d_r = %x\n",
- (unsigned int) (sk->data_ready),
- (unsigned int) (server->data_ready));
+ DEBUG1("sk->d_r = %x, server->d_r = %x\n",
+ (unsigned int) (sk->data_ready),
+ (unsigned int) (server->data_ready));
/*
* Install the callback atomically to avoid races ...
@@ -261,9 +259,9 @@
"server->data_ready == NULL\n");
goto out;
}
- pr_debug("smb_dont_catch_keepalive: sk->d_r = %x, server->d_r = %x\n",
- (unsigned int) (sk->data_ready),
- (unsigned int) (server->data_ready));
+ DEBUG1("sk->d_r = %x, server->d_r = %x\n",
+ (unsigned int) (sk->data_ready),
+ (unsigned int) (server->data_ready));
/*
* Restore the original callback atomically to avoid races ...
@@ -272,7 +270,7 @@
server->data_ready = NULL;
if (data_ready != smb_data_ready)
{
- printk("smb_dont_catch_keepalive: "
+ printk(KERN_ERR "smb_dont_catch_keepalive: "
"sk->data_ready != smb_data_ready\n");
}
error = 0;
@@ -288,14 +286,11 @@
{
struct file * file = server->sock_file;
- if (file)
- {
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_close_socket: closing socket %p\n", server_sock(server));
-#endif
+ if (file) {
+ VERBOSE("closing socket %p\n", server_sock(server));
#ifdef SMBFS_PARANOIA
-if (server_sock(server)->sk->data_ready == smb_data_ready)
-printk(KERN_DEBUG "smb_close_socket: still catching keepalives!\n");
+ if (server_sock(server)->sk->data_ready == smb_data_ready)
+ PARANOIA("still catching keepalives!\n");
#endif
server->sock_file = NULL;
fput(file);
@@ -320,8 +315,7 @@
}
if (result < 0)
{
- pr_debug("smb_send_raw: sendto error = %d\n",
- -result);
+ DEBUG1("sendto error = %d\n", -result);
return result;
}
already_sent += result;
@@ -347,8 +341,7 @@
}
if (result < 0)
{
- pr_debug("smb_receive_raw: recvfrom error = %d\n",
- -result);
+ DEBUG1("recvfrom error = %d\n", -result);
return result;
}
already_read += result;
@@ -371,9 +364,7 @@
if (result < 0)
{
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_get_length: recv error = %d\n", -result);
-#endif
+ PARANOIA("recv error = %d\n", -result);
return result;
}
switch (peek_buf[0])
@@ -383,13 +374,11 @@
break;
case 0x85:
- pr_debug("smb_get_length: Got SESSION KEEP ALIVE\n");
+ DEBUG1("Got SESSION KEEP ALIVE\n");
goto re_recv;
default:
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_get_length: Invalid NBT packet, code=%x\n", peek_buf[0]);
-#endif
+ PARANOIA("Invalid NBT packet, code=%x\n", peek_buf[0]);
return -EIO;
}
@@ -448,17 +437,15 @@
result = smb_receive_raw(socket, packet + 4, len);
if (result < 0)
{
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_receive: receive error: %d\n", result);
-#endif
+ VERBOSE("receive error: %d\n", result);
goto out;
}
server->rcls = *(packet + smb_rcls);
server->err = WVAL(packet, smb_err);
#ifdef SMBFS_DEBUG_VERBOSE
-if (server->rcls != 0)
-printk(KERN_DEBUG "smb_receive: rcls=%d, err=%d\n", server->rcls, server->err);
+ if (server->rcls != 0)
+ VERBOSE("rcls=%d, err=%d\n", server->rcls, server->err);
#endif
out:
return result;
@@ -521,10 +508,10 @@
*/
if (parm_count == parm_tot && data_count == data_tot)
{
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_receive_trans2: fast track, parm=%u %u %u, data=%u %u %u\n",
-parm_disp, parm_offset, parm_count, data_disp, data_offset, data_count);
-#endif
+ VERBOSE("fast track, parm=%u %u %u, data=%u %u %u\n",
+ parm_disp, parm_offset, parm_count,
+ data_disp, data_offset, data_count);
+
*parm = base + parm_offset;
*data = base + data_offset;
goto success;
@@ -561,10 +548,9 @@
memcpy(*parm + parm_disp, base + parm_offset, parm_count);
memcpy(*data + data_disp, base + data_offset, data_count);
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_receive_trans2: copied, parm=%u of %u, data=%u of %u\n",
-parm_len, parm_tot, data_len, data_tot);
-#endif
+ PARANOIA("copied, parm=%u of %u, data=%u of %u\n",
+ parm_len, parm_tot, data_len, data_tot);
+
/*
* Check whether we've received all of the data. Note that
* we use the packet totals -- total lengths might shrink!
@@ -584,12 +570,9 @@
server->packet_size = buf_len;
server->packet = rcv_buf;
rcv_buf = inbuf;
- } else
- {
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_receive_trans2: copying data, old size=%d, new size=%u\n",
-server->packet_size, buf_len);
-#endif
+ } else {
+ PARANOIA("copying data, old size=%d, new size=%u\n",
+ server->packet_size, buf_len);
memcpy(inbuf, rcv_buf, parm_len + data_len);
}
@@ -602,25 +585,23 @@
return result;
out_no_mem:
-#ifdef SMBFS_PARANOIA
- printk(KERN_DEBUG "smb_receive_trans2: couldn't allocate data area\n");
-#endif
+ printk(KERN_ERR "smb_receive_trans2: couldn't allocate data area\n");
result = -ENOMEM;
goto out;
out_too_long:
- printk(KERN_DEBUG "smb_receive_trans2: data/param too long, data=%d, parm=%d\n",
- data_tot, parm_tot);
+ printk(KERN_ERR "smb_receive_trans2: data/param too long, data=%d, parm=%d\n",
+ data_tot, parm_tot);
goto out_error;
out_data_grew:
- printk(KERN_DEBUG "smb_receive_trans2: data/params grew!\n");
+ printk(KERN_ERR "smb_receive_trans2: data/params grew!\n");
goto out_error;
out_bad_parm:
- printk(KERN_DEBUG "smb_receive_trans2: invalid parms, disp=%d, cnt=%d, tot=%d\n",
- parm_disp, parm_count, parm_tot);
+ printk(KERN_ERR "smb_receive_trans2: invalid parms, disp=%d, cnt=%d, tot=%d\n",
+ parm_disp, parm_count, parm_tot);
goto out_error;
out_bad_data:
- printk(KERN_DEBUG "smb_receive_trans2: invalid data, disp=%d, cnt=%d, tot=%d\n",
- data_disp, data_count, data_tot);
+ printk(KERN_ERR "smb_receive_trans2: invalid data, disp=%d, cnt=%d, tot=%d\n",
+ data_disp, data_count, data_tot);
out_error:
result = -EIO;
goto out;
@@ -651,7 +632,7 @@
goto bad_conn;
len = smb_len(buffer) + 4;
- pr_debug("smb_request: len = %d cmd = 0x%X\n", len, buffer[8]);
+ DEBUG1("len = %d cmd = 0x%X\n", len, buffer[8]);
spin_lock_irqsave(¤t->sigmask_lock, flags);
sigpipe = sigismember(¤t->signal, SIGPIPE);
@@ -684,7 +665,7 @@
int result2 = smb_catch_keepalive(server);
if (result2 < 0)
{
- printk(KERN_DEBUG "smb_request: catch keepalive failed\n");
+ printk(KERN_ERR "smb_request: catch keepalive failed\n");
result = result2;
}
}
@@ -696,28 +677,27 @@
if (server->rcls) {
int error = smb_errno(server);
if (error == EBADSLT) {
- printk(KERN_DEBUG "smb_request: tree ID invalid\n");
+ printk(KERN_ERR "smb_request: tree ID invalid\n");
result = error;
goto bad_conn;
}
}
out:
- pr_debug("smb_request: result = %d\n", result);
+ DEBUG1("result = %d\n", result);
return result;
bad_conn:
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_request: result %d, setting invalid\n", result);
-#endif
+ PARANOIA("result %d, setting invalid\n", result);
server->state = CONN_INVALID;
smb_invalidate_inodes(server);
- goto out;
+ goto out;
bad_no_packet:
- printk(KERN_DEBUG "smb_request: no packet!\n");
+ printk(KERN_ERR "smb_request: no packet!\n");
goto out;
bad_no_conn:
- printk(KERN_DEBUG "smb_request: connection %d not valid!\n", server->state);
+ printk(KERN_ERR "smb_request: connection %d not valid!\n",
+ server->state);
goto out;
}
@@ -736,16 +716,15 @@
const int smb_parameters = 15;
const int oparam =
- ROUND_UP(SMB_HEADER_LEN + 2 * smb_parameters + 2 + 3);
+ ROUND_UP(SMB_HEADER_LEN + 2 * smb_parameters + 2 + 3);
const int odata =
- ROUND_UP(oparam + lparam);
+ ROUND_UP(oparam + lparam);
const int bcc =
- odata + ldata - (SMB_HEADER_LEN + 2 * smb_parameters + 2);
+ odata + ldata - (SMB_HEADER_LEN + 2 * smb_parameters + 2);
const int packet_length =
- SMB_HEADER_LEN + 2 * smb_parameters + bcc + 2;
+ SMB_HEADER_LEN + 2 * smb_parameters + bcc + 2;
- unsigned char padding[4] =
- {0,};
+ unsigned char padding[4] = {0,};
char *p;
struct iovec iov[4];
@@ -819,8 +798,7 @@
mm_segment_t fs;
int result;
- pr_debug("smb_trans2_request: com=%d, ld=%d, lp=%d\n",
- trans2_command, ldata, lparam);
+ DEBUG1("com=%d, ld=%d, lp=%d\n", trans2_command, ldata, lparam);
/*
* These are initialized in smb_request_ok, but not here??
@@ -879,7 +857,7 @@
if (server->rcls) {
int error = smb_errno(server);
if (error == EBADSLT) {
- printk(KERN_DEBUG "smb_request: tree ID invalid\n");
+ printk(KERN_ERR "smb_request: tree ID invalid\n");
result = error;
goto bad_conn;
}
@@ -889,9 +867,7 @@
return result;
bad_conn:
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_trans2_request: result=%d, setting invalid\n", result);
-#endif
+ PARANOIA("result=%d, setting invalid\n", result);
server->state = CONN_INVALID;
smb_invalidate_inodes(server);
goto out;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)