patch to fix symlink-related GPFs on Linux

Aaron M. Ucko amu at mit.edu
Sun Jul 19 18:07:31 CEST 1998


We need to set the to_kmem argument of read_exec based on *gasp*
whether we're reading to kernel space.

--- arla-0.7.2/xfs/linux/xfs_inodeops.c.old	Thu Jul 16 17:45:39 1998
+++ arla-0.7.2/xfs/linux/xfs_inodeops.c	Sun Jul 19 11:53:12 1998
@@ -1206,7 +1206,7 @@
     int fileno;
     char *buf;
 #ifndef LINUX2_1
-    long oldfs;
+    unsigned long oldfs;
 #endif /* LINUX2_1 */
 
     XFSDEB(XDEBREADDIR, ("xfs_readdir\n"));
@@ -1228,7 +1228,7 @@
 		
 		XFSDEB(XDEBREADDIR, ("xfs_readdir begin_offset: %d offset: %d\n",(int)begin_offset,(int)offset));
 		oldfs = get_fs();
-		set_fs(KERNEL_DS);
+		set_fs(get_ds());
 		file->f_pos = begin_offset;
 		file->f_reada = 0;
 		error = t->i_op->default_file_ops->read(t, file, buf, XFS_DIRENT_BLOCKSIZE);
@@ -1349,9 +1349,11 @@
 
 static int
 #ifndef LINUX2_1
-xfs_readlink(struct inode *inode, char *buffer, int buflen)
+xfs_readlink_internal(struct inode *inode, char *buffer, int buflen,
+		      int to_kmem)
 #else
-xfs_readlink(struct dentry *dentry, char *buffer, int buflen)
+xfs_readlink_internal(struct dentry *dentry, char *buffer, int buflen,
+		      int to_kmem)
 #endif /* LINUX2_1 */
 {
     int error = 0;
@@ -1375,12 +1377,22 @@
 	size = (buflen > inode->i_size) ?
 	    (inode->i_size) :
 	    (buflen);
-	error = read_exec(t, 0, buffer, size, 1);
+	error = read_exec(t, 0, buffer, size, to_kmem);
     }
     
     return error;
 }
 
+static int
+#ifndef LINUX2_1
+xfs_readlink(struct inode *x, char *buffer, int buflen)
+#else
+xfs_readlink(struct dentry *x, char *buffer, int buflen)
+#endif /* LINUX2_1 */
+{
+    return xfs_readlink_internal(x, buffer, buflen, 0);
+}
+
 #ifndef LINUX2_1
 static int xfs_follow_link(struct inode * dir, struct inode * inode,
 			   int flag, int mode, struct inode ** res_inode)
@@ -1432,9 +1444,9 @@
 #endif /* LINUX2_1 */
     }
 #ifndef LINUX2_1
-    error = xfs_readlink(inode, buffer, MAXPATHLEN);
+    error = xfs_readlink_internal(inode, buffer, MAXPATHLEN, 1);
 #else
-    error = xfs_readlink(dentry, buffer, MAXPATHLEN);
+    error = xfs_readlink_internal(dentry, buffer, MAXPATHLEN, 1);
 #endif /* LINUX2_1 */
     if (error < 0) {
 #ifndef LINUX2_1





More information about the Arla-drinkers mailing list