patch-2.1.71 linux/fs/affs/dir.c

Next file: linux/fs/affs/file.c
Previous file: linux/fs/affs/bitmap.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.70/linux/fs/affs/dir.c linux/fs/affs/dir.c
@@ -13,6 +13,7 @@
  *
  */
 
+#define DEBUG 0
 #include <asm/uaccess.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
@@ -24,8 +25,7 @@
 #include <linux/amigaffs.h>
 
 static int affs_readdir(struct file *, void *, filldir_t);
-static ssize_t affs_dir_read(struct file * filp, char * buf,
-			     size_t count, loff_t *ppos);
+static ssize_t affs_dir_read(struct file *, char *, size_t, loff_t *);
 
 static struct file_operations affs_dir_operations = {
 	NULL,			/* lseek - default */
@@ -55,11 +55,15 @@
 	NULL,			/* mknod */
 	affs_rename,		/* rename */
 	NULL,			/* readlink */
+	NULL,			/* follow_link */
 	NULL,			/* readpage */
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permissions */
+	NULL,			/* permissions */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL			/* revalidate */
 };
 
 static ssize_t
@@ -76,15 +80,14 @@
 	int			 hash_pos;
 	int			 chain_pos;
 	unsigned long		 ino;
-	unsigned long		 old;
 	int			 stored;
-	char			 *name;
-	struct buffer_head	 *dir_bh;
-	struct buffer_head	 *fh_bh;
-	struct inode		 *dir;
-	struct inode 		 *inode = filp->f_dentry->d_inode;
+	unsigned char		*name;
+	struct buffer_head	*dir_bh;
+	struct buffer_head	*fh_bh;
+	struct inode		*dir;
+	struct inode		*inode = filp->f_dentry->d_inode;
 
-	pr_debug("AFFS: readdir(ino=%ld,f_pos=%lu)\n",inode->i_ino,filp->f_pos);
+	pr_debug("AFFS: readdir(ino=%lu,f_pos=%lu)\n",inode->i_ino,(unsigned long)filp->f_pos);
 
 	if (!inode || !S_ISDIR(inode->i_mode))
 		return -EBADF;
@@ -93,8 +96,7 @@
 	dir_bh = NULL;
 	fh_bh  = NULL;
 	dir    = NULL;
-	old    = filp->f_pos & 0x80000000;
-	filp->f_pos &= 0x7FFFFFFF;
+	ino    = inode->i_ino;
 
 	if (filp->f_pos == 0) {
 		filp->private_data = (void *)0;
@@ -106,18 +108,11 @@
 	}
 	if (filp->f_pos == 1) {
 		if (filldir(dirent,"..",2,filp->f_pos,affs_parent_ino(inode)) < 0) {
-			filp->f_pos |= 0x80000000;
 			return stored;
 		}
 		filp->f_pos = 2;
 		stored++;
 	}
-
-	/* Read original if this is a link */
-	ino = inode->u.affs_i.i_original ? inode->u.affs_i.i_original : inode->i_ino;
-	if (!(dir = iget(inode->i_sb,ino)))
-		return stored;
-	
 	chain_pos = (filp->f_pos - 2) & 0xffff;
 	hash_pos  = (filp->f_pos - 2) >> 16;
 	if (chain_pos == 0xffff) {
@@ -126,27 +121,29 @@
 		hash_pos++;
 		filp->f_pos = ((hash_pos << 16) | chain_pos) + 2;
 	}
-	if (!(dir_bh = affs_bread(inode->i_dev,ino,AFFS_I2BSIZE(inode))))
+	if (!(dir_bh = affs_bread(inode->i_dev,inode->i_ino,
+				  AFFS_I2BSIZE(inode))))
 		goto readdir_done;
 
-	while (!stored || !old) {
+	while (1) {
 		while (hash_pos < AFFS_I2HSIZE(inode) &&
 		     !((struct dir_front *)dir_bh->b_data)->hashtable[hash_pos])
 			hash_pos++;
 		if (hash_pos >= AFFS_I2HSIZE(inode))
-			goto readdir_done;
+			break;
 		
-		i = htonl(((struct dir_front *)dir_bh->b_data)->hashtable[hash_pos]);
+		i = be32_to_cpu(((struct dir_front *)dir_bh->b_data)->hashtable[hash_pos]);
 		j = chain_pos;
+
 		/* If the directory hasn't changed since the last call to readdir(),
 		 * we can jump directly to where we left off.
 		 */
-		if (filp->private_data && filp->f_version == dir->i_version) {
+		if (filp->private_data && filp->f_version == inode->i_version) {
 			i = (s32)filp->private_data;
 			j = 0;
 			pr_debug("AFFS: readdir() left off=%d\n",i);
 		}
-		filp->f_version = dir->i_version;
+		filp->f_version = inode->i_version;
 		pr_debug("AFFS: hash_pos=%d chain_pos=%d\n",hash_pos,chain_pos);
 		while (i) {
 			if (!(fh_bh = affs_bread(inode->i_dev,i,AFFS_I2BSIZE(inode)))) {
@@ -154,7 +151,7 @@
 				goto readdir_done;
 			}
 			ino = i;
-			i   = htonl(FILE_END(fh_bh->b_data,inode)->hash_chain);
+			i   = be32_to_cpu(FILE_END(fh_bh->b_data,inode)->hash_chain);
 			if (j == 0)
 				break;
 			affs_brelse(fh_bh);
@@ -163,7 +160,7 @@
 		}
 		if (fh_bh) {
 			namelen = affs_get_file_name(AFFS_I2BSIZE(inode),fh_bh->b_data,&name);
-			pr_debug("AFFS: readdir(): filldir(..,\"%.*s\",ino=%lu), i=%d\n",
+			pr_debug("AFFS: readdir(): filldir(\"%.*s\",ino=%lu), i=%d\n",
 				 namelen,name,ino,i);
 			filp->private_data = (void *)ino;
 			if (filldir(dirent,name,namelen,filp->f_pos,ino) < 0)
@@ -182,10 +179,8 @@
 	}
 
 readdir_done:
-	filp->f_pos |= old;
 	affs_brelse(dir_bh);
 	affs_brelse(fh_bh);
-	iput(dir);
 	pr_debug("AFFS: readdir()=%d\n",stored);
 	return stored;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov