xfs patch for Linux

Aaron M. Ucko amu at mit.edu
Tue Mar 3 06:21:52 CET 1998


The following patch allows the Linux xfs module to build, makes
xfs_readdir work, and fixes a memory leak.  Enjoy.  [Yes, the
set_fs/get_fs stuff should work on non-Intel platforms; Linus choose a
poor name.]

Index: xfs/linux/Makefile.in
===================================================================
RCS file: /afs/sipb/project/arla/repository/arla/xfs/linux/Makefile.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile.in
--- Makefile.in	1998/03/02 17:42:43	1.1.1.1
+++ Makefile.in	1998/03/02 21:22:46
@@ -29,7 +29,9 @@
 XFS_BIN		= $(MODULE)
 
 DEFS		= @DEFS@ -DMODULE -D__KERNEL__ -DDEBUG
-CFLAGS		= @CFLAGS@ -g -I. -I/usr/athena/include -I$(srcdir)/../include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+CFLAGS		= @CFLAGS@ -g -I. -I/usr/athena/include \
+		  -I$(srcdir)/../include -I$(srcdir)/../../include \
+		  -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 
 MODULE		= xfs.o
 
Index: xfs/linux/xfs_inodeops.c
===================================================================
RCS file: /afs/sipb/project/arla/repository/arla/xfs/linux/xfs_inodeops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 xfs_inodeops.c
--- xfs_inodeops.c	1998/03/02 17:42:44	1.1.1.1
+++ xfs_inodeops.c	1998/03/03 05:05:35
@@ -391,6 +391,7 @@
     int errno = 0;
     off_t offset, begin_offset;
     char *buf;
+    long oldfs;
 
     XFSDEB(XDEBVNOPS, ("xfs_readdir\n"));
     
@@ -409,7 +410,10 @@
 		offset = file->f_pos & (XFS_DIRENT_BLOCKSIZE - 1);
 		
 		XFSDEB(XDEBVNOPS, ("xfs_readdir begin_offset: %d offset: %d\n",begin_offset,offset));
+		oldfs = get_fs();
+		set_fs(KERNEL_DS);
 		errno = t->i_op->default_file_ops->read(t, file, buf, XFS_DIRENT_BLOCKSIZE - offset);
+		set_fs(oldfs);
 		if (errno == XFS_DIRENT_BLOCKSIZE - offset) {
 		  XFSDEB(XDEBVNOPS, ("xfs_readdir errno: %d\n",errno));
 		    while (offset < XFS_DIRENT_BLOCKSIZE) {
@@ -420,10 +424,12 @@
 				     offset+begin_offset,
 				     ((struct xfs_dirent *) (buf + offset))->d_fileno) < 0) {
 			    iput(t);
+			    xfs_free(buf);
 			    return 0;
 			}
 			offset += ((struct xfs_dirent *) (buf + offset))->d_reclen;
 		    }
+		    xfs_free(buf);
 		} else if (errno > 0) {
 		    printk("XFS Panic! expected %d bytes, got %d in xfs_readdir\n", XFS_DIRENT_BLOCKSIZE, errno);
 		    errno = -EINVAL;


-- 
Aaron M. Ucko, KB1CJC <amu at mit.edu> (finger amu at monk.mit.edu)






More information about the Arla-drinkers mailing list