	These are selected bits out of the 
		lfs-patches-v0.21-base-2.3.27-pre1.diff.A
	file

	This file contains RLIMIT64_* things

diff -ur linux-23027p1/include/linux/resource.h linux-23027p1m1/include/linux/resource.h
--- linux-23027p1/include/linux/resource.h	Mon Nov  8 14:11:09 1999
+++ linux-23027p1m1/include/linux/resource.h	Mon Nov  8 22:58:52 1999
@@ -43,11 +43,26 @@
  * Which makes a ton more sense anyway.
  */
 #define RLIM_INFINITY	(~0UL)
+#define RLIM_SAVED_MAX  ((~0UL)-1UL)
+#define RLIM_SAVED_CUR	((~0UL)-2UL)
+
+/* We compare against SIGNED 64-bit loff_t, better to limit ourself
+   to  2^63-1,  which is rather high value anyway... */
+#define RLIM64_INFINITY	((long long)((~0ULL) >> 1))
+#define RLIM64_SAVED_MAX RLIM64_INFINITY
+#define RLIM64_SAVED_CUR RLIM64_INFINITY
 
 struct rlimit {
 	unsigned long	rlim_cur;
 	unsigned long	rlim_max;
 };
+
+struct rlimit64 {
+	__u64	rlim_cur;
+	__u64	rlim_max;
+};
+
+#define INIT_RLIMFSZ   { RLIM64_INFINITY, RLIM64_INFINITY }
 
 #define	PRIO_MIN	(-20)
 #define	PRIO_MAX	20
diff -ur linux-23027p1/include/linux/sched.h linux-23027p1m1/include/linux/sched.h
--- linux-23027p1/include/linux/sched.h	Mon Nov  8 22:57:35 1999
+++ linux-23027p1m1/include/linux/sched.h	Mon Nov  8 22:58:52 1999
@@ -332,6 +332,7 @@
 	struct user_struct *user;
 /* limits */
 	struct rlimit rlim[RLIM_NLIMITS];
+	struct rlimit64 rlimfsz; /* RLIM_FSIZE -- only! */
 	unsigned short used_math;
 	char comm[16];
 /* file system info */
@@ -419,6 +420,7 @@
 /* caps */      CAP_INIT_EFF_SET,CAP_INIT_INH_SET,CAP_FULL_SET, \
 /* user */	NULL,						\
 /* rlimits */   INIT_RLIMITS, \
+/* rlimfsz */   INIT_RLIMFSZ, \
 /* math */	0, \
 /* comm */	"swapper", \
 /* fs info */	0,NULL, \
diff -ur linux-23027p1/kernel/sys.c linux-23027p1m1/kernel/sys.c
--- linux-23027p1/kernel/sys.c	Fri Oct 29 23:19:49 1999
+++ linux-23027p1m1/kernel/sys.c	Mon Nov  8 22:58:52 1999
@@ -12,6 +12,7 @@
 #include <linux/reboot.h>
 #include <linux/prctl.h>
 #include <linux/init.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -882,11 +883,44 @@
 
 asmlinkage long sys_getrlimit(unsigned int resource, struct rlimit *rlim)
 {
+	struct rlimit rl;
+
 	if (resource >= RLIM_NLIMITS)
 		return -EINVAL;
-	else
-		return copy_to_user(rlim, current->rlim + resource, sizeof(*rlim))
-			? -EFAULT : 0;
+
+	rl = current->rlim[resource];
+	if (resource == RLIMIT_FSIZE) {
+	  rl.rlim_cur = current->rlimfsz.rlim_cur;
+	  if (current->rlimfsz.rlim_cur > RLIM_INFINITY)
+	    rl.rlim_cur = RLIM_INFINITY;
+	  rl.rlim_max = current->rlimfsz.rlim_max;
+	  if (current->rlimfsz.rlim_max > RLIM_INFINITY)
+	    rl.rlim_max = RLIM_INFINITY;
+
+	  /* XX: RLIM_SAVED_MAX ? RLIM_SAVED_CUR ? (See Large-File-Summit) */
+	}
+	return (copy_to_user(rlim, &rl, sizeof(*rlim)) ? -EFAULT : 0);
+}
+
+asmlinkage long sys_getrlimit64(unsigned int resource, struct rlimit64 *rlim)
+{
+	struct rlimit64 rlim64;
+
+	if (resource >= RLIM_NLIMITS)
+		return -EINVAL;
+
+	if (resource == RLIMIT_FSIZE)
+	  rlim64 = current->rlimfsz;
+	else {
+	  rlim64.rlim_cur = current->rlim[resource].rlim_cur;
+	  rlim64.rlim_max = current->rlim[resource].rlim_max;
+	  if (rlim64.rlim_cur == RLIM_INFINITY)
+	    rlim64.rlim_cur = RLIM64_INFINITY;
+	  if (rlim64.rlim_max == RLIM_INFINITY)
+	    rlim64.rlim_max = RLIM64_INFINITY;
+	  /* XX: RLIM_SAVED_MAX ? RLIM_SAVED_CUR ? (See Large-File-Summit) */
+	}
+	return (copy_to_user(rlim, &rlim64, sizeof(*rlim)) ? -EFAULT : 0);
 }
 
 /*
@@ -899,7 +933,18 @@
 	if (resource >= RLIM_NLIMITS)
 		return -EINVAL;
 
-	memcpy(&x, current->rlim + resource, sizeof(*rlim));
+	x = current->rlim[resource];
+	if (resource == RLIMIT_FSIZE) {
+	  x.rlim_cur = current->rlimfsz.rlim_cur;
+	  if (current->rlimfsz.rlim_cur > RLIM_INFINITY)
+	    x.rlim_cur = RLIM_INFINITY;
+	  x.rlim_max = current->rlimfsz.rlim_max;
+	  if (current->rlimfsz.rlim_max > RLIM_INFINITY)
+	    x.rlim_max = RLIM_INFINITY;
+
+	  /* XX: RLIM_SAVED_MAX ? RLIM_SAVED_CUR ? (See Large-File-Summit) */
+	}
+
 	if(x.rlim_cur > 0x7FFFFFFF)
 		x.rlim_cur = 0x7FFFFFFF;
 	if(x.rlim_max > 0x7FFFFFFF)
@@ -916,8 +961,15 @@
 		return -EINVAL;
 	if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
 		return -EFAULT;
-	if (new_rlim.rlim_cur < 0 || new_rlim.rlim_max < 0)
-		return -EINVAL;
+
+#if BITS_PER_LONG < 64
+	/* compability with old RLIM_INFINITY value .. */
+	if (new_rlim.rlim_cur == 0x7fffffffUL)
+	  new_rlim.rlim_cur = RLIM_INFINITY;
+	if (new_rlim.rlim_max == 0x7fffffffUL)
+	  new_rlim.rlim_max = RLIM_INFINITY;
+#endif
+
 	old_rlim = current->rlim + resource;
 	if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
 	     (new_rlim.rlim_max > old_rlim->rlim_max)) &&
@@ -927,10 +979,62 @@
 		if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN)
 			return -EPERM;
 	}
+	if (resource == RLIMIT_FSIZE) {
+		if (new_rlim.rlim_cur == RLIM_INFINITY) {
+			current->rlimfsz.rlim_cur = RLIM64_INFINITY;
+		}
+		if (new_rlim.rlim_max == RLIM_INFINITY) {
+			current->rlimfsz.rlim_max = RLIM64_INFINITY;
+		}
+	}
 	*old_rlim = new_rlim;
 	return 0;
 }
 
+asmlinkage long sys_setrlimit64(unsigned int resource, struct rlimit64 *rlim)
+{
+	struct rlimit64 new_rlim;
+	struct rlimit  *old_rlim;
+
+	if (resource >= RLIM_NLIMITS)
+		return -EINVAL;
+	if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
+		return -EFAULT;
+	old_rlim = &current->rlim[resource];
+	
+
+	if (new_rlim.rlim_cur > RLIM_INFINITY && resource != RLIMIT_FSIZE)
+	  new_rlim.rlim_cur = RLIM_INFINITY;
+	if (new_rlim.rlim_max > RLIM_INFINITY && resource != RLIMIT_FSIZE)
+	  new_rlim.rlim_max = RLIM_INFINITY;
+
+	if (resource == RLIMIT_FSIZE) {
+		if (((new_rlim.rlim_cur > current->rlimfsz.rlim_max) ||
+		     (new_rlim.rlim_max > current->rlimfsz.rlim_max)) &&
+		    !capable(CAP_SYS_RESOURCE))
+			return -EPERM;
+	} else
+		if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
+		     (new_rlim.rlim_max > old_rlim->rlim_max)) &&
+		    !capable(CAP_SYS_RESOURCE))
+			return -EPERM;
+	if (resource == RLIMIT_NOFILE) {
+		if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN)
+			return -EPERM;
+	}
+	if (resource == RLIMIT_FSIZE) {
+		current->rlimfsz = new_rlim;
+
+		if (new_rlim.rlim_cur > RLIM_INFINITY)
+		  new_rlim.rlim_cur = RLIM_INFINITY;
+		if (new_rlim.rlim_max > RLIM_INFINITY)
+		  new_rlim.rlim_max = RLIM_INFINITY;
+	}
+	old_rlim->rlim_cur = new_rlim.rlim_cur;
+	old_rlim->rlim_max = new_rlim.rlim_max;
+	return 0;
+}
+
 /*
  * It would make sense to put struct rusage in the task_struct,
  * except that would make the task_struct be *really big*.  After
@@ -948,7 +1052,7 @@
  *
  * FIXME! Get the fault counts properly!
  */
-int getrusage(struct task_struct *p, int who, struct rusage *ru)
+long getrusage(struct task_struct *p, int who, struct rusage *ru)
 {
 	struct rusage r;
 
diff -ur linux-23027p1/mm/filemap.c linux-23027p1m1/mm/filemap.c
--- linux-23027p1/mm/filemap.c	Sat Nov  6 02:16:48 1999
+++ linux-23027p1m1/mm/filemap.c	Mon Nov  8 22:58:52 1999
@@ -1792,7 +1811,7 @@
 {
 	struct dentry	*dentry = file->f_dentry; 
 	struct inode	*inode = dentry->d_inode; 
-	unsigned long	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	loff_t		limit = current->rlimfsz.rlim_cur;
 	loff_t		pos = *ppos;
 	struct page	*page, **hash, *cached_page;
 	unsigned long	written;
@@ -1820,16 +1839,59 @@
 	 * Check whether we've reached the file size limit.
 	 */
 	err = -EFBIG;
-	if (limit != RLIM_INFINITY) {
-		if (pos >= limit) {
-			send_sig(SIGXFSZ, current, 0);
-			goto out;
-		}
-		if (count > limit - pos) {
-			send_sig(SIGXFSZ, current, 0);
-			count = limit - pos;
-		}
+	if (pos >= limit) {
+// printk(" generic_file_write() EFBIG: pos=%Lx limit=%Lx\n",pos,limit);
+		send_sig(SIGXFSZ, current, 0);
+		goto out;
+	}
+	if (count > limit - pos) {
+		/* send_sig(SIGXFSZ, current, 0); */
+		count = limit - pos;
 	}
+
+
+	/* REGULAR files have Large File Summit rules */
+
+	if (S_ISREG(inode->i_mode)) {
+
+	  const loff_t lim2G = 0x7FFFFFFFLL;
+
+	  if (!inode->i_op->pathconf ||
+	      inode->i_op->pathconf(inode,_PC_FILESIZEBITS) <= 32) {
+	    /* Hmm... 31 = 2G, 32 = 4G ?? */
+
+	    /* L-F-S: Must limit down to 2G! */
+
+	    if ((pos+count) > lim2G) {
+	      if (pos >= lim2G) { /* over 2G-1 */
+		/* Fails completely! Err = -EFBIG */
+		send_sig(SIGXFSZ, current, 0);
+		goto out;
+	      } else { /* At most 2G-1 */
+		count = lim2G-pos;
+	      }
+	    }
+	  }
+
+#if BITS_PER_LONG < 64 /* Large File Summit has meaning ! */
+	  else {
+	    /* This filesystem *can* support Large Files */
+	    if (!(file->f_flags & O_LARGEFILE)) {
+	      /* Not opened as Large File */
+	      if ((pos+count) > lim2G) {
+		if (pos >= lim2G) { /* over 2G-1 */
+		  /* Fails completely! Err = -EFBIG */
+		  send_sig(SIGXFSZ, current, 0);
+		  goto out;
+		} else { /* At most 2G-1 */
+		  count = lim2G-pos;
+		}
+	      }
+	    }
+	  }
+#endif
+	} /* ... was REGULAR file */
+
 
 	status  = 0;
 
diff -ur linux-23027p1/fs/ext2/inode.c linux-23027p1m1/fs/ext2/inode.c
--- linux-23027p1/fs/ext2/inode.c	Fri Nov  5 19:57:30 1999
+++ linux-23027p1m1/fs/ext2/inode.c	Mon Nov  8 22:58:51 1999
@@ -216,14 +216,12 @@
 
 	/* Check file limits.. */
 	{
-		unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
-		if (limit < RLIM_INFINITY) {
-			limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb);
-			if (new_block >= limit) {
-				send_sig(SIGXFSZ, current, 0);
-				*err = -EFBIG;
-				return NULL;
-			}
+		u_long limit = (current->rlimfsz.rlim_cur >>
+				EXT2_BLOCK_SIZE_BITS(inode->i_sb));
+		if (new_block >= limit) {
+			send_sig(SIGXFSZ, current, 0);
+			*err = -EFBIG;
+			return NULL;
 		}
 	}
 
@@ -337,13 +335,14 @@
 	}
 	*err = -EFBIG;
 
-	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
-	if (limit < RLIM_INFINITY) {
-		limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb);
-		if (new_block >= limit) {
-			send_sig(SIGXFSZ, current, 0);
-			goto out;
-		}
+	/* "infinity" value is 2^63-1, shifting it down a few bits
+	   will stay so high that it doesn't matter.. */
+	limit = (current->rlimfsz.rlim_cur >>
+		 EXT2_BLOCK_SIZE_BITS(inode->i_sb));
+
+	if (new_block >= limit) {
+		send_sig(SIGXFSZ, current, 0);
+		goto out;
 	}
 
 	if (inode->u.ext2_i.i_next_alloc_block == new_block)
diff -ur linux-23027p1/fs/ufs/inode.c linux-23027p1m1/fs/ufs/inode.c
--- linux-23027p1/fs/ufs/inode.c	Sun Jun 27 20:10:41 1999
+++ linux-23027p1m1/fs/ufs/inode.c	Mon Nov  8 22:58:52 1999
@@ -55,7 +55,7 @@
 {
 	unsigned swab = inode->i_sb->u.ufs_sb.s_swab;
 	printk("ino %lu  mode 0%6.6o  nlink %d  uid %d  uid32 %u"
-	       "  gid %d  gid32 %u  size %lu blocks %lu\n",
+	       "  gid %d  gid32 %u  size %Lu blocks %lu\n",
 	       inode->i_ino, inode->i_mode, inode->i_nlink,
 	       inode->i_uid, inode->u.ufs_i.i_uid, inode->i_gid, 
 	       inode->u.ufs_i.i_gid, inode->i_size, inode->i_blocks);
@@ -222,13 +222,10 @@
 	}
 	*err = -EFBIG;
 
-	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
-	if (limit < RLIM_INFINITY) {
-		limit >>= sb->s_blocksize_bits;
-		if (new_fragment >= limit) {
-			send_sig(SIGXFSZ, current, 0);
-			return NULL;
-		}
+	limit = (current->rlimfsz.rlim_cur >> sb->s_blocksize_bits);
+	if (new_fragment >= limit) {
+		send_sig(SIGXFSZ, current, 0);
+		return NULL;
 	}
 
 	lastblock = ufs_fragstoblks (lastfrag);
@@ -319,7 +316,7 @@
 	block = ufs_fragstoblks (fragment);
 	blockoff = ufs_fragnum (fragment);
 
-	UFSD(("ENTER, ino %lu, fragment %u, new_fragment %u\n", inode->i_ino, fragment, new_fragment))	
+	UFSD(("ENTER, ino %lu, fragment %u, new_fragment %u\n", inode->i_ino, fragment, new_fragment))
 
 	result = NULL;
 	if (!bh)
@@ -350,14 +347,12 @@
 	*err = -EFBIG;
 
 	{
-		unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
-		if (limit < RLIM_INFINITY) {
-			limit >>= sb->s_blocksize_bits;
-			if (new_fragment >= limit) {
-				brelse (bh);
-				send_sig(SIGXFSZ, current, 0);
-				return NULL;
-			}
+		unsigned long limit = (current->rlimfsz.rlim_cur >> sb->s_blocksize_bits);
+		/* Infinity for this is rather 'large', even shifted down. */
+		if (new_fragment >= limit) {
+			brelse (bh);
+			send_sig(SIGXFSZ, current, 0);
+			return NULL;
 		}
 	}
 	if (block && (tmp = SWAB32(((u32*)bh->b_data)[block-1]) + uspi->s_fpb))
@@ -591,13 +586,11 @@
 	}
 	
 	/*
-	 * Linux i_size can be 32 on some architectures. We will mark 
-	 * big files as read only and let user access first 32 bits.
+	 * Linux i_size used to be 32 bits on some architectures.
+	 * These days we allow access to the entire file as is..
 	 */
 	inode->u.ufs_i.i_size = SWAB64(ufs_inode->ui_size);
-	inode->i_size = (off_t) inode->u.ufs_i.i_size;
-	if (sizeof(off_t) == 4 && (inode->u.ufs_i.i_size >> 32))
-		inode->i_size = (__u32)-1;
+	inode->i_size = inode->u.ufs_i.i_size;
 
 	inode->i_atime = SWAB32(ufs_inode->ui_atime.tv_sec);
 	inode->i_ctime = SWAB32(ufs_inode->ui_ctime.tv_sec);
@@ -610,7 +603,7 @@
 	inode->u.ufs_i.i_gen = SWAB32(ufs_inode->ui_gen);
 	inode->u.ufs_i.i_shadow = SWAB32(ufs_inode->ui_u3.ui_sun.ui_shadow);
 	inode->u.ufs_i.i_oeftflag = SWAB32(ufs_inode->ui_u3.ui_sun.ui_oeftflag);
-	inode->u.ufs_i.i_lastfrag = howmany (inode->i_size, uspi->s_fsize);
+	inode->u.ufs_i.i_lastfrag = (inode->i_size + uspi->s_fsize -1) >> uspi->s_fshift;
 	
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
 		;
