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

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

diff -u --recursive --new-file v2.2.16/fs/smbfs/dir.c linux/fs/smbfs/dir.c
@@ -4,18 +4,19 @@
  *  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>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/ctype.h>
 
 #include <linux/smb_fs.h>
 #include <linux/smbno.h>
 
-#define SMBFS_PARANOIA 1
-/* #define SMBFS_DEBUG_VERBOSE 1 */
-/* #define pr_debug printk */
+#include "smb_debug.h"
+
 #define SMBFS_MAX_AGE 5*HZ
 
 static ssize_t smb_dir_read(struct file *, char *, size_t, loff_t *);
@@ -83,10 +84,8 @@
 	struct cache_head *cachep = NULL;
 	int result;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-	printk("smb_readdir: reading %s/%s, f_pos=%d\n",
-	       dentry->d_parent->d_name.name, dentry->d_name.name, (int) filp->f_pos);
-#endif
+	VERBOSE("reading %s/%s, f_pos=%d\n", DENTRY_PATH(dentry),
+		(int) filp->f_pos);
 
 	result = 0;
 	switch ((unsigned int) filp->f_pos)
@@ -117,10 +116,13 @@
 		goto out;
 	/*
 	 * Make sure the cache is up-to-date.
+	 *
+	 * To detect changes on the server we refill on each "new" access.
+	 *
+	 * Directory mtime would be nice to use for finding changes,
+	 * unfortunately some servers (NT4) doesn't update on local changes.
 	 */
-	if (!cachep->valid ||
-	    (cachep->mtime != dentry->d_inode->i_mtime &&
-	     filp->f_pos == 2))
+	if (!cachep->valid || filp->f_pos == 2)
 	{
 		result = smb_refill_dircache(cachep, dentry);
 		if (result)
@@ -174,11 +176,9 @@
 	struct dentry *dentry = file->f_dentry;
 	struct smb_sb_info *server = server_from_dentry(dentry);
 	int error = 0;
-#ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_dir_open: (%s/%s)\n", dentry->d_parent->d_name.name, 
-file->f_dentry->d_name.name);
-#endif
 
+	VERBOSE("(%s/%s)\n", dentry->d_parent->d_name.name, 
+		file->f_dentry->d_name.name);
 	if (server->conn_pid)
 		error = smb_revalidate_inode(dentry);
 	return error;
@@ -217,37 +217,24 @@
 	 */
 	valid = (age <= SMBFS_MAX_AGE);
 #ifdef SMBFS_DEBUG_VERBOSE
-if (!valid)
-printk("smb_lookup_validate: %s/%s not valid, age=%lu\n", 
-dentry->d_parent->d_name.name, dentry->d_name.name, age);
+	if (!valid)
+		VERBOSE("%s/%s not valid, age=%lu\n", DENTRY_PATH(dentry), age);
 #endif
 
-	if (inode)
-	{
-		if (is_bad_inode(inode))
-		{
-#ifdef SMBFS_PARANOIA
-			printk(KERN_DEBUG "smb_lookup_validate: %s/%s has dud inode\n", 
-			       dentry->d_parent->d_name.name, dentry->d_name.name);
-#endif
+	if (inode) {
+		if (is_bad_inode(inode)) {
+			PARANOIA("%s/%s has dud inode\n", DENTRY_PATH(dentry));
 			valid = 0;
 		} else if (!valid)
 			valid = (smb_revalidate_inode(dentry) == 0);
-	} else
-	{
-	/*
-	 * What should we do for negative dentries?
-	 */
+	} else {
+		/*
+		 * What should we do for negative dentries?
+		 */
 	}
 	return valid;
 }
 
-/*
- * XXX: It would be better to use the tolower from linux/ctype.h,
- * but _ctype is needed and it is not exported.
- */
-#define tolower(c) (((c) >= 'A' && (c) <= 'Z') ? (c)-('A'-'a') : (c))
-
 static int 
 smb_hash_dentry(struct dentry *dir, struct qstr *this)
 {
@@ -286,20 +273,15 @@
 static void
 smb_delete_dentry(struct dentry * dentry)
 {
-	if (dentry->d_inode)
-	{
-		if (is_bad_inode(dentry->d_inode))
-		{
-#ifdef SMBFS_PARANOIA
-			printk(KERN_DEBUG "smb_delete_dentry: bad inode, unhashing %s/%s\n", 
-			       dentry->d_parent->d_name.name, dentry->d_name.name);
-#endif
+	if (dentry->d_inode) {
+		if (is_bad_inode(dentry->d_inode)) {
+			PARANOIA("bad inode, unhashing %s/%s\n", 
+				 DENTRY_PATH(dentry));
 			d_drop(dentry);
 		}
 		smb_close_dentry(dentry);
-	} else
-	{
-	/* N.B. Unhash negative dentries? */
+	} else {
+		/* N.B. Unhash negative dentries? */
 	}
 }
 
@@ -334,8 +316,8 @@
 	error = smb_proc_getattr(dentry, &finfo);
 #ifdef SMBFS_PARANOIA
 	if (error && error != -ENOENT)
-		printk(KERN_DEBUG "smb_lookup: find %s/%s failed, error=%d\n",
-		       dentry->d_parent->d_name.name, dentry->d_name.name, error);
+		PARANOIA("find %s/%s failed, error=%d\n",
+			 DENTRY_PATH(dentry), error);
 #endif
 
 	inode = NULL;
@@ -370,10 +352,7 @@
 	int error;
 	struct smb_fattr fattr;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_instantiate: file %s/%s, fileid=%u\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, fileid);
-#endif
+	VERBOSE("file %s/%s, fileid=%u\n", DENTRY_PATH(dentry), fileid);
 	error = smb_proc_getattr(dentry, &fattr);
 	if (error)
 		goto out_close;
@@ -399,10 +378,8 @@
 out_close:
 	if (have_id)
 	{
-#ifdef SMBFS_PARANOIA
-		printk(KERN_DEBUG "smb_instantiate: %s/%s failed, error=%d, closing %u\n",
-		       dentry->d_parent->d_name.name, dentry->d_name.name, error, fileid);
-#endif
+		PARANOIA("%s/%s failed, error=%d, closing %u\n",
+			 DENTRY_PATH(dentry), error, fileid);
 		smb_close_fileid(dentry, fileid);
 	}
 	goto out;
@@ -415,21 +392,14 @@
 	__u16 fileid;
 	int error;
 
-#ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_create: creating %s/%s, mode=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, mode);
-#endif
+	VERBOSE("creating %s/%s, mode=%d\n", DENTRY_PATH(dentry), mode);
 
 	error = smb_proc_create(dentry, 0, CURRENT_TIME, &fileid);
-	if (!error)
-	{
+	if (!error) {
 		error = smb_instantiate(dentry, fileid, 1);
-	} else
-	{
-#ifdef SMBFS_PARANOIA
-		printk(KERN_DEBUG "smb_create: %s/%s failed, error=%d\n",
-		       dentry->d_parent->d_name.name, dentry->d_name.name, error);
-#endif
+	} else {
+		PARANOIA("%s/%s failed, error=%d\n",
+			 DENTRY_PATH(dentry), error);
 	}
 	return error;
 }
@@ -509,10 +479,8 @@
 		error = smb_proc_unlink(new_dentry);
 		if (error)
 		{
-#ifdef SMBFS_DEBUG_VERBOSE
-			printk(KERN_DEBUG "smb_rename: unlink %s/%s, error=%d\n",
-			       new_dentry->d_parent->d_name.name, new_dentry->d_name.name, error);
-#endif
+			VERBOSE("unlink %s/%s, error=%d\n",
+				DENTRY_PATH(new_dentry), error);
 			goto out;
 		}
 		/* FIXME */

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