patch-2.3.23 linux/fs/hpfs/dir.c

Next file: linux/fs/hpfs/dnode.c
Previous file: linux/fs/hpfs/anode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.22/linux/fs/hpfs/dir.c linux/fs/hpfs/dir.c
@@ -20,7 +20,34 @@
 	return 0;
 }
 
-int hpfs_readdir(struct file *filp, void * dirent, filldir_t filldir)
+/* This is slow, but it's not used often */
+
+loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
+{
+	loff_t new_off = off + (whence == 1 ? filp->f_pos : 0);
+	loff_t pos;
+	struct quad_buffer_head qbh;
+	struct inode *i = filp->f_dentry->d_inode;
+	struct super_block *s = filp->f_dentry->d_sb;
+	/*printk("dir lseek\n");*/
+	if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
+	hpfs_lock_inode(i);
+	pos = ((loff_t) hpfs_de_as_down_as_possible(s, i->i_hpfs_dno) << 4) + 1;
+	while (pos != new_off) {
+		if (map_pos_dirent(i, &pos, &qbh)) hpfs_brelse4(&qbh);
+		else goto fail;
+		if (pos == 12) goto fail;
+	}
+	hpfs_unlock_inode(i);
+	ok:
+	return filp->f_pos = new_off;
+	fail:
+	hpfs_unlock_inode(i);
+	/*printk("illegal lseek: %016llx\n", new_off);*/
+	return -ESPIPE;
+}
+
+int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
 	struct inode *inode = filp->f_dentry->d_inode;
 	struct quad_buffer_head qbh;
@@ -54,11 +81,11 @@
 		if (e) return -EFSERROR;
 	}
 	lc = inode->i_sb->s_hpfs_lowercase;
-	if (filp->f_pos == -2) { /* diff -r requires this (note, that diff -r */
-		filp->f_pos = -3; /* also fails on msdos filesystem in 2.0) */
+	if (filp->f_pos == 12) { /* diff -r requires this (note, that diff -r */
+		filp->f_pos = 13; /* also fails on msdos filesystem in 2.0) */
 		return 0;
 	}
-	if (filp->f_pos == -3) return -ENOENT;
+	if (filp->f_pos == 13) return -ENOENT;
 	
 	hpfs_lock_inode(inode);
 	
@@ -72,7 +99,7 @@
 				hpfs_unlock_inode(inode);
 				return -EFSERROR;
 			}
-		if (filp->f_pos == -2) {
+		if (filp->f_pos == 12) {
 			hpfs_unlock_inode(inode);
 			return 0;
 		}
@@ -86,9 +113,9 @@
 				hpfs_unlock_inode(inode);
 				return 0;
 			}
-			filp->f_pos = -1;
+			filp->f_pos = 11;
 		}
-		if (filp->f_pos == -1) {
+		if (filp->f_pos == 11) {
 			if (filldir(dirent, "..", 2, filp->f_pos, inode->i_hpfs_parent_dir) < 0) {
 				hpfs_unlock_inode(inode);
 				return 0;

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