patch-2.2.17 linux/fs/smbfs/file.c

Next file: linux/fs/smbfs/inode.c
Previous file: linux/fs/smbfs/dir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.16/fs/smbfs/file.c linux/fs/smbfs/file.c
@@ -4,6 +4,7 @@
  *  Copyright (C) 1995, 1996, 1997 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>
@@ -22,15 +23,8 @@
 #include <linux/smbno.h>
 #include <linux/smb_fs.h>
 
-#define SMBFS_PARANOIA 1
-/* #define SMBFS_DEBUG_VERBOSE 1 */
-/* #define pr_debug printk */
+#include "smb_debug.h"
 
-static inline int
-min(int a, int b)
-{
-	return a < b ? a : b;
-}
 
 static inline void
 smb_unlock_page(struct page *page)
@@ -42,10 +36,7 @@
 static int
 smb_fsync(struct file *file, struct dentry * dentry)
 {
-#ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_fsync: sync file %s/%s\n", 
-dentry->d_parent->d_name.name, dentry->d_name.name);
-#endif
+	VERBOSE("sync file %s/%s\n", DENTRY_PATH(dentry));
 	return 0;
 }
 
@@ -63,17 +54,13 @@
 
 	clear_bit(PG_error, &page->flags);
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_readpage_sync: file %s/%s, count=%d@%ld, rsize=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, count, offset, rsize);
-#endif
+	VERBOSE("file %s/%s, count=%d@%ld, rsize=%d\n",
+		DENTRY_PATH(dentry), count, offset, rsize);
 	result = smb_open(dentry, SMB_O_RDONLY);
 	if (result < 0)
 	{
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_readpage_sync: %s/%s open failed, error=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, result);
-#endif
+		PARANOIA("%s/%s open failed, error=%d\n",
+			 DENTRY_PATH(dentry), result);
 		goto io_error;
 	}
 
@@ -109,10 +96,10 @@
 	struct dentry *dentry = file->f_dentry;
 	int		error;
 
-	pr_debug("SMB: smb_readpage %08lx\n", page_address(page));
+	DEBUG1("SMB: smb_readpage %08lx\n", page_address(page));
 #ifdef SMBFS_PARANOIA
 	if (test_bit(PG_locked, &page->flags))
-		printk(KERN_DEBUG "smb_readpage: page already locked!\n");
+		PARANOIA("page already locked!\n");
 #endif
 	set_bit(PG_locked, &page->flags);
 	atomic_inc(&page->count);
@@ -135,10 +122,8 @@
 	int result, written = 0;
 
 	offset += page->offset;
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_writepage_sync: file %s/%s, count=%d@%ld, wsize=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, count, offset, wsize);
-#endif
+	VERBOSE("file %s/%s, count=%d@%ld, wsize=%d\n",
+		DENTRY_PATH(dentry), count, offset, wsize);
 
 	do {
 		if (count < wsize)
@@ -149,8 +134,9 @@
 			break;
 		/* N.B. what if result < wsize?? */
 #ifdef SMBFS_PARANOIA
-if (result < wsize)
-printk(KERN_DEBUG "smb_writepage_sync: short write, wsize=%d, result=%d\n", wsize, result);
+		if (result < wsize)
+			printk(KERN_DEBUG "short write, wsize=%d, result=%d\n",
+			       wsize, result);
 #endif
 		buffer += wsize;
 		offset += wsize;
@@ -179,7 +165,7 @@
 
 #ifdef SMBFS_PARANOIA
 	if (test_bit(PG_locked, &page->flags))
-		printk(KERN_DEBUG "smb_writepage: page already locked!\n");
+		PARANOIA("page already locked!\n");
 #endif
 	set_bit(PG_locked, &page->flags);
 	atomic_inc(&page->count);
@@ -194,9 +180,8 @@
 {
 	struct dentry *dentry = file->f_dentry;
 
-	pr_debug("SMBFS: smb_updatepage(%s/%s %d@%ld, sync=%d)\n",
-		dentry->d_parent->d_name.name, dentry->d_name.name,
-	 	count, page->offset+offset, sync);
+	DEBUG1("(%s/%s %d@%ld, sync=%d)\n",
+	       DENTRY_PATH(dentry), count, page->offset+offset, sync);
 
 	return smb_writepage_sync(dentry, page, offset, count);
 }
@@ -207,27 +192,21 @@
 	struct dentry * dentry = file->f_dentry;
 	ssize_t	status;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_read: file %s/%s, count=%lu@%lu\n",
-dentry->d_parent->d_name.name, dentry->d_name.name,
-(unsigned long) count, (unsigned long) *ppos);
-#endif
+	VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry),
+		(unsigned long) count, (unsigned long) *ppos);
 
 	status = smb_revalidate_inode(dentry);
 	if (status)
 	{
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_file_read: %s/%s validation failed, error=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, status);
-#endif
+		PARANOIA("%s/%s validation failed, error=%d\n",
+			 DENTRY_PATH(dentry), status);
 		goto out;
 	}
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_read: before read, size=%ld, pages=%ld, flags=%x, atime=%ld\n",
-dentry->d_inode->i_size, dentry->d_inode->i_nrpages, dentry->d_inode->i_flags,
-dentry->d_inode->i_atime);
-#endif
+	VERBOSE("before read, size=%ld, pages=%ld, flags=%x, atime=%ld\n",
+		dentry->d_inode->i_size, dentry->d_inode->i_nrpages,
+		dentry->d_inode->i_flags, dentry->d_inode->i_atime);
+
 	status = generic_file_read(file, buf, count, ppos);
 out:
 	return status;
@@ -239,18 +218,14 @@
 	struct dentry * dentry = file->f_dentry;
 	int	status;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_mmap: file %s/%s, address %lu - %lu\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, vma->vm_start, vma->vm_end);
-#endif
+	VERBOSE("file %s/%s, address %lu - %lu\n",
+		DENTRY_PATH(dentry), vma->vm_start, vma->vm_end);
 
 	status = smb_revalidate_inode(dentry);
 	if (status)
 	{
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_file_mmap: %s/%s validation failed, error=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, status);
-#endif
+		PARANOIA("%s/%s validation failed, error=%d\n",
+			 DENTRY_PATH(dentry), status);
 		goto out;
 	}
 	status = generic_file_mmap(file, vma);
@@ -267,20 +242,16 @@
 	struct dentry * dentry = file->f_dentry;
 	ssize_t	result;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_write: file %s/%s, count=%lu@%lu, pages=%ld\n",
-dentry->d_parent->d_name.name, dentry->d_name.name,
-(unsigned long) count, (unsigned long) *ppos, dentry->d_inode->i_nrpages);
-#endif
+	VERBOSE("file %s/%s, count=%lu@%lu, pages=%ld\n", DENTRY_PATH(dentry),
+		(unsigned long) count, (unsigned long) *ppos,
+		dentry->d_inode->i_nrpages);
 
 	result = smb_revalidate_inode(dentry);
 	if (result)
 	{
-#ifdef SMBFS_PARANOIA
-printk(KERN_DEBUG "smb_file_write: %s/%s validation failed, error=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, result);
-#endif
-			goto out;
+		PARANOIA("%s/%s validation failed, error=%d\n",
+			 DENTRY_PATH(dentry), result);
+		goto out;
 	}
 
 	result = smb_open(dentry, SMB_O_WRONLY);
@@ -290,11 +261,9 @@
 	if (count > 0)
 	{
 		result = generic_file_write(file, buf, count, ppos);
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_write: pos=%ld, size=%ld, mtime=%ld, atime=%ld\n",
-(long) file->f_pos, dentry->d_inode->i_size, dentry->d_inode->i_mtime,
-dentry->d_inode->i_atime);
-#endif
+		VERBOSE("pos=%ld, size=%ld, mtime=%ld, atime=%ld\n",
+			(long) file->f_pos, dentry->d_inode->i_size,
+			dentry->d_inode->i_mtime, dentry->d_inode->i_atime);
 	}
 out:
 	return result;
@@ -303,11 +272,8 @@
 static int
 smb_file_open(struct inode *inode, struct file * file)
 {
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_open: opening %s/%s, d_count=%d\n",
-file->f_dentry->d_parent->d_name.name, file->f_dentry->d_name.name,
-file->f_dentry->d_count);
-#endif
+	VERBOSE("opening %s/%s, d_count=%d\n",
+		DENTRY_PATH(file->f_dentry), file->f_dentry->d_count);
 	return 0;
 }
 
@@ -316,15 +282,12 @@
 {
 	struct dentry * dentry = file->f_dentry;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_release: closing %s/%s, d_count=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, dentry->d_count);
-#endif
-	
+	VERBOSE("closing %s/%s, d_count=%d\n",
+		DENTRY_PATH(dentry), dentry->d_count);
+
 	if (dentry->d_count == 1)
-	{
 		smb_close(inode);
-	}
+
 	return 0;
 }
 
@@ -339,9 +302,8 @@
 	int mode = inode->i_mode;
 	int error = 0;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk(KERN_DEBUG "smb_file_permission: mode=%x, mask=%x\n", mode, mask);
-#endif
+	VERBOSE("mode=%x, mask=%x\n", mode, mask);
+
 	/* Look at user permissions */
 	mode >>= 6;
 	if ((mode & 7 & mask) != mask)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)