
	    ** 64-bit file sizes/offsets at  32-bit platforms **
		Also known as  Large_File_Summit  extensions
		(At 64-bit platforms this is 'natural' thing,
		 not so at 32-bit systems...)

	    **	In realily the largest file size supported in
		the *kernel* is right now mere 4k*4G, or 
		16 terabytes. (i386 platform with 4k pages)

	    **	Largest EXT2 file size is more difficult thing
		to explain, see comments at the begining of
		try-lfs.c  program.

	* This PATCH is against Linux 2.2.9

	* Comments/questions to:  <matti.aarnio@sonera.fi>
	  (I can't tell when Linus accepts this into the standard source.
	   This is too fresh to push to there right now...)

	* There are problematic issues with glibc 2.1.* which has
	  absolutely braindead 'struct stat64' -- at least for i386.

TODO:
	+ libc space...

	* SYSCALL VECTORS AND NUMBERS:
	+ Done mostly for Alpha, ARM, i386, m68k, ppc
	+ Missing: mmap64() (ppc, SPARCs, MIPS)
	+ Missing: MIPS: vectors, SPARCs: numbers and vectors
	+ syscall vectors for (platform depending):
	        mmap64()                32-bit systems only (sizeof(long)<8)
	        setrlimit64()           -""-
	        getrlimit64()           -""-
	        truncate64()            -""-
	        ftruncate64()           -""-
	        stat64()                all systems (also 64-bitters!)
	        lstat64()               -""-
	        fstat64()               -""-
	        statfs64()              -""-
	        fstatfs64()             -""-
	        getdents64()            -""-
	* syscalls: sysconf(), pathconf(), fpathconf() missing for
	  SPARC, MIPS (both as above..)

SOME MORE COMMENTS:

	* This version contains (for i386) 'struct stat64', which matches
	  that of the glibc-2.1.1 supplies to the userspace, but it is
	  *very* stupid structure.

	* TESTED ONLY AT i386 SYSTEM!

	* {,f}pathconf() inode operation codes for filesystems:
	  Done:
		EXT2, CODA (with some open questions), ADFS, AFFS,
		FAT, VFAT, UMSDOS(?), UFS, SYSV, ISOFS, ROMFS, MSDOS,
		MINIX, NFS (with a few "unknown" replies; should it
		go over the NFS protocol itself ?), HFS, HPFS, NTFS,
		NCPFS, SMBFS, QNX
	  No need(?): (not done)
		DEVPTS, AUTOFS, PROC

	* more checking of things
		( See try-lfs*.c file(s) for tests. )

	* 64-bit offsets supported at EXT2 on ALL platforms, AND
	  on UFS -- latter is NOT TESTED -- in fact it was just
	  a "patch thru" work, without very much carefull thought!
	  THE UFS CODE NEEDS TO BE CHECKED CAREFULLY!
	  ( But still I found what looked like heaps of ugly assumptions
	    within the UFS code -- and couple other filesystems.
	    Lots of  64-bit/32-bit  division and modulus operations were
	    attempted, but the Linux kernel does not link with  libgcc.a
	    so linkage failed. That helped me to hunt down the offending
	    code :-) )


	+ From v0.13:
	  - fs/hpfs/hpfs_fs.c: struct inode_operations update
	  - fs/minix/file.c:   limit maximum file sizes
	  - fs/nfs/: Limit maximum file sizes to 2G-1 (wait for NFSv3)
	  - include/linux/nfs.h: offset & size change: __u32 -> __u64
	  - fs/read_write.c:   "possibly uninitialized..."
	  - fs/affs/: Limit maximum file sizes to 2G-1
	  - fs/ncpfs/: Limit maximum file sizes to 2G-1 (really ? Not 4G-1 ?)
	  - fs/open.c: Truncate rules matched with Single-Unix-Spec-v2
	  - fs/smbfs/: File sizes limited to 4G-1 -- or should it be 2G-1 ??
	  - fs/sysv/: Limit maximum file sizes to 4G-1 (should it be 2G-1 ?)

	+ From v0.12:
	  - Updated to 2.2.1
	  - Fixed fs/pipe.c  inode_operations  table.

	+ From v0.11:
	  - llseek() needs O_LARGEFILE open flag only to REGULAR FILES.
	    Devices etc. don't need it!

	+ From v0.10:
	  - Added among others: POSIX sysconf() and pathconf()
	    calls to most platforms, and most filesystems;
	  - Fixed pread() and pwrite() call error handlings a bit
	    to match single-unix-specification

	* At some platforms I have had to change syscall numbers
	  as sys_vfork() appeared 'out of the blue' during last
	  moments of 2.2.0 construction.

	+ From v0.08: Two fixes so that no 64/32 bits divisions are
	  needed (fs/ufs/super.c, fs/stat.c); egcs-1.0.3 didn't
	  have problems at the latter, but gcc-2.7.2.3 did have..
	  Changed name of 'readdir64' to 'getdents64', but no
	  implementation so far..

	+ From v0.05: support a.out shared pageing in case it is
	  page aligned in the file. (Manfred Spraul)

	* This boots, and the work to write these comments has been
	  done at machine running this patched kernel.
	  * SOME MORE TESTING OF LARGE FILES HAS NOW BEEN DONE, AND
	    IT MATERIALIZED RLIM64 OBJECT FOR FILE SIZES INTO THE
	    task_struct OBJECT *
	  Now large files are easy to create, and limit handling works.


	  With glibc 2.0 you can do following code:
	  (This isn't a complete program, just the salient parts.)

	extern long long llseek(int fd, long long offset, int whence);
	...
	fd = open("name.dat",O_CREAT|O_TRUNC|O_RDWR|O_LARGEFILE, 0644);
	llseek(fd, 6000000000LL, SEEK_SET);
	write(fd, "01234567", 8);

	  and the file will be written at offset 6000 million.
	  (You will need only 4 blocks of disk-space for it, try it!)


	  LFS-spec says that if you do this and you have not opened
	  file file with  open64()  (alias: open( ... O_LARGEFILE ...) )
	  then you are bound to get error  EOVERFLOW at seek, and
	  EFBIG at write

	  Directory listing attempt with  lstat()  will result file size
	  of 4G-1 (2^32-1).    Doing  fstat()  on the file with size
	  exceeding that value will result  -EOVERFLOW, but  stat() and
	  lstat() will result success -- and peaked size field..


	  Do note that O_LARGEFILE flag codes vary in between different
	  systems, and that they are *not* defined in any glibc as of
	  yet (22-Dec-1998):

		alpha:	#define O_LARGEFILE  0400000
		arm:	#define O_LARGEFILE  0200000
		i386:	#define O_LARGEFILE  0100000
		m68k:	#define O_LARGEFILE  0200000
		mips:	#define O_LARGEFILE   0x2000
		ppc:	#define O_LARGEFILE  0200000
		sparc:	#define O_LARGEFILE  0x40000
		sparc64:#define O_LARGEFILE  0x40000



	* lib/vsprintf.c:
		Support for L-qualifier (64-bit values) on 32-bit platforms.
		Has slowish open-coded (generic?) C-code for 64/32 division
		with 32-bit reminder and 64-bit quotient.  This is only for
		use within kernel vsprintf(), it is *not* generic GCC oriented
		__divdi3, __moddi3, et.al. code!

	* arch/i386/kernel/sys_i386.c:
	* arch/m68k/kernel/sys_m68k.c:
		Internal structures and functions for doing  mmap64().

	* fs/proc/array.c:
		64-bit file offsets in  /proc/##/maps  file!
		Will this break proctools e.g. "ps" ?

	* fs/*/*.c:
		Many filesystems needed "a bit" of revisioning due to
		changes in page-cache, resource management, and the
		64-bit file size/position/offset parameters which
		at times were divided stupidly...   Note also  statfs!

	* LFS interfaces missing (except F_GETLK64 and friends..)
	  Codepoint reserved for O_LARGEFILE flag, but no functionality
	  implemented for it per LFS spec.
	  It will need for example new system calls for most functions!

	* include/asm-*/posix_types.h:
		__kernel_off64_t
		__kernel_ino64_t
	  See LFS spec for the explanations!

	* include/asm-*/fcntl.h, fs/fcntl.c, fs/locks.c:
		Marked codepoints for all O_LARGEFILE, F_GETLK64+friends,
		and declared 'struct flock64'.  Coded support for 64-bit
		offset regions.  (Made that *native* form, and added
		old 'struct flock' as backwards compatible mode..)

	* include/asm-*/stat.h,  fs/stat.c:
		Defined   struct stat64
		Yield EOVERFLOW if the target file has size (or blockcount,
		or ..) exceeding that presentable with  off_t (0..2G in 32-
		bit systems).

	* include/asm-*/statfs.h:
		Defined   struct statfs64
		Made MASSIVE change all over to FS interface for STATFS.
		The "copy_to_user()" thing is done in generic level, and
		all fs drivers just copy/write data to pointed statfs64
		area.

	* include/linux/dirent.h:
		Defined  struct dirent64 -- does it match LFS ?

	* include/linux/fs.h:
		Defined  fslog2()  function to calculate base-2 logarithm
		of input value -- how many zero bits at low end of the
		input value ?  Usefull to replace generic division with
		">> fslog2(fs_block_size)", presuming the  fs_block_size
		is power of two...  That value *should* be in the Super-
		Block, but...   (Now used by FAT and NCPFS codes.)

		All file offsets/sizes use  loff_t,  which is 64-bit signed
		value.

		** WATCH COMPILATIONS CAREFULLY FOR 'INITIALIZATION FROM
		   INCOMPATIBLE POINTER' WHICH TELLS ABOUT DECLARATION
		   MISMATCH! **

	* include/linux/mm.h:
		For compile-time mismatch traps:  pgoff_t  opaque type;
		which for generic use shall be replaced with way simpler
		macroes..  (NOT YET!  Although EGCS may produce same
		code with the more difficult inline function, as it does
		with macroes...)

	* include/linux/pagemap.h:
		Do all operations without ">> PAGE_SHIFT", as the input
		value in  pgoff_t  is already downshifted..

	* include/linux/resource.h:
		RLIM64_INFINITY, and friends; See LFS document.

	* include/linux/swap.h:
		Use  pgoff_t  type values, *BUT DO NOT* downshift
		those values that are used within the SWAP subsystem!
		Roughly all bits are in active use for the swap-cache..

	* include/linux/types.h
		Define  ino64_t,  off64_t; see LFS document

	* ipc/shm.c:
		Adapted to page-index operation

	* kernel/sys.c:
		Implemented (initially)  sys_setrlimit64()/sys_getrlimit64()
		and compability facilities for them within the non-64
		calls.  The real 64-bit rlim  is only for the RLIMIT_FSIZE
		resource, which is needed in filesystems in 32-bit systems.
		(Memory space et.al. exist only as 32-bit values.)


diff -u -r linux-22009/arch/alpha/kernel/entry.S linux-22009m/arch/alpha/kernel/entry.S
--- linux-22009/arch/alpha/kernel/entry.S	Mon May 10 19:55:21 1999
+++ linux-22009m/arch/alpha/kernel/entry.S	Sun May 16 15:41:19 1999
@@ -8,7 +8,7 @@
 
 #define SIGCHLD 20
 
-#define NR_SYSCALLS 371
+#define NR_SYSCALLS 400
 
 /*
  * These offsets must match with alpha_mv in <asm/machvec.h>.
@@ -1143,3 +1143,17 @@
 	.quad sys_capget
 	.quad sys_capset
 	.quad sys_sendfile			/* 370 */
+	.quad sys_newstat64
+	.quad sys_newlstat64
+	.quad sys_newfstat64
+	.quad sys_statfs64
+	.quad sys_fstatfs64			/* 375 */
+	.quad sys_getdents64
+	.quad sys_ni_syscall /* msgctl32 */
+	.quad sys_sysconf
+	.quad sys_pathconf
+	.quad sys_fpathconf			/* 380 */
+
+	.rept NR_SYSCALLS - 380
+		.quad sys_ni_syscall
+	.endr
diff -u -r linux-22009/arch/alpha/kernel/osf_sys.c linux-22009m/arch/alpha/kernel/osf_sys.c
--- linux-22009/arch/alpha/kernel/osf_sys.c	Mon May 10 19:55:21 1999
+++ linux-22009m/arch/alpha/kernel/osf_sys.c	Sun May 16 15:41:19 1999
@@ -293,7 +293,7 @@
 	__kernel_fsid_t f_fsid;
 } *osf_stat;
 
-static int linux_to_osf_statfs(struct statfs *linux_stat, struct osf_statfs *osf_stat, unsigned long bufsiz)
+static int linux_to_osf_statfs(struct statfs64 *linux_stat, struct osf_statfs *osf_stat, unsigned long bufsiz)
 {
 	struct osf_statfs tmp_stat;
 
@@ -315,16 +315,14 @@
 
 static int do_osf_statfs(struct dentry * dentry, struct osf_statfs *buffer, unsigned long bufsiz)
 {
-	struct statfs linux_stat;
+	struct statfs64 linux_stat;
 	struct inode * inode = dentry->d_inode;
 	struct super_block * sb = inode->i_sb;
 	int error;
 
 	error = -ENODEV;
 	if (sb && sb->s_op && sb->s_op->statfs) {
-		set_fs(KERNEL_DS);
-		error = sb->s_op->statfs(sb, &linux_stat, sizeof(linux_stat));
-		set_fs(USER_DS);
+		error = sb->s_op->statfs(sb, &linux_stat);
 		if (!error)
 			error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
 	}
diff -u -r linux-22009/arch/arm/kernel/calls.S linux-22009m/arch/arm/kernel/calls.S
--- linux-22009/arch/arm/kernel/calls.S	Thu Dec 17 19:05:42 1998
+++ linux-22009m/arch/arm/kernel/calls.S	Sun May 16 15:41:19 1999
@@ -196,8 +196,26 @@
 		.long	SYMBOL_NAME(sys_capget)
 /* 185 */	.long	SYMBOL_NAME(sys_capset)
 		.long	SYMBOL_NAME(sys_sigaltstack_wrapper)
-
-		.rept	NR_syscalls-186
+		.long	SYMBOL_NAME(sys_sendfile)
+		.long	SYMBOL_NAME(sys_ni_syscall) /* streams1 */
+		.long	SYMBOL_NAME(sys_ni_syscall) /* streams2 */
+/* 190 */	.long	SYMBOL_NAME(sys_vfork_wrapper)
+		.long	SYMBOL_NAME(old_mmap64)
+		.long	SYMBOL_NAME(sys_setrlimit64)
+		.long	SYMBOL_NAME(sys_getrlimit64)
+		.long	SYMBOL_NAME(sys_truncate64)
+/* 195 */	.long	SYMBOL_NAME(sys_ftruncate64)
+		.long	SYMBOL_NAME(sys_newstat64)
+		.long	SYMBOL_NAME(sys_newlstat64)
+		.long	SYMBOL_NAME(sys_newfstat64)
+		.long	SYMBOL_NAME(sys_statfs64)
+/* 200 */	.long	SYMBOL_NAME(sys_fstatfs64)
+		.long	SYMBOL_NAME(sys_getdents64)
+		.long	SYMBOL_NAME(sys_sysconf)
+		.long	SYMBOL_NAME(sys_pathconf)
+		.long	SYMBOL_NAME(sys_fpathconf)
+/* 205 */
+		.rept	NR_syscalls-200
 			.long	SYMBOL_NAME(sys_ni_syscall)
 		.endr
 #endif
diff -u -r linux-22009/arch/arm/kernel/sys_arm.c linux-22009m/arch/arm/kernel/sys_arm.c
--- linux-22009/arch/arm/kernel/sys_arm.c	Sat May  8 21:14:01 1999
+++ linux-22009m/arch/arm/kernel/sys_arm.c	Sun May 16 15:41:19 1999
@@ -90,6 +90,42 @@
 	return error;
 }
 
+struct mmap_arg_struct64 {
+	unsigned long addr;
+	unsigned long len;
+	unsigned long prot;
+	unsigned long flags;
+	unsigned long fd;
+	unsigned long long offset; /* 64 bits */
+};
+
+asmlinkage int old_mmap64(struct mmap_arg_struct64 *arg)
+{
+	int error = -EFAULT;
+	struct file * file = NULL;
+	struct mmap_arg_struct64 a;
+
+	if (copy_from_user(&a, arg, sizeof(a)))
+		return -EFAULT;
+
+	down(&current->mm->mmap_sem);
+	lock_kernel();
+	if (!(a.flags & MAP_ANONYMOUS)) {
+		error = -EBADF;
+		file = fget(a.fd);
+		if (!file)
+			goto out;
+	}
+	a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+	error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
+	if (file)
+		fput(file);
+out:
+	unlock_kernel();
+	up(&current->mm->mmap_sem);
+	return error;
+}
 
 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 
diff -u -r linux-22009/arch/i386/kernel/entry.S linux-22009m/arch/i386/kernel/entry.S
--- linux-22009/arch/i386/kernel/entry.S	Fri Apr 30 18:13:37 1999
+++ linux-22009m/arch/i386/kernel/entry.S	Sun May 16 15:41:19 1999
@@ -561,7 +561,21 @@
 	.long SYMBOL_NAME(sys_sendfile)
 	.long SYMBOL_NAME(sys_ni_syscall)		/* streams1 */
 	.long SYMBOL_NAME(sys_ni_syscall)		/* streams2 */
-	.long SYMBOL_NAME(sys_vfork)            /* 190 */
+	.long SYMBOL_NAME(sys_vfork)		/* 190 */
+	.long SYMBOL_NAME(sys_setrlimit64)
+	.long SYMBOL_NAME(sys_getrlimit64)
+	.long SYMBOL_NAME(sys_truncate64)
+	.long SYMBOL_NAME(sys_ftruncate64)
+	.long SYMBOL_NAME(sys_newstat64)	/* 195 */
+	.long SYMBOL_NAME(sys_newlstat64)
+	.long SYMBOL_NAME(sys_newfstat64)
+	.long SYMBOL_NAME(sys_statfs64)
+	.long SYMBOL_NAME(sys_fstatfs64)
+	.long SYMBOL_NAME(sys_getdents64)	/* 200 */
+	.long SYMBOL_NAME(old_mmap64)
+	.long SYMBOL_NAME(sys_sysconf)
+	.long SYMBOL_NAME(sys_pathconf)
+	.long SYMBOL_NAME(sys_fpathconf)
 
 	/*
 	 * NOTE!! This doesn't have to be exact - we just have
@@ -569,6 +583,7 @@
 	 * entries. Don't panic if you notice that this hasn't
 	 * been shrunk every time we add a new system call.
 	 */
-	.rept NR_syscalls-190
+	.long SYMBOL_NAME(sys_ni_syscall)
+	.rept NR_syscalls - 204
 		.long SYMBOL_NAME(sys_ni_syscall)
 	.endr
diff -u -r linux-22009/arch/i386/kernel/sys_i386.c linux-22009m/arch/i386/kernel/sys_i386.c
--- linux-22009/arch/i386/kernel/sys_i386.c	Fri Dec 18 02:27:35 1998
+++ linux-22009m/arch/i386/kernel/sys_i386.c	Sun May 16 15:41:19 1999
@@ -85,6 +85,43 @@
 	return error;
 }
 
+struct mmap_arg_struct64 {
+	unsigned long addr;
+	unsigned long len;
+	unsigned long prot;
+	unsigned long flags;
+	unsigned long fd;
+	unsigned long long offset; /* 64 bits */
+};
+
+asmlinkage int old_mmap64(struct mmap_arg_struct64 *arg)
+{
+	int error = -EFAULT;
+	struct file * file = NULL;
+	struct mmap_arg_struct64 a;
+
+	if (copy_from_user(&a, arg, sizeof(a)))
+		return -EFAULT;
+
+	down(&current->mm->mmap_sem);
+	lock_kernel();
+	if (!(a.flags & MAP_ANONYMOUS)) {
+		error = -EBADF;
+		file = fget(a.fd);
+		if (!file)
+			goto out;
+	}
+	a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+	error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
+	if (file)
+		fput(file);
+out:
+	unlock_kernel();
+	up(&current->mm->mmap_sem);
+	return error;
+}
+
 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 
 struct sel_arg_struct {
@@ -248,3 +285,111 @@
 	return -ERESTARTNOHAND;
 }
 
+
+
+/*
+ * Revalidate the inode. This is required for proper NFS attribute caching.
+ * THIS FUNCTION IS A COPY FROM  fs/stat.c  FILE!
+ */
+static __inline__ int
+do_revalidate(struct dentry *dentry)
+{
+	struct inode * inode = dentry->d_inode;
+	if (inode->i_op && inode->i_op->revalidate)
+		return inode->i_op->revalidate(dentry);
+	return 0;
+}
+
+/*
+ * For backward compatibility?  Old entry vectors ?
+ */
+
+static int cp_old_stat(struct inode * inode, struct __old_kernel_stat * statbuf)
+{
+	static int warncount = 5;
+	struct __old_kernel_stat tmp;
+
+	if (warncount) {
+		warncount--;
+		printk("VFS: Warning: %s using old stat() call. Recompile your binary.\n",
+			current->comm);
+	}
+
+	tmp.st_dev = kdev_t_to_nr(inode->i_dev);
+	tmp.st_ino = inode->i_ino;
+	tmp.st_mode = inode->i_mode;
+	tmp.st_nlink = inode->i_nlink;
+	tmp.st_uid = inode->i_uid;
+	tmp.st_gid = inode->i_gid;
+	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
+	tmp.st_size = inode->i_size;
+	tmp.st_atime = inode->i_atime;
+	tmp.st_mtime = inode->i_mtime;
+	tmp.st_ctime = inode->i_ctime;
+	return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
+}
+
+asmlinkage int sys_stat(char * filename, struct __old_kernel_stat * statbuf)
+{
+	struct dentry * dentry;
+	int error;
+
+	printk("old stat() called by: %s\n",current->comm);
+
+	lock_kernel();
+	dentry = namei(filename);
+
+	error = PTR_ERR(dentry);
+	if (!IS_ERR(dentry)) {
+		error = do_revalidate(dentry);
+		if (!error)
+			error = cp_old_stat(dentry->d_inode, statbuf);
+
+		dput(dentry);
+	}
+	unlock_kernel();
+	return error;
+}
+
+asmlinkage int sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
+{
+	struct dentry * dentry;
+	int error;
+
+	printk("old lstat() called by: %s\n",current->comm);
+
+	lock_kernel();
+	dentry = lnamei(filename);
+
+	error = PTR_ERR(dentry);
+	if (!IS_ERR(dentry)) {
+		error = do_revalidate(dentry);
+		if (!error)
+			error = cp_old_stat(dentry->d_inode, statbuf);
+
+		dput(dentry);
+	}
+	unlock_kernel();
+	return error;
+}
+
+asmlinkage int sys_fstat(unsigned int fd, struct __old_kernel_stat * statbuf)
+{
+	struct file * f;
+	int err = -EBADF;
+
+	printk("old fstat() called by: %s\n",current->comm);
+
+	lock_kernel();
+	f = fget(fd);
+	if (f) {
+		struct dentry * dentry = f->f_dentry;
+
+		err = do_revalidate(dentry);
+		if (!err)
+			err = cp_old_stat(dentry->d_inode, statbuf);
+		fput(f);
+	}
+	unlock_kernel();
+	return err;
+}
diff -u -r linux-22009/arch/m68k/kernel/entry.S linux-22009m/arch/m68k/kernel/entry.S
--- linux-22009/arch/m68k/kernel/entry.S	Tue May 11 19:57:14 1999
+++ linux-22009m/arch/m68k/kernel/entry.S	Sun May 16 15:41:19 1999
@@ -609,7 +609,28 @@
 	.long SYMBOL_NAME(sys_ni_syscall)		/* streams1 */
 	.long SYMBOL_NAME(sys_ni_syscall)		/* streams2 */
 	.long SYMBOL_NAME(sys_vfork)            /* 190 */
+	.long SYMBOL_NAME(sys_setrlimit64)
+	.long SYMBOL_NAME(sys_getrlimit64)
+	.long SYMBOL_NAME(sys_truncate64)
+	.long SYMBOL_NAME(sys_ftruncate64)
+	.long SYMBOL_NAME(sys_newstat64)	/* 195 */
+	.long SYMBOL_NAME(sys_newlstat64)
+	.long SYMBOL_NAME(sys_newfstat64)
+	.long SYMBOL_NAME(sys_statfs64)
+	.long SYMBOL_NAME(sys_fstatfs64)
+	.long SYMBOL_NAME(sys_getdents64)	/* 200 */ /* "getdents64" */
+	.long SYMBOL_NAME(sys_oldmmap64)
+	.long SYMBOL_NAME(sys_sysconf)
+	.long SYMBOL_NAME(sys_pathconf)
+	.long SYMBOL_NAME(sys_fpathconf)
 
-	.rept NR_syscalls-(.-SYMBOL_NAME(sys_call_table))/4
+	/*
+	 * NOTE!! This doesn't have to be exact - we just have
+	 * to make sure we have _enough_ of the "sys_ni_syscall"
+	 * entries. Don't panic if you notice that this hasn't
+	 * been shrunk every time we add a new system call.
+	 */
+	.long SYMBOL_NAME(sys_ni_syscall)
+	.rept NR_syscalls - 204
 		.long SYMBOL_NAME(sys_ni_syscall)
 	.endr
diff -u -r linux-22009/arch/m68k/kernel/sys_m68k.c linux-22009m/arch/m68k/kernel/sys_m68k.c
--- linux-22009/arch/m68k/kernel/sys_m68k.c	Tue Jan 19 20:58:34 1999
+++ linux-22009m/arch/m68k/kernel/sys_m68k.c	Sun May 16 15:41:19 1999
@@ -89,6 +89,43 @@
 }
 
 
+struct mmap_arg_struct64 {
+	unsigned long addr;
+	unsigned long len;
+	unsigned long prot;
+	unsigned long flags;
+	unsigned long fd;
+	unsigned long long offset; /* 64 bits */
+};
+
+asmlinkage int old_mmap64(struct mmap_arg_struct64 *arg)
+{
+	int error = -EFAULT;
+	struct file * file = NULL;
+	struct mmap_arg_struct64 a;
+
+	if (copy_from_user(&a, arg, sizeof(a)))
+		return -EFAULT;
+
+	down(&current->mm->mmap_sem);
+	lock_kernel();
+	if (!(a.flags & MAP_ANONYMOUS)) {
+		error = -EBADF;
+		file = fget(a.fd);
+		if (!file)
+			goto out;
+	}
+	a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+	error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
+	if (file)
+		fput(file);
+out:
+	unlock_kernel();
+	up(&current->mm->mmap_sem);
+	return error;
+}
+
 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 
 struct sel_arg_struct {
@@ -603,4 +640,105 @@
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
 	return -ERESTARTNOHAND;
+}
+
+
+/*
+ * Revalidate the inode. This is required for proper NFS attribute caching.
+ * THIS FUNCTION IS A COPY FROM  fs/stat.c  FILE!
+ */
+static __inline__ int
+do_revalidate(struct dentry *dentry)
+{
+	struct inode * inode = dentry->d_inode;
+	if (inode->i_op && inode->i_op->revalidate)
+		return inode->i_op->revalidate(dentry);
+	return 0;
+}
+
+/*
+ * For backward compatibility?  Old entry vectors ?
+ */
+static int cp_old_stat(struct inode * inode, struct __old_kernel_stat * statbuf)
+{
+	static int warncount = 5;
+	struct __old_kernel_stat tmp;
+
+	if (warncount) {
+		warncount--;
+		printk("VFS: Warning: %s using old stat() call. Recompile your binary.\n",
+			current->comm);
+	}
+
+	tmp.st_dev = kdev_t_to_nr(inode->i_dev);
+	tmp.st_ino = inode->i_ino;
+	tmp.st_mode = inode->i_mode;
+	tmp.st_nlink = inode->i_nlink;
+	tmp.st_uid = inode->i_uid;
+	tmp.st_gid = inode->i_gid;
+	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
+	tmp.st_size = inode->i_size;
+	tmp.st_atime = inode->i_atime;
+	tmp.st_mtime = inode->i_mtime;
+	tmp.st_ctime = inode->i_ctime;
+	return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
+}
+
+asmlinkage int sys_stat(char * filename, struct __old_kernel_stat * statbuf)
+{
+	struct dentry * dentry;
+	int error;
+
+	lock_kernel();
+	dentry = namei(filename);
+
+	error = PTR_ERR(dentry);
+	if (!IS_ERR(dentry)) {
+		error = do_revalidate(dentry);
+		if (!error)
+			error = cp_old_stat(dentry->d_inode, statbuf);
+
+		dput(dentry);
+	}
+	unlock_kernel();
+	return error;
+}
+
+asmlinkage int sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
+{
+	struct dentry * dentry;
+	int error;
+
+	lock_kernel();
+	dentry = lnamei(filename);
+
+	error = PTR_ERR(dentry);
+	if (!IS_ERR(dentry)) {
+		error = do_revalidate(dentry);
+		if (!error)
+			error = cp_old_stat(dentry->d_inode, statbuf);
+
+		dput(dentry);
+	}
+	unlock_kernel();
+	return error;
+}
+
+asmlinkage int sys_fstat(unsigned int fd, struct __old_kernel_stat * statbuf)
+{
+	struct file * f;
+	int err = -EBADF;
+
+	lock_kernel();
+	f = fget(fd);
+	if (f) {
+		struct dentry * dentry = f->f_dentry;
+
+		err = do_revalidate(dentry);
+		if (!err)
+			err = cp_old_stat(dentry->d_inode, statbuf);
+		fput(f);
+	}
+	unlock_kernel();
+	return err;
 }
diff -u -r linux-22009/arch/mips/kernel/syscalls.h linux-22009m/arch/mips/kernel/syscalls.h
--- linux-22009/arch/mips/kernel/syscalls.h	Tue Oct 20 23:52:54 1998
+++ linux-22009m/arch/mips/kernel/syscalls.h	Sun May 16 15:41:19 1999
@@ -223,5 +223,19 @@
 SYS(sys_capset, 2)				/* 4205 */
 SYS(sys_sigaltstack, 2)
 SYS(sys_sendfile, 3)
-SYS(sys_ni_syscall, 0)
-SYS(sys_ni_syscall, 0)
+SYS(sys_ni_syscall, 0) /* streams getpmsg */
+SYS(sys_ni_syscall, 0) /* streams putpmsg */
+SYS(sys_ni_syscall, 0) /* mmap64 */		/* 4210 */
+SYS(sys_ni_syscall, 0) /* setrlimit64 */
+SYS(sys_ni_syscall, 0) /* getrlimit64 */
+SYS(sys_ni_syscall, 0) /* truncate64 */
+SYS(sys_ni_syscall, 0) /* ftruncate64 */
+SYS(sys_ni_syscall, 0) /* stat64 */		/* 4215 */
+SYS(sys_ni_syscall, 0) /* lstat64 */
+SYS(sys_ni_syscall, 0) /* fstat64 */
+SYS(sys_ni_syscall, 0) /* statfs64 */
+SYS(sys_ni_syscall, 0) /* fstatfs64 */
+SYS(sys_ni_syscall, 0) /* getdents64 */		/* 4220 */
+SYS(sys_ni_syscall, 0) /* sysconf */
+SYS(sys_ni_syscall, 0) /* pathconf */
+SYS(sys_ni_syscall, 0) /* fpathconf */
diff -u -r linux-22009/arch/mips/kernel/sysirix.c linux-22009m/arch/mips/kernel/sysirix.c
--- linux-22009/arch/mips/kernel/sysirix.c	Sat May  8 21:14:01 1999
+++ linux-22009m/arch/mips/kernel/sysirix.c	Sun May 16 15:41:19 1999
@@ -730,8 +730,7 @@
 {
 	struct dentry *dentry;
 	struct inode *inode;
-	mm_segment_t old_fs;
-	struct statfs kbuf;
+	struct statfs64 kbuf;
 	int error, i;
 
 	/* We don't support this feature yet. */
@@ -749,10 +748,7 @@
 		goto out;
 
 	inode = dentry->d_inode;
-	old_fs = get_fs(); set_fs(get_ds());
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf,
-	                                  sizeof(struct statfs));
-	set_fs(old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf);
 	if (error)
 		goto dput_and_out;
 
@@ -779,8 +775,7 @@
 asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs *buf)
 {
 	struct inode *inode;
-	struct statfs kbuf;
-	mm_segment_t old_fs;
+	struct statfs64 kbuf;
 	struct file *file;
 	int error, i;
 
@@ -806,10 +801,7 @@
 		goto out_f;
 	}
 
-	old_fs = get_fs(); set_fs(get_ds());
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf,
-	                                  sizeof(struct statfs));
-	set_fs(old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf);
 	if (error)
 		goto out_f;
 
@@ -1510,8 +1502,7 @@
 {
 	struct dentry *dentry;
 	struct inode *inode;
-	mm_segment_t old_fs;
-	struct statfs kbuf;
+	struct statfs64 kbuf;
 	int error, i;
 
 	lock_kernel();
@@ -1530,10 +1521,7 @@
 	if(!inode->i_sb->s_op->statfs)
 		goto dput_and_out;
 
-	old_fs = get_fs(); set_fs(get_ds());
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf,
-	                                  sizeof(struct statfs));
-	set_fs(old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf);
 	if (error)
 		goto dput_and_out;
 
@@ -1569,8 +1557,7 @@
 asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs *buf)
 {
 	struct inode *inode;
-	mm_segment_t old_fs;
-	struct statfs kbuf;
+	struct statfs64 kbuf;
 	struct file *file;
 	int error, i;
 
@@ -1598,10 +1585,7 @@
 		goto out_f;
 	}
 
-	old_fs = get_fs(); set_fs(get_ds());
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf,
-	                                  sizeof(struct statfs));
-	set_fs(old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf);
 	if (error)
 		goto out_f;
 
@@ -1806,8 +1790,7 @@
 {
 	struct dentry *dentry;
 	struct inode *inode;
-	mm_segment_t old_fs;
-	struct statfs kbuf;
+	struct statfs64 kbuf;
 	int error, i;
 
 	lock_kernel();
@@ -1825,10 +1808,7 @@
 	if(!inode->i_sb->s_op->statfs)
 		goto dput_and_out;
 
-	old_fs = get_fs(); set_fs(get_ds());
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf,
-	                                  sizeof(struct statfs));
-	set_fs(old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf);
 	if (error)
 		goto dput_and_out;
 
@@ -1864,8 +1844,7 @@
 asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
 {
 	struct inode *inode;
-	mm_segment_t old_fs;
-	struct statfs kbuf;
+	struct statfs64 kbuf;
 	struct file *file;
 	int error, i;
 
@@ -1893,10 +1872,7 @@
 		goto out_f;
 	}
 
-	old_fs = get_fs(); set_fs(get_ds());
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf,
-	                                  sizeof(struct statfs));
-	set_fs(old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &kbuf);
 	if (error)
 		goto out_f;
 
diff -u -r linux-22009/arch/ppc/kernel/misc.S linux-22009m/arch/ppc/kernel/misc.S
--- linux-22009/arch/ppc/kernel/misc.S	Thu Apr 29 22:39:01 1999
+++ linux-22009m/arch/ppc/kernel/misc.S	Sun May 16 15:41:19 1999
@@ -897,4 +897,28 @@
 	.long sys_ni_syscall		/* streams1 */
 	.long sys_ni_syscall		/* streams2 */
 	.long sys_vfork
-	.space (NR_syscalls-183)*4
+	.long sys_ni_syscall /* mmap64 */ /* 190 */
+	.long sys_setrlimit64
+	.long sys_getrlimit64
+	.long sys_truncate64
+	.long sys_ftruncate64
+	.long sys_newstat64	/* 195 */
+	.long sys_newlstat64
+	.long sys_newfstat64
+	.long sys_statfs64
+	.long sys_fstatfs64
+	.long sys_getdents64	/* 200 */
+	.long sys_sysconf
+	.long sys_pathconf
+	.long sys_fpathconf
+
+	/*
+	 * NOTE!! This doesn't have to be exact - we just have
+	 * to make sure we have _enough_ of the "sys_ni_syscall"
+	 * entries. Don't panic if you notice that this hasn't
+	 * been shrunk every time we add a new system call.
+	 */
+	.long sys_ni_syscall
+	.rept NR_syscalls - 203
+		.long sys_ni_syscall
+	.endr
diff -u -r linux-22009/arch/sparc64/solaris/fs.c linux-22009m/arch/sparc64/solaris/fs.c
--- linux-22009/arch/sparc64/solaris/fs.c	Thu Mar 11 02:53:37 1999
+++ linux-22009m/arch/sparc64/solaris/fs.c	Sun May 16 15:41:19 1999
@@ -443,14 +443,11 @@
 
 static int report_statvfs64(struct inode *inode, u32 buf)
 {
-	struct statfs s;
-	mm_segment_t old_fs = get_fs();
+	struct statfs64 s;
 	int error;
 	struct sol_statvfs64 *ss = (struct sol_statvfs64 *)A(buf);
 			
-	set_fs (KERNEL_DS);
-	error = inode->i_sb->s_op->statfs(inode->i_sb, &s, sizeof(struct statfs));
-	set_fs (old_fs);
+	error = inode->i_sb->s_op->statfs(inode->i_sb, &s);
 	if (!error) {
 		const char *p = inode->i_sb->s_type->name;
 		int i = 0;
diff -u -r linux-22009/drivers/block/loop.c linux-22009m/drivers/block/loop.c
--- linux-22009/drivers/block/loop.c	Thu Jan 14 20:33:36 1999
+++ linux-22009m/drivers/block/loop.c	Sun May 16 15:41:19 1999
@@ -137,12 +137,12 @@
 	int	size;
 
 	if (S_ISREG(lo->lo_dentry->d_inode->i_mode))
-		size = (lo->lo_dentry->d_inode->i_size - lo->lo_offset) / BLOCK_SIZE;
+		size = (lo->lo_dentry->d_inode->i_size - lo->lo_offset) >> BLOCK_SIZE_BITS;
 	else {
 		kdev_t lodev = lo->lo_device;
 		if (blk_size[MAJOR(lodev)])
 			size = blk_size[MAJOR(lodev)][MINOR(lodev)] -
-                                lo->lo_offset / BLOCK_SIZE;
+				 (lo->lo_offset >> BLOCK_SIZE_BITS);
 		else
 			size = MAX_DISK_SIZE;
 	}
diff -u -r linux-22009/fs/adfs/dir.c linux-22009m/fs/adfs/dir.c
--- linux-22009/fs/adfs/dir.c	Wed May 12 02:30:36 1999
+++ linux-22009m/fs/adfs/dir.c	Sun May 16 15:41:19 1999
@@ -9,6 +9,7 @@
 #include <linux/adfs_fs.h>
 #include <linux/sched.h>
 #include <linux/stat.h>
+#include <linux/unistd.h>
 
 static ssize_t adfs_dirread (struct file *filp, char *buf,
 			     size_t siz, loff_t *ppos)
@@ -17,6 +18,7 @@
 }
 
 static int adfs_readdir (struct file *, void *, filldir_t);
+extern int adfs_pathconf(struct inode *, int);
 
 static struct file_operations adfs_dir_operations = {
 	NULL,			/* lseek - default */
@@ -56,7 +58,10 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	adfs_pathconf,		/* pathconf */
 };
 
 unsigned int adfs_val (unsigned char *p, int len)
@@ -347,4 +352,30 @@
 	}
 	adfs_dir_free (bh, buffers);
 	return 0;
+}
+
+int adfs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return ADFS_NAME_LEN;	/* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* Semantics ??? */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 2;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
diff -u -r linux-22009/fs/adfs/file.c linux-22009m/fs/adfs/file.c
--- linux-22009/fs/adfs/file.c	Mon Aug 24 23:02:44 1998
+++ linux-22009m/fs/adfs/file.c	Sun May 16 15:41:19 1999
@@ -48,6 +48,8 @@
 	NULL			/* revalidate		*/
 };
 
+extern int adfs_pathconf(struct inode *, int);
+
 struct inode_operations adfs_file_inode_operations = {
 	&adfs_file_operations,	/* default file operations	*/
 	NULL,			/* create			*/
@@ -66,5 +68,8 @@
 	adfs_bmap,		/* bmap				*/
 	NULL,			/* truncate			*/
 	NULL,			/* permission			*/
-	NULL			/* smap				*/
+	NULL,			/* smap				*/
+	NULL,			/* updatepage			*/
+	NULL,			/* revalidate			*/
+	adfs_pathconf,		/* pathconf			*/
 };
diff -u -r linux-22009/fs/adfs/inode.c linux-22009m/fs/adfs/inode.c
--- linux-22009/fs/adfs/inode.c	Fri Mar 26 23:57:41 1999
+++ linux-22009m/fs/adfs/inode.c	Sun May 16 15:41:19 1999
@@ -181,7 +181,7 @@
 		inode->i_nlink	 = 2;
 		inode->i_size	 = ADFS_NEWDIR_SIZE;
 		inode->i_blksize = PAGE_SIZE;
-		inode->i_blocks  = inode->i_size / sb->s_blocksize;
+		inode->i_blocks  = inode->i_size >> sb->s_blocksize_bits;
 		inode->i_mtime   =
 		inode->i_atime   =
 		inode->i_ctime   = 0;
diff -u -r linux-22009/fs/adfs/super.c linux-22009m/fs/adfs/super.c
--- linux-22009/fs/adfs/super.c	Fri Mar 26 23:57:41 1999
+++ linux-22009m/fs/adfs/super.c	Sun May 16 15:41:19 1999
@@ -23,7 +23,7 @@
 
 static void adfs_put_super(struct super_block *sb);
 static int adfs_remount(struct super_block *sb, int *flags, char *data);
-static int adfs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz);
+static int adfs_statfs(struct super_block *sb, struct statfs64 *buf);
 void adfs_read_inode(struct inode *inode);
 
 void adfs_error(struct super_block *sb, const char *function, const char *fmt, ...)
@@ -323,16 +323,15 @@
 	return NULL;
 }
 
-static int adfs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+static int adfs_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
 	const unsigned int nidlen = sb->u.adfs_sb.s_idlen + 1;
 
-	tmp.f_type = ADFS_SUPER_MAGIC;
-	tmp.f_bsize = sb->s_blocksize;
-	tmp.f_blocks = sb->u.adfs_sb.s_dr->disc_size_high << (32 - sb->s_blocksize_bits) |
+	buf->f_type = ADFS_SUPER_MAGIC;
+	buf->f_bsize = sb->s_blocksize;
+	buf->f_blocks = sb->u.adfs_sb.s_dr->disc_size_high << (32 - sb->s_blocksize_bits) |
 		       sb->u.adfs_sb.s_dr->disc_size >> sb->s_blocksize_bits;
-	tmp.f_files = tmp.f_blocks >> nidlen;
+	buf->f_files = buf->f_blocks >> nidlen;
 	{
 		unsigned int i, j = 0;
 		const unsigned mask = (1 << (nidlen - 1)) - 1;
@@ -374,12 +373,12 @@
 			else if (freelink)
 				adfs_error(sb, NULL, "undersized free fragment\n");
 		}
-		tmp.f_bfree = tmp.f_bavail = j <<
+		buf->f_bfree = buf->f_bavail = j <<
 			(sb->u.adfs_sb.s_dr->log2bpmb - sb->s_blocksize_bits);
 	}
-	tmp.f_ffree = tmp.f_bfree >> nidlen;
-	tmp.f_namelen = ADFS_NAME_LEN;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_ffree = buf->f_bfree >> nidlen;
+	buf->f_namelen = ADFS_NAME_LEN;
+	return 0;
 }
 
 static struct file_system_type adfs_fs_type = {
diff -u -r linux-22009/fs/affs/dir.c linux-22009m/fs/affs/dir.c
--- linux-22009/fs/affs/dir.c	Sat Apr 24 07:20:37 1999
+++ linux-22009m/fs/affs/dir.c	Sun May 16 15:41:19 1999
@@ -23,9 +23,11 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/amigaffs.h>
+#include <linux/unistd.h>
 
 static int affs_readdir(struct file *, void *, filldir_t);
 static ssize_t affs_dir_read(struct file *, char *, size_t, loff_t *);
+extern int affs_pathconf(struct inode *inode, int option);
 
 static struct file_operations affs_dir_operations = {
 	NULL,			/* lseek - default */
@@ -64,7 +66,8 @@
 	NULL,			/* permissions */
 	NULL,			/* smap */
 	NULL,			/* updatepage */
-	NULL			/* revalidate */
+	NULL,			/* revalidate */
+	affs_pathconf,		/* pathconf */
 };
 
 static ssize_t
@@ -181,4 +184,30 @@
 	affs_brelse(fh_bh);
 	pr_debug("AFFS: readdir()=%d\n",stored);
 	return stored;
+}
+
+int affs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return 30;	/* name component max length */
+	case _PC_NO_TRUNC:
+		return 0;	/* Will *silently* truncate */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return -INT_MAX; /* Unknown ?? */
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
diff -u -r linux-22009/fs/affs/file.c linux-22009m/fs/affs/file.c
--- linux-22009/fs/affs/file.c	Mon Aug 24 23:02:44 1998
+++ linux-22009m/fs/affs/file.c	Sun May 16 15:41:19 1999
@@ -580,17 +580,17 @@
 affs_file_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
 {
 	struct inode		*inode = filp->f_dentry->d_inode;
-	off_t			 pos;
+	loff_t			 pos;
 	ssize_t			 written;
 	ssize_t			 c;
-	ssize_t			 blocksize;
+	ssize_t			 blocksize, blockshift;
 	struct buffer_head	*bh;
 	char			*p;
 
 	if (!count)
 		return 0;
-	pr_debug("AFFS: file_write(ino=%lu,pos=%lu,count=%d)\n",inode->i_ino,
-		 (unsigned long)*ppos,count);
+	pr_debug("AFFS: file_write(ino=%lu,pos=%Lu,count=%d)\n",inode->i_ino,
+		 *ppos,count);
 
 	if (!inode) {
 		affs_error(inode->i_sb,"file_write","Inode = NULL");
@@ -609,16 +609,22 @@
 	else
 		pos = *ppos;
 	written   = 0;
-	blocksize = AFFS_I2BSIZE(inode);
+	blocksize  = AFFS_I2BSIZE(inode);
+	blockshift = AFFS_I2BITS(inode);
+
+	if (pos >= 0x7fffffff) /* Max size: 2G-1 */
+		return -EFBIG;
+	if ((pos + count) > 0x7fffffff)
+		count = 0x7fffffff - pos;
 
 	while (written < count) {
-		bh = affs_getblock(inode,pos / blocksize);
+		bh = affs_getblock(inode, pos >> blockshift);
 		if (!bh) {
 			if (!written)
 				written = -ENOSPC;
 			break;
 		}
-		c = blocksize - (pos % blocksize);
+		c = blocksize - (pos & (blocksize -1));
 		if (c > count - written)
 			c = count - written;
 		if (c != blocksize && !buffer_uptodate(bh)) {
@@ -631,7 +637,7 @@
 				break;
 			}
 		}
-		p  = (pos % blocksize) + bh->b_data;
+		p  = (pos & (blocksize -1)) + bh->b_data;
 		c -= copy_from_user(p,buf,c);
 		if (!c) {
 			affs_brelse(bh);
@@ -662,7 +668,7 @@
 	off_t			 pos;
 	ssize_t			 written;
 	ssize_t			 c;
-	ssize_t			 blocksize;
+	ssize_t			 blocksize, blockshift;
 	struct buffer_head	*bh;
 	char			*p;
 
@@ -690,15 +696,16 @@
 
 	bh        = NULL;
 	blocksize = AFFS_I2BSIZE(inode) - 24;
+	blockshift = AFFS_I2BITS(inode);
 	written   = 0;
 	while (written < count) {
-		bh = affs_getblock(inode,pos / blocksize);
+		bh = affs_getblock(inode,pos >> blockshift);
 		if (!bh) {
 			if (!written)
 				written = -ENOSPC;
 			break;
 		}
-		c = blocksize - (pos % blocksize);
+		c = blocksize - (pos & (blocksize -1));
 		if (c > count - written)
 			c = count - written;
 		if (c != blocksize && !buffer_uptodate(bh)) {
@@ -711,7 +718,7 @@
 				break;
 			}
 		}
-		p  = (pos % blocksize) + bh->b_data + 24;
+		p  = (pos & (blocksize -1)) + bh->b_data + 24;
 		c -= copy_from_user(p,buf,c);
 		if (!c) {
 			affs_brelse(bh);
@@ -780,10 +787,12 @@
 	int	 rem;
 	int	 ext;
 
-	pr_debug("AFFS: truncate(inode=%ld,size=%lu)\n",inode->i_ino,inode->i_size);
+	pr_debug("AFFS: truncate(inode=%ld,size=%Lu)\n",inode->i_ino,inode->i_size);
+	if (inode->i_size > 0x7fffffffULL)
+		return -EFBIG;
 
 	net_blocksize = blocksize - ((inode->i_sb->u.affs_sb.s_flags & SF_OFS) ? 24 : 0);
-	first = (inode->i_size + net_blocksize - 1) / net_blocksize;
+	first = (u_long)(inode->i_size + net_blocksize - 1) / net_blocksize;
 	if (inode->u.affs_i.i_lastblock < first - 1) {
 		/* There has to be at least one new block to be allocated */
 		if (!inode->u.affs_i.i_ec && alloc_ext_cache(inode)) {
@@ -793,9 +802,9 @@
 		bh = affs_getblock(inode,first - 1);
 		if (!bh) {
 			affs_warning(inode->i_sb,"truncate","Cannot extend file");
-			inode->i_size = net_blocksize * (inode->u.affs_i.i_lastblock + 1);
+			inode->i_size = (inode->u.affs_i.i_lastblock + 1) * net_blocksize;
 		} else if (inode->i_sb->u.affs_sb.s_flags & SF_OFS) {
-			rem = inode->i_size % net_blocksize;
+			rem = ((u_long)inode->i_size) & (net_blocksize -1);
 			DATA_FRONT(bh)->data_size = cpu_to_be32(rem ? rem : net_blocksize);
 			affs_fix_checksum(blocksize,bh->b_data,5);
 			mark_buffer_dirty(bh,0);
@@ -862,7 +871,7 @@
 			affs_free_block(inode->i_sb,ekey);
 		ekey = key;
 	}
-	block = ((inode->i_size + net_blocksize - 1) / net_blocksize) - 1;
+	block = (((u_long)inode->i_size + net_blocksize - 1) / net_blocksize) - 1;
 	inode->u.affs_i.i_lastblock = block;
 
 	/* If the file is not truncated to a block boundary,
@@ -870,7 +879,7 @@
 	 * so it cannot become accessible again.
 	 */
 
-	rem = inode->i_size % net_blocksize;
+	rem = inode->i_size & (net_blocksize -1);
 	if (rem) {
 		if ((inode->i_sb->u.affs_sb.s_flags & SF_OFS)) 
 			rem += 24;
diff -u -r linux-22009/fs/affs/inode.c linux-22009m/fs/affs/inode.c
--- linux-22009/fs/affs/inode.c	Mon Mar  8 01:25:23 1999
+++ linux-22009m/fs/affs/inode.c	Sun May 16 15:41:19 1999
@@ -146,7 +146,7 @@
 				block = AFFS_I2BSIZE(inode) - 24;
 			else
 				block = AFFS_I2BSIZE(inode);
-			inode->u.affs_i.i_lastblock = ((inode->i_size + block - 1) / block) - 1;
+			inode->u.affs_i.i_lastblock = (((u_long)inode->i_size + block - 1) / block) - 1;
 			break;
 		case ST_SOFTLINK:
 			inode->i_mode |= S_IFLNK;
diff -u -r linux-22009/fs/affs/super.c linux-22009m/fs/affs/super.c
--- linux-22009/fs/affs/super.c	Mon Mar  8 01:25:23 1999
+++ linux-22009m/fs/affs/super.c	Sun May 16 15:41:19 1999
@@ -35,7 +35,7 @@
 
 #define MIN(a,b) (((a)<(b))?(a):(b))
 
-static int affs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz);
+static int affs_statfs(struct super_block *sb, struct statfs64 *buf);
 static int affs_remount (struct super_block *sb, int *flags, char *data);
 
 static void
@@ -662,23 +662,22 @@
 }
 
 static int
-affs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+affs_statfs(struct super_block *sb, struct statfs64 *buf)
 {
 	int		 free;
-	struct statfs	 tmp;
 
 	pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",sb->u.affs_sb.s_partition_size,
 	     sb->u.affs_sb.s_reserved);
 
 	free          = affs_count_free_blocks(sb);
-	tmp.f_type    = AFFS_SUPER_MAGIC;
-	tmp.f_bsize   = sb->s_blocksize;
-	tmp.f_blocks  = sb->u.affs_sb.s_partition_size - sb->u.affs_sb.s_reserved;
-	tmp.f_bfree   = free;
-	tmp.f_bavail  = free;
-	tmp.f_files   = 0;
-	tmp.f_ffree   = 0;
-	return copy_to_user(buf,&tmp,bufsiz) ? -EFAULT : 0;
+	buf->f_type    = AFFS_SUPER_MAGIC;
+	buf->f_bsize   = sb->s_blocksize;
+	buf->f_blocks  = sb->u.affs_sb.s_partition_size - sb->u.affs_sb.s_reserved;
+	buf->f_bfree   = free;
+	buf->f_bavail  = free;
+	buf->f_files   = 0;
+	buf->f_ffree   = 0;
+	return 0;
 }
 
 static struct file_system_type affs_fs_type = {
diff -u -r linux-22009/fs/autofs/inode.c linux-22009m/fs/autofs/inode.c
--- linux-22009/fs/autofs/inode.c	Tue Jan 12 01:03:30 1999
+++ linux-22009m/fs/autofs/inode.c	Sun May 16 15:41:19 1999
@@ -55,7 +55,7 @@
 #endif
 }
 
-static int autofs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz);
+static int autofs_statfs(struct super_block *sb, struct statfs64 *buf);
 static void autofs_read_inode(struct inode *inode);
 static void autofs_write_inode(struct inode *inode);
 
@@ -277,19 +277,17 @@
 	return NULL;
 }
 
-static int autofs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+static int autofs_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = AUTOFS_SUPER_MAGIC;
-	tmp.f_bsize = 1024;
-	tmp.f_blocks = 0;
-	tmp.f_bfree = 0;
-	tmp.f_bavail = 0;
-	tmp.f_files = 0;
-	tmp.f_ffree = 0;
-	tmp.f_namelen = NAME_MAX;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = AUTOFS_SUPER_MAGIC;
+	buf->f_bsize = 1024;
+	buf->f_blocks = 0;
+	buf->f_bfree = 0;
+	buf->f_bavail = 0;
+	buf->f_files = 0;
+	buf->f_ffree = 0;
+	buf->f_namelen = NAME_MAX;
+	return 0;
 }
 
 static void autofs_read_inode(struct inode *inode)
diff -u -r linux-22009/fs/binfmt_aout.c linux-22009m/fs/binfmt_aout.c
--- linux-22009/fs/binfmt_aout.c	Mon May 10 23:01:21 1999
+++ linux-22009m/fs/binfmt_aout.c	Sun May 16 15:41:19 1999
@@ -413,7 +413,13 @@
 			return fd;
 		file = fcheck(fd);
 
-		if (!file->f_op || !file->f_op->mmap) {
+		if ((fd_offset & ~PAGE_MASK) != 0) {
+			printk(KERN_WARNING 
+			       "fd_offset is not page aligned. Please convert program: %s\n",
+			       file->f_dentry->d_name.name);
+		}
+		if (!file->f_op || !file->f_op->mmap ||
+		    ((fd_offset & ~PAGE_MASK) != 0)) {
 			sys_close(fd);
 			do_mmap(NULL, 0, ex.a_text+ex.a_data,
 				PROT_READ|PROT_WRITE|PROT_EXEC,
@@ -534,6 +540,23 @@
 
 	start_addr =  ex.a_entry & 0xfffff000;
 
+	if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) {
+		printk(KERN_WARNING 
+		       "N_TXTOFF is not page aligned. Please convert library: %s\n",
+		       file->f_dentry->d_name.name
+		       );
+
+		do_mmap(NULL, start_addr & PAGE_MASK, ex.a_text + ex.a_data + ex.a_bss,
+			PROT_READ | PROT_WRITE | PROT_EXEC,
+			MAP_FIXED| MAP_PRIVATE, 0);
+
+		read_exec(file->f_dentry, N_TXTOFF(ex),
+			  (char *)start_addr, ex.a_text + ex.a_data, 0);
+		flush_icache_range((unsigned long) start_addr,
+				   (unsigned long) start_addr + ex.a_text + ex.a_data);
+		retval = 0;
+		goto out_putf;
+	}
 	/* Now use mmap to map the library into memory. */
 	error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
 			PROT_READ | PROT_WRITE | PROT_EXEC,
diff -u -r linux-22009/fs/buffer.c linux-22009m/fs/buffer.c
--- linux-22009/fs/buffer.c	Thu May 13 23:14:04 1999
+++ linux-22009m/fs/buffer.c	Sun May 16 15:41:19 1999
@@ -1111,7 +1111,7 @@
 #endif
 	}
 	if (test_and_clear_bit(PG_swap_unlock_after, &page->flags))
-		swap_after_unlock_page(page->offset);
+		swap_after_unlock_page(pgoff2ulong(page->pg_offset));
 	if (test_and_clear_bit(PG_free_after, &page->flags))
 		__free_page(page);
 }
@@ -1334,15 +1334,46 @@
 	set_bit(PG_locked, &page->flags);
 	set_bit(PG_free_after, &page->flags);
 	
+	/* Blocks within a page */
 	i = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
-	block = page->offset >> inode->i_sb->s_blocksize_bits;
-	p = nr;
-	do {
-		*p = inode->i_op->bmap(inode, block);
-		i--;
-		block++;
-		p++;
-	} while (i > 0);
+
+	block = pgoff2ulong(page->pg_offset);
+	/* Scaled already by PAGE_SHIFT, which said shift should
+	   be same or larger, than that of any filesystem in
+	   this system -- that is, at i386 with 4k pages one
+	   can't use 8k (primitive) blocks at the filesystems... */
+
+	if (i > 0) {
+		/* Filesystem blocksize is same, or smaller than CPU
+		   page size, we can easily process this.. */
+
+		if (i > 1)
+			block *= i;
+		/* Scale by FS blocks per page, presuming FS-blocks are smaller
+		   than the processor page... */
+
+		p = nr;
+		do {
+			*p = inode->i_op->bmap(inode, block);
+			i--;
+			block++;
+			p++;
+		} while (i > 0);
+	} else {
+		/* Filesystem blocksize is larger than CPU page size,
+		   but if the underlying storage system block size is
+		   smaller than CPU page size, all is well, else we
+		   are in deep trouble -- for direct paging in at least.. */
+		/* Nobody needs such monsterous fs block sizes ?
+		   Well, it is the only way to get files in terabyte
+		   range..  Nobody needs them ?  You are for a surprise..
+		   However EXT2 (at least) needs access to internal
+		   blocks and there it needs allocations of 8k/16k (or
+		   whatever the block size is) for internal uses..
+		   Fixing this function alone isn't enough, although
+		   perhaps fairly trivial.. */
+		/* FIXME: WRITE THE CODE HERE !!! */
+	}
 
 	/* IO start */
 	brw_page(READ, page, inode->i_dev, nr, inode->i_sb->s_blocksize, 1);
diff -u -r linux-22009/fs/coda/dir.c linux-22009m/fs/coda/dir.c
--- linux-22009/fs/coda/dir.c	Sun May  9 03:56:37 1999
+++ linux-22009m/fs/coda/dir.c	Sun May 16 15:41:19 1999
@@ -18,6 +18,7 @@
 #include <asm/segment.h>
 #include <asm/uaccess.h>
 #include <linux/string.h>
+#include <linux/unistd.h>
 
 #include <linux/coda.h>
 #include <linux/coda_linux.h>
@@ -50,7 +51,8 @@
 /* support routines */
 static int coda_venus_readdir(struct file *filp, void *dirent, 
 			      filldir_t filldir);
-int coda_fsync(struct file *, struct dentry *dentry);
+extern int coda_fsync(struct file *, struct dentry *dentry);
+extern int coda_pathconf(struct inode *, int);
 
 int coda_crossvol_rename = 0;
 int coda_hasmknod = 0;
@@ -84,7 +86,8 @@
 	coda_permission,        /* permission */
 	NULL,                   /* smap */
 	NULL,                   /* update page */
-        coda_revalidate_inode   /* revalidate */
+        coda_revalidate_inode,	/* revalidate */
+	coda_pathconf,		/* pathconf */
 };
 
 struct file_operations coda_dir_operations = {
@@ -908,3 +911,29 @@
 	return 0;
 }
 
+
+int coda_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return CODA_MAXNAMLEN;	/* name component max length */
+	case _PC_NO_TRUNC:
+		return 1;	/* Will yield -ENAMETOOLONG */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 64;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return -INT_MAX; /* Unknown ?? */
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
diff -u -r linux-22009/fs/coda/file.c linux-22009m/fs/coda/file.c
--- linux-22009/fs/coda/file.c	Tue Sep  1 01:46:10 1998
+++ linux-22009m/fs/coda/file.c	Sun May 16 15:41:19 1999
@@ -32,7 +32,8 @@
 static int coda_file_mmap(struct file * file, struct vm_area_struct * vma);
 
 /* also exported from this file (used for dirs) */
-int coda_fsync(struct file *, struct dentry *dentry);
+extern int coda_fsync(struct file *, struct dentry *dentry);
+extern int coda_pathconf(struct inode *, int);
 
 struct inode_operations coda_file_inode_operations = {
 	&coda_file_operations,	/* default file operations */
@@ -54,7 +55,8 @@
         coda_permission,        /* permission */
 	NULL,                   /* smap */
 	NULL,                   /* update page */
-        coda_revalidate_inode   /* revalidate */
+        coda_revalidate_inode,	/* revalidate */
+	coda_pathconf,		/* pathconf */
 };
 
 struct file_operations coda_file_operations = {
@@ -99,7 +101,7 @@
 			      &cont_file, &cont_dentry);
 
         CDEBUG(D_INODE, "coda ino: %ld, cached ino %ld, page offset: %lx\n", 
-	       coda_inode->i_ino, cii->c_ovp->i_ino, page->offset);
+	       coda_inode->i_ino, cii->c_ovp->i_ino, pgoff2ulong(page->pg_offset));
 
         generic_readpage(&cont_file, page);
         EXIT;
diff -u -r linux-22009/fs/coda/inode.c linux-22009m/fs/coda/inode.c
--- linux-22009/fs/coda/inode.c	Thu Mar 11 03:03:52 1999
+++ linux-22009m/fs/coda/inode.c	Sun May 16 15:41:19 1999
@@ -40,8 +40,7 @@
 static void coda_put_inode(struct inode *);
 static void coda_delete_inode(struct inode *);
 static void coda_put_super(struct super_block *);
-static int coda_statfs(struct super_block *sb, struct statfs *buf, 
-		       int bufsiz);
+static int coda_statfs(struct super_block *sb, struct statfs64 *buf);
 
 /* exported operations */
 struct super_operations coda_super_operations =
@@ -239,21 +238,17 @@
 }
 
 /*  we need _something_ for this routine. Let's mimic AFS */
-static int coda_statfs(struct super_block *sb, struct statfs *buf, 
-		       int bufsiz)
+static int coda_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = CODA_SUPER_MAGIC;
-	tmp.f_bsize = 1024;
-	tmp.f_blocks = 9000000;
-	tmp.f_bfree = 9000000;
-	tmp.f_bavail = 9000000 ;
-	tmp.f_files = 9000000;
-	tmp.f_ffree = 9000000;
-	tmp.f_namelen = 0;
-	copy_to_user(buf, &tmp, bufsiz);
-	return 0; 
+	buf->f_type    = CODA_SUPER_MAGIC;
+	buf->f_bsize   = 1024;
+	buf->f_blocks  = 9000000;
+	buf->f_bfree   = 9000000;
+	buf->f_bavail  = 9000000;
+	buf->f_files   = 9000000;
+	buf->f_ffree   = 9000000;
+	buf->f_namelen = 0;
+	return 0;
 }
 
 
@@ -267,6 +262,3 @@
 {
 	return register_filesystem(&coda_fs_type);
 }
-
-
-
diff -u -r linux-22009/fs/devpts/inode.c linux-22009m/fs/devpts/inode.c
--- linux-22009/fs/devpts/inode.c	Fri Aug 21 04:33:50 1998
+++ linux-22009m/fs/devpts/inode.c	Sun May 16 15:41:19 1999
@@ -56,7 +56,7 @@
 #endif
 }
 
-static int devpts_statfs(struct super_block *sb, struct statfs *buf, int bufsiz);
+static int devpts_statfs(struct super_block *sb, struct statfs64 *buf);
 static void devpts_read_inode(struct inode *inode);
 static void devpts_write_inode(struct inode *inode);
 
@@ -243,19 +243,17 @@
 	return NULL;
 }
 
-static int devpts_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+static int devpts_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = DEVPTS_SUPER_MAGIC;
-	tmp.f_bsize = 1024;
-	tmp.f_blocks = 0;
-	tmp.f_bfree = 0;
-	tmp.f_bavail = 0;
-	tmp.f_files = 0;
-	tmp.f_ffree = 0;
-	tmp.f_namelen = NAME_MAX;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type    = DEVPTS_SUPER_MAGIC;
+	buf->f_bsize   = 1024;
+	buf->f_blocks  = 0;
+	buf->f_bfree   = 0;
+	buf->f_bavail  = 0;
+	buf->f_files   = 0;
+	buf->f_ffree   = 0;
+	buf->f_namelen = NAME_MAX;
+	return 0;
 }
 
 static void devpts_read_inode(struct inode *inode)
diff -u -r linux-22009/fs/ext2/dir.c linux-22009m/fs/ext2/dir.c
--- linux-22009/fs/ext2/dir.c	Sat Apr 24 07:20:37 1999
+++ linux-22009m/fs/ext2/dir.c	Sun May 16 15:41:19 1999
@@ -33,6 +33,7 @@
 }
 
 static int ext2_readdir(struct file *, void *, filldir_t);
+extern int ext2_pathconf(struct inode *, int);
 
 static struct file_operations ext2_dir_operations = {
 	NULL,			/* lseek - default */
@@ -72,7 +73,10 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	ext2_permission,	/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	ext2_pathconf,		/* pathconf */
 };
 
 int ext2_check_dir_entry (const char * function, struct inode * dir,
diff -u -r linux-22009/fs/ext2/file.c linux-22009m/fs/ext2/file.c
--- linux-22009/fs/ext2/file.c	Tue Dec 22 01:22:54 1998
+++ linux-22009m/fs/ext2/file.c	Sun May 16 15:41:19 1999
@@ -30,6 +30,7 @@
 #include <linux/locks.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
+#include <linux/unistd.h>
 
 #define	NBUF	32
 
@@ -39,10 +40,6 @@
 static long long ext2_file_lseek(struct file *, long long, int);
 static ssize_t ext2_file_write (struct file *, const char *, size_t, loff_t *);
 static int ext2_release_file (struct inode *, struct file *);
-#if BITS_PER_LONG < 64
-static int ext2_open_file (struct inode *, struct file *);
-
-#else
 
 #define EXT2_MAX_SIZE(bits)							\
 	(((EXT2_NDIR_BLOCKS + (1LL << (bits - 2)) + 				\
@@ -55,7 +52,7 @@
 EXT2_MAX_SIZE(10), EXT2_MAX_SIZE(11), EXT2_MAX_SIZE(12), EXT2_MAX_SIZE(13)
 };
 
-#endif
+extern int ext2_pathconf(struct inode *, int);
 
 /*
  * We have mostly NULL's here: the current defaults are ok for
@@ -69,11 +66,7 @@
 	NULL,			/* poll - default */
 	ext2_ioctl,		/* ioctl */
 	generic_file_mmap,	/* mmap */
-#if BITS_PER_LONG == 64	
 	NULL,			/* no special open is needed */
-#else
-	ext2_open_file,
-#endif
 	NULL,			/* flush */
 	ext2_release_file,	/* release */
 	ext2_sync_file,		/* fsync */
@@ -100,7 +93,10 @@
 	ext2_bmap,		/* bmap */
 	ext2_truncate,		/* truncate */
 	ext2_permission,	/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	ext2_pathconf,		/* pathconf */
 };
 
 /*
@@ -121,12 +117,8 @@
 			offset += file->f_pos;
 	}
 	if (((unsigned long long) offset >> 32) != 0) {
-#if BITS_PER_LONG < 64
-		return -EINVAL;
-#else
 		if (offset > ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(inode->i_sb)])
 			return -EINVAL;
-#endif
 	} 
 	if (offset != file->f_pos) {
 		file->f_pos = offset;
@@ -155,7 +147,7 @@
 				size_t count, loff_t *ppos)
 {
 	struct inode * inode = filp->f_dentry->d_inode;
-	off_t pos;
+	loff_t pos;
 	long block;
 	int offset;
 	int written, c;
@@ -192,22 +184,23 @@
 		pos = *ppos;
 		if (pos != *ppos)
 			return -EINVAL;
-#if BITS_PER_LONG >= 64
 		if (pos > ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)])
 			return -EINVAL;
-#endif
 	}
 
-	/* Check for overflow.. */
-#if BITS_PER_LONG < 64
-	if (pos > (__u32) (pos + count)) {
-		count = ~pos; /* == 0xFFFFFFFF - pos */
-		if (!count)
+	/* L-F-S spec 2.2.1.27: */
+	if (!(filp->f_flags & O_LARGEFILE)) {
+		if (!off_t_presentable(1 + pos)) /* pos@LONG_MAX forbidden */
 			return -EFBIG;
+
+		if (!off_t_presentable(pos + count))
+			/* Write only until end of allowed region */
+			count = LONG_MAX - pos;
 	}
-#else
+
+	/* Check for overflow.. */
 	{
-		off_t max = ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)];
+		loff_t max = ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)];
 
 		if (pos + count > max) {
 			count = max - pos;
@@ -224,7 +217,6 @@
 			mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
 		}
 	}
-#endif
 
 	/*
 	 * If a file has been opened in synchronous mode, we have to ensure
@@ -323,15 +315,28 @@
 	return 0;
 }
 
-#if BITS_PER_LONG < 64
-/*
- * Called when an inode is about to be open.
- * We use this to disallow opening RW large files on 32bit systems.
- */
-static int ext2_open_file (struct inode * inode, struct file * filp)
+int ext2_pathconf(struct inode *inode, int option)
 {
-	if (inode->u.ext2_i.i_high_size && (filp->f_mode & FMODE_WRITE))
-		return -EFBIG;
-	return 0;
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return EXT2_NAME_LEN;	/* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* Semantics ??? */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 64; /* FIXME: L-F-S:  mount-option: nolargefiles ? */
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return EXT2_LINK_MAX;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
-#endif
diff -u -r linux-22009/fs/ext2/inode.c linux-22009m/fs/ext2/inode.c
--- linux-22009/fs/ext2/inode.c	Wed May  5 02:27:07 1999
+++ linux-22009m/fs/ext2/inode.c	Mon May 17 01:07:36 1999
@@ -224,15 +224,13 @@
 
 	/* 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);
+		u_long limit = (current->rlimfsz.rlim_cur >>
+				EXT2_BLOCK_SIZE_BITS(inode->i_sb));
+		if (new_block >= limit) {
+			send_sig(SIGXFSZ, current, 0);
 dont_create:
-				*err = -EFBIG;
-				return NULL;
-			}
+			*err = -EFBIG;
+			return NULL;
 		}
 	}
 
@@ -316,14 +314,15 @@
 		return NULL;
 	}
 
-	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
-	if (limit < RLIM_INFINITY) {
-		limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb);
-		if (new_block >= limit) {
-			brelse (bh);
-			send_sig(SIGXFSZ, current, 0);
-			return NULL;
-		}
+	/* "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 (!create || new_block >= limit) {
+		brelse (bh);
+		send_sig(SIGXFSZ, current, 0);
+		return NULL;
 	}
 
 	if (inode->u.ext2_i.i_next_alloc_block == new_block)
@@ -554,13 +553,8 @@
 		inode->u.ext2_i.i_dir_acl = 0;
 		inode->u.ext2_i.i_high_size =
 			le32_to_cpu(raw_inode->i_size_high);
-#if BITS_PER_LONG < 64
-		if (raw_inode->i_size_high)
-			inode->i_size = (__u32)-1;
-#else
-		inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high))
-			<< 32;
-#endif
+		inode->i_size = ((__u64)(inode->i_size & 0xFFFFFFFFUL)) |
+			(((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32);
 	}
 	inode->u.ext2_i.i_version = le32_to_cpu(raw_inode->i_version);
 	inode->u.ext2_i.i_block_group = block_group;
@@ -685,12 +679,7 @@
 	if (S_ISDIR(inode->i_mode))
 		raw_inode->i_dir_acl = cpu_to_le32(inode->u.ext2_i.i_dir_acl);
 	else { 
-#if BITS_PER_LONG < 64
-		raw_inode->i_size_high =
-			cpu_to_le32(inode->u.ext2_i.i_high_size);
-#else
 		raw_inode->i_size_high = cpu_to_le32(inode->i_size >> 32);
-#endif
 	}
 	raw_inode->i_version = cpu_to_le32(inode->u.ext2_i.i_version);
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
diff -u -r linux-22009/fs/ext2/super.c linux-22009m/fs/ext2/super.c
--- linux-22009/fs/ext2/super.c	Mon Apr 12 20:03:45 1999
+++ linux-22009m/fs/ext2/super.c	Sun May 16 15:41:20 1999
@@ -759,10 +759,9 @@
 
 #endif
 
-int ext2_statfs (struct super_block * sb, struct statfs * buf, int bufsiz)
+int ext2_statfs (struct super_block * sb, struct statfs64 * buf)
 {
 	unsigned long overhead;
-	struct statfs tmp;
 	int	ngroups, i;
 
 	if (test_opt (sb, MINIX_DF))
@@ -802,15 +801,15 @@
 			     (2 + sb->u.ext2_sb.s_itb_per_group));
 	}
 
-	tmp.f_type = EXT2_SUPER_MAGIC;
-	tmp.f_bsize = sb->s_blocksize;
-	tmp.f_blocks = le32_to_cpu(sb->u.ext2_sb.s_es->s_blocks_count) - overhead;
-	tmp.f_bfree = ext2_count_free_blocks (sb);
-	tmp.f_bavail = tmp.f_bfree - le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count);
-	if (tmp.f_bfree < le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count))
-		tmp.f_bavail = 0;
-	tmp.f_files = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
-	tmp.f_ffree = ext2_count_free_inodes (sb);
-	tmp.f_namelen = EXT2_NAME_LEN;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type   = EXT2_SUPER_MAGIC;
+	buf->f_bsize  = sb->s_blocksize;
+	buf->f_blocks = le32_to_cpu(sb->u.ext2_sb.s_es->s_blocks_count) - overhead;
+	buf->f_bfree  = ext2_count_free_blocks (sb);
+	buf->f_bavail = buf->f_bfree - le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count);
+	if (buf->f_bfree < le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count))
+		buf->f_bavail = 0;
+	buf->f_files = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
+	buf->f_ffree = ext2_count_free_inodes (sb);
+	buf->f_namelen = EXT2_NAME_LEN;
+	return 0;
 }
diff -u -r linux-22009/fs/ext2/truncate.c linux-22009m/fs/ext2/truncate.c
--- linux-22009/fs/ext2/truncate.c	Mon Oct  5 20:04:34 1998
+++ linux-22009m/fs/ext2/truncate.c	Sun May 16 15:41:20 1999
@@ -53,9 +53,10 @@
  * Currently we always hold the inode semaphore during truncate, so
  * there's no need to test for changes during the operation.
  */
-#define DIRECT_BLOCK(inode) \
-	((inode->i_size + inode->i_sb->s_blocksize - 1) / \
-			  inode->i_sb->s_blocksize)
+#define DIRECT_BLOCK(inode)	\
+	((long)			\
+	 ((inode->i_size + inode->i_sb->s_blocksize - 1) >> \
+			  inode->i_sb->s_blocksize_bits))
 #define INDIRECT_BLOCK(inode,offset) ((int)DIRECT_BLOCK(inode) - offset)
 #define DINDIRECT_BLOCK(inode,offset) \
 	(INDIRECT_BLOCK(inode,offset) / addr_per_block)
diff -u -r linux-22009/fs/fat/file.c linux-22009m/fs/fat/file.c
--- linux-22009/fs/fat/file.c	Sun Feb 28 19:47:37 1999
+++ linux-22009m/fs/fat/file.c	Sun May 16 15:41:20 1999
@@ -18,6 +18,7 @@
 #include <linux/string.h>
 #include <linux/pagemap.h>
 #include <linux/fat_cvf.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -30,6 +31,8 @@
 #define PRINTK(x)
 #define Printk(x) printk x
 
+extern int fat_pathconf(struct inode*,int);
+
 static struct file_operations fat_file_operations = {
 	NULL,			/* lseek - default */
 	fat_file_read,		/* read */
@@ -62,7 +65,10 @@
 	fat_bmap,		/* bmap */
 	fat_truncate,		/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	fat_pathconf,		/* pathconf */
 };
 
 /* #Specification: msdos / special devices / mmap	
@@ -112,7 +118,10 @@
 	NULL,			/* bmap */
 	fat_truncate,		/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	fat_pathconf,		/* pathconf */
 };
 
 static struct file_operations fat_file_operations_readpage = {
@@ -147,7 +156,10 @@
 	NULL,			/* bmap */
 	fat_truncate,		/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	fat_pathconf,		/* pathconf */
 };
 
 #define MSDOS_PREFETCH	32
@@ -227,7 +239,7 @@
 		Each time we process one block in bhlist, we replace
 		it by a new prefetch block if needed.
 	*/
-	PRINTK (("#### ino %ld pos %ld size %ld count %d\n",inode->i_ino,*ppos,inode->i_size,count));
+	PRINTK (("#### ino %ld pos %ld size %ld count %d\n",inode->i_ino,*ppos,(u_long)inode->i_size,count));
 	{
 		/*
 			We must prefetch complete block, so we must
@@ -253,7 +265,7 @@
 	}
 	pre.nolist = 0;
 	PRINTK (("count %d ahead %d nblist %d\n",count,read_ahead[MAJOR(inode->i_dev)],pre.nblist));
-	while ((left_in_file = inode->i_size - *ppos) > 0
+	while ((left_in_file = (u_long)inode->i_size - *ppos) > 0
 		&& buf < end){
 		struct buffer_head *bh = pre.bhlist[pre.nolist];
 		char *data;
@@ -451,7 +463,7 @@
 
 void fat_truncate(struct inode *inode)
 {
-	int cluster;
+	int cluster_bytes, cluster_shift;
 
 	/* Why no return value?  Surely the disk could fail... */
 	if (IS_IMMUTABLE(inode))
@@ -460,8 +472,36 @@
 		printk("FAT: fat_truncate called though fs is read-only, uhh...\n");
 		return /* -EROFS */;
 	}
-	cluster = SECTOR_SIZE*MSDOS_SB(inode->i_sb)->cluster_size;
-	(void) fat_free(inode,(inode->i_size+(cluster-1))/cluster);
+	cluster_bytes = SECTOR_SIZE * MSDOS_SB(inode->i_sb)->cluster_size;
+	cluster_shift = fslog2(cluster_bytes);
+	(void) fat_free(inode,
+			(inode->i_size+(cluster_bytes-1)) >> cluster_shift);
 	MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
 	mark_inode_dirty(inode);
+}
+
+int fat_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return 8+3;	/* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* Semantics ??? */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
diff -u -r linux-22009/fs/fat/inode.c linux-22009m/fs/fat/inode.c
--- linux-22009/fs/fat/inode.c	Sat Apr 24 07:20:37 1999
+++ linux-22009m/fs/fat/inode.c	Sun May 16 15:41:20 1999
@@ -531,15 +531,14 @@
 	return NULL;
 }
 
-int fat_statfs(struct super_block *sb,struct statfs *buf, int bufsiz)
+int fat_statfs(struct super_block *sb,struct statfs64 *buf)
 {
 	int free,nr;
-	struct statfs tmp;
        
 	if (MSDOS_SB(sb)->cvf_format &&
 	    MSDOS_SB(sb)->cvf_format->cvf_statfs)
-		return MSDOS_SB(sb)->cvf_format->cvf_statfs(sb,buf,bufsiz);
-	  
+		return MSDOS_SB(sb)->cvf_format->cvf_statfs(sb,buf);
+
 	lock_fat(sb);
 	if (MSDOS_SB(sb)->free_clusters != -1)
 		free = MSDOS_SB(sb)->free_clusters;
@@ -550,15 +549,15 @@
 		MSDOS_SB(sb)->free_clusters = free;
 	}
 	unlock_fat(sb);
-	tmp.f_type = sb->s_magic;
-	tmp.f_bsize = MSDOS_SB(sb)->cluster_size*SECTOR_SIZE;
-	tmp.f_blocks = MSDOS_SB(sb)->clusters;
-	tmp.f_bfree = free;
-	tmp.f_bavail = free;
-	tmp.f_files = 0;
-	tmp.f_ffree = 0;
-	tmp.f_namelen = MSDOS_SB(sb)->options.isvfat ? 260 : 12;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = sb->s_magic;
+	buf->f_bsize = MSDOS_SB(sb)->cluster_size*SECTOR_SIZE;
+	buf->f_blocks = MSDOS_SB(sb)->clusters;
+	buf->f_bfree = free;
+	buf->f_bavail = free;
+	buf->f_files = 0;
+	buf->f_ffree = 0;
+	buf->f_namelen = MSDOS_SB(sb)->options.isvfat ? 260 : 12;
+	return 0;
 }
 
 
@@ -627,8 +626,9 @@
 		}
 		inode->i_blksize = MSDOS_SB(sb)->cluster_size*
 		    SECTOR_SIZE;
-		inode->i_blocks = (inode->i_size+inode->i_blksize-1)/
-		    inode->i_blksize*MSDOS_SB(sb)->cluster_size;
+		inode->i_blocks = (((inode->i_size+inode->i_blksize-1) >>
+				    fslog2(inode->i_blksize)) *
+				   MSDOS_SB(sb)->cluster_size);
 		MSDOS_I(inode)->i_logstart = 0;
 
 		MSDOS_I(inode)->i_attrs = 0;
@@ -708,8 +708,9 @@
 	MSDOS_I(inode)->i_attrs = raw_entry->attr & ATTR_UNUSED;
 	/* this is as close to the truth as we can get ... */
 	inode->i_blksize = MSDOS_SB(sb)->cluster_size*SECTOR_SIZE;
-	inode->i_blocks = (inode->i_size+inode->i_blksize-1)/
-	    inode->i_blksize*MSDOS_SB(sb)->cluster_size;
+	inode->i_blocks = (((inode->i_size+inode->i_blksize-1) >>
+			    fslog2(inode->i_blksize)) *
+			   MSDOS_SB(sb)->cluster_size);
 	inode->i_mtime = inode->i_atime =
 	    date_dos2unix(CF_LE_W(raw_entry->time),CF_LE_W(raw_entry->date));
 	inode->i_ctime =
diff -u -r linux-22009/fs/fcntl.c linux-22009m/fs/fcntl.c
--- linux-22009/fs/fcntl.c	Fri Nov 13 20:07:26 1998
+++ linux-22009m/fs/fcntl.c	Sun May 16 15:41:20 1999
@@ -140,6 +140,17 @@
 		case F_SETLKW:
 			err = fcntl_setlk(fd, cmd, (struct flock *) arg);
 			break;
+
+		case F_GETLK64:
+			err = fcntl_getlk64(fd, (struct flock64 *) arg);
+			break;
+		case F_SETLK64:
+			err = fcntl_setlk64(fd, cmd, (struct flock64 *) arg);
+			break;
+		case F_SETLKW64:
+			err = fcntl_setlk64(fd, cmd, (struct flock64 *) arg);
+			break;
+
 		case F_GETOWN:
 			/*
 			 * XXX If f_owner is a process group, the
diff -u -r linux-22009/fs/hfs/dir_cap.c linux-22009m/fs/hfs/dir_cap.c
--- linux-22009/fs/hfs/dir_cap.c	Sat Apr 24 07:20:37 1999
+++ linux-22009m/fs/hfs/dir_cap.c	Sun May 16 15:41:20 1999
@@ -92,7 +92,10 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 struct inode_operations hfs_cap_fdir_inode_operations = {
@@ -113,7 +116,10 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 struct inode_operations hfs_cap_rdir_inode_operations = {
@@ -134,7 +140,10 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 /*================ File-local functions ================*/
diff -u -r linux-22009/fs/hfs/dir_dbl.c linux-22009m/fs/hfs/dir_dbl.c
--- linux-22009/fs/hfs/dir_dbl.c	Sat Apr 24 07:20:37 1999
+++ linux-22009m/fs/hfs/dir_dbl.c	Sun May 16 15:41:20 1999
@@ -92,7 +92,10 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 
diff -u -r linux-22009/fs/hfs/dir_nat.c linux-22009m/fs/hfs/dir_nat.c
--- linux-22009/fs/hfs/dir_nat.c	Sat Apr 24 07:20:37 1999
+++ linux-22009m/fs/hfs/dir_nat.c	Sun May 16 15:41:20 1999
@@ -100,7 +100,8 @@
 	NULL,			/* permission */
 	NULL,			/* smap */
 	NULL,                   /* updatepage */
-	NULL                    /* revalidate */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 struct inode_operations hfs_nat_hdir_inode_operations = {
@@ -123,7 +124,8 @@
 	NULL,			/* permission */
 	NULL,			/* smap */
 	NULL,                   /* updatepage */
-	NULL                    /* revalidate */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 /*================ File-local functions ================*/
diff -u -r linux-22009/fs/hfs/file.c linux-22009m/fs/hfs/file.c
--- linux-22009/fs/hfs/file.c	Mon Nov  2 19:35:16 1998
+++ linux-22009m/fs/hfs/file.c	Sun May 16 15:41:20 1999
@@ -20,6 +20,7 @@
 #include <linux/hfs_fs_sb.h>
 #include <linux/hfs_fs_i.h>
 #include <linux/hfs_fs.h>
+#include <linux/unistd.h>
 
 /*================ Forward declarations ================*/
 
@@ -70,7 +71,8 @@
 	NULL,			/* permission */
 	NULL,			/* smap */
 	NULL,			/* updatepage */
-	NULL			/* revalidate */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 /*================ Variable-like macros ================*/
@@ -545,4 +547,30 @@
 			}
 		}
 	}
+}
+
+int hfs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return HFS_NAMELEN;
+	case _PC_NO_TRUNC:
+		return 0;
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return 1;	/* No classical UNIX links */
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
diff -u -r linux-22009/fs/hfs/file_cap.c linux-22009m/fs/hfs/file_cap.c
--- linux-22009/fs/hfs/file_cap.c	Mon Nov  2 19:35:16 1998
+++ linux-22009m/fs/hfs/file_cap.c	Sun May 16 15:41:20 1999
@@ -84,7 +84,8 @@
 	NULL,				/* permission */
 	NULL,				/* smap */
 	NULL,				/* updatepage */
-	NULL				/* revalidata */
+	NULL,				/* revalidata */
+	hfs_pathconf,			/* pathconf */
 };
 
 /*================ File-local functions ================*/
diff -u -r linux-22009/fs/hfs/file_hdr.c linux-22009m/fs/hfs/file_hdr.c
--- linux-22009/fs/hfs/file_hdr.c	Wed May 12 23:26:34 1999
+++ linux-22009m/fs/hfs/file_hdr.c	Sun May 16 15:41:20 1999
@@ -86,7 +86,8 @@
 	NULL,			/* permission */
 	NULL,			/* smap */
 	NULL,			/* updatepage */
-	NULL			/* revalidate */
+	NULL,			/* revalidate */
+	hfs_pathconf,		/* pathconf */
 };
 
 const struct hfs_hdr_layout hfs_dbl_fil_hdr_layout = {
diff -u -r linux-22009/fs/hfs/hfs.h linux-22009m/fs/hfs/hfs.h
--- linux-22009/fs/hfs/hfs.h	Wed May 12 23:26:34 1999
+++ linux-22009m/fs/hfs/hfs.h	Mon May 17 01:18:19 1999
@@ -494,6 +494,9 @@
 extern void hfs_extent_adj(struct hfs_fork *);
 extern void hfs_extent_free(struct hfs_fork *);
 
+/* file.c */
+extern int hfs_pathconf(struct inode *, int);
+
 /* mdb.c */
 extern struct hfs_mdb *hfs_mdb_get(hfs_sysmdb, int, hfs_s32);
 extern void hfs_mdb_commit(struct hfs_mdb *, int);
diff -u -r linux-22009/fs/hfs/super.c linux-22009m/fs/hfs/super.c
--- linux-22009/fs/hfs/super.c	Wed May 12 23:26:34 1999
+++ linux-22009m/fs/hfs/super.c	Sun May 16 15:41:20 1999
@@ -36,7 +36,7 @@
 
 static void hfs_read_inode(struct inode *);
 static void hfs_put_super(struct super_block *);
-static int hfs_statfs(struct super_block *, struct statfs *, int);
+static int hfs_statfs(struct super_block *, struct statfs64 *);
 static void hfs_write_super(struct super_block *);
 
 /*================ Global variables ================*/
@@ -144,21 +144,20 @@
  *
  * changed f_files/f_ffree to reflect the fs_ablock/free_ablocks.
  */
-static int hfs_statfs(struct super_block *sb, struct statfs *buf, int len)
+static int hfs_statfs(struct super_block *sb, struct statfs64 *buf)
 {
 	struct hfs_mdb *mdb = HFS_SB(sb)->s_mdb;
-	struct statfs tmp;
 
-	tmp.f_type = HFS_SUPER_MAGIC;
-	tmp.f_bsize = HFS_SECTOR_SIZE;
-	tmp.f_blocks = mdb->alloc_blksz * mdb->fs_ablocks;
-	tmp.f_bfree = mdb->alloc_blksz * mdb->free_ablocks;
-	tmp.f_bavail = tmp.f_bfree;
-	tmp.f_files = mdb->fs_ablocks;  
-	tmp.f_ffree = mdb->free_ablocks;
-	tmp.f_namelen = HFS_NAMELEN;
+	buf->f_type = HFS_SUPER_MAGIC;
+	buf->f_bsize = HFS_SECTOR_SIZE;
+	buf->f_blocks = mdb->alloc_blksz * mdb->fs_ablocks;
+	buf->f_bfree = mdb->alloc_blksz * mdb->free_ablocks;
+	buf->f_bavail = buf->f_bfree;
+	buf->f_files = mdb->fs_ablocks;  
+	buf->f_ffree = mdb->free_ablocks;
+	buf->f_namelen = HFS_NAMELEN;
 
-	return copy_to_user(buf, &tmp, len) ? -EFAULT : 0;
+	return 0;
 }
 
 /*
diff -u -r linux-22009/fs/hpfs/hpfs_fs.c linux-22009m/fs/hpfs/hpfs_fs.c
--- linux-22009/fs/hpfs/hpfs_fs.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/hpfs/hpfs_fs.c	Sun May 16 15:41:20 1999
@@ -24,6 +24,8 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/unistd.h>
+
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
 
@@ -128,8 +130,9 @@
 
 static void hpfs_read_inode(struct inode *);
 static void hpfs_put_super(struct super_block *);
-static int hpfs_statfs(struct super_block *, struct statfs *, int);
+static int hpfs_statfs(struct super_block *, struct statfs64 *);
 static int hpfs_remount_fs(struct super_block *, int *, char *);
+static int hpfs_pathconf(struct inode *, int);
 
 static const struct super_operations hpfs_sops =
 {
@@ -184,6 +187,10 @@
 	&hpfs_bmap,			/* bmap */
 	NULL,				/* truncate */
 	NULL,				/* permission */
+	NULL,				/* smap */
+	NULL,				/* updatepage */
+	NULL,				/* revalidate */
+	hpfs_pathconf,			/* pathconf */
 };
 
 /* directory ops */
@@ -222,11 +229,16 @@
 	NULL,				/* mknod */
 	NULL,				/* rename */
 	NULL,				/* readlink */
+	NULL,				/* follow_link */
 	NULL,				/* readpage */
 	NULL,				/* writepage */
 	NULL,				/* bmap */
 	NULL,				/* truncate */
 	NULL,				/* permission */
+	NULL,				/* smap */
+	NULL,				/* updatepage */
+	NULL,				/* revalidate */
+	hpfs_pathconf,			/* pathconf */
 };
 
 /* Four 512-byte buffers and the 2k block obtained by concatenating them */
@@ -741,9 +753,8 @@
  * directory band -- not exactly right but pretty analogous.
  */
 
-static int hpfs_statfs(struct super_block *s, struct statfs *buf, int bufsiz)
+static int hpfs_statfs(struct super_block *s, struct statfs64 *buf)
 {
-	struct statfs tmp;
 
 	/*
 	 * count the bits in the bitmaps, unless we already have
@@ -757,16 +768,16 @@
 	/*
 	 * fill in the user statfs struct
 	 */
-	tmp.f_type = s->s_magic;
-	tmp.f_bsize = 512;
-	tmp.f_blocks = s->s_hpfs_fs_size;
-	tmp.f_bfree = s->s_hpfs_n_free;
-	tmp.f_bavail = s->s_hpfs_n_free;
-	tmp.f_files = s->s_hpfs_dirband_size;
-	tmp.f_ffree = s->s_hpfs_n_free_dnodes;
-	tmp.f_namelen = 254;
+	buf->f_type = s->s_magic;
+	buf->f_bsize = 512;
+	buf->f_blocks = s->s_hpfs_fs_size;
+	buf->f_bfree = s->s_hpfs_n_free;
+	buf->f_bavail = s->s_hpfs_n_free;
+	buf->f_files = s->s_hpfs_dirband_size;
+	buf->f_ffree = s->s_hpfs_n_free_dnodes;
+	buf->f_namelen = 254;
 
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	return 0;
 }
 
 /*
@@ -1737,6 +1748,34 @@
         hpfs_read_super,
 	NULL
 };
+
+
+static int hpfs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return 254;
+
+	case _PC_NO_TRUNC:
+		return 0;		/* UNIX semantics */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
 
 __initfunc(int init_hpfs_fs(void))
 {
diff -u -r linux-22009/fs/isofs/dir.c linux-22009m/fs/isofs/dir.c
--- linux-22009/fs/isofs/dir.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/isofs/dir.c	Sun May 16 15:41:20 1999
@@ -21,11 +21,39 @@
 #include <linux/sched.h>
 #include <linux/locks.h>
 #include <linux/config.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 
 static int isofs_readdir(struct file *, void *, filldir_t);
 
+int isofs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		break;	/* This is read-only filesystem! */
+	case _PC_NO_TRUNC:
+		break;	/* This is read-only filesystem! */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		break;	/* This is read-only filesystem! */
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
+
 static struct file_operations isofs_dir_operations =
 {
 	NULL,			/* lseek - default */
@@ -61,7 +89,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,                   /* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	isofs_pathconf,		/* pathconf */
 };
 
 static int isofs_name_translate(char * old, int len, char * new)
diff -u -r linux-22009/fs/isofs/file.c linux-22009m/fs/isofs/file.c
--- linux-22009/fs/isofs/file.c	Mon Mar  8 01:25:23 1999
+++ linux-22009m/fs/isofs/file.c	Sun May 16 15:41:20 1999
@@ -17,6 +17,8 @@
 #include <linux/locks.h>
 #include <linux/fs.h>
 
+extern int isofs_pathconf(struct inode *, int);
+
 /*
  * We have mostly NULLs here: the current defaults are OK for
  * the isofs filesystem.
@@ -51,6 +53,10 @@
 	generic_readpage,	/* readpage */
 	NULL,			/* writepage */
 	isofs_bmap,		/* bmap */
-	NULL,	       		/* truncate */
-	NULL			/* permission */
+	NULL,			/* truncate */
+	NULL,			/* permission */
+	NULL,                   /* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	isofs_pathconf,		/* pathconf */
 };
diff -u -r linux-22009/fs/isofs/inode.c linux-22009m/fs/isofs/inode.c
--- linux-22009/fs/isofs/inode.c	Tue Dec 29 21:40:35 1998
+++ linux-22009m/fs/isofs/inode.c	Sun May 16 15:41:20 1999
@@ -859,25 +859,24 @@
 	return NULL;
 }
 
-int isofs_statfs (struct super_block *sb, struct statfs *buf, int bufsiz)
+int isofs_statfs (struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = ISOFS_SUPER_MAGIC;
-	tmp.f_bsize = sb->s_blocksize;
-	tmp.f_blocks = (sb->u.isofs_sb.s_nzones
+	buf->f_type = ISOFS_SUPER_MAGIC;
+	buf->f_bsize = sb->s_blocksize;
+	buf->f_blocks = (sb->u.isofs_sb.s_nzones
                   << (sb->u.isofs_sb.s_log_zone_size - sb->s_blocksize_bits));
-	tmp.f_bfree = 0;
-	tmp.f_bavail = 0;
-	tmp.f_files = sb->u.isofs_sb.s_ninodes;
-	tmp.f_ffree = 0;
-	tmp.f_namelen = NAME_MAX;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_bfree = 0;
+	buf->f_bavail = 0;
+	buf->f_files = sb->u.isofs_sb.s_ninodes;
+	buf->f_ffree = 0;
+	buf->f_namelen = NAME_MAX;
+	return 0;
 }
 
 int isofs_bmap(struct inode * inode,int block)
 {
-	off_t b_off, offset, size;
+	loff_t b_off;
+	off_t offset, size;
 	struct inode *ino;
 	unsigned int firstext;
 	unsigned long nextino;
@@ -888,7 +887,7 @@
 		return 0;
 	}
 
-	b_off = block << ISOFS_BUFFER_BITS(inode);
+	b_off = (loff_t)block << ISOFS_BUFFER_BITS(inode);
 
 	/*
 	 * If we are beyond the end of this file, don't give out any
@@ -896,7 +895,7 @@
 	 */
 	if( b_off > inode->i_size )
 	  {
-	    off_t	max_legal_read_offset;
+	    loff_t	max_legal_read_offset;
 
 	    /*
 	     * If we are *way* beyond the end of the file, print a message.
@@ -907,20 +906,21 @@
 	     * I/O errors.
 	     */
 	    max_legal_read_offset = (inode->i_size + PAGE_SIZE - 1)
-	      & ~(PAGE_SIZE - 1);
+					& ~(loff_t)(PAGE_SIZE - 1);
 	    if( b_off >= max_legal_read_offset )
 	      {
 
 		printk("_isofs_bmap: block>= EOF(%d, %ld)\n", block,
-		       inode->i_size);
+		       (u_long)((inode->i_size >> ISOFS_BUFFER_BITS(inode)) +
+				((inode->i_size & ((1 << ISOFS_BUFFER_BITS(inode))-1)) != 0)));
 	      }
 	    return 0;
 	  }
 
 	offset = 0;
 	firstext = inode->u.isofs_i.i_first_extent;
-	size = inode->u.isofs_i.i_section_size;
-	nextino = inode->u.isofs_i.i_next_section_ino;
+	size     = inode->u.isofs_i.i_section_size;
+	nextino  = inode->u.isofs_i.i_next_section_ino;
 #ifdef DEBUG
 	printk("first inode: inode=%x nextino=%x firstext=%u size=%lu\n",
 		inode->i_ino, nextino, firstext, size);
@@ -1152,7 +1152,7 @@
 
 #ifdef DEBUG
 	printk("Get inode %x: %d %d: %d\n",inode->i_ino, block,
-	       ((int)pnt) & 0x3ff, inode->i_size);
+	       ((int)pnt) & 0x3ff, (u_long)inode->i_size);
 #endif
 
 	inode->i_mtime = inode->i_atime = inode->i_ctime =
diff -u -r linux-22009/fs/lockd/svclock.c linux-22009m/fs/lockd/svclock.c
--- linux-22009/fs/lockd/svclock.c	Wed Feb 17 19:44:33 1999
+++ linux-22009m/fs/lockd/svclock.c	Sun May 16 15:41:20 1999
@@ -94,13 +94,15 @@
 	struct file_lock	*fl;
 
 	dprintk("lockd: nlmsvc_lookup_block f=%p pd=%d %ld-%ld ty=%d\n",
-				file, lock->fl.fl_pid, lock->fl.fl_start,
-				lock->fl.fl_end, lock->fl.fl_type);
+		file, lock->fl.fl_pid,
+		(u_long)lock->fl.fl_start, (u_long)lock->fl.fl_end,
+		lock->fl.fl_type);
 	for (head = &nlm_blocked; (block = *head); head = &block->b_next) {
 		fl = &block->b_call.a_args.lock.fl;
 		dprintk("       check f=%p pd=%d %ld-%ld ty=%d\n",
-				block->b_file, fl->fl_pid, fl->fl_start,
-				fl->fl_end, fl->fl_type);
+				block->b_file, fl->fl_pid,
+				(u_long)fl->fl_start, (u_long)fl->fl_end,
+				fl->fl_type);
 		if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) {
 			if (remove)
 				*head = block->b_next;
@@ -286,8 +288,8 @@
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_type, lock->fl.fl_pid,
-				lock->fl.fl_start,
-				lock->fl.fl_end,
+				(u_long)lock->fl.fl_start,
+				(u_long)lock->fl.fl_end,
 				wait);
 
 	/* Lock file against concurrent access */
@@ -356,12 +358,13 @@
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_type,
-				lock->fl.fl_start,
-				lock->fl.fl_end);
+				(u_long)lock->fl.fl_start,
+				(u_long)lock->fl.fl_end);
 
 	if ((fl = posix_test_lock(&file->f_file, &lock->fl)) != NULL) {
 		dprintk("lockd: conflicting lock(ty=%d, %ld-%ld)\n",
-				fl->fl_type, fl->fl_start, fl->fl_end);
+				fl->fl_type,
+				(u_long)fl->fl_start, (u_long)fl->fl_end);
 		conflock->caller = "somehost";	/* FIXME */
 		conflock->oh.len = 0;		/* don't return OH info */
 		conflock->fl = *fl;
@@ -387,8 +390,8 @@
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_pid,
-				lock->fl.fl_start,
-				lock->fl.fl_end);
+				(u_long)lock->fl.fl_start,
+				(u_long)lock->fl.fl_end);
 
 	/* First, cancel any lock that might be there */
 	nlmsvc_cancel_blocked(file, lock);
@@ -415,8 +418,8 @@
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_pid,
-				lock->fl.fl_start,
-				lock->fl.fl_end);
+				(u_long)lock->fl.fl_start,
+				(u_long)lock->fl.fl_end);
 
 	down(&file->f_sema);
 	if ((block = nlmsvc_lookup_block(file, lock, 1)) != NULL)
diff -u -r linux-22009/fs/lockd/xdr.c linux-22009m/fs/lockd/xdr.c
--- linux-22009/fs/lockd/xdr.c	Sat Feb  6 22:46:21 1999
+++ linux-22009m/fs/lockd/xdr.c	Sun May 16 15:41:20 1999
@@ -142,7 +142,7 @@
 	fl->fl_pid   = ntohl(*p++);
 	fl->fl_flags = FL_POSIX;
 	fl->fl_type  = F_RDLCK;		/* as good as anything else */
-	fl->fl_start = ntohl(*p++);
+	fl->fl_start = (u_long)ntohl(*p++);
 	len = ntohl(*p++);
 	if (len == 0 || (fl->fl_end = fl->fl_start + len - 1) < 0)
 		fl->fl_end = NLM_OFFSET_MAX;
@@ -163,11 +163,11 @@
 		return NULL;
 
 	*p++ = htonl(fl->fl_pid);
-	*p++ = htonl(lock->fl.fl_start);
+	*p++ = htonl((u_long)lock->fl.fl_start);
 	if (lock->fl.fl_end == NLM_OFFSET_MAX)
 		*p++ = xdr_zero;
 	else
-		*p++ = htonl(lock->fl.fl_end - lock->fl.fl_start + 1);
+		*p++ = htonl((u_long)(lock->fl.fl_end - lock->fl.fl_start + 1));
 
 	return p;
 }
@@ -192,11 +192,11 @@
 		if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
 			return 0;
 
-		*p++ = htonl(fl->fl_start);
+		*p++ = htonl((u_long)fl->fl_start);
 		if (fl->fl_end == NLM_OFFSET_MAX)
 			*p++ = xdr_zero;
 		else
-			*p++ = htonl(fl->fl_end - fl->fl_start + 1);
+			*p++ = htonl((u_long)(fl->fl_end - fl->fl_start + 1));
 	}
 
 	return p;
@@ -425,7 +425,7 @@
 
 		fl->fl_flags = FL_POSIX;
 		fl->fl_type  = excl? F_WRLCK : F_RDLCK;
-		fl->fl_start = ntohl(*p++);
+		fl->fl_start = (u_long)ntohl(*p++);
 		len = ntohl(*p++);
 		if (len == 0 || (fl->fl_end = fl->fl_start + len - 1) < 0)
 			fl->fl_end = NLM_OFFSET_MAX;
diff -u -r linux-22009/fs/locks.c linux-22009m/fs/locks.c
--- linux-22009/fs/locks.c	Tue May 11 18:52:14 1999
+++ linux-22009m/fs/locks.c	Sun May 16 15:41:20 1999
@@ -111,12 +111,12 @@
 
 #include <asm/uaccess.h>
 
-#define OFFSET_MAX	((off_t)LONG_MAX)	/* FIXME: move elsewhere? */
+#define OFFSET_MAX	((loff_t)((~0ULL)>>1))	/* FIXME: move elsewhere? */
 
 static int flock_make_lock(struct file *filp, struct file_lock *fl,
 			       unsigned int cmd);
 static int posix_make_lock(struct file *filp, struct file_lock *fl,
-			       struct flock *l);
+			       struct flock64 *l);
 static int flock_locks_conflict(struct file_lock *caller_fl,
 				struct file_lock *sys_fl);
 static int posix_locks_conflict(struct file_lock *caller_fl,
@@ -315,7 +315,192 @@
 {
 	struct file *filp;
 	struct file_lock *fl,file_lock;
-	struct flock flock;
+	int error = -EFAULT;
+
+	struct flock flock32;
+	struct flock64 flock;
+
+	if (copy_from_user(&flock32, l, sizeof(flock32)))
+		goto out;
+	error = -EINVAL;
+	if ((flock32.l_type != F_RDLCK) && (flock32.l_type != F_WRLCK))
+		goto out;
+	/* Convert to 64-bit offsets for internal use */
+	flock.l_type   = flock32.l_type;
+	flock.l_whence = flock32.l_whence;
+	flock.l_start  = (u_long)flock32.l_start;
+	flock.l_len    = (u_long)flock32.l_len;
+	flock.l_pid    = flock32.l_pid;
+
+	error = -EBADF;
+	filp = fget(fd);
+	if (!filp)
+		goto out;
+
+	error = -EINVAL;
+	if (!filp->f_dentry || !filp->f_dentry->d_inode)
+		goto out_putf;
+
+	if (!posix_make_lock(filp, &file_lock, &flock))
+		goto out_putf;
+
+	if (filp->f_op->lock) {
+		error = filp->f_op->lock(filp, F_GETLK, &file_lock);
+		if (error < 0)
+			goto out_putf;
+		fl = &file_lock;
+	} else {
+		fl = posix_test_lock(filp, &file_lock);
+	}
+ 
+	flock.l_type = F_UNLCK;
+	if (fl != NULL) {
+		flock.l_pid = fl->fl_pid;
+		flock.l_start = fl->fl_start;
+		flock.l_len = fl->fl_end == OFFSET_MAX ? 0 :
+			fl->fl_end - fl->fl_start + 1;
+		flock.l_whence = 0;
+		flock.l_type = fl->fl_type;
+	}
+
+	/* Convert to 32-bit offsets (at 32-bit systems) */
+
+	if (!off_t_presentable(flock.l_start) ||
+	    !off_t_presentable(flock.l_len) ||
+	    !off_t_presentable(flock.l_start + flock.l_len)) {
+		error = -EOVERFLOW;
+		goto out_putf;
+	}
+
+	flock32.l_type   = flock.l_type;
+	flock32.l_whence = flock.l_whence;
+	flock32.l_start  = flock.l_start;
+	flock32.l_len    = flock.l_len;
+	flock32.l_pid    = flock.l_pid;
+
+	error = -EFAULT;
+	if (!copy_to_user(l, &flock32, sizeof(flock32)))
+		error = 0;
+  
+out_putf:
+	fput(filp);
+out:
+	return error;
+}
+
+/* Apply the lock described by l to an open file descriptor.
+ * This implements both the F_SETLK and F_SETLKW commands of fcntl().
+ */
+int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l)
+{
+	struct file *filp;
+	struct file_lock file_lock;
+	struct flock64 flock;
+	struct flock flock32;
+	struct dentry * dentry;
+	struct inode *inode;
+	int error;
+
+	/*
+	 * This might block, so we do it before checking the inode.
+	 */
+	error = -EFAULT;
+	if (copy_from_user(&flock32, l, sizeof(flock32)))
+		goto out;
+	/* Convert to 64-bit offsets for internal use */
+	flock.l_type   = flock32.l_type;
+	flock.l_whence = flock32.l_whence;
+	flock.l_start  = (u_long)flock32.l_start;
+	flock.l_len    = (u_long)flock32.l_len;
+	flock.l_pid    = flock32.l_pid;
+
+	/* Get arguments and validate them ...
+	 */
+
+	error = -EBADF;
+	filp = fget(fd);
+	if (!filp)
+		goto out;
+
+	error = -EINVAL;
+	if (!(dentry = filp->f_dentry))
+		goto out_putf;
+	if (!(inode = dentry->d_inode))
+		goto out_putf;
+
+	/* Don't allow mandatory locks on files that may be memory mapped
+	 * and shared.
+	 */
+	if (IS_MANDLOCK(inode) &&
+	    (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
+	    inode->i_mmap) {
+		struct vm_area_struct *vma = inode->i_mmap;
+		error = -EAGAIN;
+		do {
+			if (vma->vm_flags & VM_MAYSHARE)
+				goto out_putf;
+		} while ((vma = vma->vm_next_share) != NULL);
+	}
+
+	error = -EINVAL;
+	if (!posix_make_lock(filp, &file_lock, &flock))
+		goto out_putf;
+	
+	error = -EBADF;
+	switch (flock.l_type) {
+	case F_RDLCK:
+		if (!(filp->f_mode & FMODE_READ))
+			goto out_putf;
+		break;
+	case F_WRLCK:
+		if (!(filp->f_mode & FMODE_WRITE))
+			goto out_putf;
+		break;
+	case F_UNLCK:
+		break;
+	case F_SHLCK:
+	case F_EXLCK:
+#ifdef __sparc__
+/* warn a bit for now, but don't overdo it */
+{
+	static int count = 0;
+	if (!count) {
+		count=1;
+		printk(KERN_WARNING
+		       "fcntl_setlk() called by process %d (%s) with broken flock() emulation\n",
+		       current->pid, current->comm);
+	}
+}
+		if (!(filp->f_mode & 3))
+			goto out_putf;
+		break;
+#endif
+	default:
+		error = -EINVAL;
+		goto out_putf;
+	}
+
+	if (filp->f_op->lock != NULL) {
+		error = filp->f_op->lock(filp, cmd, &file_lock);
+		if (error < 0)
+			goto out_putf;
+	}
+	error = posix_lock_file(filp, &file_lock, cmd == F_SETLKW);
+
+out_putf:
+	fput(filp);
+out:
+	return error;
+}
+
+/* Report the first existing lock that would conflict with l.
+ * This implements the F_GETLK command of fcntl().
+ */
+int fcntl_getlk64(unsigned int fd, struct flock64 *l)
+{
+	struct file *filp;
+	struct file_lock *fl,file_lock;
+	struct flock64 flock;
 	int error;
 
 	error = -EFAULT;
@@ -368,11 +553,11 @@
 /* Apply the lock described by l to an open file descriptor.
  * This implements both the F_SETLK and F_SETLKW commands of fcntl().
  */
-int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l)
+int fcntl_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l)
 {
 	struct file *filp;
 	struct file_lock file_lock;
-	struct flock flock;
+	struct flock64 flock;
 	struct dentry * dentry;
 	struct inode *inode;
 	int error;
@@ -640,9 +825,9 @@
  * style lock.
  */
 static int posix_make_lock(struct file *filp, struct file_lock *fl,
-			   struct flock *l)
+			   struct flock64 *l)
 {
-	off_t start;
+	loff_t start;
 
 	memset(fl, 0, sizeof(*fl));
 	
@@ -1192,8 +1377,9 @@
 	p += sprintf(p, "%s ", (fl->fl_type == F_RDLCK) ? "READ " : "WRITE");
 	p += sprintf(p, "%d %s:%ld %ld %ld ",
 		     fl->fl_pid,
-		     kdevname(inode->i_dev), inode->i_ino, fl->fl_start,
-		     fl->fl_end);
+		     kdevname(inode->i_dev), inode->i_ino,
+		     (u_long)fl->fl_start,
+		     (u_long)fl->fl_end);
 	sprintf(p, "%08lx %08lx %08lx %08lx %08lx\n",
 		(long)fl, (long)fl->fl_prevlink, (long)fl->fl_nextlink,
 		(long)fl->fl_next, (long)fl->fl_nextblock);
diff -u -r linux-22009/fs/minix/dir.c linux-22009m/fs/minix/dir.c
--- linux-22009/fs/minix/dir.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/minix/dir.c	Sun May 16 15:41:20 1999
@@ -21,6 +21,7 @@
 }
 
 static int minix_readdir(struct file *, void *, filldir_t);
+extern int minix_pathconf(struct inode *, int);
 
 static struct file_operations minix_dir_operations = {
 	NULL,			/* lseek - default */
@@ -56,7 +57,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,                   /* smap */
+	NULL,                   /* updatepage */
+	NULL,                   /* revalidate */
+	minix_pathconf,		/* pathconf */
 };
 
 static int minix_readdir(struct file * filp,
diff -u -r linux-22009/fs/minix/file.c linux-22009m/fs/minix/file.c
--- linux-22009/fs/minix/file.c	Mon Aug 24 23:02:44 1998
+++ linux-22009m/fs/minix/file.c	Sun May 16 15:41:20 1999
@@ -15,6 +15,7 @@
 #include <linux/locks.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -29,6 +30,34 @@
 
 static ssize_t minix_file_write(struct file *, const char *, size_t, loff_t *);
 
+int minix_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return inode->i_sb->u.minix_sb.s_namelen;
+
+	case _PC_NO_TRUNC:
+		return 1;		/* UNIX semantics */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return inode->i_sb->u.minix_sb.s_link_max;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
+
 /*
  * We have mostly NULLs here: the current defaults are OK for
  * the minix filesystem.
@@ -64,14 +93,18 @@
 	NULL,			/* writepage */
 	minix_bmap,		/* bmap */
 	minix_truncate,		/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,                   /* smap */
+	NULL,                   /* updatepage */
+	NULL,                   /* revalidate */
+	minix_pathconf,		/* pathconf */
 };
 
 static ssize_t minix_file_write(struct file * filp, const char * buf,
 				size_t count, loff_t *ppos)
 {
 	struct inode * inode = filp->f_dentry->d_inode;
-	off_t pos;
+	loff_t pos;
 	ssize_t written, c;
 	struct buffer_head * bh;
 	char * p;
@@ -88,6 +121,24 @@
 		pos = inode->i_size;
 	else
 		pos = *ppos;
+
+	/* L-F-S spec 2.2.1.27: */
+	if (!(filp->f_flags & O_LARGEFILE)) {
+		if (!off_t_presentable(1 + pos)) /* pos@LONG_MAX forbidden */
+			return -EFBIG;
+
+		if (!off_t_presentable(pos + count))
+			/* Write only until end of allowed region */
+			count = LONG_MAX - pos;
+	}
+	/* MINIX i-node file-size can't exceed 4G-1 */
+	/* With 1k blocks and triple indirection MINIX can have files
+	   up to 16 GB in size -- filesystem maximum is then 4G*1k = 4T */
+	if (pos >= 0xffffffffULL)
+		return -EFBIG; /* Absolutely too much! */
+	if ((pos + count) >= 0x100000000ULL) /* too much to write! */
+		count = 0xffffffffULL - pos;
+
 	written = 0;
 	while (written < count) {
 		bh = minix_getblk(inode,pos/BLOCK_SIZE,1);
diff -u -r linux-22009/fs/minix/inode.c linux-22009m/fs/minix/inode.c
--- linux-22009/fs/minix/inode.c	Sat Apr 24 22:45:37 1999
+++ linux-22009m/fs/minix/inode.c	Sun May 16 15:41:20 1999
@@ -28,7 +28,7 @@
 
 static void minix_read_inode(struct inode * inode);
 static void minix_write_inode(struct inode * inode);
-static int minix_statfs(struct super_block *sb, struct statfs *buf, int bufsiz);
+static int minix_statfs(struct super_block *sb, struct statfs64 *buf);
 static int minix_remount (struct super_block * sb, int * flags, char * data);
 
 static void minix_delete_inode(struct inode *inode)
@@ -330,19 +330,17 @@
 	return NULL;
 }
 
-static int minix_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+static int minix_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = sb->s_magic;
-	tmp.f_bsize = sb->s_blocksize;
-	tmp.f_blocks = (sb->u.minix_sb.s_nzones - sb->u.minix_sb.s_firstdatazone) << sb->u.minix_sb.s_log_zone_size;
-	tmp.f_bfree = minix_count_free_blocks(sb);
-	tmp.f_bavail = tmp.f_bfree;
-	tmp.f_files = sb->u.minix_sb.s_ninodes;
-	tmp.f_ffree = minix_count_free_inodes(sb);
-	tmp.f_namelen = sb->u.minix_sb.s_namelen;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = sb->s_magic;
+	buf->f_bsize = sb->s_blocksize;
+	buf->f_blocks = (sb->u.minix_sb.s_nzones - sb->u.minix_sb.s_firstdatazone) << sb->u.minix_sb.s_log_zone_size;
+	buf->f_bfree = minix_count_free_blocks(sb);
+	buf->f_bavail = buf->f_bfree;
+	buf->f_files = sb->u.minix_sb.s_ninodes;
+	buf->f_ffree = minix_count_free_inodes(sb);
+	buf->f_namelen = sb->u.minix_sb.s_namelen;
+	return 0;
 }
 
 /*
diff -u -r linux-22009/fs/minix/symlink.c linux-22009m/fs/minix/symlink.c
--- linux-22009/fs/minix/symlink.c	Sat Sep 19 23:42:44 1998
+++ linux-22009m/fs/minix/symlink.c	Sun May 16 15:41:20 1999
@@ -16,6 +16,7 @@
 
 static int minix_readlink(struct dentry *, char *, int);
 static struct dentry *minix_follow_link(struct dentry *, struct dentry *, unsigned int);
+extern int minix_pathconf(struct inode *, int);
 
 /*
  * symlinks can't do much...
@@ -37,7 +38,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,                   /* smap */
+	NULL,                   /* updatepage */
+	NULL,                   /* revalidate */
+	minix_pathconf,		/* pathconf */
 };
 
 static struct dentry * minix_follow_link(struct dentry * dentry,
diff -u -r linux-22009/fs/msdos/namei.c linux-22009m/fs/msdos/namei.c
--- linux-22009/fs/msdos/namei.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/msdos/namei.c	Sun May 16 15:41:20 1999
@@ -792,6 +792,7 @@
 	return error;
 }
 
+extern int fat_pathconf(struct inode *, int);
 
 /* The public inode operations for the msdos fs */
 struct inode_operations msdos_dir_inode_operations = {
@@ -815,6 +816,7 @@
 	NULL,                   /* smap */
 	NULL,                   /* updatepage */
 	NULL,                   /* revalidate */
+	fat_pathconf,		/* pathconf */
 };
 
 
diff -u -r linux-22009/fs/ncpfs/dir.c linux-22009m/fs/ncpfs/dir.c
--- linux-22009/fs/ncpfs/dir.c	Sun May  9 03:56:37 1999
+++ linux-22009m/fs/ncpfs/dir.c	Sun May 16 15:41:21 1999
@@ -59,7 +59,8 @@
 #ifdef CONFIG_NCPFS_EXTRAS
 extern int ncp_symlink(struct inode *, struct dentry *, const char *);
 #endif
-		      
+extern int ncp_pathconf(struct inode *, int);
+
 static struct file_operations ncp_dir_operations =
 {
 	NULL,			/* lseek - default */
@@ -101,6 +102,7 @@
 	NULL,			/* smap */
 	NULL,			/* updatepage */
 	NULL,			/* revalidate */
+	ncp_pathconf,		/* pathconf */
 };
 
 static ssize_t 
diff -u -r linux-22009/fs/ncpfs/file.c linux-22009m/fs/ncpfs/file.c
--- linux-22009/fs/ncpfs/file.c	Mon Aug 24 23:02:44 1998
+++ linux-22009m/fs/ncpfs/file.c	Sun May 16 15:41:21 1999
@@ -17,6 +17,7 @@
 #include <linux/mm.h>
 #include <linux/locks.h>
 #include <linux/malloc.h>
+#include <linux/unistd.h>
 
 #include <linux/ncp_fs.h>
 #include "ncplib_kernel.h"
@@ -138,7 +139,7 @@
 	/* First read in as much as possible for each bufsize. */
 	while (already_read < count) {
 		int read_this_time;
-		int to_read = min(bufsize - (pos % bufsize),
+		int to_read = min(bufsize - (pos & (bufsize-1)),
 				  count - already_read);
 
 		error = ncp_read(NCP_SERVER(inode),
@@ -175,7 +176,7 @@
 	struct dentry *dentry = file->f_dentry;
 	struct inode *inode = dentry->d_inode;
 	size_t already_written = 0;
-	off_t pos;
+	loff_t pos;
 	int bufsize, errno;
 
 	DPRINTK(KERN_DEBUG "ncp_file_write: enter %s/%s\n",
@@ -201,7 +202,7 @@
 		printk(KERN_ERR "ncp_file_write: open failed, error=%d\n", errno);
 		return errno;
 	}
-	pos = file->f_pos;
+	pos = *ppos;
 
 	if (file->f_flags & O_APPEND) {
 		pos = inode->i_size;
@@ -210,9 +211,15 @@
 
 	already_written = 0;
 
+	/* Maximum file size: 2G-1 */
+	if (pos >= 0x7fffffffULL)
+		return -EFBIG;
+	if ((pos + count) >= 0x7fffffffULL)
+		count = 0x7fffffffULL - pos;
+
 	while (already_written < count) {
 		int written_this_time;
-		int to_write = min(bufsize - (pos % bufsize),
+		int to_write = min(bufsize - (pos & (bufsize-1)),
 				   count - already_written);
 
 		if (ncp_write(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,
@@ -230,8 +237,6 @@
 
 	inode->i_mtime = inode->i_atime = CURRENT_TIME;
 	
-	file->f_pos = pos;
-
 	if (pos > inode->i_size) {
 		inode->i_size = pos;
 		ncp_invalid_dir_cache(dentry->d_parent->d_inode);
@@ -242,6 +247,33 @@
 	return already_written ? already_written : errno;
 }
 
+int ncp_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return NCP_MAXNAMELEN; /* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* varies per server.. */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
+
 static struct file_operations ncp_file_operations =
 {
 	NULL,			/* lseek - default */
@@ -271,5 +303,10 @@
 	NULL,			/* rename */
 	NULL,			/* readlink */
 	NULL,			/* bmap */
-	NULL			/* truncate */
+	NULL,			/* truncate */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	ncp_pathconf,		/* pathconf */
 };
diff -u -r linux-22009/fs/ncpfs/inode.c linux-22009m/fs/ncpfs/inode.c
--- linux-22009/fs/ncpfs/inode.c	Wed Apr 21 01:17:20 1999
+++ linux-22009m/fs/ncpfs/inode.c	Sun May 16 15:41:21 1999
@@ -35,7 +35,7 @@
 static void ncp_put_inode(struct inode *);
 static void ncp_delete_inode(struct inode *);
 static void ncp_put_super(struct super_block *);
-static int  ncp_statfs(struct super_block *, struct statfs *, int);
+static int  ncp_statfs(struct super_block *, struct statfs64 *);
 
 static struct super_operations ncp_sops =
 {
@@ -132,7 +132,7 @@
 	}
 	inode->i_blocks = 0;
 	if ((inode->i_size)&&(inode->i_blksize)) {
-		inode->i_blocks = (inode->i_size-1)/(inode->i_blksize)+1;
+		inode->i_blocks = ((inode->i_size-1) >> fslog2(inode->i_blksize)) +1;
 	}
 	/* TODO: times? I'm not sure... */
 	NCP_FINFO(inode)->DosDirNum = nwinfo->i.DosDirNum;
@@ -198,7 +198,7 @@
 	inode->i_blocks = 0;
 	if ((inode->i_blksize != 0) && (inode->i_size != 0)) {
 		inode->i_blocks =
-		    (inode->i_size - 1) / inode->i_blksize + 1;
+		    ((inode->i_size - 1) >> fslog2(inode->i_blksize)) + 1;
 	}
 
 	inode->i_mtime = ncp_date_dos2unix(le16_to_cpu(nwi->modifyTime),
@@ -527,25 +527,23 @@
 	MOD_DEC_USE_COUNT;
 }
 
-static int ncp_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+static int ncp_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
 	/* We cannot say how much disk space is left on a mounted
 	   NetWare Server, because free space is distributed over
 	   volumes, and the current user might have disk quotas. So
 	   free space is not that simple to determine. Our decision
 	   here is to err conservatively. */
 
-	tmp.f_type = NCP_SUPER_MAGIC;
-	tmp.f_bsize = 512;
-	tmp.f_blocks = 0;
-	tmp.f_bfree = 0;
-	tmp.f_bavail = 0;
-	tmp.f_files = -1;
-	tmp.f_ffree = -1;
-	tmp.f_namelen = 12;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = NCP_SUPER_MAGIC;
+	buf->f_bsize = 512;
+	buf->f_blocks = 0;
+	buf->f_bfree = 0;
+	buf->f_bavail = 0;
+	buf->f_files = -1;
+	buf->f_ffree = -1;
+	buf->f_namelen = 12;
+	return 0;
 }
 
 int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
diff -u -r linux-22009/fs/nfs/dir.c linux-22009m/fs/nfs/dir.c
--- linux-22009/fs/nfs/dir.c	Sun May  9 09:18:22 1999
+++ linux-22009m/fs/nfs/dir.c	Sun May 16 15:41:21 1999
@@ -63,6 +63,7 @@
 static int nfs_mknod(struct inode *, struct dentry *, int, int);
 static int nfs_rename(struct inode *, struct dentry *,
 		      struct inode *, struct dentry *);
+extern int nfs_pathconf(struct inode *, int);
 
 static struct file_operations nfs_dir_operations = {
 	NULL,			/* lseek - default */
@@ -99,6 +100,7 @@
 	NULL,			/* smap */
 	NULL,			/* updatepage */
 	nfs_revalidate,		/* revalidate */
+	nfs_pathconf,		/* pathconf */
 };
 
 static ssize_t
diff -u -r linux-22009/fs/nfs/file.c linux-22009m/fs/nfs/file.c
--- linux-22009/fs/nfs/file.c	Sun May  9 06:01:19 1999
+++ linux-22009m/fs/nfs/file.c	Sun May 16 17:23:13 1999
@@ -26,6 +26,7 @@
 #include <linux/malloc.h>
 #include <linux/pagemap.h>
 #include <linux/lockd/bind.h>
+#include <linux/unistd.h>
 
 #include <asm/segment.h>
 #include <asm/system.h>
@@ -37,6 +38,7 @@
 static ssize_t nfs_file_write(struct file *, const char *, size_t, loff_t *);
 static int  nfs_file_flush(struct file *);
 static int  nfs_fsync(struct file *, struct dentry *dentry);
+extern int  nfs_pathconf(struct inode *, int);
 
 static struct file_operations nfs_file_operations = {
 	NULL,			/* lseek - default */
@@ -77,6 +79,7 @@
 	NULL,			/* smap */
 	nfs_updatepage,		/* updatepage */
 	nfs_revalidate,		/* revalidate */
+	nfs_pathconf,		/* pathconf */
 };
 
 /* Hack for future NFS swap support */
@@ -114,6 +117,11 @@
 		dentry->d_parent->d_name.name, dentry->d_name.name,
 		(unsigned long) count, (unsigned long) *ppos);
 
+	/* Unconditionally allow only up to 2G files */
+	/* FIXME: NFSv3 could allow 64-bit file offsets! */
+	if (!off_t_presentable(*ppos+1LL))
+		return -EOVERFLOW;
+
 	result = nfs_revalidate_inode(NFS_DSERVER(dentry), dentry);
 	if (!result)
 		result = generic_file_read(file, buf, count, ppos);
@@ -178,6 +186,13 @@
 	if (result)
 		goto out;
 
+	/* Unconditionally allow only up to 2G files */
+	/* FIXME: NFSv3 could allow 64-bit file offsets! */
+	if (!off_t_presentable(*ppos+1LL)) {
+		result = -EOVERFLOW;
+		goto out;
+	}
+
 	result = count;
 	if (!count)
 		goto out;
@@ -203,7 +218,7 @@
 	dprintk("NFS: nfs_lock(f=%4x/%ld, t=%x, fl=%x, r=%ld:%ld)\n",
 			inode->i_dev, inode->i_ino,
 			fl->fl_type, fl->fl_flags,
-			fl->fl_start, fl->fl_end);
+			(u_long)fl->fl_start, (u_long)fl->fl_end);
 
 	if (!inode)
 		return -EINVAL;
@@ -243,4 +258,31 @@
 	 */
 	NFS_CACHEINV(inode);
 	return 0;
+}
+
+int nfs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return -INT_MAX; /* Unknown */
+
+	case _PC_NO_TRUNC:
+		return -INT_MAX; /* Unknown */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;	 /* NFSv3 would allow 64-bit sizes */
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return -INT_MAX; /* Unknown */
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
diff -u -r linux-22009/fs/nfs/inode.c linux-22009m/fs/nfs/inode.c
--- linux-22009/fs/nfs/inode.c	Sun May  9 06:00:46 1999
+++ linux-22009m/fs/nfs/inode.c	Sun May 16 15:41:21 1999
@@ -46,7 +46,7 @@
 static int  nfs_notify_change(struct dentry *, struct iattr *);
 static void nfs_put_super(struct super_block *);
 static void nfs_umount_begin(struct super_block *);
-static int  nfs_statfs(struct super_block *, struct statfs *, int);
+static int  nfs_statfs(struct super_block *, struct statfs64 *);
 
 static struct super_operations nfs_sops = { 
 	nfs_read_inode,		/* read inode */
@@ -232,6 +232,7 @@
 	sb->s_op         = &nfs_sops;
 	sb->s_blocksize  = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
 	sb->u.nfs_sb.s_root = data->root;
+
 	server           = &sb->u.nfs_sb.s_server;
 	server->rsize    = nfs_block_size(data->rsize, NULL);
 	server->wsize    = nfs_block_size(data->wsize, NULL);
@@ -364,11 +365,10 @@
 }
 
 static int
-nfs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+nfs_statfs(struct super_block *sb, struct statfs64 *buf)
 {
 	int error;
 	struct nfs_fsinfo res;
-	struct statfs tmp;
 
 	error = nfs_proc_statfs(&sb->u.nfs_sb.s_server, &sb->u.nfs_sb.s_root,
 		&res);
@@ -376,15 +376,15 @@
 		printk("nfs_statfs: statfs error = %d\n", -error);
 		res.bsize = res.blocks = res.bfree = res.bavail = 0;
 	}
-	tmp.f_type = NFS_SUPER_MAGIC;
-	tmp.f_bsize = res.bsize;
-	tmp.f_blocks = res.blocks;
-	tmp.f_bfree = res.bfree;
-	tmp.f_bavail = res.bavail;
-	tmp.f_files = 0;
-	tmp.f_ffree = 0;
-	tmp.f_namelen = NAME_MAX;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = NFS_SUPER_MAGIC;
+	buf->f_bsize = res.bsize;
+	buf->f_blocks = res.blocks;
+	buf->f_bfree = res.bfree;
+	buf->f_bavail = res.bavail;
+	buf->f_files = 0;
+	buf->f_ffree = 0;
+	buf->f_namelen = NAME_MAX;
+	return 0;
 }
 
 /*
@@ -674,7 +674,7 @@
 	 */
 	if (sattr.size != (u32) -1) {
 		if (sattr.size != fattr.size)
-			printk("nfs_notify_change: sattr=%d, fattr=%d??\n",
+			printk("nfs_notify_change: sattr=%Ld, fattr=%Ld??\n",
 				sattr.size, fattr.size);
 		inode->i_size  = sattr.size;
 		inode->i_mtime = fattr.mtime.seconds;
diff -u -r linux-22009/fs/nfs/proc.c linux-22009m/fs/nfs/proc.c
--- linux-22009/fs/nfs/proc.c	Tue Jan 13 20:03:40 1998
+++ linux-22009m/fs/nfs/proc.c	Sun May 16 15:41:21 1999
@@ -110,14 +110,14 @@
 
 int
 nfs_proc_read(struct nfs_server *server, struct nfs_fh *fhandle, int swap,
-			  unsigned long offset, unsigned int count,
-			  void *buffer, struct nfs_fattr *fattr)
+	      loff_t offset, unsigned int count,
+	      void *buffer, struct nfs_fattr *fattr)
 {
 	struct nfs_readargs	arg = { fhandle, offset, count, buffer };
 	struct nfs_readres	res = { fattr, count };
 	int			status;
 
-	dprintk("NFS call  read %d @ %ld\n", count, offset);
+	dprintk("NFS call  read %d @ %Ld\n", count, offset);
 	status = rpc_call(server->client, NFSPROC_READ, &arg, &res,
 			swap? NFS_RPC_SWAPFLAGS : 0);
 	dprintk("NFS reply read: %d\n", status);
@@ -126,13 +126,13 @@
 
 int
 nfs_proc_write(struct nfs_server *server, struct nfs_fh *fhandle, int swap,
-			unsigned long offset, unsigned int count,
-			const void *buffer, struct nfs_fattr *fattr)
+	       loff_t offset, unsigned int count,
+	       const void *buffer, struct nfs_fattr *fattr)
 {
 	struct nfs_writeargs	arg = { fhandle, offset, count, buffer };
 	int			status;
 
-	dprintk("NFS call  write %d @ %ld\n", count, offset);
+	dprintk("NFS call  write %d @ %Ld\n", count, offset);
 	status = rpc_call(server->client, NFSPROC_WRITE, &arg, fattr,
 			swap? (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS) : 0);
 	dprintk("NFS reply read: %d\n", status);
diff -u -r linux-22009/fs/nfs/read.c linux-22009m/fs/nfs/read.c
--- linux-22009/fs/nfs/read.c	Tue Dec 22 19:37:43 1998
+++ linux-22009m/fs/nfs/read.c	Sun May 16 15:41:21 1999
@@ -51,7 +51,7 @@
  */
 static inline void
 nfs_readreq_setup(struct nfs_rreq *req, struct nfs_fh *fh,
-		  unsigned long offset, void *buffer, unsigned int rsize)
+		  loff_t offset, void *buffer, unsigned int rsize)
 {
 	req->ra_args.fh     = fh;
 	req->ra_args.offset = offset;
@@ -69,12 +69,12 @@
 nfs_readpage_sync(struct dentry *dentry, struct inode *inode, struct page *page)
 {
 	struct nfs_rreq	rqst;
-	unsigned long	offset = page->offset;
-	char		*buffer = (char *) page_address(page);
-	int		rsize = NFS_SERVER(inode)->rsize;
-	int		result, refresh = 0;
-	int		count = PAGE_SIZE;
-	int		flags = IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0;
+	loff_t	offset = pgoff2loff(page->pg_offset);
+	char	*buffer = (char *) page_address(page);
+	int	rsize = NFS_SERVER(inode)->rsize;
+	int	result = 0, refresh = 0;
+	int	count = PAGE_SIZE;
+	int	flags = IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0;
 
 	dprintk("NFS: nfs_readpage_sync(%p)\n", page);
 	clear_bit(PG_error, &page->flags);
@@ -83,13 +83,28 @@
 		if (count < rsize)
 			rsize = count;
 
-		dprintk("NFS: nfs_proc_read(%s, (%s/%s), %ld, %d, %p)\n",
+		dprintk("NFS: nfs_proc_read(%s, (%s/%s), %Ld, %d, %p)\n",
 			NFS_SERVER(inode)->hostname,
 			dentry->d_parent->d_name.name, dentry->d_name.name,
 			offset, rsize, buffer);
 
+		/* FIXME: NFSv3 could allow 64-bit offsets! ... */
+
+		if (offset > 0x7ffffffeULL) {
+		  if (result)
+		  	break;
+		  result = -EOVERFLOW;
+		  goto io_error;
+		}
+		if ((offset + rsize) > 0x7fffffffULL) /* 2G-1 */
+		  rsize = 0x7fffffffULL - offset;
+
+		/* ... END FIXME! */
+
 		/* Set up arguments and perform rpc call */
-		nfs_readreq_setup(&rqst, NFS_FH(dentry), offset, buffer, rsize);
+		nfs_readreq_setup(&rqst, NFS_FH(dentry), offset,
+				  buffer, rsize);
+
 		result = rpc_call(NFS_CLIENT(inode), NFSPROC_READ,
 					&rqst.ra_args, &rqst.ra_res, flags);
 
@@ -170,8 +185,16 @@
 	unsigned long address = page_address(page);
 	struct nfs_rreq	*req;
 	int		result = -1, flags;
+	loff_t	loffset = pgoff2loff(page->pg_offset);
 
 	dprintk("NFS: nfs_readpage_async(%p)\n", page);
+
+	/* FIXME: NFSv3 allows 64-bit offsets.. */
+	if ((loffset + PAGE_SIZE) >= 0x7fffffffULL) {
+	  dprintk("NFS: Async read beyond 2G-1 marker!\n");
+	  return -EOVERFLOW;
+	}
+
 	if (NFS_CONGESTED(inode))
 		goto out_defer;
 
@@ -183,8 +206,9 @@
 
 	/* Initialize request */
 	/* N.B. Will the dentry remain valid for life of request? */
-	nfs_readreq_setup(req, NFS_FH(dentry), page->offset,
-				(void *) address, PAGE_SIZE);
+	nfs_readreq_setup(req, NFS_FH(dentry), loffset,
+			  (void *) address, PAGE_SIZE);
+
 	req->ra_inode = inode;
 	req->ra_page = page; /* count has been incremented by caller */
 
@@ -227,8 +251,8 @@
 	struct inode *inode = dentry->d_inode;
 	int		error;
 
-	dprintk("NFS: nfs_readpage (%p %ld@%ld)\n",
-		page, PAGE_SIZE, page->offset);
+	dprintk("NFS: nfs_readpage (%p %ld@%Ld)\n",
+		page, PAGE_SIZE, pgoff2loff(page->pg_offset));
 	atomic_inc(&page->count);
 	set_bit(PG_locked, &page->flags);
 
diff -u -r linux-22009/fs/nfs/write.c linux-22009m/fs/nfs/write.c
--- linux-22009/fs/nfs/write.c	Wed Mar  3 21:17:02 1999
+++ linux-22009m/fs/nfs/write.c	Sun May 16 15:41:21 1999
@@ -86,26 +86,46 @@
  */
 static int
 nfs_writepage_sync(struct dentry *dentry, struct inode *inode,
-		struct page *page, unsigned long offset, unsigned int count)
+		   struct page *page, unsigned int offset, unsigned int count)
 {
 	unsigned int	wsize = NFS_SERVER(inode)->wsize;
 	int		result, refresh = 0, written = 0;
 	u8		*buffer;
 	struct nfs_fattr fattr;
+	loff_t		loffset = pgoff2loff(page->pg_offset)+offset;
 
-	dprintk("NFS:      nfs_writepage_sync(%s/%s %d@%ld)\n",
+	dprintk("NFS:      nfs_writepage_sync(%s/%s %d@%Ld)\n",
 		dentry->d_parent->d_name.name, dentry->d_name.name,
-		count, page->offset + offset);
+		count, loffset);
 
 	buffer = (u8 *) page_address(page) + offset;
-	offset += page->offset;
+
+	/* FIXME: NFSv3 !!! */
+#if 1
+	if (!off_t_presentable(loffset+1)
+	    || loffset >= 0x7ffffffeULL) {
+	  return -EFBIG;
+	}
+	if (!off_t_presentable(loffset + count)
+	    || (loffset + count) >= 0x7fffffffULL) {
+	  /* At MOST this much! */
+	  count = 0x7fffffffULL - loffset;
+	}
+#else
+	if (S_ISREG(inode->i_flags) &&
+	    !(dentry->d_file->f_flags & O_LARGEFILE) &&
+	    (!off_t_presentable(loffset) ||
+	     !off_t_presentable(loffset + count))) {
+	  /* Writing beyond LargeFile maximums without O_LARGEFILE */
+	}
+#endif
 
 	do {
 		if (count < wsize && !IS_SWAPFILE(inode))
 			wsize = count;
 
 		result = nfs_proc_write(NFS_DSERVER(dentry), NFS_FH(dentry),
-					IS_SWAPFILE(inode), offset, wsize,
+					IS_SWAPFILE(inode), loffset, wsize,
 					buffer, &fattr);
 
 		if (result < 0) {
@@ -118,15 +138,15 @@
 			wsize, result);
 		refresh = 1;
 		buffer  += wsize;
-		offset  += wsize;
+		loffset += wsize;
 		written += wsize;
 		count   -= wsize;
 		/*
 		 * If we've extended the file, update the inode
 		 * now so we don't invalidate the cache.
 		 */
-		if (offset > inode->i_size)
-			inode->i_size = offset;
+		if (loffset > inode->i_size)
+			inode->i_size = loffset;
 	} while (count);
 
 io_error:
@@ -271,7 +291,7 @@
 
 	dprintk("NFS:      create_write_request(%s/%s, %ld+%d)\n",
 		dentry->d_parent->d_name.name, dentry->d_name.name,
-		page->offset + offset, bytes);
+		(u_long)pgoff2loff(page->pg_offset) + offset, bytes);
 
 	/* FIXME: Enforce hard limit on number of concurrent writes? */
 	wreq = (struct nfs_wreq *) kmalloc(sizeof(*wreq), GFP_KERNEL);
@@ -417,7 +437,7 @@
 
 	dprintk("NFS:      nfs_updatepage(%s/%s %d@%ld, sync=%d)\n",
 		dentry->d_parent->d_name.name, dentry->d_name.name,
-		count, page->offset+offset, sync);
+		count, (u_long)pgoff2loff(page->pg_offset)+offset, sync);
 
 	/*
 	 * Try to find a corresponding request on the writeback queue.
@@ -603,7 +623,7 @@
 	/* Setup the task struct for a writeback call */
 	req->wb_flags |= NFS_WRITE_INPROGRESS;
 	req->wb_args.fh     = NFS_FH(dentry);
-	req->wb_args.offset = page->offset + req->wb_offset;
+	req->wb_args.offset = pgoff2loff(page->pg_offset) + req->wb_offset;
 	req->wb_args.count  = req->wb_bytes;
 	req->wb_args.buffer = (void *) (page_address(page) + req->wb_offset);
 
diff -u -r linux-22009/fs/nfsd/nfs3xdr.c linux-22009m/fs/nfsd/nfs3xdr.c
--- linux-22009/fs/nfsd/nfs3xdr.c	Mon Apr  7 21:35:31 1997
+++ linux-22009m/fs/nfsd/nfs3xdr.c	Sun May 16 15:41:21 1999
@@ -620,7 +620,7 @@
 /* READDIR */
 int
 nfs3svc_encode_readdirres(struct svc_rqst *rqstp, u32 *p,
-					struct nfsd3_readdirres *resp)
+			  struct nfsd3_readdirres *resp)
 {
 	p = encode_post_op_attr(rqstp, p, resp->fh.fh_inode);
 	if (resp->status == 0) {
@@ -636,7 +636,7 @@
 #define NFS3_ENTRYPLUS_BAGGAGE	((1 + 20 + 1 + NFS3_FHSIZE) << 2)
 int
 nfs3svc_encode_entry(struct readdir_cd *cd, const char *name,
-				int namlen, unsigned long offset, ino_t ino)
+		     int namlen, unsigned long offset, ino_t ino)
 {
 	u32		*p = cd->buffer;
 	int		buflen, slen, elen;
@@ -688,7 +688,7 @@
 /* FSSTAT */
 int
 nfs3svc_encode_statfsres(struct svc_rqst *rqstp, u32 *p,
-					struct nfsd3_statfsres *resp)
+			 struct nfsd3_statfsres *resp)
 {
 	struct statfs	*s = &resp->stats;
 	u64		bs = s->f_bsize;
@@ -710,7 +710,7 @@
 /* FSINFO */
 int
 nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, u32 *p,
-					struct nfsd3_fsinfores *resp)
+			 struct nfsd3_fsinfores *resp)
 {
 	*p++ = xdr_zero;	/* no post_op_attr */
 
@@ -734,7 +734,7 @@
 /* PATHCONF */
 int
 nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, u32 *p,
-					struct nfsd3_pathconfres *resp)
+			   struct nfsd3_pathconfres *resp)
 {
 	*p++ = xdr_zero;	/* no post_op_attr */
 
diff -u -r linux-22009/fs/nfsd/nfsxdr.c linux-22009m/fs/nfsd/nfsxdr.c
--- linux-22009/fs/nfsd/nfsxdr.c	Wed Nov 26 23:08:38 1997
+++ linux-22009m/fs/nfsd/nfsxdr.c	Sun May 16 15:41:21 1999
@@ -412,7 +412,7 @@
 nfssvc_encode_statfsres(struct svc_rqst *rqstp, u32 *p,
 					struct nfsd_statfsres *resp)
 {
-	struct statfs	*stat = &resp->stats;
+	struct statfs64	*stat = &resp->stats;
 
 	*p++ = htonl(8 * 1024);		/* max transfer size */
 	*p++ = htonl(stat->f_bsize);
diff -u -r linux-22009/fs/nfsd/vfs.c linux-22009m/fs/nfsd/vfs.c
--- linux-22009/fs/nfsd/vfs.c	Mon Apr 12 20:03:45 1999
+++ linux-22009m/fs/nfsd/vfs.c	Sun May 16 15:41:21 1999
@@ -472,8 +472,9 @@
 	/* Write back readahead params */
 	if (ra != NULL) {
 		dprintk("nfsd: raparms %ld %ld %ld %ld %ld\n",
-			file.f_reada, file.f_ramax, file.f_raend,
-			file.f_ralen, file.f_rawin);
+			(u_long)file.f_reada, (u_long)file.f_ramax,
+			(u_long)file.f_raend, (u_long)file.f_ralen,
+			(u_long)file.f_rawin);
 		ra->p_reada = file.f_reada;
 		ra->p_ramax = file.f_ramax;
 		ra->p_raend = file.f_raend;
@@ -554,17 +555,17 @@
 	/* clear setuid/setgid flag after write */
 	if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) {
 		struct iattr	ia;
-		kernel_cap_t	saved_cap;
 
 		ia.ia_valid = ATTR_MODE;
 		ia.ia_mode  = inode->i_mode & ~(S_ISUID | S_ISGID);
 		if (current->fsuid != 0) {
+			kernel_cap_t	saved_cap;
 			saved_cap = current->cap_effective;
 			cap_clear(current->cap_effective);
-		}
-		notify_change(dentry, &ia);
-		if (current->fsuid != 0)
+			notify_change(dentry, &ia);
 			current->cap_effective = saved_cap;
+		} else
+			notify_change(dentry, &ia);
 	}
 
 	fh_unlock(fhp);			/* unlock inode */
@@ -759,7 +760,6 @@
 	struct inode	*inode;
 	struct iattr	newattrs;
 	int		err;
-	kernel_cap_t	saved_cap;
 
 	err = fh_verify(rqstp, fhp, S_IFREG, MAY_WRITE | MAY_TRUNC);
 	if (err)
@@ -778,12 +778,14 @@
 	newattrs.ia_size = size;
 	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
 	if (current->fsuid != 0) {
+		kernel_cap_t	saved_cap;
 		saved_cap = current->cap_effective;
 		cap_clear(current->cap_effective);
-	}
-	err = notify_change(dentry, &newattrs);
-	if (current->fsuid != 0)
+		err = notify_change(dentry, &newattrs);
 		current->cap_effective = saved_cap;
+	} else
+		err = notify_change(dentry, &newattrs);
+
 	if (!err) {
 		vmtruncate(inode, size);
 		if (inode->i_op && inode->i_op->truncate)
@@ -1278,12 +1280,11 @@
  * N.B. After this call fhp needs an fh_put
  */
 int
-nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct statfs *stat)
+nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct statfs64 *stat)
 {
 	struct dentry		*dentry;
 	struct inode		*inode;
 	struct super_block	*sb;
-	mm_segment_t		oldfs;
 	int			err;
 
 	err = fh_verify(rqstp, fhp, 0, MAY_NOP);
@@ -1296,10 +1297,7 @@
 	if (!(sb = inode->i_sb) || !sb->s_op->statfs)
 		goto out;
 
-	oldfs = get_fs();
-	set_fs (KERNEL_DS);
-	sb->s_op->statfs(sb, stat, sizeof(*stat));
-	set_fs (oldfs);
+	sb->s_op->statfs(sb, stat);
 	err = 0;
 
 out:
@@ -1314,7 +1312,6 @@
 {
 	struct inode	*inode = dentry->d_inode;
 	int		err;
-	kernel_cap_t	saved_cap;
 
 	if (acc == MAY_NOP)
 		return 0;
@@ -1363,18 +1360,24 @@
 		return 0;
 
 	if (current->fsuid != 0) {
+		kernel_cap_t	saved_cap;
 		saved_cap = current->cap_effective;
 		cap_clear(current->cap_effective);
-	}
 
-	err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC));
+		err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC));
 
-	/* Allow read access to binaries even when mode 111 */
-	if (err == -EACCES && S_ISREG(inode->i_mode) && acc == MAY_READ)
-		err = permission(inode, MAY_EXEC);
+		/* Allow read access to binaries even when mode 111 */
+		if (err == -EACCES && S_ISREG(inode->i_mode) && acc==MAY_READ)
+			err = permission(inode, MAY_EXEC);
 
-	if (current->fsuid != 0)
 		current->cap_effective = saved_cap;
+	} else {
+		err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC));
+
+		/* Allow read access to binaries even when mode 111 */
+		if (err == -EACCES && S_ISREG(inode->i_mode) && acc==MAY_READ)
+			err = permission(inode, MAY_EXEC);
+	}
 
 	return err? nfserrno(-err) : 0;
 }
diff -u -r linux-22009/fs/ntfs/fs.c linux-22009m/fs/ntfs/fs.c
--- linux-22009/fs/ntfs/fs.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/ntfs/fs.c	Mon May 17 01:39:07 1999
@@ -28,12 +28,40 @@
 #include <linux/nls.h>
 #include <linux/locks.h>
 #include <linux/init.h>
+#include <linux/unistd.h>
 
 /* Forward declarations */
 static struct inode_operations ntfs_dir_inode_operations;
 
 #define ITEM_SIZE 2040
 
+static int ntfs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		return 255;
+
+	case _PC_NO_TRUNC:
+		return 0;	/* Non-UNIX semantics */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
 /* io functions to user space */
 static void ntfs_putuser(ntfs_io* dest,void *src,ntfs_size_t len)
 {
@@ -447,6 +475,7 @@
 	NULL, /* smap */
 	NULL, /* updatepage */
 	NULL, /* revalidate */
+	ntfs_pathconf, /* pathconf */
 };
 
 #ifdef CONFIG_NTFS_RW
@@ -630,6 +659,7 @@
 	NULL, /* smap */
 	NULL, /* updatepage */
 	NULL, /* revalidate */
+	ntfs_pathconf, /* pathconf */
 };
 
 static struct file_operations ntfs_dir_operations = {
@@ -679,6 +709,7 @@
 	NULL, /* smap */
 	NULL, /* updatepage */
 	NULL, /* revalidate */
+	ntfs_pathconf, /* pathconf */
 };
 
 /* ntfs_read_inode is called by the Virtual File System (the kernel layer that
@@ -813,34 +844,32 @@
 }
 
 /* Called by the kernel when asking for stats */
-static int ntfs_statfs(struct super_block *sb, struct statfs *sf, int bufsize)
+static int ntfs_statfs(struct super_block *sb, struct statfs64 *fs)
 {
-	struct statfs fs;
 	struct inode *mft;
 	ntfs_volume *vol;
 	int error;
 
 	ntfs_debug(DEBUG_OTHER, "ntfs_statfs\n");
 	vol=NTFS_SB2VOL(sb);
-	memset(&fs,0,sizeof(fs));
-	fs.f_type=NTFS_SUPER_MAGIC;
-	fs.f_bsize=vol->clustersize;
+	memset(&fs,0,sizeof(*fs));
+	fs->f_type=NTFS_SUPER_MAGIC;
+	fs->f_bsize=vol->clustersize;
 
-	error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &fs.f_blocks );
+	error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &fs->f_blocks );
 	if( error )
 		return -error;
-	fs.f_bfree=ntfs_get_free_cluster_count(vol->bitmap);
-	fs.f_bavail=fs.f_bfree;
+	fs->f_bfree = ntfs_get_free_cluster_count(vol->bitmap);
+	fs->f_bavail = fs->f_bfree;
 
 	/* Number of files is limited by free space only, so we lie here */
-	fs.f_ffree=0;
+	fs->f_ffree=0;
 	mft=iget(sb,FILE_MFT);
-	fs.f_files=mft->i_size/vol->mft_recordsize;
+	fs->f_files = mft->i_size/vol->mft_recordsize;
 	iput(mft);
 
 	/* should be read from volume */
-	fs.f_namelen=255;
-	copy_to_user(sf,&fs,bufsize);
+	fs->f_namelen=255;
 	return 0;
 }
 
diff -u -r linux-22009/fs/ntfs/super.c linux-22009m/fs/ntfs/super.c
--- linux-22009/fs/ntfs/super.c	Mon Apr 12 20:05:58 1999
+++ linux-22009m/fs/ntfs/super.c	Sun May 16 15:41:21 1999
@@ -253,7 +253,7 @@
  * Writes the volume size into vol_size. Returns 0 if successful
  * or error.
  */
-int ntfs_get_volumesize(ntfs_volume *vol, long *vol_size )
+int ntfs_get_volumesize(ntfs_volume *vol, ntfs_u64 *vol_size )
 {
 	ntfs_io io;
 	ntfs_u64 size;
@@ -274,9 +274,7 @@
 	ntfs_getput_clusters(vol,0,0,&io);
 	size=NTFS_GETU64(cluster0+0x28);
 	ntfs_free(cluster0);
-	/* FIXME: more than 2**32 cluster */
-	/* FIXME: gcc will emit udivdi3 if we don't truncate it */
-	*vol_size = ((unsigned long)size)/vol->clusterfactor;
+	*vol_size = size;
 	return 0;
 }
 
diff -u -r linux-22009/fs/ntfs/super.h linux-22009m/fs/ntfs/super.h
--- linux-22009/fs/ntfs/super.h	Mon Apr 12 20:05:58 1999
+++ linux-22009m/fs/ntfs/super.h	Sun May 16 15:41:21 1999
@@ -10,7 +10,7 @@
 #define ALLOC_REQUIRE_SIZE     2
 
 int ntfs_get_free_cluster_count(ntfs_inode *bitmap);
-int ntfs_get_volumesize(ntfs_volume *vol, long *vol_size );
+int ntfs_get_volumesize(ntfs_volume *vol, ntfs_u64 *vol_size );
 int ntfs_init_volume(ntfs_volume *vol,char *boot);
 int ntfs_load_special_files(ntfs_volume *vol);
 int ntfs_release_volume(ntfs_volume *vol);
diff -u -r linux-22009/fs/open.c linux-22009m/fs/open.c
--- linux-22009/fs/open.c	Sat Apr 17 00:21:39 1999
+++ linux-22009m/fs/open.c	Sun May 16 15:41:21 1999
@@ -16,6 +16,7 @@
 {
 	struct dentry * dentry;
 	int error;
+	struct statfs64 sbuf64;
 
 	lock_kernel();
 	dentry = namei(path);
@@ -26,10 +27,25 @@
 
 		error = -ENODEV;
 		if (sb && sb->s_op && sb->s_op->statfs)
-			error = sb->s_op->statfs(sb, buf, sizeof(struct statfs));
+			error = sb->s_op->statfs(sb, &sbuf64);
 
 		dput(dentry);
-	}
+
+		if (!error) {
+			struct statfs   sbuf;
+			memset(&sbuf,0,sizeof(sbuf));
+			sbuf.f_type    = sbuf64.f_type;
+			sbuf.f_bsize   = sbuf64.f_bsize;
+			sbuf.f_blocks  = sbuf64.f_blocks;
+			sbuf.f_bfree   = sbuf64.f_bfree;
+			sbuf.f_bavail  = sbuf64.f_bavail;
+			sbuf.f_files   = sbuf64.f_files;
+			sbuf.f_ffree   = sbuf64.f_ffree;
+			sbuf.f_fsid    = sbuf64.f_fsid;
+			sbuf.f_namelen = sbuf64.f_namelen;
+			error = copy_to_user(buf, &sbuf, sizeof(*buf));
+		}
+	}		
 	unlock_kernel();
 	return error;
 }
@@ -40,6 +56,7 @@
 	struct inode * inode;
 	struct dentry * dentry;
 	struct super_block * sb;
+	struct statfs64 sbuf64;
 	int error;
 
 	lock_kernel();
@@ -55,7 +72,21 @@
 	error = -ENODEV;
 	sb = inode->i_sb;
 	if (sb && sb->s_op && sb->s_op->statfs)
-		error = sb->s_op->statfs(sb, buf, sizeof(struct statfs));
+		error = sb->s_op->statfs(sb, &sbuf64);
+	if (!error) {
+		struct statfs   sbuf;
+		memset(&sbuf,0,sizeof(sbuf));
+		sbuf.f_type    = sbuf64.f_type;
+		sbuf.f_bsize   = sbuf64.f_bsize;
+		sbuf.f_blocks  = sbuf64.f_blocks;
+		sbuf.f_bfree   = sbuf64.f_bfree;
+		sbuf.f_bavail  = sbuf64.f_bavail;
+		sbuf.f_files   = sbuf64.f_files;
+		sbuf.f_ffree   = sbuf64.f_ffree;
+		sbuf.f_fsid    = sbuf64.f_fsid;
+		sbuf.f_namelen = sbuf64.f_namelen;
+		error = copy_to_user(buf, &sbuf, sizeof(*buf));
+	}
 out_putf:
 	fput(file);
 out:
@@ -63,16 +94,82 @@
 	return error;
 }
 
-int do_truncate(struct dentry *dentry, unsigned long length)
+asmlinkage int sys_statfs64(const char * path, struct statfs64 * buf)
+{
+	struct dentry * dentry;
+	int error;
+	struct statfs64 sbuf64;
+
+	lock_kernel();
+	dentry = namei(path);
+	error = PTR_ERR(dentry);
+	if (!IS_ERR(dentry)) {
+		struct inode * inode = dentry->d_inode;
+
+		error = -ENOSYS;
+		if (inode->i_sb->s_op->statfs)
+			error = inode->i_sb->s_op->statfs(inode->i_sb, &sbuf64);
+		dput(dentry);
+		if (!error) {
+			error = copy_to_user(buf, &sbuf64, sizeof(*buf));
+		}
+	}
+	unlock_kernel();
+	return error;
+}
+
+asmlinkage int sys_fstatfs64(unsigned int fd, struct statfs64 * buf)
+{
+	struct file * file;
+	struct inode * inode;
+	struct dentry * dentry;
+	struct super_block * sb;
+	struct statfs64 sbuf64;
+	int error;
+
+	lock_kernel();
+	error = -EBADF;
+	file = fget(fd);
+	if (!file)
+		goto out;
+	error = -ENOENT;
+	if (!(dentry = file->f_dentry))
+		goto out_putf;
+	if (!(inode = dentry->d_inode))
+		goto out_putf;
+	error = -ENODEV;
+	if (!(sb = inode->i_sb))
+		goto out_putf;
+	error = -ENOSYS;
+	if (sb->s_op->statfs)
+		error = sb->s_op->statfs(sb, &sbuf64);
+	if (!error) {
+		error = copy_to_user(buf, &sbuf64, sizeof(*buf));
+	}
+out_putf:
+	fput(file);
+out:
+	unlock_kernel();
+	return error;
+}
+
+int do_truncate(struct dentry *dentry, loff_t length)
 {
 	struct inode *inode = dentry->d_inode;
 	int error;
 	struct iattr newattrs;
 
-	/* Not pretty: "inode->i_size" shouldn't really be "off_t". But it is. */
-	if ((off_t) length < 0)
+	if (length < 0)
 		return -EINVAL;
 
+	if (current->rlimfsz.rlim_cur < inode->i_size) {
+		/* If the target size is higher than our current (soft)
+		   file size limit, a SIGXFSZ shall be sent along
+		   with error -EFBIG. */
+		send_sig(SIGXFSZ, current, 0);
+		return -EFBIG;
+	}
+
 	down(&inode->i_sem);
 	newattrs.ia_size = length;
 	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
@@ -101,7 +198,7 @@
 		goto out;
 	inode = dentry->d_inode;
 
-	error = -EACCES;
+	error = -EISDIR;
 	if (S_ISDIR(inode->i_mode))
 		goto dput_and_out;
 
@@ -117,6 +214,10 @@
 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
 		goto dput_and_out;
 
+	error = -EINVAL;
+	if (inode->i_size < length)
+		goto dput_and_out;
+
 	error = get_write_access(inode);
 	if (error)
 		goto dput_and_out;
@@ -153,12 +254,120 @@
 		goto out_putf;
 	if (!(inode = dentry->d_inode))
 		goto out_putf;
+	error = -EISDIR;
+	if (S_ISDIR(inode->i_mode))
+		goto out_putf;
+	error = -EACCES;
+	if (!(file->f_mode & FMODE_WRITE))
+		goto out_putf;
+	error = -EPERM;
+	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
+		goto out_putf;
+	error = -EINVAL;
+	if (inode->i_size < length)
+		goto out_putf;
+	/* Large File Summit */
+	error = -EFBIG;
+	if (S_ISREG(inode->i_mode) && !(file->f_flags & O_LARGEFILE) &&
+	    !off_t_presentable(inode->i_size))
+		goto out_putf;
+	error = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file,
+				  length<inode->i_size ? length : inode->i_size,
+				  abs(inode->i_size - length));
+	if (!error)
+		error = do_truncate(dentry, length);
+out_putf:
+	fput(file);
+out:
+	unlock_kernel();
+	return error;
+}
+
+#if BITS_PER_LONG < 64
+asmlinkage int sys_truncate64(const char * path, loff_t length)
+{
+	struct dentry * dentry;
+	struct inode * inode;
+	int error;
+
+	lock_kernel();
+	dentry = namei(path);
+
+	error = PTR_ERR(dentry);
+	if (IS_ERR(dentry))
+		goto out;
+	inode = dentry->d_inode;
+
+	error = -EACCES;
+	if (S_ISDIR(inode->i_mode))
+		goto dput_and_out;
+
+	error = permission(inode,MAY_WRITE);
+	if (error)
+		goto dput_and_out;
+
+	error = -EROFS;
+	if (IS_RDONLY(inode))
+		goto dput_and_out;
+
+	error = -EPERM;
+	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
+		goto dput_and_out;
+
+	error = -EFBIG;
+	if (inode->i_size < length)
+		goto dput_and_out;
+
+	error = get_write_access(inode);
+	if (error)
+		goto dput_and_out;
+
+	error = locks_verify_area(FLOCK_VERIFY_WRITE, inode, NULL,
+				  length < inode->i_size ? length : inode->i_size,
+				  abs(inode->i_size - length));
+	if (!error) {
+		DQUOT_INIT(inode);
+		error = do_truncate(dentry, length);
+	}
+	put_write_access(inode);
+dput_and_out:
+	dput(dentry);
+out:
+	unlock_kernel();
+	return error;
+}
+
+asmlinkage int sys_ftruncate64(unsigned int fd, loff_t length)
+{
+	struct inode * inode;
+	struct dentry *dentry;
+	struct file * file;
+	int error;
+
+	lock_kernel();
+	error = -EBADF;
+	file = fget(fd);
+	if (!file)
+		goto out;
+	error = -ENOENT;
+	if (!(dentry = file->f_dentry))
+		goto out_putf;
+	if (!(inode = dentry->d_inode))
+		goto out_putf;
 	error = -EACCES;
 	if (S_ISDIR(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
 		goto out_putf;
 	error = -EPERM;
 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
 		goto out_putf;
+	error = -EINVAL;
+	if (inode->i_size < length || length < 0)
+		goto out_putf;
+	/* Large File Summit */
+	error = -EFBIG;
+	if (S_ISREG(inode->i_mode) && !(file->f_flags & O_LARGEFILE) &&
+	    !off_t_presentable(inode->i_size))
+		goto out_putf;
 	error = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file,
 				  length<inode->i_size ? length : inode->i_size,
 				  abs(inode->i_size - length));
@@ -170,6 +379,7 @@
 	unlock_kernel();
 	return error;
 }
+#endif /* BITS_PER_LONG < 64 */
 
 #ifndef __alpha__
 
@@ -657,6 +867,16 @@
 			goto cleanup_dentry;
 	}
 
+	/* L-F-S spec: 3.1.1.3:  If open() is done without  O_LARGEFILE,
+	   and the target (regular) file size exceeds that presentable with
+	   'off_t' datatype in the system, the open shall be rejected with
+	   EOVERFLOW  error. */
+	if (S_ISREG(inode->i_mode) && !(flags & O_LARGEFILE) &&
+	    !off_t_presentable(inode->i_size)) {
+		error = -EOVERFLOW;
+		goto cleanup_all;
+	}
+
 	f->f_dentry = dentry;
 	f->f_pos = 0;
 	f->f_reada = 0;
@@ -755,8 +975,7 @@
 #ifndef __alpha__
 
 /*
- * For backward compatibility?  Maybe this should be moved
- * into arch/i386 instead?
+ * This one is used atabout all platforms, except Alpha..
  */
 asmlinkage int sys_creat(const char * pathname, int mode)
 {
diff -u -r linux-22009/fs/pipe.c linux-22009m/fs/pipe.c
--- linux-22009/fs/pipe.c	Fri Nov 13 20:07:26 1998
+++ linux-22009m/fs/pipe.c	Sun May 16 15:41:21 1999
@@ -7,6 +7,7 @@
 #include <linux/mm.h>
 #include <linux/file.h>
 #include <linux/poll.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 
@@ -400,9 +401,10 @@
 	NULL
 };
 
+static struct inode_operations pipe_inode_operations;
+
 static struct inode * get_pipe_inode(void)
 {
-	extern struct inode_operations pipe_inode_operations;
 	struct inode *inode = get_empty_inode();
 
 	if (inode) {
@@ -436,7 +438,18 @@
 	return inode;
 }
 
-struct inode_operations pipe_inode_operations = {
+int pipe_pathconf(struct inode *inode, int option)
+{
+	printk("pipe pathconf() called by %p cmd %s \n",
+	       __builtin_return_address(0), current->comm);
+
+	if (option != _PC_PIPE_BUF)
+		return -EINVAL;
+	return PIPE_BUF;
+}
+
+
+static struct inode_operations pipe_inode_operations = {
 	&rdwr_pipe_fops,
 	NULL,			/* create */
 	NULL,			/* lookup */
@@ -448,11 +461,16 @@
 	NULL,			/* mknod */
 	NULL,			/* rename */
 	NULL,			/* readlink */
+	NULL,			/* follow_link */
 	NULL,			/* readpage */
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	pipe_pathconf,		/* pathconf */
 };
 
 int do_pipe(int *fd)
diff -u -r linux-22009/fs/proc/array.c linux-22009m/fs/proc/array.c
--- linux-22009/fs/proc/array.c	Wed May 12 02:30:35 1999
+++ linux-22009m/fs/proc/array.c	Sun May 16 15:41:21 1999
@@ -1075,11 +1075,11 @@
  *         + (index into the line)
  */
 /* for systems with sizeof(void*) == 4: */
-#define MAPS_LINE_FORMAT4	  "%08lx-%08lx %s %08lx %s %lu"
-#define MAPS_LINE_MAX4	49 /* sum of 8  1  8  1 4 1 8 1 5 1 10 1 */
+#define MAPS_LINE_FORMAT4	  "%08lx-%08lx %s %016Lx %s %lu"
+#define MAPS_LINE_MAX4	57 /* sum of 8  1  8  1 4 1 16 1 5 1 10 1 */
 
 /* for systems with sizeof(void*) == 8: */
-#define MAPS_LINE_FORMAT8	  "%016lx-%016lx %s %016lx %s %lu"
+#define MAPS_LINE_FORMAT8	  "%016lx-%016lx %s %016Lx %s %lu"
 #define MAPS_LINE_MAX8	73 /* sum of 16  1  16  1 4 1 16 1 5 1 10 1 */
 
 #define MAPS_LINE_MAX	MAPS_LINE_MAX8
diff -u -r linux-22009/fs/proc/inode.c linux-22009m/fs/proc/inode.c
--- linux-22009/fs/proc/inode.c	Sat May  9 04:10:30 1998
+++ linux-22009m/fs/proc/inode.c	Sun May 16 15:41:21 1999
@@ -334,19 +334,17 @@
 	return NULL;
 }
 
-int proc_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+int proc_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = PROC_SUPER_MAGIC;
-	tmp.f_bsize = PAGE_SIZE/sizeof(long);
-	tmp.f_blocks = 0;
-	tmp.f_bfree = 0;
-	tmp.f_bavail = 0;
-	tmp.f_files = 0;
-	tmp.f_ffree = 0;
-	tmp.f_namelen = NAME_MAX;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = PROC_SUPER_MAGIC;
+	buf->f_bsize = PAGE_SIZE/sizeof(long);
+	buf->f_blocks = 0;
+	buf->f_bfree = 0;
+	buf->f_bavail = 0;
+	buf->f_files = 0;
+	buf->f_ffree = 0;
+	buf->f_namelen = NAME_MAX;
+	return 0;
 }
 
 void proc_read_inode(struct inode * inode)
diff -u -r linux-22009/fs/qnx4/dir.c linux-22009m/fs/qnx4/dir.c
--- linux-22009/fs/qnx4/dir.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/qnx4/dir.c	Sun May 16 15:41:21 1999
@@ -20,6 +20,8 @@
 
 #include <asm/segment.h>
 
+extern int qnx4_pathconf(struct inode *, int);
+
 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir);
 
 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
@@ -119,5 +121,8 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	qnx4_pathconf,		/* pathconf */
 };
diff -u -r linux-22009/fs/qnx4/file.c linux-22009m/fs/qnx4/file.c
--- linux-22009/fs/qnx4/file.c	Fri Mar 26 23:57:41 1999
+++ linux-22009m/fs/qnx4/file.c	Sun May 16 15:41:21 1999
@@ -25,6 +25,7 @@
 #include <linux/locks.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
+#include <linux/unistd.h>
 
 #include <asm/segment.h>
 #include <asm/system.h>
@@ -144,6 +145,32 @@
 }
 #endif
 
+int qnx4_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return QNX4_NAME_MAX;
+	case _PC_NO_TRUNC:
+	  return 0;		/* silent truncation */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
 /*
  * We have moostly NULL's here: the current defaults are ok for
  * the qnx4 filesystem.
@@ -198,7 +225,10 @@
 	NULL,
 #endif
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	qnx4_pathconf,		/* pathconf */
 };
 
 static int qnx4_readpage(struct file *file, struct page *page)
@@ -213,7 +243,8 @@
 	struct buffer_head *bh;
 	int res = -EIO;
 
-	QNX4DEBUG(("qnx4: readpage offset=[%ld]\n", (long) page->offset));
+	QNX4DEBUG(("qnx4: readpage offset=[%ld]\n",
+		   (u_long) pgoff2ulong(page->pg_offset)));
 
 	if (qnx4_ino->i_xblk != 0) {
 		printk("qnx4: sorry, this file is extended, don't know how to handle it (yet) !\n");
@@ -224,7 +255,7 @@
 	buf = page_address(page);
 	clear_bit(PG_uptodate, &page->flags);
 	clear_bit(PG_error, &page->flags);
-	offset = page->offset;
+	offset = pgoff2loff(page->pg_offset);
 
 	if (offset < inode->i_size) {
 		res = 0;
diff -u -r linux-22009/fs/qnx4/inode.c linux-22009m/fs/qnx4/inode.c
--- linux-22009/fs/qnx4/inode.c	Sun Sep  6 03:01:45 1998
+++ linux-22009m/fs/qnx4/inode.c	Sun May 16 15:41:21 1999
@@ -124,7 +124,7 @@
 static void qnx4_put_super(struct super_block *sb);
 static void qnx4_read_inode(struct inode *);
 static int qnx4_remount(struct super_block *sb, int *flags, char *data);
-static int qnx4_statfs(struct super_block *, struct statfs *, int);
+static int qnx4_statfs(struct super_block *, struct statfs64 *);
 
 static struct super_operations qnx4_sops =
 {
@@ -225,22 +225,19 @@
 	return NULL;
 }
 
-static int qnx4_statfs(struct super_block *sb,
-		       struct statfs *buf, int bufsize)
+static int qnx4_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
+	memset(buf, 0, sizeof(*buf));
+	buf->f_type = sb->s_magic;
+	buf->f_bsize = sb->s_blocksize;
+	buf->f_blocks = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_size) * 8;
+	buf->f_bfree = qnx4_count_free_blocks(sb);
+	buf->f_bavail = buf->f_bfree;
+	buf->f_files = 0x00;	/* change this !!! */
+	buf->f_ffree = qnx4_count_free_inodes(sb);
+	buf->f_namelen = QNX4_NAME_MAX;
 
-	memset(&tmp, 0, sizeof tmp);
-	tmp.f_type = sb->s_magic;
-	tmp.f_bsize = sb->s_blocksize;
-	tmp.f_blocks = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_size) * 8;
-	tmp.f_bfree = qnx4_count_free_blocks(sb);
-	tmp.f_bavail = tmp.f_bfree;
-	tmp.f_files = 0x00;	/* change this !!! */
-	tmp.f_ffree = qnx4_count_free_inodes(sb);
-	tmp.f_namelen = QNX4_NAME_MAX;
-
-	return copy_to_user(buf, &tmp, bufsize) ? -EFAULT : 0;
+	return 0;
 }
 
 /*
diff -u -r linux-22009/fs/qnx4/symlinks.c linux-22009m/fs/qnx4/symlinks.c
--- linux-22009/fs/qnx4/symlinks.c	Mon Jan  4 21:42:43 1999
+++ linux-22009m/fs/qnx4/symlinks.c	Sun May 16 15:41:21 1999
@@ -24,6 +24,7 @@
 
 static int qnx4_readlink(struct dentry *, char *, int);
 static struct dentry *qnx4_follow_link(struct dentry *, struct dentry *, unsigned int follow);
+extern int qnx4_pathconf(struct inode *, int);
 
 /*
  * symlinks can't do much...
@@ -46,7 +47,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	qnx4_pathconf,		/* pathconf */
 };
 
 static struct dentry *qnx4_follow_link(struct dentry *dentry,
diff -u -r linux-22009/fs/read_write.c linux-22009m/fs/read_write.c
--- linux-22009/fs/read_write.c	Sun Dec 27 20:52:09 1998
+++ linux-22009m/fs/read_write.c	Sun May 16 15:41:21 1999
@@ -39,6 +39,10 @@
 static inline loff_t llseek(struct file *file, loff_t offset, int origin)
 {
 	loff_t (*fn)(struct file *, loff_t, int);
+	umode_t mode = file->f_dentry->d_inode->i_mode;
+
+	if (S_ISFIFO(mode) || S_ISSOCK(mode))
+	  return -ESPIPE;
 
 	fn = default_llseek;
 	if (file->f_op && file->f_op->llseek)
@@ -48,7 +52,7 @@
 
 asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
 {
-	off_t retval;
+	off_t retval, oldpos;
 	struct file * file;
 	struct dentry * dentry;
 	struct inode * inode;
@@ -62,9 +66,19 @@
 	if (!(dentry = file->f_dentry) ||
 	    !(inode = dentry->d_inode))
 		goto out_putf;
+	oldpos = file->f_pos;
 	retval = -EINVAL;
 	if (origin <= 2)
 		retval = llseek(file, offset, origin);
+
+	/* Demand L-F-S compliance only from normal files,
+	   thus raw devices can do whatever they please.. */
+	if (retval >= 0 && S_ISREG(inode->i_mode) &&
+	    !(file->f_flags & O_LARGEFILE) &&
+	    !off_t_presentable(file->f_pos+1LL)) {
+		file->f_pos = oldpos;
+		retval = -EOVERFLOW;
+	}
 out_putf:
 	fput(file);
 bad:
@@ -81,7 +95,7 @@
 	struct file * file;
 	struct dentry * dentry;
 	struct inode * inode;
-	loff_t offset;
+	loff_t offset, oldpos;
 
 	lock_kernel();
 	retval = -EBADF;
@@ -96,6 +110,7 @@
 	if (origin > 2)
 		goto out_putf;
 
+	oldpos = file->f_pos;
 	offset = llseek(file, ((loff_t) offset_high << 32) | offset_low,
 			origin);
 
@@ -105,6 +120,14 @@
 		if (!copy_to_user(result, &offset, sizeof(offset)))
 			retval = 0;
 	}
+	if (!(file->f_flags & O_LARGEFILE) && S_ISREG(inode->i_mode) &&
+	    !off_t_presentable(file->f_pos+1LL)) {
+		/* The target position isn't presentable without
+		   O_LARGEFILE flag being set --> yield error, and
+		   restore the file position. */
+		file->f_pos = oldpos;
+		retval = -EOVERFLOW;
+	}
 out_putf:
 	fput(file);
 bad:
@@ -325,6 +348,7 @@
 	ssize_t ret;
 	struct file * file;
 	ssize_t (*read)(struct file *, char *, size_t, loff_t *);
+	struct inode * inode;
 
 	lock_kernel();
 
@@ -332,10 +356,30 @@
 	file = fget(fd);
 	if (!file)
 		goto bad_file;
+
+	inode = file->f_dentry->d_inode;
+
 	if (!(file->f_mode & FMODE_READ))
 		goto out;
-	ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode,
-				file, pos, count);
+
+	/* Start position must be non-negative! */
+	if (pos < 0) {
+	  ret = -EINVAL;
+	  goto out;
+	}
+	/* Read starting from beyond the end of file ? */
+	if (inode->i_size <= pos) {
+	  ret = -EOVERFLOW;
+	  goto out;
+	}
+
+	if (!(file->f_flags & O_LARGEFILE) && S_ISREG(inode->i_mode) &&
+	    !off_t_presentable(pos+1LL)) {
+	  ret = -EOVERFLOW;
+	  goto out;
+	}
+
+	ret = locks_verify_area(FLOCK_VERIFY_READ, inode, file, pos, count);
 	if (ret)
 		goto out;
 	ret = -EINVAL;
@@ -357,6 +401,7 @@
 	ssize_t ret;
 	struct file * file;
 	ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
+	struct inode * inode;
 
 	lock_kernel();
 
@@ -366,8 +411,21 @@
 		goto bad_file;
 	if (!(file->f_mode & FMODE_WRITE))
 		goto out;
-	ret = locks_verify_area(FLOCK_VERIFY_WRITE, file->f_dentry->d_inode,
-				file, pos, count);
+	/* Start position must be non-negative! */
+	if (pos < 0) {
+	  ret = -EINVAL;
+	  goto out;
+	}
+
+	inode = file->f_dentry->d_inode;
+
+	if (!(file->f_flags & O_LARGEFILE) && S_ISREG(inode->i_mode) &&
+	    !off_t_presentable(pos+1LL)) {
+	  ret = -EOVERFLOW;
+	  goto out;
+	}
+
+	ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file, pos, count);
 	if (ret)
 		goto out;
 	ret = -EINVAL;
@@ -376,9 +434,9 @@
 	if (pos < 0)
 		goto out;
 
-	down(&file->f_dentry->d_inode->i_sem);
+	down(&inode->i_sem);
 	ret = write(file, buf, count, &pos);
-	up(&file->f_dentry->d_inode->i_sem);
+	up(&inode->i_sem);
 
 out:
 	fput(file);
diff -u -r linux-22009/fs/readdir.c linux-22009m/fs/readdir.c
--- linux-22009/fs/readdir.c	Wed Dec  2 07:45:10 1998
+++ linux-22009m/fs/readdir.c	Sun May 16 15:41:21 1999
@@ -196,3 +196,100 @@
 	unlock_kernel();
 	return error;
 }
+
+/*
+ * New, some-improved getdents64() (for LFS) interface. 
+ */
+struct linux_dirent64 {
+	__u64		d_ino;
+	unsigned long	d_off;
+	unsigned short	d_reclen;
+	char		d_name[1];
+};
+
+struct getdents_callback64 {
+	struct linux_dirent64 * current_dir;
+	struct linux_dirent64 * previous;
+	int count;
+	int error;
+};
+
+static int filldir64(void * __buf, const char * name, int namlen, off_t offset, ino_t ino)
+{
+	struct linux_dirent64 * dirent;
+	struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf;
+	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
+	__u64 ino64;
+
+	buf->error = -EINVAL;	/* only used if we fail.. */
+	if (reclen > buf->count)
+		return -EINVAL;
+	dirent = buf->previous;
+	if (dirent)
+		put_user(offset, &dirent->d_off);
+	dirent = buf->current_dir;
+	buf->previous = dirent;
+	ino64 = ino;
+	copy_to_user(&dirent->d_reclen, &ino64, sizeof(ino64));
+	copy_to_user(dirent->d_name, name, namlen);
+	put_user(0, dirent->d_name + namlen);
+	((char *) dirent) += reclen;
+	buf->current_dir = dirent;
+	buf->count -= reclen;
+	return 0;
+}
+
+asmlinkage int sys_getdents64(unsigned int fd, void * dirent, unsigned int count)
+{
+	struct file * file;
+	struct dentry * dentry;
+	struct inode * inode;
+	struct linux_dirent64 * lastdirent;
+	struct getdents_callback64 buf;
+	int error;
+
+	lock_kernel();
+	error = -EBADF;
+	file = fget(fd);
+	if (!file)
+		goto out;
+
+	dentry = file->f_dentry;
+	if (!dentry)
+		goto out_putf;
+
+	inode = dentry->d_inode;
+	if (!inode)
+		goto out_putf;
+
+	buf.current_dir = (struct linux_dirent64 *) dirent;
+	buf.previous = NULL;
+	buf.count = count;
+	buf.error = 0;
+
+	error = -ENOTDIR;
+	if (!file->f_op || !file->f_op->readdir)
+		goto out_putf;
+
+	/*
+	 * Get the inode's semaphore to prevent changes
+	 * to the directory while we read it.
+	 */
+	down(&inode->i_sem);
+	error = file->f_op->readdir(file, &buf, filldir64);
+	up(&inode->i_sem);
+	if (error < 0)
+		goto out_putf;
+	error = buf.error;
+	lastdirent = buf.previous;
+	if (lastdirent) {
+		put_user(file->f_pos, &lastdirent->d_off);
+		error = count - buf.count;
+	}
+
+out_putf:
+	fput(file);
+out:
+	unlock_kernel();
+	return error;
+}
diff -u -r linux-22009/fs/romfs/inode.c linux-22009m/fs/romfs/inode.c
--- linux-22009/fs/romfs/inode.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/romfs/inode.c	Sun May 16 15:41:21 1999
@@ -57,6 +57,7 @@
 #include <linux/fs.h>
 #include <linux/locks.h>
 #include <linux/init.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 
@@ -165,16 +166,14 @@
 /* That's simple too. */
 
 static int
-romfs_statfs(struct super_block *sb, struct statfs *buf, int bufsize)
+romfs_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	memset(&tmp, 0, sizeof(tmp));
-	tmp.f_type = ROMFS_MAGIC;
-	tmp.f_bsize = ROMBSIZE;
-	tmp.f_blocks = (sb->u.romfs_sb.s_maxsize+ROMBSIZE-1)>>ROMBSBITS;
-	tmp.f_namelen = ROMFS_MAXFN;
-	return copy_to_user(buf, &tmp, bufsize) ? -EFAULT : 0;
+	memset(buf, 0, sizeof(*buf));
+	buf->f_type = ROMFS_MAGIC;
+	buf->f_bsize = ROMBSIZE;
+	buf->f_blocks = (sb->u.romfs_sb.s_maxsize+ROMBSIZE-1)>>ROMBSBITS;
+	buf->f_namelen = ROMFS_MAXFN;
+	return 0;
 }
 
 /* some helper routines */
@@ -395,7 +394,7 @@
 	buf = page_address(page);
 	clear_bit(PG_uptodate, &page->flags);
 	clear_bit(PG_error, &page->flags);
-	offset = page->offset;
+	offset = pgoff2loff(page->pg_offset);
 	if (offset < inode->i_size) {
 		avail = inode->i_size-offset;
 		readlen = min(avail, PAGE_SIZE);
@@ -476,6 +475,32 @@
 	return dentry;
 }
 
+static int romfs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+		break;	/* This is read-only filesystem! */
+	case _PC_NO_TRUNC:
+		break;	/* This is read-only filesystem! */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+		return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		break;	/* This is read-only filesystem! */
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+		break;
+	default:
+		break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
 /* Mapping from our types to the kernel */
 
 static struct file_operations romfs_file_operations = {
@@ -514,6 +539,9 @@
 	NULL,			/* truncate */
 	NULL,			/* permission */
 	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	romfs_pathconf,		/* pathconf */
 };
 
 static struct file_operations romfs_dir_operations = {
@@ -556,6 +584,9 @@
 	NULL,			/* truncate */
 	NULL,			/* permission */
 	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	romfs_pathconf,		/* pathconf */
 };
 
 static struct inode_operations romfs_link_inode_operations = {
@@ -577,6 +608,9 @@
 	NULL,			/* truncate */
 	NULL,			/* permission */
 	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	romfs_pathconf,		/* pathconf */
 };
 
 static mode_t romfs_modemap[] =
diff -u -r linux-22009/fs/smbfs/cache.c linux-22009m/fs/smbfs/cache.c
--- linux-22009/fs/smbfs/cache.c	Mon Mar  8 01:25:23 1999
+++ linux-22009m/fs/smbfs/cache.c	Sun May 16 15:41:21 1999
@@ -41,14 +41,13 @@
 printk("smb_get_dircache: finding cache for %s/%s\n",
 dentry->d_parent->d_name.name, dentry->d_name.name);
 #endif
-	cachep = (struct cache_head *) get_cached_page(inode, 0, 1);
+	cachep = (struct cache_head *) get_cached_page(inode,ulong2pgoff(0),1);
 	if (!cachep)
 		goto out;
 	if (cachep->valid)
 	{
 		struct cache_index * index = cachep->index;
 		struct cache_block * block;
-		unsigned long offset;
 		int i;
 
 		cachep->valid = 0;
@@ -62,9 +61,10 @@
 printk("smb_get_dircache: cache %s/%s has existing block!\n",
 dentry->d_parent->d_name.name, dentry->d_name.name);
 #endif
-			offset = PAGE_SIZE + (i << PAGE_SHIFT);
-			block = (struct cache_block *) get_cached_page(inode,
-								offset, 0);
+			/* byte_offset = PAGE_SIZE + (i << PAGE_SHIFT); */
+			/*    --> page_offset = 1 + i  */ 
+			block = (struct cache_block *)
+				get_cached_page(inode, ulong2pgoff(i+1), 0);
 			if (!block)
 				goto out;
 			index->block = block;
@@ -135,7 +135,7 @@
 	struct inode * inode = get_cache_inode(cachep);
 	struct cache_index * index;
 	struct cache_block * block;
-	unsigned long page_off;
+	pgoff_t page_off;
 	unsigned int nent, offset, len = entry->len;
 	unsigned int needed = len + sizeof(struct cache_entry);
 
@@ -191,7 +191,8 @@
 	 */
 get_block:
 	cachep->pages++;
-	page_off = PAGE_SIZE + (cachep->idx << PAGE_SHIFT);
+	/* page_byte_off = PAGE_SIZE + (cachep->idx << PAGE_SHIFT); */
+	page_off = ulong2pgoff(1 + cachep->idx);
 	block = (struct cache_block *) get_cached_page(inode, page_off, 1);
 	if (block)
 	{
@@ -199,7 +200,7 @@
 		index->space = PAGE_SIZE;
 #ifdef SMBFS_DEBUG_VERBOSE
 printk("smb_add_to_cache: inode=%p, pages=%d, block at %ld\n",
-inode, cachep->pages, page_off);
+inode, cachep->pages, (u_long)pgoff2loff(page_off));
 #endif
 		goto add_entry;
 	}
diff -u -r linux-22009/fs/smbfs/dir.c linux-22009m/fs/smbfs/dir.c
--- linux-22009/fs/smbfs/dir.c	Sun May  9 03:56:37 1999
+++ linux-22009m/fs/smbfs/dir.c	Sun May 16 15:41:21 1999
@@ -29,6 +29,7 @@
 static int smb_unlink(struct inode *, struct dentry *);
 static int smb_rename(struct inode *, struct dentry *,
 		      struct inode *, struct dentry *);
+extern int smb_pathconf(struct inode *, int);
 
 static struct file_operations smb_dir_operations =
 {
@@ -67,6 +68,7 @@
 	NULL,			/* smap */
 	NULL,			/* updatepage */
 	smb_revalidate_inode,	/* revalidate */
+	smb_pathconf,		/* pathconf */
 };
 
 static ssize_t
diff -u -r linux-22009/fs/smbfs/file.c linux-22009m/fs/smbfs/file.c
--- linux-22009/fs/smbfs/file.c	Thu Feb 18 01:59:32 1999
+++ linux-22009m/fs/smbfs/file.c	Sun May 16 15:41:21 1999
@@ -14,6 +14,7 @@
 #include <linux/mm.h>
 #include <linux/malloc.h>
 #include <linux/pagemap.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -55,7 +56,7 @@
 smb_readpage_sync(struct dentry *dentry, struct page *page)
 {
 	char *buffer = (char *) page_address(page);
-	unsigned long offset = page->offset;
+	loff_t loffset = pgoff2loff(page->pg_offset);
 	int rsize = smb_get_rsize(server_from_dentry(dentry));
 	int count = PAGE_SIZE;
 	int result;
@@ -63,8 +64,8 @@
 	clear_bit(PG_error, &page->flags);
 
 #ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_readpage_sync: file %s/%s, count=%d@%ld, rsize=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, count, offset, rsize);
+printk("smb_readpage_sync: file %s/%s, count=%d@%Ld, rsize=%d\n",
+dentry->d_parent->d_name.name, dentry->d_name.name, count, loffset, rsize);
 #endif
 	result = smb_open(dentry, SMB_O_RDONLY);
 	if (result < 0)
@@ -80,12 +81,12 @@
 		if (count < rsize)
 			rsize = count;
 
-		result = smb_proc_read(dentry, offset, rsize, buffer);
+		result = smb_proc_read(dentry, loffset, rsize, buffer);
 		if (result < 0)
 			goto io_error;
 
 		count -= result;
-		offset += result;
+		loffset += result;
 		buffer += result;
 		dentry->d_inode->i_atime = CURRENT_TIME;
 		if (result < rsize)
@@ -124,25 +125,42 @@
  * Offset is the data offset within the page.
  */
 static int
-smb_writepage_sync(struct dentry *dentry, struct page *page,
+smb_writepage_sync(struct file *file, struct page *page,
 		   unsigned long offset, unsigned int count)
 {
+	struct dentry * dentry = file->f_dentry;
 	struct inode *inode = dentry->d_inode;
 	u8 *buffer = (u8 *) page_address(page) + offset;
 	int wsize = smb_get_wsize(server_from_dentry(dentry));
 	int result, written = 0;
+	loff_t loffset = pgoff2loff(page->pg_offset) + offset;
 
-	offset += page->offset;
 #ifdef SMBFS_DEBUG_VERBOSE
 printk("smb_writepage_sync: file %s/%s, count=%d@%ld, wsize=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, count, offset, wsize);
+       dentry->d_parent->d_name.name, dentry->d_name.name, count,
+       loffset, wsize);
 #endif
 
+	if (!(file->f_flags & O_LARGEFILE) &&
+	    !off_t_presentable(loffset+1))
+	  /* Write starts beyond allowed type-range of off_t */
+	  return -EFBIG; /* Might trap at 2G, or might go above .. */
+
+	if (!(file->f_flags & O_LARGEFILE) &&
+	    !off_t_presentable(loffset + count))
+	  /* Writing beyond LargeFile maximums without O_LARGEFILE */
+	  count = LONG_MAX - loffset;
+
+	if (loffset >= 0xffffffffULL) /* 4G-1 ???  Or 2G-1 ??? */
+	  return -EFBIG;
+	if ((loffset + count) >= 0xffffffffULL)
+	  count = 0xffffffffULL - loffset;
+
 	do {
 		if (count < wsize)
 			wsize = count;
 
-		result = smb_proc_write(dentry, offset, wsize, buffer);
+		result = smb_proc_write(dentry, loffset, wsize, buffer);
 		if (result < 0)
 			break;
 		/* N.B. what if result < wsize?? */
@@ -150,29 +168,27 @@
 if (result < wsize)
 printk("smb_writepage_sync: short write, wsize=%d, result=%d\n", wsize, result);
 #endif
-		buffer += wsize;
-		offset += wsize;
+		buffer  += wsize;
+		loffset += wsize;
 		written += wsize;
-		count -= wsize;
+		count   -= wsize;
 		/*
 		 * Update the inode now rather than waiting for a refresh.
 		 */
 		inode->i_mtime = inode->i_atime = CURRENT_TIME;
-		if (offset > inode->i_size)
-			inode->i_size = offset;
+		if (loffset > inode->i_size)
+			inode->i_size = loffset;
 		inode->u.smbfs_i.cache_valid |= SMB_F_LOCALWRITE;
 	} while (count);
 	return written ? written : result;
 }
 
 /*
- * Write a page to the server. This will be used for NFS swapping only
- * (for now), and we currently do this synchronously only.
+ * Write a page to the server.
  */
 static int
 smb_writepage(struct file *file, struct page *page)
 {
-	struct dentry *dentry = file->f_dentry;
 	int 	result;
 
 #ifdef SMBFS_PARANOIA
@@ -181,7 +197,7 @@
 #endif
 	set_bit(PG_locked, &page->flags);
 	atomic_inc(&page->count);
-	result = smb_writepage_sync(dentry, page, 0, PAGE_SIZE);
+	result = smb_writepage_sync(file, page, 0, PAGE_SIZE);
 	smb_unlock_page(page);
 	free_page(page_address(page));
 	return result;
@@ -192,11 +208,11 @@
 {
 	struct dentry *dentry = file->f_dentry;
 
-	pr_debug("SMBFS: smb_updatepage(%s/%s %d@%ld, sync=%d)\n",
+	pr_debug("SMBFS: smb_updatepage(%s/%s %d@%Ld, sync=%d)\n",
 		dentry->d_parent->d_name.name, dentry->d_name.name,
-	 	count, page->offset+offset, sync);
+	 	count, pgoff2loff(page->pg_offset)+offset, sync);
 
-	return smb_writepage_sync(dentry, page, offset, count);
+	return smb_writepage_sync(file, page, offset, count);
 }
 
 static ssize_t
@@ -206,9 +222,9 @@
 	ssize_t	status;
 
 #ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_file_read: file %s/%s, count=%lu@%lu\n",
-dentry->d_parent->d_name.name, dentry->d_name.name,
-(unsigned long) count, (unsigned long) *ppos);
+printk("smb_file_read: file %s/%s, count=%lu@%Lu\n",
+       dentry->d_parent->d_name.name, dentry->d_name.name,
+       (unsigned long) count, *ppos);
 #endif
 
 	status = smb_revalidate_inode(dentry);
@@ -239,7 +255,8 @@
 
 #ifdef SMBFS_DEBUG_VERBOSE
 printk("smb_file_mmap: file %s/%s, address %lu - %lu\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, vma->vm_start, vma->vm_end);
+       dentry->d_parent->d_name.name, dentry->d_name.name,
+       vma->vm_start, vma->vm_end);
 #endif
 
 	status = smb_revalidate_inode(dentry);
@@ -247,7 +264,7 @@
 	{
 #ifdef SMBFS_PARANOIA
 printk("smb_file_mmap: %s/%s validation failed, error=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, status);
+       dentry->d_parent->d_name.name, dentry->d_name.name, status);
 #endif
 		goto out;
 	}
@@ -266,9 +283,9 @@
 	ssize_t	result;
 
 #ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_file_write: file %s/%s, count=%lu@%lu, pages=%ld\n",
-dentry->d_parent->d_name.name, dentry->d_name.name,
-(unsigned long) count, (unsigned long) *ppos, dentry->d_inode->i_nrpages);
+printk("smb_file_write: file %s/%s, count=%lu@%Lu, pages=%ld\n",
+       dentry->d_parent->d_name.name, dentry->d_name.name,
+       (unsigned long) count, *ppos, dentry->d_inode->i_nrpages);
 #endif
 
 	result = smb_revalidate_inode(dentry);
@@ -276,7 +293,7 @@
 	{
 #ifdef SMBFS_PARANOIA
 printk("smb_file_write: %s/%s validation failed, error=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, result);
+       dentry->d_parent->d_name.name, dentry->d_name.name, result);
 #endif
 			goto out;
 	}
@@ -289,9 +306,9 @@
 	{
 		result = generic_file_write(file, buf, count, ppos);
 #ifdef SMBFS_DEBUG_VERBOSE
-printk("smb_file_write: pos=%ld, size=%ld, mtime=%ld, atime=%ld\n",
-(long) file->f_pos, dentry->d_inode->i_size, dentry->d_inode->i_mtime,
-dentry->d_inode->i_atime);
+printk("smb_file_write: pos=%Ld, size=%ld, mtime=%ld, atime=%ld\n",
+       file->f_pos, dentry->d_inode->i_size, dentry->d_inode->i_mtime,
+       dentry->d_inode->i_atime);
 #endif
 	}
 out:
@@ -347,6 +364,32 @@
 	return error;
 }
 
+int smb_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return SMB_MAXNAMELEN;
+	case _PC_NO_TRUNC:
+	  return 1;		/* UNIX-like semantics */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
 static struct file_operations smb_file_operations =
 {
 	NULL,			/* lseek - default */
@@ -388,4 +431,5 @@
 	NULL,			/* smap */
 	smb_updatepage,		/* updatepage */
 	smb_revalidate_inode,	/* revalidate */
+	smb_pathconf,		/* pathconf */
 };
diff -u -r linux-22009/fs/smbfs/inode.c linux-22009m/fs/smbfs/inode.c
--- linux-22009/fs/smbfs/inode.c	Wed Dec 23 19:44:42 1998
+++ linux-22009m/fs/smbfs/inode.c	Sun May 16 15:41:21 1999
@@ -35,7 +35,7 @@
 static void smb_put_inode(struct inode *);
 static void smb_delete_inode(struct inode *);
 static void smb_put_super(struct super_block *);
-static int  smb_statfs(struct super_block *, struct statfs *, int);
+static int  smb_statfs(struct super_block *, struct statfs64 *);
 
 static struct super_operations smb_sops =
 {
@@ -440,19 +440,17 @@
 }
 
 static int
-smb_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+smb_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs attr;
+	memset(buf, 0, sizeof(*buf));
 
-	memset(&attr, 0, sizeof(attr));
+	smb_proc_dskattr(sb, buf);
 
-	smb_proc_dskattr(sb, &attr);
-
-	attr.f_type = SMB_SUPER_MAGIC;
-	attr.f_files = -1;
-	attr.f_ffree = -1;
-	attr.f_namelen = SMB_MAXPATHLEN;
-	return copy_to_user(buf, &attr, bufsiz) ? -EFAULT : 0;
+	buf->f_type = SMB_SUPER_MAGIC;
+	buf->f_files = -1;
+	buf->f_ffree = -1;
+	buf->f_namelen = SMB_MAXPATHLEN;
+	return 0;
 }
 
 int
diff -u -r linux-22009/fs/smbfs/proc.c linux-22009m/fs/smbfs/proc.c
--- linux-22009/fs/smbfs/proc.c	Wed Nov  4 07:56:58 1998
+++ linux-22009m/fs/smbfs/proc.c	Sun May 16 15:41:22 1999
@@ -979,7 +979,7 @@
    file-id would not be valid after a reconnection. */
 
 int
-smb_proc_read(struct dentry *dentry, off_t offset, int count, char *data)
+smb_proc_read(struct dentry *dentry, loff_t offset, int count, char *data)
 {
 	struct smb_sb_info *server = server_from_dentry(dentry);
 	__u16 returned_count, data_len;
@@ -1021,16 +1021,16 @@
 }
 
 int
-smb_proc_write(struct dentry *dentry, off_t offset, int count, const char *data)
+smb_proc_write(struct dentry *dentry, loff_t offset, int count, const char *data)
 {
 	struct smb_sb_info *server = server_from_dentry(dentry);
 	int result;
 	__u8 *p;
 
 #if SMBFS_DEBUG_VERBOSE
-printk("smb_proc_write: file %s/%s, count=%d@%ld, packet_size=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, 
-count, offset, server->packet_size);
+printk("smb_proc_write: file %s/%s, count=%d@%Ld, packet_size=%d\n",
+       dentry->d_parent->d_name.name, dentry->d_name.name, 
+       count, offset, server->packet_size);
 #endif
 	smb_lock_server(server);
 	p = smb_setup_header(server, SMBwrite, 5, count + 3);
@@ -1815,7 +1815,7 @@
 	fattr->f_mtime = date_dos2unix(date, time);
 #ifdef SMBFS_DEBUG_VERBOSE
 printk("smb_proc_getattr_ff: name=%s, date=%x, time=%x, mtime=%ld\n",
-mask, date, time, fattr->f_mtime);
+       mask, date, time, fattr->f_mtime);
 #endif
 	fattr->f_size = DVAL(resp_data, 12);
 	/* ULONG allocation size */
@@ -1855,7 +1855,7 @@
 	fattr->f_atime = fattr->f_mtime; 
 #ifdef SMBFS_DEBUG_TIMESTAMP
 printk("getattr_core: %s/%s, mtime=%ld\n",
-dir->d_name.name, name->name, fattr->f_mtime);
+       dir->d_name.name, name->name, fattr->f_mtime);
 #endif
 	result = 0;
 
@@ -1937,7 +1937,7 @@
 	attr->f_mtime = date_dos2unix(date, time);
 #ifdef SMBFS_DEBUG_TIMESTAMP
 printk("getattr_trans2: %s/%s, date=%x, time=%x, mtime=%ld\n",
-dir->d_name.name, name->name, date, time, attr->f_mtime);
+       dir->d_name.name, name->name, date, time, attr->f_mtime);
 #endif
 	attr->f_size = DVAL(resp_data, 12);
 	attr->attr = WVAL(resp_data, 20);
@@ -2077,7 +2077,7 @@
 	WSET(server->packet, smb_vwv6, time);
 #ifdef SMBFS_DEBUG_TIMESTAMP
 printk("smb_proc_setattr_ext: date=%d, time=%d, mtime=%ld\n", 
-date, time, fattr->f_mtime);
+       date, time, fattr->f_mtime);
 #endif
 
 	result = smb_request_ok(server, SMBsetattrE, 0, 0);
@@ -2127,7 +2127,8 @@
 	WSET(data, 10, time);
 #ifdef SMBFS_DEBUG_TIMESTAMP
 printk("setattr_trans2: %s/%s, date=%x, time=%x, mtime=%ld\n", 
-dir->d_parent->d_name.name, dir->d_name.name, date, time, fattr->f_mtime);
+       dir->d_parent->d_name.name, dir->d_name.name, date, time,
+       fattr->f_mtime);
 #endif
 	DSET(data, 12, 0); /* size */
 	DSET(data, 16, 0); /* blksize */
@@ -2212,7 +2213,7 @@
 }
 
 int
-smb_proc_dskattr(struct super_block *sb, struct statfs *attr)
+smb_proc_dskattr(struct super_block *sb, struct statfs64 *attr)
 {
 	struct smb_sb_info *server = &(sb->u.smbfs_sb);
 	int error;
diff -u -r linux-22009/fs/stat.c linux-22009m/fs/stat.c
--- linux-22009/fs/stat.c	Fri Nov 13 20:07:26 1998
+++ linux-22009m/fs/stat.c	Sun May 16 15:41:22 1999
@@ -8,11 +8,14 @@
 #include <linux/errno.h>
 #include <linux/file.h>
 #include <linux/smp_lock.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 
 /*
  * Revalidate the inode. This is required for proper NFS attribute caching.
+ * THIS FUNCTION IS ALSO COPIED TO  arch/i386/kernel/sys_i386.c, AND TO
+ * arch/m68k/kernel/sys_m68k.c
  */
 static __inline__ int
 do_revalidate(struct dentry *dentry)
@@ -23,41 +26,13 @@
 	return 0;
 }
 
+static int all_fail_alike_fstat = 0;
+/* "No lie" policy yields EOVERFLOW if file size exceeds
+   a value which is presentable in field st_size (or st_blocks,
+   or st_ino). But then the file will not appear in the directory
+   listing at all before we have stat64() syscalls in use.. */
 
-#if !defined(__alpha__) && !defined(__sparc__)
-
-/*
- * For backward compatibility?  Maybe this should be moved
- * into arch/i386 instead?
- */
-static int cp_old_stat(struct inode * inode, struct __old_kernel_stat * statbuf)
-{
-	static int warncount = 5;
-	struct __old_kernel_stat tmp;
-
-	if (warncount) {
-		warncount--;
-		printk("VFS: Warning: %s using old stat() call. Recompile your binary.\n",
-			current->comm);
-	}
-
-	tmp.st_dev = kdev_t_to_nr(inode->i_dev);
-	tmp.st_ino = inode->i_ino;
-	tmp.st_mode = inode->i_mode;
-	tmp.st_nlink = inode->i_nlink;
-	tmp.st_uid = inode->i_uid;
-	tmp.st_gid = inode->i_gid;
-	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
-	tmp.st_size = inode->i_size;
-	tmp.st_atime = inode->i_atime;
-	tmp.st_mtime = inode->i_mtime;
-	tmp.st_ctime = inode->i_ctime;
-	return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
-}
-
-#endif
-
-static int cp_new_stat(struct inode * inode, struct stat * statbuf)
+static int cp_new_stat(struct inode * inode, struct stat * statbuf, int f)
 {
 	struct stat tmp;
 	unsigned int blocks, indirect;
@@ -65,15 +40,32 @@
 	memset(&tmp, 0, sizeof(tmp));
 	tmp.st_dev = kdev_t_to_nr(inode->i_dev);
 	tmp.st_ino = inode->i_ino;
+	if (tmp.st_ino != inode->i_ino) {
+		if (f || all_fail_alike_fstat)
+			return -EOVERFLOW; /* See LFS spec: 2.2.1.14
+					      Xstat() shall fail with
+					      EOVERFLOW. */
+	  tmp.st_ino = -1;
+	}
 	tmp.st_mode = inode->i_mode;
 	tmp.st_nlink = inode->i_nlink;
 	tmp.st_uid = inode->i_uid;
 	tmp.st_gid = inode->i_gid;
 	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
-	tmp.st_size = inode->i_size;
 	tmp.st_atime = inode->i_atime;
 	tmp.st_mtime = inode->i_mtime;
 	tmp.st_ctime = inode->i_ctime;
+	/* large-file stat() problem...
+	   If your file size is 4G-1, it *propably*
+	   is over 4G in a 32-bit system... */
+	tmp.st_size = inode->i_size;
+	if (inode->i_size != tmp.st_size) {
+		if (f || all_fail_alike_fstat)
+			return -EOVERFLOW; /* See LFS spec: 2.2.1.14
+					      Xstat() shall fail with
+					      EOVERFLOW. */
+		tmp.st_size = ULONG_MAX;
+	}
 /*
  * st_blocks and st_blksize are approximated with a simple algorithm if
  * they aren't supported directly by the filesystem. The minix and msdos
@@ -110,16 +102,20 @@
 		tmp.st_blocks = inode->i_blocks;
 		tmp.st_blksize = inode->i_blksize;
 	}
+#if BITS_PER_LONG < 64
+	if (tmp.st_blocks != inode->i_blocks) {
+		if (f || all_fail_alike_fstat)
+			return -EOVERFLOW; /* See LFS spec: 2.2.1.14
+					      Xstat() shall fail with
+					      EOVERFLOW. */
+		tmp.st_blocks = ULONG_MAX;
+	}
+#endif
 	return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
 }
 
 
-#if !defined(__alpha__) && !defined(__sparc__)
-/*
- * For backward compatibility?  Maybe this should be moved
- * into arch/i386 instead?
- */
-asmlinkage int sys_stat(char * filename, struct __old_kernel_stat * statbuf)
+asmlinkage int sys_newstat(char * filename, struct stat * statbuf)
 {
 	struct dentry * dentry;
 	int error;
@@ -131,28 +127,27 @@
 	if (!IS_ERR(dentry)) {
 		error = do_revalidate(dentry);
 		if (!error)
-			error = cp_old_stat(dentry->d_inode, statbuf);
+			error = cp_new_stat(dentry->d_inode, statbuf, 0);
 
 		dput(dentry);
 	}
 	unlock_kernel();
 	return error;
 }
-#endif
 
-asmlinkage int sys_newstat(char * filename, struct stat * statbuf)
+asmlinkage int sys_newlstat(char * filename, struct stat * statbuf)
 {
 	struct dentry * dentry;
 	int error;
 
 	lock_kernel();
-	dentry = namei(filename);
+	dentry = lnamei(filename);
 
 	error = PTR_ERR(dentry);
 	if (!IS_ERR(dentry)) {
 		error = do_revalidate(dentry);
 		if (!error)
-			error = cp_new_stat(dentry->d_inode, statbuf);
+			error = cp_new_stat(dentry->d_inode, statbuf, 0);
 
 		dput(dentry);
 	}
@@ -160,25 +155,97 @@
 	return error;
 }
 
-#if !defined(__alpha__) && !defined(__sparc__)
+asmlinkage int sys_newfstat(unsigned int fd, struct stat * statbuf)
+{
+	struct file * f;
+	int err = -EBADF;
+
+	lock_kernel();
+	f = fget(fd);
+	if (f) {
+		struct dentry * dentry = f->f_dentry;
 
+		err = do_revalidate(dentry);
+		if (!err)
+			err = cp_new_stat(dentry->d_inode, statbuf, 1);
+		fput(f);
+	}
+	unlock_kernel();
+	return err;
+}
+
+/* ---------- LFS-64 ----------- */
+
+static int cp_new_stat64(struct inode * inode, struct stat64 * statbuf)
+{
+	struct stat64 tmp;
+	unsigned int blocks, indirect;
+
+	memset(&tmp, 0, sizeof(tmp));
+	tmp.st_dev = kdev_t_to_nr(inode->i_dev);
+	tmp.st_ino = inode->i_ino;
+	tmp.st_mode = inode->i_mode;
+	tmp.st_nlink = inode->i_nlink;
+	tmp.st_uid = inode->i_uid;
+	tmp.st_gid = inode->i_gid;
+	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
+	tmp.st_atime = inode->i_atime;
+	tmp.st_mtime = inode->i_mtime;
+	tmp.st_ctime = inode->i_ctime;
+	tmp.st_size = inode->i_size;
 /*
- * For backward compatibility?  Maybe this should be moved
- * into arch/i386 instead?
+ * st_blocks and st_blksize are approximated with a simple algorithm if
+ * they aren't supported directly by the filesystem. The minix and msdos
+ * filesystems don't keep track of blocks, so they would either have to
+ * be counted explicitly (by delving into the file itself), or by using
+ * this simple algorithm to get a reasonable (although not 100% accurate)
+ * value.
+ */
+
+/*
+ * Use minix fs values for the number of direct and indirect blocks.  The
+ * count is now exact for the minix fs except that it counts zero blocks.
+ * Everything is in units of BLOCK_SIZE until the assignment to
+ * tmp.st_blksize.
  */
-asmlinkage int sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
+#define D_B   7
+#define I_B   (BLOCK_SIZE / sizeof(unsigned short))
+
+	if (!inode->i_blksize) {
+		blocks = (tmp.st_size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS;
+		if (blocks > D_B) {
+			indirect = (blocks - D_B + I_B - 1) / I_B;
+			blocks += indirect;
+			if (indirect > 1) {
+				indirect = (indirect - 1 + I_B - 1) / I_B;
+				blocks += indirect;
+				if (indirect > 1)
+					blocks++;
+			}
+		}
+		tmp.st_blocks = (BLOCK_SIZE / 512) * blocks;
+		tmp.st_blksize = BLOCK_SIZE;
+	} else {
+		tmp.st_blocks = inode->i_blocks;
+		tmp.st_blksize = inode->i_blksize;
+	}
+	return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
+}
+
+
+asmlinkage int sys_newstat64(char * filename, struct stat64 * statbuf)
 {
 	struct dentry * dentry;
 	int error;
 
 	lock_kernel();
-	dentry = lnamei(filename);
+	dentry = namei(filename);
 
 	error = PTR_ERR(dentry);
 	if (!IS_ERR(dentry)) {
 		error = do_revalidate(dentry);
 		if (!error)
-			error = cp_old_stat(dentry->d_inode, statbuf);
+			error = cp_new_stat64(dentry->d_inode, statbuf);
 
 		dput(dentry);
 	}
@@ -186,9 +253,7 @@
 	return error;
 }
 
-#endif
-
-asmlinkage int sys_newlstat(char * filename, struct stat * statbuf)
+asmlinkage int sys_newlstat64(char * filename, struct stat64 * statbuf)
 {
 	struct dentry * dentry;
 	int error;
@@ -200,7 +265,7 @@
 	if (!IS_ERR(dentry)) {
 		error = do_revalidate(dentry);
 		if (!error)
-			error = cp_new_stat(dentry->d_inode, statbuf);
+			error = cp_new_stat64(dentry->d_inode, statbuf);
 
 		dput(dentry);
 	}
@@ -208,34 +273,7 @@
 	return error;
 }
 
-#if !defined(__alpha__) && !defined(__sparc__)
-
-/*
- * For backward compatibility?  Maybe this should be moved
- * into arch/i386 instead?
- */
-asmlinkage int sys_fstat(unsigned int fd, struct __old_kernel_stat * statbuf)
-{
-	struct file * f;
-	int err = -EBADF;
-
-	lock_kernel();
-	f = fget(fd);
-	if (f) {
-		struct dentry * dentry = f->f_dentry;
-
-		err = do_revalidate(dentry);
-		if (!err)
-			err = cp_old_stat(dentry->d_inode, statbuf);
-		fput(f);
-	}
-	unlock_kernel();
-	return err;
-}
-
-#endif
-
-asmlinkage int sys_newfstat(unsigned int fd, struct stat * statbuf)
+asmlinkage int sys_newfstat64(unsigned int fd, struct stat64 * statbuf)
 {
 	struct file * f;
 	int err = -EBADF;
@@ -247,7 +285,7 @@
 
 		err = do_revalidate(dentry);
 		if (!err)
-			err = cp_new_stat(dentry->d_inode, statbuf);
+			err = cp_new_stat64(dentry->d_inode, statbuf);
 		fput(f);
 	}
 	unlock_kernel();
@@ -279,4 +317,130 @@
 	}
 	unlock_kernel();
 	return error;
+}
+
+
+/*
+ * POSIX pathconf()
+ *
+ * return value rules differ from sysconf(); If no explicite limit
+ * is in effect for given option,  pathconf()  shall return -1 without
+ * touching errno.  If the failure is anywhere else, errors like EINVAL,
+ * EACCESS, ENOENT,  etc. are possible..
+ *
+ * Returning ``-1'' without errno is indicated by returning ``-INT_MAX''
+ */
+
+extern int pipe_pathconf(struct inode *inode, int option);
+extern __u32 sysctl_wmem_max;
+
+static int dpathconf(struct dentry *dentry, int option)
+{
+	int (*pathconf)(struct inode*, int);
+	umode_t mode = dentry->d_inode->i_mode;
+
+	switch (option) {
+	case _PC_ASYNC_IO:	/* POSIX.4: TTY only (per Solaris) */
+	case _PC_PRIO_IO:
+	case _PC_MAX_CANON:	/* POSIX.1: TTY only */
+	case _PC_MAX_INPUT:
+	case _PC_VDISABLE:
+		if (!S_ISCHR(mode)) /* CHAR devices -- at least */
+			return -EINVAL;
+		break;
+
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	case _PC_NO_TRUNC:
+		if (!S_ISDIR(mode))
+			return -EINVAL;
+		break;
+
+	case _PC_PATH_MAX:
+		if (!S_ISDIR(mode))
+			return -EINVAL;
+		return PATH_MAX;
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+		if (!S_ISREG(mode) && !S_ISDIR(mode))
+			return -EINVAL;
+		break;
+
+	case _PC_PIPE_BUF:	/* POSIX.1: Pipes & dirs only */
+		if (!S_ISFIFO(mode) && !S_ISDIR(mode))
+			return -EINVAL;
+		/* This direct call to pipe_pathconf() is done this
+		   way, because with named pipes the names may exist
+		   in some remote directories, but the pipes them-
+		   selves live only in the local system kernel */
+		return pipe_pathconf(dentry->d_inode, option);
+
+	case _PC_SOCK_MAXBUF:	/* POSIX.1g: fpathconf() */
+		if (!S_ISSOCK(mode))
+			return -EINVAL;
+		return sysctl_wmem_max;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+		if (!S_ISREG(mode) && !S_ISDIR(mode))
+			return -EINVAL;
+		break;
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only */
+		/* Solaris: Dirs ok too! */
+		if (!S_ISREG(mode) && !S_ISDIR(mode))
+			return -EINVAL;
+		break;
+
+	default:		/* Eh ?? */
+		return -EINVAL;
+	}
+
+	pathconf = dentry->d_inode->i_op->pathconf;
+	if (pathconf)
+		return pathconf(dentry->d_inode, option);
+
+	return -EINVAL;	/* No pathconf, no direct processing! */
+}
+
+asmlinkage int sys_pathconf(char *pathname, int option)
+{
+	struct dentry * dentry;
+	int error;
+
+	lock_kernel();
+	dentry = namei(pathname);
+
+	error = PTR_ERR(dentry);
+	if (!IS_ERR(dentry)) {
+		error = do_revalidate(dentry);
+		if (!error)
+			error = dpathconf(dentry, option);
+		dput(dentry);
+	}
+	unlock_kernel();
+	return error;
+}
+
+/*
+ * POSIX fpathconf() -- pathconf() with 'fd'
+ */
+
+asmlinkage int sys_fpathconf(int fd, int option)
+{
+	struct file * f;
+	int err;
+
+	lock_kernel();
+	f = fget(fd);
+	if (f) {
+		struct dentry * dentry = f->f_dentry;
+		
+		err = do_revalidate(dentry);
+		if (!err)
+			err = dpathconf(dentry, option);
+		fput(f);
+	} else
+		err = -EBADF;
+	unlock_kernel();
+	return err;
 }
diff -u -r linux-22009/fs/super.c linux-22009m/fs/super.c
--- linux-22009/fs/super.c	Mon May 10 20:08:51 1999
+++ linux-22009m/fs/super.c	Sun May 16 15:41:22 1999
@@ -478,8 +478,7 @@
 {
         struct super_block *s;
         struct ustat tmp;
-        struct statfs sbuf;
-        mm_segment_t old_fs;
+        struct statfs64 sbuf64;
 	int err = -EINVAL;
 
 	lock_kernel();
@@ -490,18 +489,15 @@
         if (!(s->s_op->statfs))
                 goto out;
 
-        old_fs = get_fs();
-        set_fs(get_ds());
-        s->s_op->statfs(s,&sbuf,sizeof(struct statfs));
-        set_fs(old_fs);
+        s->s_op->statfs(s, &sbuf64);
+	unlock_kernel();
 
         memset(&tmp,0,sizeof(struct ustat));
-        tmp.f_tfree = sbuf.f_bfree;
-        tmp.f_tinode = sbuf.f_ffree;
+        tmp.f_tfree = sbuf64.f_bfree;
+        tmp.f_tinode = sbuf64.f_ffree;
 
         err = copy_to_user(ubuf,&tmp,sizeof(struct ustat)) ? -EFAULT : 0;
 out:
-	unlock_kernel();
 	return err;
 }
 
diff -u -r linux-22009/fs/sysv/dir.c linux-22009m/fs/sysv/dir.c
--- linux-22009/fs/sysv/dir.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/sysv/dir.c	Sun May 16 15:41:22 1999
@@ -18,6 +18,7 @@
 #include <linux/sysv_fs.h>
 #include <linux/stat.h>
 #include <linux/string.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 
@@ -28,6 +29,7 @@
 }
 
 static int sysv_readdir(struct file *, void *, filldir_t);
+extern int sysv_pathconf(struct inode *inode, int option);
 
 static struct file_operations sysv_dir_operations = {
 	NULL,			/* lseek - default */
@@ -63,7 +65,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	sysv_pathconf,		/* pathconf */
 };
 
 static int sysv_readdir(struct file * filp, void * dirent, filldir_t filldir)
@@ -111,4 +117,30 @@
 		brelse(bh);
 	}
 	return 0;
+}
+
+int sysv_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return SYSV_NAMELEN;	/* name component max length */
+	case _PC_NO_TRUNC:
+	  return !inode->i_sb->sv_truncate;
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return inode->i_sb->sv_link_max;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
 }
diff -u -r linux-22009/fs/sysv/file.c linux-22009m/fs/sysv/file.c
--- linux-22009/fs/sysv/file.c	Mon Aug 24 23:02:44 1998
+++ linux-22009m/fs/sysv/file.c	Sun May 16 15:41:22 1999
@@ -34,6 +34,7 @@
 #include <linux/sysv_fs.h>
 
 static ssize_t sysv_file_write(struct file *, const char *, size_t, loff_t *);
+extern int sysv_pathconf(struct inode *, int);
 
 /*
  * We have mostly NULLs here: the current defaults are OK for
@@ -70,7 +71,11 @@
 	NULL,			/* writepage */
 	sysv_bmap,		/* bmap */
 	sysv_truncate,		/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	sysv_pathconf,		/* pathconf */
 };
 
 ssize_t sysv_file_read(struct file * filp, char * buf, 
@@ -207,7 +212,7 @@
 {
 	struct inode * inode = filp->f_dentry->d_inode;
 	struct super_block * sb = inode->i_sb;
-	off_t pos;
+	loff_t pos;
 	ssize_t written, c;
 	struct buffer_head * bh;
 	char * p;
@@ -232,6 +237,21 @@
 	else
 		pos = *ppos;
 	written = 0;
+
+	/* L-F-S spec 2.2.1.27: */
+	if (!(filp->f_flags & O_LARGEFILE)) {
+		if (!off_t_presentable(1 + pos)) /* pos@LONG_MAX forbidden */
+			return -EFBIG;
+
+		if (!off_t_presentable(pos + count))
+			/* Write only until end of allowed region */
+			count = LONG_MAX - pos;
+	}
+	if (pos >= 0xffffffffULL)
+		return -EFBIG; /* Only up to 4G-1! */
+	if ((pos + count) > 0xffffffffULL)
+		count = 0xffffffffULL - pos;
+
 	while (written<count) {
 		bh = sysv_getblk (inode, pos >> sb->sv_block_size_bits, 1);
 		if (!bh) {
diff -u -r linux-22009/fs/sysv/inode.c linux-22009m/fs/sysv/inode.c
--- linux-22009/fs/sysv/inode.c	Sun Mar 21 17:11:37 1999
+++ linux-22009m/fs/sysv/inode.c	Sun May 16 15:41:22 1999
@@ -555,20 +555,18 @@
 	MOD_DEC_USE_COUNT;
 }
 
-int sysv_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+int sysv_statfs(struct super_block *sb, struct statfs64 *buf)
 {
-	struct statfs tmp;
-
-	tmp.f_type = sb->s_magic;			/* type of filesystem */
-	tmp.f_bsize = sb->sv_block_size;		/* block size */
-	tmp.f_blocks = sb->sv_ndatazones;		/* total data blocks in file system */
-	tmp.f_bfree = sysv_count_free_blocks(sb);	/* free blocks in fs */
-	tmp.f_bavail = tmp.f_bfree;			/* free blocks available to non-superuser */
-	tmp.f_files = sb->sv_ninodes;			/* total file nodes in file system */
-	tmp.f_ffree = sysv_count_free_inodes(sb);	/* free file nodes in fs */
-	tmp.f_namelen = SYSV_NAMELEN;
-	/* Don't know what value to put in tmp.f_fsid */ /* file system id */
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_type = sb->s_magic;			/* type of filesystem */
+	buf->f_bsize = sb->sv_block_size;		/* block size */
+	buf->f_blocks = sb->sv_ndatazones;		/* total data blocks in file system */
+	buf->f_bfree = sysv_count_free_blocks(sb);	/* free blocks in fs */
+	buf->f_bavail = buf->f_bfree;			/* free blocks available to non-superuser */
+	buf->f_files = sb->sv_ninodes;			/* total file nodes in file system */
+	buf->f_ffree = sysv_count_free_inodes(sb);	/* free file nodes in fs */
+	buf->f_namelen = SYSV_NAMELEN;
+	/* Don't know what value to put in buf->f_fsid */ /* file system id */
+	return 0;
 }
 
 
diff -u -r linux-22009/fs/sysv/symlink.c linux-22009m/fs/sysv/symlink.c
--- linux-22009/fs/sysv/symlink.c	Sat Sep 19 23:45:42 1998
+++ linux-22009m/fs/sysv/symlink.c	Sun May 16 15:41:22 1999
@@ -22,6 +22,7 @@
 
 static int sysv_readlink(struct dentry *, char *, int);
 static struct dentry *sysv_follow_link(struct dentry *, struct dentry *, unsigned int);
+extern int sysv_pathconf(struct inode *, int);
 
 /*
  * symlinks can't do much...
@@ -43,7 +44,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	sysv_pathconf,		/* pathconf */
 };
 
 static struct dentry *sysv_follow_link(struct dentry * dentry,
diff -u -r linux-22009/fs/ufs/balloc.c linux-22009m/fs/ufs/balloc.c
--- linux-22009/fs/ufs/balloc.c	Mon Jan 18 04:32:26 1999
+++ linux-22009m/fs/ufs/balloc.c	Sun May 16 15:41:22 1999
@@ -652,9 +652,9 @@
 	struct ufs_sb_private_info * uspi;
 	struct ufs_super_block_first * usb1;
 	struct ufs_cylinder_group * ucg;
-	unsigned start, length, location, result;
-	unsigned possition, fragsize, blockmap, mask;
-	unsigned swab;
+	unsigned int start, length, location, result;
+	unsigned int possition, fragsize, blockmap, mask;
+	unsigned int swab;
 	
 	UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count))
 
@@ -668,7 +668,7 @@
 	else
 		start = ucpi->c_frotor >> 3;
 		
-	length = howmany(uspi->s_fpg, 8) - start;
+	length = ((uspi->s_fpg + 7) >> 3) - start;
 	location = ubh_scanc(UCPI_UBH, ucpi->c_freeoff + start, length,
 		(uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other,
 		1 << (count - 1 + (uspi->s_fpb & 7))); 
diff -u -r linux-22009/fs/ufs/dir.c linux-22009m/fs/ufs/dir.c
--- linux-22009/fs/ufs/dir.c	Sat Apr 24 07:20:38 1999
+++ linux-22009m/fs/ufs/dir.c	Sun May 16 15:41:22 1999
@@ -15,6 +15,7 @@
 
 #include <linux/fs.h>
 #include <linux/ufs_fs.h>
+#include <linux/unistd.h>
 
 #include "swab.h"
 #include "util.h"
@@ -172,13 +173,39 @@
 	if (error_msg != NULL)
 		ufs_error (sb, function, "bad entry in directory #%lu, size %lu: %s - "
 			    "offset=%lu, inode=%lu, reclen=%d, namlen=%d",
-			    dir->i_ino, dir->i_size, error_msg, offset,
+			    dir->i_ino, (u_long)dir->i_size, error_msg, offset,
 			    (unsigned long) SWAB32(de->d_ino),
 			    SWAB16(de->d_reclen), ufs_get_de_namlen(de));
 	
 	return (error_msg == NULL ? 1 : 0);
 }
 
+int ufs_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return UFS_MAXNAMLEN; /* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* UNIX semantics */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 64; /* FIXME: L-F-S:  mount-option: nolargefiles ? */
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return UFS_LINK_MAX;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
 static struct file_operations ufs_dir_operations = {
 	NULL,			/* lseek */
 	NULL,			/* read */
@@ -215,4 +242,7 @@
 	NULL,			/* truncate */
 	ufs_permission,		/* permission */
 	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	ufs_pathconf,		/* pathconf */
 };
diff -u -r linux-22009/fs/ufs/file.c linux-22009m/fs/ufs/file.c
--- linux-22009/fs/ufs/file.c	Thu Jan 14 20:31:41 1999
+++ linux-22009m/fs/ufs/file.c	Sun May 16 15:41:22 1999
@@ -66,6 +66,8 @@
 	NULL			/* revalidate */
 };
 
+extern int ufs_pathconf(struct inode *, int);
+
 struct inode_operations ufs_file_inode_operations = {
 	&ufs_file_operations,/* default file operations */
 	NULL,			/* create */
@@ -84,7 +86,10 @@
 	ufs_bmap,		/* bmap */
 	ufs_truncate,		/* truncate */
 	NULL, 			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	ufs_pathconf,		/* pathconf */
 };
 
 /*
diff -u -r linux-22009/fs/ufs/inode.c linux-22009m/fs/ufs/inode.c
--- linux-22009/fs/ufs/inode.c	Mon Jan 18 04:32:26 1999
+++ linux-22009m/fs/ufs/inode.c	Sun May 16 15:41:22 1999
@@ -54,7 +54,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);
@@ -212,14 +212,12 @@
 	*err = -EFBIG;
 	if (!create)
 		return NULL;
-	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);
 	lastblockoff = ufs_fragnum (lastfrag);
 	/*
@@ -321,7 +319,8 @@
 		brelse (result);
 		goto repeat;
 	}
-	if (!create || new_fragment >= (current->rlim[RLIMIT_FSIZE].rlim_cur >> sb->s_blocksize)) {
+	if (!create || (new_fragment >=
+			(current->rlimfsz.rlim_cur >> sb->s_blocksize_bits))) {
 		brelse (bh);
 		*err = -EFBIG;
 		return NULL;
@@ -496,13 +495,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);
@@ -515,7 +512,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))
 		inode->i_rdev = to_kdev_t(SWAB32(ufs_inode->ui_u2.ui_addr.ui_db[0]));
diff -u -r linux-22009/fs/ufs/super.c linux-22009m/fs/ufs/super.c
--- linux-22009/fs/ufs/super.c	Mon Apr 12 20:03:45 1999
+++ linux-22009m/fs/ufs/super.c	Sun May 16 15:41:22 1999
@@ -326,7 +326,7 @@
 	 * on the device. 
 	 */
 	size = uspi->s_cssize;
-	blks = howmany(size, uspi->s_fsize);
+	blks = (size + uspi->s_fsize-1) >> uspi->s_fshift;
 	base = space = kmalloc(size, GFP_KERNEL);
 	if (!base)
 		goto failed; 
@@ -403,7 +403,7 @@
 	uspi = sb->u.ufs_sb.s_uspi;
 
 	size = uspi->s_cssize;
-	blks = howmany(size, uspi->s_fsize);
+	blks = (size + uspi->s_fsize-1) >> uspi->s_fshift;
 	base = space = (char*) sb->u.ufs_sb.s_csp[0];
 	for (i = 0; i < blks; i += uspi->s_fpb) {
 		size = uspi->s_bsize;
@@ -874,28 +874,27 @@
 	return 0;
 }
 
-int ufs_statfs (struct super_block * sb, struct statfs * buf, int bufsiz)
+int ufs_statfs (struct super_block * sb, struct statfs64 * buf)
 {
 	struct ufs_sb_private_info * uspi;
 	struct ufs_super_block_first * usb1;
-	struct statfs tmp;
 	unsigned swab;
 
 	swab = sb->u.ufs_sb.s_swab;
 	uspi = sb->u.ufs_sb.s_uspi;
 	usb1 = ubh_get_usb_first (USPI_UBH);
 	
-	tmp.f_type = UFS_MAGIC;
-	tmp.f_bsize = sb->s_blocksize;
-	tmp.f_blocks = uspi->s_dsize;
-	tmp.f_bfree = ufs_blkstofrags(SWAB32(usb1->fs_cstotal.cs_nbfree)) +
+	buf->f_type = UFS_MAGIC;
+	buf->f_bsize = sb->s_blocksize;
+	buf->f_blocks = uspi->s_dsize;
+	buf->f_bfree = ufs_blkstofrags(SWAB32(usb1->fs_cstotal.cs_nbfree)) +
 		SWAB32(usb1->fs_cstotal.cs_nffree);
-	tmp.f_bavail = (tmp.f_bfree > ((tmp.f_blocks / 100) * uspi->s_minfree))
-		? (tmp.f_bfree - ((tmp.f_blocks / 100) * uspi->s_minfree)) : 0;
-	tmp.f_files = uspi->s_ncg * uspi->s_ipg;
-	tmp.f_ffree = SWAB32(usb1->fs_cstotal.cs_nifree);
-	tmp.f_namelen = UFS_MAXNAMLEN;
-	return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+	buf->f_bavail = (buf->f_bfree > ((uspi->s_dsize / 100) * uspi->s_minfree))
+		? (buf->f_bfree - ((uspi->s_dsize / 100) * uspi->s_minfree)) : 0;
+	buf->f_files = uspi->s_ncg * uspi->s_ipg;
+	buf->f_ffree = SWAB32(usb1->fs_cstotal.cs_nifree);
+	buf->f_namelen = UFS_MAXNAMLEN;
+	return 0;
 }
 
 static struct super_operations ufs_super_ops = {
diff -u -r linux-22009/fs/ufs/symlink.c linux-22009m/fs/ufs/symlink.c
--- linux-22009/fs/ufs/symlink.c	Thu Jan 14 20:31:41 1999
+++ linux-22009m/fs/ufs/symlink.c	Sun May 16 15:41:22 1999
@@ -116,6 +116,8 @@
 	return i;
 }
 
+extern int ufs_pathconf(struct inode *, int);
+
 struct inode_operations ufs_symlink_inode_operations = {
 	NULL,			/* no file-operations */
 	NULL,			/* create */
@@ -134,5 +136,8 @@
 	NULL,			/* bmap */
 	NULL,			/* truncate */
 	NULL,			/* permission */
-	NULL			/* smap */
+	NULL,			/* smap */
+	NULL,                   /* update page */
+        NULL,			/* revalidate */
+	ufs_pathconf,		/* pathconf */
 };
diff -u -r linux-22009/fs/ufs/truncate.c linux-22009m/fs/ufs/truncate.c
--- linux-22009/fs/ufs/truncate.c	Tue Sep  1 20:50:11 1998
+++ linux-22009m/fs/ufs/truncate.c	Sun May 16 15:41:22 1999
@@ -59,8 +59,8 @@
  *		Linus
  */
 
-#define DIRECT_BLOCK howmany (inode->i_size, uspi->s_bsize)
-#define DIRECT_FRAGMENT howmany (inode->i_size, uspi->s_fsize)
+#define DIRECT_BLOCK ((inode->i_size + uspi->s_bsize -1) >> uspi->s_bshift)
+#define DIRECT_FRAGMENT ((inode->i_size + uspi->s_fsize -1) >> uspi->s_fshift)
 
 static int ufs_trunc_direct (struct inode * inode)
 {
@@ -194,7 +194,7 @@
 }
 
 
-static int ufs_trunc_indirect (struct inode * inode, unsigned offset, u32 * p)
+static int ufs_trunc_indirect (struct inode * inode, u_long offset, u32 * p)
 {
 	struct super_block * sb;
 	struct ufs_sb_private_info * uspi;
@@ -297,7 +297,7 @@
 	struct super_block * sb;
 	struct ufs_sb_private_info * uspi;
 	struct ufs_buffer_head * dind_bh;
-	unsigned i, tmp, dindirect_block;
+	unsigned int i, tmp, dindirect_block;
 	u32 * dind;
 	int retry = 0;
 	unsigned swab;
@@ -308,8 +308,8 @@
 	swab = sb->u.ufs_sb.s_swab;
 	uspi = sb->u.ufs_sb.s_uspi;
 
-	dindirect_block = (DIRECT_BLOCK > offset) 
-		? ((DIRECT_BLOCK - offset) / uspi->s_apb) : 0;
+	dindirect_block = ((DIRECT_BLOCK > offset) ?
+			   ((DIRECT_BLOCK - offset) >> uspi->s_apbshift) : 0);
 	retry = 0;
 	
 	tmp = SWAB32(*p);
@@ -379,7 +379,7 @@
 	retry = 0;
 	
 	tindirect_block = (DIRECT_BLOCK > (UFS_NDADDR + uspi->s_apb + uspi->s_2apb))
-		? ((DIRECT_BLOCK - UFS_NDADDR - uspi->s_apb - uspi->s_2apb) / uspi->s_2apb) : 0;
+		? ((DIRECT_BLOCK - UFS_NDADDR - uspi->s_apb - uspi->s_2apb) >> uspi->s_2apbshift) : 0;
 	p = inode->u.ufs_i.i_u1.i_data + UFS_TIND_BLOCK;
 	if (!(tmp = SWAB32(*p)))
 		return 0;
@@ -467,7 +467,8 @@
 		}
 	}
 	inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-	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;
 	mark_inode_dirty(inode);
 	UFSD(("EXIT\n"))
 }
diff -u -r linux-22009/fs/ufs/util.h linux-22009m/fs/ufs/util.h
--- linux-22009/fs/ufs/util.h	Mon Apr 12 19:53:45 1999
+++ linux-22009m/fs/ufs/util.h	Mon May 17 01:39:45 1999
@@ -14,7 +14,6 @@
  * some useful macros
  */
 #define in_range(b,first,len)	((b)>=(first)&&(b)<(first)+(len))
-#define howmany(x,y)		(((x)+(y)-1)/(y))
 #define min(x,y)		((x)<(y)?(x):(y))
 #define max(x,y)		((x)>(y)?(x):(y))
 
diff -u -r linux-22009/fs/umsdos/dir.c linux-22009m/fs/umsdos/dir.c
--- linux-22009/fs/umsdos/dir.c	Sun May  9 03:56:37 1999
+++ linux-22009m/fs/umsdos/dir.c	Sun May 16 15:41:22 1999
@@ -16,6 +16,7 @@
 #include <linux/limits.h>
 #include <linux/umsdos_fs.h>
 #include <linux/malloc.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 
@@ -784,6 +785,32 @@
 	goto out_free;
 }	
 
+static int umsdos_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return 256;	/* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* Semantics ??? */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
+
 
 static struct file_operations umsdos_dir_operations =
 {
@@ -822,4 +849,5 @@
 	NULL,			/* smap */
 	NULL,			/* updatepage */
 	NULL,			/* revalidate */
+	umsdos_pathconf,	/* pathconf */
 };
diff -u -r linux-22009/fs/vfat/namei.c linux-22009m/fs/vfat/namei.c
--- linux-22009/fs/vfat/namei.c	Sun May  9 03:56:37 1999
+++ linux-22009m/fs/vfat/namei.c	Sun May 16 15:41:22 1999
@@ -23,6 +23,7 @@
 #include <linux/stat.h>
 #include <linux/mm.h>
 #include <linux/malloc.h>
+#include <linux/unistd.h>
 
 #include "../fat/msbuffer.h"
 
@@ -1695,6 +1696,31 @@
 
 }
 
+static int vfat_pathconf(struct inode *inode, int option)
+{
+	switch (option) {
+	case _PC_NAME_MAX:	/* POSIX.1: Directory only */
+	  return 256;	/* name component max length */
+	case _PC_NO_TRUNC:
+	  return 1;		/* Semantics ??? */
+
+	case _PC_FILESIZEBITS:	/* LFS: Regular files, and dirs */
+	  return 32;
+
+	case _PC_LINK_MAX:	/* POSIX.1: regular files and dirs */
+	  return 1;
+
+	case _PC_CHOWN_RESTRICTED: /* POSIX.1: Any file, any dir */
+	  break;		/* FIXME: some mount-option ??? */
+
+	case _PC_SYNC_IO:	/* POSIX.4: Regular files only ? */
+	case _PC_ASYNC_IO: /* TTY only ?? */
+	  break;
+	default:
+	  break;
+	}
+	return -EINVAL; /* Unknown thing! */
+}
 
 
 /* Public inode operations for the VFAT fs */
@@ -1715,7 +1741,11 @@
 	NULL,			/* writepage */
 	NULL,			/* bmap */
 	NULL,			/* truncate */
-	NULL			/* permission */
+	NULL,			/* permission */
+	NULL,			/* smap */
+	NULL,			/* updatepage */
+	NULL,			/* revalidate */
+	vfat_pathconf,		/* pathconf */
 };
 
 
diff -u -r linux-22009/include/asm-alpha/fcntl.h linux-22009m/include/asm-alpha/fcntl.h
--- linux-22009/include/asm-alpha/fcntl.h	Wed Oct 21 20:02:48 1998
+++ linux-22009m/include/asm-alpha/fcntl.h	Sun May 16 15:41:22 1999
@@ -20,6 +20,7 @@
 #define O_DIRECT	040000	/* direct disk access - should check with OSF/1 */
 #define O_DIRECTORY	0100000	/* must be a directory */
 #define O_NOFOLLOW	0200000 /* don't follow links */
+#define O_LARGEFILE     0400000 /* 64-bit offsets ok -- default at Alpha */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get f_flags */
@@ -35,6 +36,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -60,6 +65,14 @@
 	__kernel_off_t l_start;
 	__kernel_off_t l_len;
 	__kernel_pid_t l_pid;
+};
+
+struct flock64 {
+	int     l_type;
+	int     l_whence;
+	off64_t l_start;
+	off64_t l_len;
+	int     l_pid;
 };
 
 #endif
diff -u -r linux-22009/include/asm-alpha/posix_types.h linux-22009m/include/asm-alpha/posix_types.h
--- linux-22009/include/asm-alpha/posix_types.h	Fri Aug 21 16:33:36 1998
+++ linux-22009m/include/asm-alpha/posix_types.h	Sun May 16 15:41:22 1999
@@ -9,9 +9,11 @@
 
 typedef unsigned int	__kernel_dev_t;
 typedef unsigned int	__kernel_ino_t;
+typedef unsigned long	__kernel_ino64_t;
 typedef unsigned int	__kernel_mode_t;
 typedef unsigned int	__kernel_nlink_t;
 typedef long		__kernel_off_t;
+typedef long		__kernel_off64_t;
 typedef int		__kernel_pid_t;
 typedef int		__kernel_ipc_pid_t;
 typedef unsigned int	__kernel_uid_t;
diff -u -r linux-22009/include/asm-alpha/stat.h linux-22009m/include/asm-alpha/stat.h
--- linux-22009/include/asm-alpha/stat.h	Mon Sep 30 17:42:43 1996
+++ linux-22009m/include/asm-alpha/stat.h	Sun May 16 15:41:22 1999
@@ -1,24 +1,6 @@
 #ifndef _ALPHA_STAT_H
 #define _ALPHA_STAT_H
 
-struct __old_kernel_stat {
-	unsigned int	st_dev;
-	unsigned int	st_ino;
-	unsigned int	st_mode;
-	unsigned int	st_nlink;
-	unsigned int	st_uid;
-	unsigned int	st_gid;
-	unsigned int	st_rdev;
-	long		st_size;
-	unsigned long	st_atime;
-	unsigned long	st_mtime;
-	unsigned long	st_ctime;
-	unsigned int	st_blksize;
-	int		st_blocks;
-	unsigned int	st_flags;
-	unsigned int	st_gen;
-};
-
 struct stat {
 	unsigned int	st_dev;
 	unsigned int	st_ino;
@@ -36,5 +18,4 @@
 	unsigned int	st_flags;
 	unsigned int	st_gen;
 };
-
 #endif
diff -u -r linux-22009/include/asm-alpha/statfs.h linux-22009m/include/asm-alpha/statfs.h
--- linux-22009/include/asm-alpha/statfs.h	Sun Aug 18 10:42:02 1996
+++ linux-22009m/include/asm-alpha/statfs.h	Sun May 16 15:41:22 1999
@@ -22,4 +22,17 @@
 	int f_spare[6];
 };
 
+struct statfs64 {
+	int f_type;
+	int f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	int f_namelen;
+	int f_spare[6];
+};
+
 #endif
diff -u -r linux-22009/include/asm-alpha/unistd.h linux-22009m/include/asm-alpha/unistd.h
--- linux-22009/include/asm-alpha/unistd.h	Thu Jan 21 21:26:30 1999
+++ linux-22009m/include/asm-alpha/unistd.h	Sun May 16 15:41:22 1999
@@ -308,6 +308,16 @@
 #define __NR_capget			368
 #define __NR_capset			369
 #define __NR_sendfile			370
+#define __NR_stat64			371
+#define __NR_lstat64			372
+#define __NR_fstat64			373
+#define __NR_statfs64			374
+#define __NR_fstatfs64			375
+#define __NR_getdents64			376
+#define __NR_msgctl32			377
+#define __NR_sysconf			378
+#define __NR_pathconf			379
+#define __NR_fpathconf			380
 
 #if defined(__LIBRARY__) && defined(__GNUC__)
 
diff -u -r linux-22009/include/asm-arm/fcntl.h linux-22009m/include/asm-arm/fcntl.h
--- linux-22009/include/asm-arm/fcntl.h	Wed Oct 21 23:30:46 1998
+++ linux-22009m/include/asm-arm/fcntl.h	Sun May 16 15:41:22 1999
@@ -18,6 +18,7 @@
 #define FASYNC		020000	/* fcntl, for BSD compatibility */
 #define O_DIRECTORY	040000	/* must be a directory */
 #define O_NOFOLLOW	0100000	/* don't follow links */
+#define O_LARGEFILE	0200000 /* file sizes exceeding 32-bit signed value */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get f_flags */
@@ -33,6 +34,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -58,6 +63,14 @@
 	off_t l_start;
 	off_t l_len;
 	pid_t l_pid;
+};
+
+struct flock64 {
+	int    l_type;
+	int    l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	int    l_pid;
 };
 
 #endif
diff -u -r linux-22009/include/asm-arm/posix_types.h linux-22009m/include/asm-arm/posix_types.h
--- linux-22009/include/asm-arm/posix_types.h	Sat May  8 21:06:57 1999
+++ linux-22009m/include/asm-arm/posix_types.h	Sun May 16 15:41:22 1999
@@ -17,9 +17,11 @@
 
 typedef unsigned short		__kernel_dev_t;
 typedef unsigned long		__kernel_ino_t;
+typedef unsigned long long	__kernel_ino64_t;
 typedef unsigned short		__kernel_mode_t;
 typedef unsigned short		__kernel_nlink_t;
 typedef long			__kernel_off_t;
+typedef long long		__kernel_off64_t;
 typedef int			__kernel_pid_t;
 typedef unsigned short		__kernel_ipc_pid_t;
 typedef unsigned short		__kernel_uid_t;
diff -u -r linux-22009/include/asm-arm/stat.h linux-22009m/include/asm-arm/stat.h
--- linux-22009/include/asm-arm/stat.h	Wed Aug  5 02:07:17 1998
+++ linux-22009m/include/asm-arm/stat.h	Sun May 16 15:41:22 1999
@@ -1,20 +1,6 @@
 #ifndef _ASMARM_STAT_H
 #define _ASMARM_STAT_H
 
-struct __old_kernel_stat {
-	unsigned short st_dev;
-	unsigned short st_ino;
-	unsigned short st_mode;
-	unsigned short st_nlink;
-	unsigned short st_uid;
-	unsigned short st_gid;
-	unsigned short st_rdev;
-	unsigned long  st_size;
-	unsigned long  st_atime;
-	unsigned long  st_mtime;
-	unsigned long  st_ctime;
-};
-
 struct stat {
 	unsigned short st_dev;
 	unsigned short __pad1;
@@ -37,5 +23,4 @@
 	unsigned long  __unused4;
 	unsigned long  __unused5;
 };
-
 #endif
diff -u -r linux-22009/include/asm-arm/statfs.h linux-22009m/include/asm-arm/statfs.h
--- linux-22009/include/asm-arm/statfs.h	Wed Jan 21 02:39:43 1998
+++ linux-22009m/include/asm-arm/statfs.h	Sun May 16 15:41:22 1999
@@ -22,4 +22,17 @@
 	long f_spare[6];
 };
 
+struct statfs64 {
+	__u32 f_type;
+	__u32 f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	int f_namelen;
+	int f_spare[6];
+};
+
 #endif
diff -u -r linux-22009/include/asm-arm/unistd.h linux-22009m/include/asm-arm/unistd.h
--- linux-22009/include/asm-arm/unistd.h	Sat May  8 21:06:58 1999
+++ linux-22009m/include/asm-arm/unistd.h	Sun May 16 17:15:28 1999
@@ -198,6 +198,20 @@
 					/* 188 reserved */
 					/* 189 reserved */
 #define __NR_vfork			(__NR_SYSCALL_BASE+190)
+#define __NR_mmap64			(__NR_SYSCALL_BASE+191)
+#define __NR_setrlimit64		(__NR_SYSCALL_BASE+192)
+#define __NR_getrlimit64		(__NR_SYSCALL_BASE+193)
+#define __NR_truncate64			(__NR_SYSCALL_BASE+194)
+#define __NR_ftruncate64		(__NR_SYSCALL_BASE+195)
+#define __NR_stat64			(__NR_SYSCALL_BASE+196)
+#define __NR_lstat64			(__NR_SYSCALL_BASE+197)
+#define __NR_fstat64			(__NR_SYSCALL_BASE+200)
+#define __NR_getdents64			(__NR_SYSCALL_BASE+198)
+#define __NR_statfs64			(__NR_SYSCALL_BASE+199)
+#define __NR_fstatfs64			(__NR_SYSCALL_BASE+201)
+#define __NR_sysconf			(__NR_SYSCALL_BASE+202)
+#define __NR_pathconf			(__NR_SYSCALL_BASE+203)
+#define __NR_fpathconf			(__NR_SYSCALL_BASE+204)
 
 #define __sys2(x) #x
 #define __sys1(x) __sys2(x)
diff -u -r linux-22009/include/asm-i386/fcntl.h linux-22009m/include/asm-i386/fcntl.h
--- linux-22009/include/asm-i386/fcntl.h	Wed Oct 21 20:02:48 1998
+++ linux-22009m/include/asm-i386/fcntl.h	Sun May 16 15:41:22 1999
@@ -35,6 +35,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -60,6 +64,14 @@
 	off_t l_start;
 	off_t l_len;
 	pid_t l_pid;
+};
+
+struct flock64 {
+	int    l_type;
+	int    l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	int    l_pid;
 };
 
 #endif
diff -u -r linux-22009/include/asm-i386/posix_types.h linux-22009m/include/asm-i386/posix_types.h
--- linux-22009/include/asm-i386/posix_types.h	Sun Dec 27 20:39:50 1998
+++ linux-22009m/include/asm-i386/posix_types.h	Sun May 16 15:41:22 1999
@@ -9,9 +9,11 @@
 
 typedef unsigned short	__kernel_dev_t;
 typedef unsigned long	__kernel_ino_t;
+typedef unsigned long long __kernel_ino64_t;
 typedef unsigned short	__kernel_mode_t;
 typedef unsigned short	__kernel_nlink_t;
 typedef long		__kernel_off_t;
+typedef long long	__kernel_off64_t;
 typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
 typedef unsigned short	__kernel_uid_t;
diff -u -r linux-22009/include/asm-i386/stat.h linux-22009m/include/asm-i386/stat.h
--- linux-22009/include/asm-i386/stat.h	Mon Sep 30 17:42:31 1996
+++ linux-22009m/include/asm-i386/stat.h	Sun May 16 23:03:40 1999
@@ -38,4 +38,37 @@
 	unsigned long  __unused5;
 };
 
+
+/* This following structure matches GLIBC 2.1 on i386.
+   The things found in there are truly stupid, but never mind... */
+
+#define __ARCH_STRUCT_STAT64
+
+struct stat64
+  {
+    __u64 st_dev;			/* Device.  */
+	    __u16 __pad1; /* Matches glibc 2.1 - stupid .. */
+
+    __u32 st_ino; /* Should be 64-bits!*/ /* File serial number.	*/
+    __u32 st_mode;			/* File mode.  */
+    __u32 st_nlink;			/* Link count.  */
+    __u32 st_uid;			/* User ID of the file's owner.	*/
+    __u32 st_gid;			/* Group ID of the file's group.*/
+    __u64 st_rdev;			/* Device number, if device.  */
+	    __u16 __pad2;
+    __u64 st_size;			/* Size of file, in bytes.  */
+    __u32 st_blksize;	/* Optimal block size for I/O.  */
+
+    __u64 st_blocks;		/* Number 512-byte blocks allocated. */
+    __s32 st_atime;			/* Time of last access.  */
+    __u32 __unused1;
+    __s32 st_mtime;			/* Time of last modification.  */
+    __u32 __unused2;
+    __s32 st_ctime;			/* Time of last status change.  */
+    __u32 __unused3;
+    __u32 __unused4;
+    __u32 __unused5;
+  };
+
 #endif
+
diff -u -r linux-22009/include/asm-i386/statfs.h linux-22009m/include/asm-i386/statfs.h
--- linux-22009/include/asm-i386/statfs.h	Mon Dec 28 08:18:28 1998
+++ linux-22009m/include/asm-i386/statfs.h	Mon May 17 00:39:54 1999
@@ -22,4 +22,17 @@
 	long f_spare[6];
 };
 
+struct statfs64 {
+	__u32 f_type;
+	__u32 f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	int f_namelen;
+	int f_spare[6];
+};
+
 #endif
diff -u -r linux-22009/include/asm-i386/unistd.h linux-22009m/include/asm-i386/unistd.h
--- linux-22009/include/asm-i386/unistd.h	Wed Jan 20 21:06:24 1999
+++ linux-22009m/include/asm-i386/unistd.h	Sun May 16 15:41:22 1999
@@ -195,6 +195,20 @@
 #define __NR_getpmsg		188	/* some people actually want streams */
 #define __NR_putpmsg		189	/* some people actually want streams */
 #define __NR_vfork		190
+#define __NR_setrlimit64	191
+#define __NR_getrlimit64	192
+#define __NR_truncate64		193
+#define __NR_ftruncate64	194
+#define __NR_stat64		195
+#define __NR_lstat64		196
+#define __NR_fstat64		197
+#define __NR_statfs64		198
+#define __NR_fstatfs64		199
+#define __NR_getdents64		200
+#define __NR_mmap64		201
+#define __NR_sysconf		202
+#define __NR_pathconf		203
+#define __NR_fpathconf		204
 
 /* user-visible error numbers are in the range -1 - -122: see <asm-i386/errno.h> */
 
diff -u -r linux-22009/include/asm-m68k/fcntl.h linux-22009m/include/asm-m68k/fcntl.h
--- linux-22009/include/asm-m68k/fcntl.h	Wed Oct 21 23:30:56 1998
+++ linux-22009m/include/asm-m68k/fcntl.h	Sun May 16 15:41:22 1999
@@ -18,6 +18,7 @@
 #define FASYNC		020000	/* fcntl, for BSD compatibility */
 #define O_DIRECTORY	040000	/* must be a directory */
 #define O_NOFOLLOW	0100000	/* don't follow links */
+#define O_LARGEFILE	0200000 /* file sizes exceeding 32-bit signed value */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get f_flags */
@@ -33,6 +34,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -58,6 +63,14 @@
 	off_t l_start;
 	off_t l_len;
 	pid_t l_pid;
+};
+
+struct flock64 {
+	int    l_type;
+	int    l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	int    l_pid;
 };
 
 #endif /* _M68K_FCNTL_H */
diff -u -r linux-22009/include/asm-m68k/posix_types.h linux-22009m/include/asm-m68k/posix_types.h
--- linux-22009/include/asm-m68k/posix_types.h	Mon Aug 10 21:02:24 1998
+++ linux-22009m/include/asm-m68k/posix_types.h	Sun May 16 15:41:22 1999
@@ -9,9 +9,11 @@
 
 typedef unsigned short	__kernel_dev_t;
 typedef unsigned long	__kernel_ino_t;
+typedef unsigned long long __kernel_ino64_t;
 typedef unsigned short	__kernel_mode_t;
 typedef unsigned short	__kernel_nlink_t;
 typedef long		__kernel_off_t;
+typedef long long	__kernel_off64_t;
 typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
 typedef unsigned short	__kernel_uid_t;
diff -u -r linux-22009/include/asm-m68k/statfs.h linux-22009m/include/asm-m68k/statfs.h
--- linux-22009/include/asm-m68k/statfs.h	Mon Jun  3 10:09:13 1996
+++ linux-22009m/include/asm-m68k/statfs.h	Sun May 16 15:41:22 1999
@@ -22,4 +22,17 @@
 	long f_spare[6];
 };
 
+struct statfs64 {
+	__u32 f_type;
+	__u32 f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	int f_namelen;
+	int f_spare[6];
+};
+
 #endif /* _M68K_STATFS_H */
diff -u -r linux-22009/include/asm-m68k/unistd.h linux-22009m/include/asm-m68k/unistd.h
--- linux-22009/include/asm-m68k/unistd.h	Tue Jan 19 20:58:34 1999
+++ linux-22009m/include/asm-m68k/unistd.h	Sun May 16 15:41:22 1999
@@ -194,6 +194,20 @@
 #define __NR_getpmsg		188	/* some people actually want streams */
 #define __NR_putpmsg		189	/* some people actually want streams */
 #define __NR_vfork		190
+#define __NR_setrlimit64	191
+#define __NR_getrlimit64	192
+#define __NR_truncate64		193
+#define __NR_ftruncate64	194
+#define __NR_stat64		195
+#define __NR_lstat64		196
+#define __NR_fstat64		197
+#define __NR_statfs64		198
+#define __NR_fstatfs64		199
+#define __NR_getdents64		200
+#define __NR_mmap64		201
+#define __NR_sysconf		202
+#define __NR_pathconf		203
+#define __NR_fpathconf		204
 
 /* user-visible error numbers are in the range -1 - -122: see
    <asm-m68k/errno.h> */
diff -u -r linux-22009/include/asm-mips/fcntl.h linux-22009m/include/asm-mips/fcntl.h
--- linux-22009/include/asm-mips/fcntl.h	Wed Oct 21 20:04:28 1998
+++ linux-22009m/include/asm-mips/fcntl.h	Sun May 16 15:41:22 1999
@@ -44,6 +44,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -72,5 +76,15 @@
 	__kernel_pid_t l_pid;
 	long  pad[4];			/* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
 } flock_t;
+
+typedef struct flock64 {
+	int   l_type;
+	int   l_whence;
+	__kernel_loff_t l_start;
+	__kernel_loff_t l_len;
+	long  l_sysid;			/* XXXXXXXXXXXXXXXXXXXXXXXXX */
+	__kernel_pid_t l_pid;
+	long  pad[4];			/* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
+} flock64_t;
 
 #endif /* __ASM_MIPS_FCNTL_H */
diff -u -r linux-22009/include/asm-mips/posix_types.h linux-22009m/include/asm-mips/posix_types.h
--- linux-22009/include/asm-mips/posix_types.h	Tue Oct 20 23:52:53 1998
+++ linux-22009m/include/asm-mips/posix_types.h	Sun May 16 15:41:22 1999
@@ -21,9 +21,11 @@
 
 typedef unsigned long	__kernel_dev_t;
 typedef unsigned long	__kernel_ino_t;
+typedef unsigned long long __kernel_ino64_t;
 typedef unsigned long	__kernel_mode_t;
 typedef unsigned long	__kernel_nlink_t;
 typedef long		__kernel_off_t;
+typedef long long	__kernel_off64_t;
 typedef long		__kernel_pid_t;
 typedef long		__kernel_ipc_pid_t;
 typedef long		__kernel_uid_t;
diff -u -r linux-22009/include/asm-mips/stat.h linux-22009m/include/asm-mips/stat.h
--- linux-22009/include/asm-mips/stat.h	Thu Jun 26 22:33:40 1997
+++ linux-22009m/include/asm-mips/stat.h	Sun May 16 15:41:22 1999
@@ -3,24 +3,6 @@
 
 #include <linux/types.h>
 
-struct __old_kernel_stat {
-	unsigned int	st_dev;
-	unsigned int	st_ino;
-	unsigned int	st_mode;
-	unsigned int	st_nlink;
-	unsigned int	st_uid;
-	unsigned int	st_gid;
-	unsigned int	st_rdev;
-	long		st_size;
-	unsigned int	st_atime, st_res1;
-	unsigned int	st_mtime, st_res2;
-	unsigned int	st_ctime, st_res3;
-	unsigned int	st_blksize;
-	int		st_blocks;
-	unsigned int	st_flags;
-	unsigned int	st_gen;
-};
-
 struct stat {
 	dev_t		st_dev;
 	long		st_pad1[3];		/* Reserved for network id */
@@ -51,5 +33,4 @@
 	unsigned int	st_flags;
 	unsigned int	st_gen;
 };
-
 #endif /* __ASM_MIPS_STAT_H */
diff -u -r linux-22009/include/asm-mips/statfs.h linux-22009m/include/asm-mips/statfs.h
--- linux-22009/include/asm-mips/statfs.h	Thu Jun 26 22:33:40 1997
+++ linux-22009m/include/asm-mips/statfs.h	Sun May 16 15:41:22 1999
@@ -37,4 +37,21 @@
 	long		f_spare[6];
 };
 
+struct statfs64 {
+	long		f_type;
+#define f_fstyp f_type
+	long		f_bsize;
+	__u64		f_frsize;	/* Fragment size - unsupported */
+	__u64		f_blocks;
+	__u64		f_bfree;
+	__u64		f_files;
+	__u64		f_ffree;
+
+	/* Linux specials */
+	__u64		f_bavail;
+	__kernel_fsid_t	f_fsid;
+	long		f_namelen;
+	long		f_spare[6];
+};
+
 #endif /* __ASM_MIPS_STATFS_H */
diff -u -r linux-22009/include/asm-mips/unistd.h linux-22009m/include/asm-mips/unistd.h
--- linux-22009/include/asm-mips/unistd.h	Tue Oct 20 23:52:54 1998
+++ linux-22009m/include/asm-mips/unistd.h	Sun May 16 15:41:22 1999
@@ -1196,6 +1196,21 @@
 #define __NR_sendfile			(__NR_Linux + 207)
 #define __NR_getpmsg			(__NR_Linux + 208)
 #define __NR_putpmsg			(__NR_Linux + 209)
+#define __NR_mmap64			(__NR_Linux + 210)
+#define __NR_setrlimit64		(__NR_Linux + 211)
+#define __NR_getrlimit64		(__NR_Linux + 212)
+#define __NR_truncate64			(__NR_Linux + 213)
+#define __NR_ftruncate64		(__NR_Linux + 214)
+#define __NR_stat64			(__NR_Linux + 215)
+#define __NR_lstat64			(__NR_Linux + 216)
+#define __NR_fstat64			(__NR_Linux + 217)
+#define __NR_statfs64			(__NR_Linux + 218)
+#define __NR_fstatfs64			(__NR_Linux + 219)
+#define __NR_getdents64			(__NR_Linux + 220)
+#define __NR_sysconf			(__NR_Linux + 221)
+#define __NR_pathconf			(__NR_Linux + 222)
+#define __NR_fpathconf			(__NR_Linux + 223)
+
 
 /*
  * Offset of the last Linux flavoured syscall
diff -u -r linux-22009/include/asm-ppc/fcntl.h linux-22009m/include/asm-ppc/fcntl.h
--- linux-22009/include/asm-ppc/fcntl.h	Wed Oct 21 23:31:06 1998
+++ linux-22009m/include/asm-ppc/fcntl.h	Sun May 16 15:41:22 1999
@@ -18,6 +18,7 @@
 #define FASYNC		020000	/* fcntl, for BSD compatibility */
 #define O_DIRECTORY	040000	/* must be a directory */
 #define O_NOFOLLOW	0100000	/* don't follow links */
+#define O_LARGEFILE	0200000 /* file sizes exceeding 'off_t' */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get f_flags */
@@ -33,6 +34,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -64,6 +69,14 @@
 	off_t l_start;
 	off_t l_len;
 	pid_t l_pid;
+};
+
+struct flock64 {
+	int    l_type;
+	int    l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	int    l_pid;
 };
 
 #endif
diff -u -r linux-22009/include/asm-ppc/posix_types.h linux-22009m/include/asm-ppc/posix_types.h
--- linux-22009/include/asm-ppc/posix_types.h	Thu Apr 29 22:39:01 1999
+++ linux-22009m/include/asm-ppc/posix_types.h	Sun May 16 15:41:22 1999
@@ -9,9 +9,11 @@
 
 typedef unsigned int	__kernel_dev_t;
 typedef unsigned int	__kernel_ino_t;
+typedef unsigned long long __kernel_ino64_t;
 typedef unsigned int	__kernel_mode_t;
 typedef unsigned short	__kernel_nlink_t;
 typedef long		__kernel_off_t;
+typedef long long	__kernel_off64_t;
 typedef int		__kernel_pid_t;
 typedef unsigned int	__kernel_uid_t;
 typedef unsigned int	__kernel_gid_t;
diff -u -r linux-22009/include/asm-ppc/stat.h linux-22009m/include/asm-ppc/stat.h
--- linux-22009/include/asm-ppc/stat.h	Wed Aug  5 02:06:36 1998
+++ linux-22009m/include/asm-ppc/stat.h	Sun May 16 15:41:22 1999
@@ -3,19 +3,6 @@
 
 #include <linux/types.h>
 
-struct __old_kernel_stat {
-	unsigned short st_dev;
-	unsigned short st_ino;
-	unsigned short st_mode;
-	unsigned short st_nlink;
-	unsigned short st_uid;
-	unsigned short st_gid;
-	unsigned short st_rdev;
-	unsigned long  st_size;
-	unsigned long  st_atime;
-	unsigned long  st_mtime;
-	unsigned long  st_ctime;
-};
 struct stat {
 	dev_t		st_dev;
 	ino_t		st_ino;
@@ -36,5 +23,4 @@
 	unsigned long  	__unused4;
 	unsigned long  	__unused5;
 };
-
 #endif
diff -u -r linux-22009/include/asm-ppc/statfs.h linux-22009m/include/asm-ppc/statfs.h
--- linux-22009/include/asm-ppc/statfs.h	Mon Jun  3 10:09:13 1996
+++ linux-22009m/include/asm-ppc/statfs.h	Sun May 16 15:41:22 1999
@@ -22,6 +22,19 @@
 	long f_spare[6];
 };
 
+struct statfs64 {
+	long f_type;
+	long f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	long f_namelen;
+	long f_spare[6];
+};
+
 #endif
 
 
diff -u -r linux-22009/include/asm-ppc/unistd.h linux-22009m/include/asm-ppc/unistd.h
--- linux-22009/include/asm-ppc/unistd.h	Thu Mar 11 07:30:32 1999
+++ linux-22009m/include/asm-ppc/unistd.h	Sun May 16 15:41:22 1999
@@ -194,6 +194,20 @@
 #define __NR_getpmsg		187	/* some people actually want streams */
 #define __NR_putpmsg		188	/* some people actually want streams */
 #define __NR_vfork		189
+#define __NR_mmap64		190	/* LFS stuff */
+#define __NR_setrlimit64	191
+#define __NR_getrlimit64	192
+#define __NR_truncate64		193
+#define __NR_ftruncate64	194
+#define __NR_stat64		195
+#define __NR_lstat64		196
+#define __NR_fstat64		197
+#define __NR_statfs64		198
+#define __NR_fstatfs64		199
+#define __NR_getdents64		200
+#define __NR_sysconf		201
+#define __NR_pathconf		202
+#define __NR_fpathconf		203
 
 #define __NR(n)	#n
 
diff -u -r linux-22009/include/asm-sparc/fcntl.h linux-22009m/include/asm-sparc/fcntl.h
--- linux-22009/include/asm-sparc/fcntl.h	Tue Oct 27 19:52:21 1998
+++ linux-22009m/include/asm-sparc/fcntl.h	Sun May 16 15:41:22 1999
@@ -19,6 +19,7 @@
 #define O_NOCTTY	0x8000	/* not fcntl */
 #define O_DIRECTORY	0x10000	/* must be a directory */
 #define O_NOFOLLOW	0x20000	/* don't follow links */
+#define O_LARGEFILE	0x40000 /* file sizes exceeding 'off_t' range (2G) */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get f_flags */
@@ -33,6 +34,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -59,6 +64,14 @@
 	off_t l_len;
 	pid_t l_pid;
 	short __unused;
+};
+
+struct flock64 {
+	int    l_type;
+	int    l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	int    l_pid;
 };
 
 #endif
diff -u -r linux-22009/include/asm-sparc/posix_types.h linux-22009m/include/asm-sparc/posix_types.h
--- linux-22009/include/asm-sparc/posix_types.h	Thu Mar 11 02:53:37 1999
+++ linux-22009m/include/asm-sparc/posix_types.h	Sun May 16 15:41:22 1999
@@ -25,11 +25,13 @@
 typedef unsigned short         __kernel_gid_t;
 typedef unsigned short         __kernel_dev_t;
 typedef unsigned long          __kernel_ino_t;
+typedef unsigned long long     __kernel_ino64_t;
 typedef unsigned short         __kernel_mode_t;
 typedef unsigned short         __kernel_umode_t;
 typedef short                  __kernel_nlink_t;
 typedef long                   __kernel_daddr_t;
 typedef long                   __kernel_off_t;
+typedef long long              __kernel_off64_t;
 typedef char *                 __kernel_caddr_t;
 
 #ifdef __GNUC__
diff -u -r linux-22009/include/asm-sparc/stat.h linux-22009m/include/asm-sparc/stat.h
--- linux-22009/include/asm-sparc/stat.h	Wed Aug  5 02:03:35 1998
+++ linux-22009m/include/asm-sparc/stat.h	Sun May 16 15:41:22 1999
@@ -4,20 +4,6 @@
 
 #include <linux/types.h>
 
-struct __old_kernel_stat {
-	unsigned short st_dev;
-	unsigned short st_ino;
-	unsigned short st_mode;
-	unsigned short st_nlink;
-	unsigned short st_uid;
-	unsigned short st_gid;
-	unsigned short st_rdev;
-	unsigned long  st_size;
-	unsigned long  st_atime;
-	unsigned long  st_mtime;
-	unsigned long  st_ctime;
-};
-
 struct stat {
 	dev_t   st_dev;
 	ino_t   st_ino;
@@ -37,5 +23,4 @@
 	off_t   st_blocks;
 	unsigned long  __unused4[2];
 };
-
 #endif
diff -u -r linux-22009/include/asm-sparc/statfs.h linux-22009m/include/asm-sparc/statfs.h
--- linux-22009/include/asm-sparc/statfs.h	Sat Nov  9 21:39:33 1996
+++ linux-22009m/include/asm-sparc/statfs.h	Sun May 16 15:41:22 1999
@@ -23,4 +23,17 @@
 	long f_spare[6];
 };
 
+struct statfs64 {
+	long f_type;
+	long f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	long f_namelen;  /* SunOS ignores this field. */
+	long f_spare[6];
+};
+
 #endif
diff -u -r linux-22009/include/asm-sparc64/fcntl.h linux-22009m/include/asm-sparc64/fcntl.h
--- linux-22009/include/asm-sparc64/fcntl.h	Tue Oct 27 19:52:21 1998
+++ linux-22009m/include/asm-sparc64/fcntl.h	Sun May 16 15:41:22 1999
@@ -19,6 +19,7 @@
 #define O_NOCTTY	0x8000	/* not fcntl */
 #define O_DIRECTORY	0x10000	/* must be a directory */
 #define O_NOFOLLOW	0x20000	/* don't follow links */
+#define O_LARGEFILE	0x40000 /* file sizes exceeding 'off_t' range (2G) */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get f_flags */
@@ -33,6 +34,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	12	/*  using 'struct flock64' */
+#define F_SETLK64	13
+#define F_SETLKW64	14
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -71,5 +76,13 @@
 	short __unused;
 };
 #endif
+
+struct flock64 {
+	int    l_type;
+	int    l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	int    l_pid;
+};
 
 #endif /* !(_SPARC64_FCNTL_H) */
diff -u -r linux-22009/include/asm-sparc64/posix_types.h linux-22009m/include/asm-sparc64/posix_types.h
--- linux-22009/include/asm-sparc64/posix_types.h	Thu Mar 11 02:53:38 1999
+++ linux-22009m/include/asm-sparc64/posix_types.h	Sun May 16 15:41:22 1999
@@ -23,11 +23,13 @@
 typedef unsigned int           __kernel_gid_t;
 typedef unsigned int           __kernel_dev_t;
 typedef unsigned long          __kernel_ino_t;
+typedef unsigned long          __kernel_ino64_t;
 typedef unsigned int           __kernel_mode_t;
 typedef unsigned short         __kernel_umode_t;
 typedef unsigned int           __kernel_nlink_t;
 typedef int                    __kernel_daddr_t;
 typedef long                   __kernel_off_t;
+typedef long                   __kernel_off64_t;
 typedef char *                 __kernel_caddr_t;
 
 /* Note this piece of asymmetry from the v9 ABI.  */
diff -u -r linux-22009/include/asm-sparc64/statfs.h linux-22009m/include/asm-sparc64/statfs.h
--- linux-22009/include/asm-sparc64/statfs.h	Thu Apr 24 05:01:28 1997
+++ linux-22009m/include/asm-sparc64/statfs.h	Sun May 16 15:41:22 1999
@@ -36,4 +36,17 @@
 	long f_spare[6];
 };
 
+struct statfs64 {
+	long f_type;
+	long f_bsize;
+	__u64 f_blocks;
+	__u64 f_bfree;
+	__u64 f_bavail;
+	__u64 f_files;
+	__u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	long f_namelen;
+	long f_spare[6];
+};
+
 #endif
diff -u -r linux-22009/include/linux/dirent.h linux-22009m/include/linux/dirent.h
--- linux-22009/include/linux/dirent.h	Wed Jul 10 07:38:08 1996
+++ linux-22009m/include/linux/dirent.h	Sun May 16 15:41:22 1999
@@ -8,4 +8,11 @@
 	char		d_name[256]; /* We must not include limits.h! */
 };
 
+struct dirent64 {
+	long long	d_ino;		/* 32 bits *should* be enough */
+	__kernel_off_t	d_off;
+	unsigned short	d_reclen;
+	char		d_name[256];	/* We must not include limits.h! */
+};
+
 #endif
diff -u -r linux-22009/include/linux/ext2_fs.h linux-22009m/include/linux/ext2_fs.h
--- linux-22009/include/linux/ext2_fs.h	Sat Apr 24 07:20:38 1999
+++ linux-22009m/include/linux/ext2_fs.h	Mon May 17 00:39:54 1999
@@ -596,7 +596,7 @@
 extern int ext2_remount (struct super_block *, int *, char *);
 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
 extern int init_ext2_fs(void);
-extern int ext2_statfs (struct super_block *, struct statfs *, int);
+extern int ext2_statfs (struct super_block *, struct statfs64 *);
 
 /* truncate.c */
 extern void ext2_truncate (struct inode *);
diff -u -r linux-22009/include/linux/fat_cvf.h linux-22009m/include/linux/fat_cvf.h
--- linux-22009/include/linux/fat_cvf.h	Fri Jan  9 00:02:41 1998
+++ linux-22009m/include/linux/fat_cvf.h	Sun May 16 15:41:23 1999
@@ -25,7 +25,7 @@
                         int nbreq,
                         struct buffer_head *bh[32]);
   int (*fat_access) (struct super_block *sb,int nr,int new_value);
-  int (*cvf_statfs) (struct super_block *sb,struct statfs *buf, int bufsiz);
+  int (*cvf_statfs) (struct super_block *sb,struct statfs64 *buf);
   int (*cvf_bmap) (struct inode *inode,int block);
   int (*cvf_smap) (struct inode *inode,int sector);
   ssize_t (*cvf_file_read) ( struct file *, char *, size_t, loff_t *);
diff -u -r linux-22009/include/linux/fs.h linux-22009m/include/linux/fs.h
--- linux-22009/include/linux/fs.h	Tue May 11 20:35:44 1999
+++ linux-22009m/include/linux/fs.h	Mon May 17 00:40:00 1999
@@ -257,6 +257,25 @@
 #define buffer_page(bh)		(mem_map + MAP_NR((bh)->b_data))
 #define touch_buffer(bh)	set_bit(PG_referenced, &buffer_page(bh)->flags)
 
+/* log of base-2 for filesystem uses, in case their super-blocks
+   don't have the shift counts readily calculated.. -- presuming
+   the divisors in question are power-of-two values! */
+static int fslog2(unsigned long val) __attribute__ ((const));
+static __inline__ int fslog2(unsigned long val)
+{
+	int i;
+	for (i = 0; val != 0; ++i, val >>= 1) {
+	  if (val & 1) return i;
+	}
+	return 0;
+}
+
+static int off_t_presentable(loff_t) __attribute((const));
+static __inline__ int off_t_presentable(loff_t loff)
+{
+	return ((unsigned long long)loff < LONG_MAX);
+}
+
 #include <linux/pipe_fs_i.h>
 #include <linux/minix_fs_i.h>
 #include <linux/ext2_fs_i.h>
@@ -306,7 +325,7 @@
 	umode_t		ia_mode;
 	uid_t		ia_uid;
 	gid_t		ia_gid;
-	off_t		ia_size;
+	loff_t		ia_size;
 	time_t		ia_atime;
 	time_t		ia_mtime;
 	time_t		ia_ctime;
@@ -341,7 +360,7 @@
 	uid_t			i_uid;
 	gid_t			i_gid;
 	kdev_t			i_rdev;
-	off_t			i_size;
+	loff_t			i_size;
 	time_t			i_atime;
 	time_t			i_mtime;
 	time_t			i_ctime;
@@ -417,7 +436,7 @@
 	mode_t			f_mode;
 	loff_t			f_pos;
 	unsigned int 		f_count, f_flags;
-	unsigned long 		f_reada, f_ramax, f_raend, f_ralen, f_rawin;
+	loff_t			f_reada, f_ramax, f_raend, f_ralen, f_rawin;
 	struct fown_struct	f_owner;
 	unsigned int		f_uid, f_gid;
 	int			f_error;
@@ -457,8 +476,8 @@
 	struct file *fl_file;
 	unsigned char fl_flags;
 	unsigned char fl_type;
-	off_t fl_start;
-	off_t fl_end;
+	loff_t fl_start;
+	loff_t fl_end;
 
 	void (*fl_notify)(struct file_lock *);	/* unblock callback */
 
@@ -474,6 +493,9 @@
 extern int fcntl_getlk(unsigned int fd, struct flock *l);
 extern int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l);
 
+extern int fcntl_getlk64(unsigned int fd, struct flock64 *l);
+extern int fcntl_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l);
+
 /* fs/locks.c */
 extern void locks_remove_posix(struct file *, fl_owner_t id);
 extern void locks_remove_flock(struct file *);
@@ -616,6 +638,7 @@
 	int (*smap) (struct inode *,int);
 	int (*updatepage) (struct file *, struct page *, unsigned long, unsigned int, int);
 	int (*revalidate) (struct dentry *);
+	int (*pathconf) (struct inode *, int option);
 };
 
 struct super_operations {
@@ -626,7 +649,7 @@
 	int (*notify_change) (struct dentry *, struct iattr *);
 	void (*put_super) (struct super_block *);
 	void (*write_super) (struct super_block *);
-	int (*statfs) (struct super_block *, struct statfs *, int);
+	int (*statfs) (struct super_block *, struct statfs64 *);
 	int (*remount_fs) (struct super_block *, int *, char *);
 	void (*clear_inode) (struct inode *);
 	void (*umount_begin) (struct super_block *);
@@ -691,7 +714,7 @@
 
 asmlinkage int sys_open(const char *, int, int);
 asmlinkage int sys_close(unsigned int);		/* yes, it's really unsigned */
-extern int do_truncate(struct dentry *, unsigned long);
+extern int do_truncate(struct dentry *, loff_t);
 extern int get_unused_fd(void);
 extern void put_unused_fd(unsigned int);
 
diff -u -r linux-22009/include/linux/iso_fs.h linux-22009m/include/linux/iso_fs.h
--- linux-22009/include/linux/iso_fs.h	Sat Apr 24 07:20:38 1999
+++ linux-22009m/include/linux/iso_fs.h	Mon May 17 01:08:57 1999
@@ -200,7 +200,7 @@
 extern int init_iso9660_fs(void);
 extern void isofs_read_inode(struct inode *);
 extern void isofs_put_inode(struct inode *);
-extern int isofs_statfs(struct super_block *, struct statfs *, int);
+extern int isofs_statfs(struct super_block *, struct statfs64 *);
 
 extern int isofs_lseek(struct inode *, struct file *, off_t, int);
 extern int isofs_read(struct inode *, struct file *, char *, int);
diff -u -r linux-22009/include/linux/mm.h linux-22009m/include/linux/mm.h
--- linux-22009/include/linux/mm.h	Tue May 11 20:35:45 1999
+++ linux-22009m/include/linux/mm.h	Mon May 17 00:40:01 1999
@@ -54,7 +54,7 @@
 	struct vm_area_struct **vm_pprev_share;
 
 	struct vm_operations_struct * vm_ops;
-	unsigned long vm_offset;
+	loff_t vm_offset;
 	struct file * vm_file;
 	unsigned long vm_pte;			/* shared mem */
 };
@@ -106,9 +106,46 @@
 	unsigned long (*wppage)(struct vm_area_struct * area, unsigned long address,
 		unsigned long page);
 	int (*swapout)(struct vm_area_struct *, struct page *);
-	pte_t (*swapin)(struct vm_area_struct *, unsigned long, unsigned long);
+	pte_t (*swapin)(struct vm_area_struct *, loff_t, unsigned long);
 };
 
+
+/*
+ *  pgoff_t  type -- a complex one, and its simple alternate.
+ *  The complex one has type that compiler can trap at compile
+ *  time, but the simple one does simpler code (?)
+ */
+
+#if 1
+typedef struct pgoff_t {
+  unsigned long pgoff;
+} pgoff_t;
+
+#define pgoff2ulong(pgof) ((pgof).pgoff)
+extern __inline__ pgoff_t ulong2pgoff(unsigned long ul) {
+  pgoff_t up;
+  up.pgoff = ul;
+  return up;
+}
+
+#define pgoff2loff(pgof) (((loff_t)(pgof).pgoff) << PAGE_SHIFT)
+#define loff2pgoff(loff) ulong2pgoff((loff) >> PAGE_SHIFT)
+
+#else /* Integer scalars -- simpler code.. */
+
+typedef unsigned long pgoff_t;
+
+#define pgoff2ulong(pgof) (pgof)
+#define ulong2pgoff(pgof) (pgof)
+
+#define pgoff2loff(pgof) (((loff_t)(pgof)) << PAGE_SHIFT)
+#define loff2pgoff(loff) ulong2pgoff((loff) >> PAGE_SHIFT)
+
+#endif
+
+#define PAGE_MASK_loff ((loff_t)(long)(PAGE_MASK))
+
+
 /*
  * Try to keep the most commonly accessed fields in single cache lines
  * here (16 bytes or greater).  This ordering should be particularly
@@ -117,12 +154,13 @@
  * The first line is data used in page cache lookup, the second line
  * is used for linear searches (eg. clock algorithm scans). 
  */
+
 typedef struct page {
 	/* these must be first (free area handling) */
 	struct page *next;
 	struct page *prev;
+	pgoff_t pg_offset;	/* 8 bytes at all platforms (?) */
 	struct inode *inode;
-	unsigned long offset;
 	struct page *next_hash;
 	atomic_t count;
 	unsigned long flags;	/* atomic flags, some possibly updated asynchronously */
@@ -290,7 +328,7 @@
 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot);
 extern int zeromap_page_range(unsigned long from, unsigned long size, pgprot_t prot);
 
-extern void vmtruncate(struct inode * inode, unsigned long offset);
+extern void vmtruncate(struct inode * inode, loff_t offset);
 extern int handle_mm_fault(struct task_struct *tsk,struct vm_area_struct *vma, unsigned long address, int write_access);
 extern void make_pages_present(unsigned long addr, unsigned long end);
 
@@ -312,15 +350,15 @@
 extern unsigned long get_unmapped_area(unsigned long, unsigned long);
 
 extern unsigned long do_mmap(struct file *, unsigned long, unsigned long,
-	unsigned long, unsigned long, unsigned long);
+			     unsigned long, unsigned long, loff_t);
 extern int do_munmap(unsigned long, size_t);
 
 /* filemap.c */
 extern void remove_inode_page(struct page *);
 extern unsigned long page_unuse(struct page *);
 extern int shrink_mmap(int, int);
-extern void truncate_inode_pages(struct inode *, unsigned long);
-extern unsigned long get_cached_page(struct inode *, unsigned long, int);
+extern void truncate_inode_pages(struct inode *, loff_t);
+extern unsigned long get_cached_page(struct inode *, pgoff_t, int);
 extern void put_cached_page(unsigned long);
 
 /*
diff -u -r linux-22009/include/linux/msdos_fs.h linux-22009m/include/linux/msdos_fs.h
--- linux-22009/include/linux/msdos_fs.h	Tue May 11 20:37:13 1999
+++ linux-22009m/include/linux/msdos_fs.h	Mon May 17 01:08:57 1999
@@ -232,7 +232,7 @@
 extern void fat_read_inode(struct inode *inode, struct inode_operations *dir_ops);
 extern struct super_block *fat_read_super(struct super_block *s, void *data, int silent);
 extern void msdos_put_super(struct super_block *sb);
-extern int fat_statfs(struct super_block *sb,struct statfs *buf, int);
+extern int fat_statfs(struct super_block *sb,struct statfs64 *buf);
 extern void fat_write_inode(struct inode *inode);
 
 /* dir.c */
diff -u -r linux-22009/include/linux/nfs.h linux-22009m/include/linux/nfs.h
--- linux-22009/include/linux/nfs.h	Sun Mar  7 00:21:13 1999
+++ linux-22009m/include/linux/nfs.h	Sun May 16 15:41:23 1999
@@ -111,7 +111,7 @@
 	__u32			nlink;
 	__u32			uid;
 	__u32			gid;
-	__u32			size;
+	__u64			size;
 	__u32			blocksize;
 	__u32			rdev;
 	__u32			blocks;
@@ -126,7 +126,7 @@
 	__u32			mode;
 	__u32			uid;
 	__u32			gid;
-	__u32			size;
+	__u64			size;
 	struct nfs_time		atime;
 	struct nfs_time		mtime;
 };
@@ -141,7 +141,7 @@
 
 struct nfs_writeargs {
 	struct nfs_fh *		fh;
-	__u32			offset;
+	__u64			offset;
 	__u32			count;
 	const void *		buffer;
 };
@@ -160,7 +160,7 @@
 
 struct nfs_readargs {
 	struct nfs_fh *		fh;
-	__u32			offset;
+	__u64			offset;
 	__u32			count;
 	void *			buffer;
 };
diff -u -r linux-22009/include/linux/nfs_fs.h linux-22009m/include/linux/nfs_fs.h
--- linux-22009/include/linux/nfs_fs.h	Tue May 11 20:35:46 1999
+++ linux-22009m/include/linux/nfs_fs.h	Mon May 17 00:40:27 1999
@@ -143,10 +143,10 @@
 			void **p0, char **string, unsigned int *len,
 			unsigned int maxlen);
 extern int nfs_proc_read(struct nfs_server *server, struct nfs_fh *fhandle,
-			int swap, unsigned long offset, unsigned int count,
+			int swap, loff_t offset, unsigned int count,
 			void *buffer, struct nfs_fattr *fattr);
 extern int nfs_proc_write(struct nfs_server *server, struct nfs_fh *fhandle,
-			int swap, unsigned long offset, unsigned int count,
+			int swap, loff_t offset, unsigned int count,
 			const void *buffer, struct nfs_fattr *fattr);
 extern int nfs_proc_create(struct nfs_server *server, struct nfs_fh *dir,
 			const char *name, struct nfs_sattr *sattr,
diff -u -r linux-22009/include/linux/nfsd/nfsd.h linux-22009m/include/linux/nfsd/nfsd.h
--- linux-22009/include/linux/nfsd/nfsd.h	Tue May 11 20:36:17 1999
+++ linux-22009m/include/linux/nfsd/nfsd.h	Mon May 17 01:17:00 1999
@@ -106,7 +106,7 @@
 				loff_t, encode_dent_fn,
 				u32 *buffer, int *countp);
 int		nfsd_statfs(struct svc_rqst *, struct svc_fh *,
-				struct statfs *);
+				struct statfs64 *);
 int		nfsd_notify_change(struct inode *, struct iattr *);
 int		nfsd_permission(struct svc_export *, struct dentry *, int);
 
diff -u -r linux-22009/include/linux/nfsd/xdr.h linux-22009m/include/linux/nfsd/xdr.h
--- linux-22009/include/linux/nfsd/xdr.h	Tue Dec 29 00:09:59 1998
+++ linux-22009m/include/linux/nfsd/xdr.h	Mon May 17 01:19:17 1999
@@ -101,7 +101,7 @@
 };
 
 struct nfsd_statfsres {
-	struct statfs		stats;
+	struct statfs64		stats;
 };
 
 /*
diff -u -r linux-22009/include/linux/nfsd/xdr3.h linux-22009m/include/linux/nfsd/xdr3.h
--- linux-22009/include/linux/nfsd/xdr3.h	Mon Apr  7 21:35:32 1997
+++ linux-22009m/include/linux/nfsd/xdr3.h	Sun May 16 15:41:23 1999
@@ -163,7 +163,7 @@
 
 struct nfsd3_statfsres {
 	__u32			status;
-	struct statfs		stats;
+	struct statfs64		stats;
 	__u32			invarsec;
 };
 
diff -u -r linux-22009/include/linux/pagemap.h linux-22009m/include/linux/pagemap.h
--- linux-22009/include/linux/pagemap.h	Tue May 11 20:35:49 1999
+++ linux-22009m/include/linux/pagemap.h	Mon May 17 00:40:04 1999
@@ -28,6 +28,7 @@
 #define PAGE_CACHE_SHIFT	PAGE_SHIFT
 #define PAGE_CACHE_SIZE		PAGE_SIZE
 #define PAGE_CACHE_MASK		PAGE_MASK
+#define PAGE_CACHE_MASK_loff	PAGE_MASK_loff
 
 #define page_cache_alloc()	__get_free_page(GFP_USER)
 #define page_cache_free(x)	free_page(x)
@@ -50,10 +51,10 @@
  * inode pointer and offsets are distributed (ie, we
  * roughly know which bits are "significant")
  */
-static inline unsigned long _page_hashfn(struct inode * inode, unsigned long offset)
+static inline unsigned long _page_hashfn(struct inode * inode, pgoff_t poffset)
 {
 #define i (((unsigned long) inode)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))
-#define o (offset >> PAGE_SHIFT)
+#define o pgoff2ulong(poffset) /* already shifted down to pages.. */
 #define s(x) ((x)+((x)>>PAGE_HASH_BITS))
 	return s(i+o) & (PAGE_HASH_SIZE-1);
 #undef i
@@ -61,9 +62,9 @@
 #undef s
 }
 
-#define page_hash(inode,offset) (page_hash_table+_page_hashfn(inode,offset))
+#define page_hash(inode,poffset) (page_hash_table+_page_hashfn(inode,poffset))
 
-static inline struct page * __find_page(struct inode * inode, unsigned long offset, struct page *page)
+static inline struct page * __find_page(struct inode * inode, pgoff_t pg_offset, struct page *page)
 {
 	goto inside;
 	for (;;) {
@@ -73,7 +74,7 @@
 			goto not_found;
 		if (page->inode != inode)
 			continue;
-		if (page->offset == offset)
+		if (pgoff2ulong(page->pg_offset) == pgoff2ulong(pg_offset))
 			break;
 	}
 	/* Found the page. */
@@ -83,9 +84,9 @@
 	return page;
 }
 
-static inline struct page *find_page(struct inode * inode, unsigned long offset)
+static inline struct page *find_page(struct inode * inode, pgoff_t poffset)
 {
-	return __find_page(inode, offset, *page_hash(inode, offset));
+	return __find_page(inode, poffset, *page_hash(inode, poffset));
 }
 
 static inline void remove_page_from_hash_queue(struct page * page)
@@ -108,9 +109,9 @@
 	page->pprev_hash = p;
 }
 
-static inline void add_page_to_hash_queue(struct page * page, struct inode * inode, unsigned long offset)
+static inline void add_page_to_hash_queue(struct page * page, struct inode * inode, pgoff_t poffset)
 {
-	__add_page_to_hash_queue(page, page_hash(inode,offset));
+	__add_page_to_hash_queue(page, page_hash(inode,poffset));
 }
 
 static inline void remove_page_from_inode_queue(struct page * page)
@@ -148,6 +149,6 @@
 		__wait_on_page(page);
 }
 
-extern void update_vm_cache(struct inode *, unsigned long, const char *, int);
+extern void update_vm_cache(struct inode *, loff_t, const char *, int);
 
 #endif
diff -u -r linux-22009/include/linux/proc_fs.h linux-22009m/include/linux/proc_fs.h
--- linux-22009/include/linux/proc_fs.h	Tue May 11 20:36:09 1999
+++ linux-22009m/include/linux/proc_fs.h	Mon May 17 00:40:04 1999
@@ -367,7 +367,7 @@
 extern struct super_block *proc_read_super(struct super_block *,void *,int);
 extern int init_proc_fs(void);
 extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
-extern int proc_statfs(struct super_block *, struct statfs *, int);
+extern int proc_statfs(struct super_block *, struct statfs64 *);
 extern void proc_read_inode(struct inode *);
 extern void proc_write_inode(struct inode *);
 extern int proc_permission(struct inode *, int);
diff -u -r linux-22009/include/linux/resource.h linux-22009m/include/linux/resource.h
--- linux-22009/include/linux/resource.h	Mon Dec 28 08:18:28 1998
+++ linux-22009m/include/linux/resource.h	Mon May 17 00:39:54 1999
@@ -38,11 +38,24 @@
 };
 
 #define RLIM_INFINITY	((long)(~0UL>>1))
+#define RLIM_SAVED_MAX  ((long)(~0UL>>1)-1L)
+#define RLIM_SAVED_CUR	((long)(~0UL>>1)-2L)
+
+#define RLIM64_INFINITY	((long long)(~0ULL>>1))
+#define RLIM64_SAVED_MAX RLIM64_INFINITY
+#define RLIM64_SAVED_CUR RLIM64_INFINITY
 
 struct rlimit {
 	long	rlim_cur;
 	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 -u -r linux-22009/include/linux/sched.h linux-22009m/include/linux/sched.h
--- linux-22009/include/linux/sched.h	Tue May 11 20:35:45 1999
+++ linux-22009m/include/linux/sched.h	Mon May 17 00:40:01 1999
@@ -287,7 +287,8 @@
         kernel_cap_t   cap_effective, cap_inheritable, cap_permitted;
 	struct user_struct *user;
 /* limits */
-	struct rlimit rlim[RLIM_NLIMITS];
+	struct rlimit   rlim[RLIM_NLIMITS];
+	struct rlimit64 rlimfsz; /* RLIM_FSIZE -- only! at 32-bit systems */
 	unsigned short used_math;
 	char comm[16];
 /* file system info */
@@ -369,6 +370,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 -u -r linux-22009/include/linux/smb_fs.h linux-22009m/include/linux/smb_fs.h
--- linux-22009/include/linux/smb_fs.h	Tue May 11 20:37:15 1999
+++ linux-22009m/include/linux/smb_fs.h	Mon May 17 01:08:57 1999
@@ -112,8 +112,8 @@
 void smb_close_dentry(struct dentry *);
 int smb_close_fileid(struct dentry *, __u16);
 int smb_open(struct dentry *, int);
-int smb_proc_read(struct dentry *, off_t, int, char *);
-int smb_proc_write(struct dentry *, off_t, int, const char *);
+int smb_proc_read(struct dentry *, loff_t, int, char *);
+int smb_proc_write(struct dentry *, loff_t, int, const char *);
 int smb_proc_create(struct dentry *, __u16, time_t, __u16 *);
 int smb_proc_mv(struct dentry *, struct dentry *);
 int smb_proc_mkdir(struct dentry *);
@@ -123,7 +123,7 @@
 int smb_proc_getattr(struct dentry *, struct smb_fattr *);
 int smb_proc_setattr(struct dentry *, struct smb_fattr *);
 int smb_proc_settime(struct dentry *, struct smb_fattr *);
-int smb_proc_dskattr(struct super_block *, struct statfs *);
+int smb_proc_dskattr(struct super_block *, struct statfs64 *);
 int smb_proc_reconnect(struct smb_sb_info *);
 int smb_proc_connect(struct smb_sb_info *);
 int smb_proc_disconnect(struct smb_sb_info *);
diff -u -r linux-22009/include/linux/stat.h linux-22009m/include/linux/stat.h
--- linux-22009/include/linux/stat.h	Mon May 25 20:32:52 1998
+++ linux-22009m/include/linux/stat.h	Mon May 17 00:39:54 1999
@@ -3,8 +3,40 @@
 
 #ifdef __KERNEL__
 
+#include <linux/types.h>
 #include <asm/stat.h>
 
+#ifndef __ARCH_STRUCT_STAT64
+struct stat64 { /* Generically sized structure for all Linuxes */
+	__u64	st_dev;		/* Usually 16 or 32 bits */
+	__u64	st_rdev;
+
+	__u32	st_mode;
+	__u32	st_nlink;
+
+	__u32	st_uid;
+	__u32	st_gid;
+
+	__u64	st_ino;		/* inode is usually mere 32-bits */
+
+	__s64	st_size;	/* Large File Support */
+	__s64	st_blocks;
+	__u32	st_blksize;
+
+	long	st_atime;	/* Yup, 32 bits or 64 bits per natural */
+	long	__unused1;	/* .. size of the 'long'. */
+	long	st_mtime;
+	long	__unused2;
+	long	st_ctime;
+	long	__unused3
+;
+	__u32	st_gen;		/* Linux-FS things */
+	__u32	st_flags;
+
+	char	st_fstype[16];	/* Filesystem type name; From IRIX */
+	__u32	__unused4[8];	/* .. more IRIX originated things */
+};
+#endif
 #endif
 
 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
diff -u -r linux-22009/include/linux/swap.h linux-22009m/include/linux/swap.h
--- linux-22009/include/linux/swap.h	Tue May 11 20:35:43 1999
+++ linux-22009m/include/linux/swap.h	Mon May 17 00:40:04 1999
@@ -114,7 +114,7 @@
 extern unsigned int nr_swapfiles;
 extern struct swap_info_struct swap_info[];
 void si_swapinfo(struct sysinfo *);
-unsigned long get_swap_page(void);
+extern unsigned long  get_swap_page(void);
 extern void FASTCALL(swap_free(unsigned long));
 struct swap_list_t {
 	int head;	/* head of priority-ordered swapfile list */
@@ -146,8 +146,11 @@
 
 extern inline unsigned long in_swap_cache(struct page *page)
 {
+	/* DO NOT EXCEED 4G OF SWAP IN 32-BIT SYSTEM! */
+	/* (this is actually to be checked -- perhaps just
+	    forbidding exceeding 4G per SWAP partition/file) */
 	if (PageSwapCache(page))
-		return page->offset;
+		return pgoff2ulong(page->pg_offset);
 	return 0;
 }
 
@@ -164,7 +167,7 @@
 		return 1;
 	count = atomic_read(&page->count);
 	if (PageSwapCache(page))
-		count += swap_count(page->offset) - 2;
+		count += swap_count(pgoff2ulong(page->pg_offset)) - 2;
 	if (PageFreeAfter(page))
 		count--;
 	return  count > 1;
diff -u -r linux-22009/include/linux/sysv_fs.h linux-22009m/include/linux/sysv_fs.h
--- linux-22009/include/linux/sysv_fs.h	Tue May 11 20:37:14 1999
+++ linux-22009m/include/linux/sysv_fs.h	Mon May 17 01:08:57 1999
@@ -398,7 +398,7 @@
 extern void sysv_read_inode(struct inode *);
 extern int sysv_notify_change(struct dentry *, struct iattr *);
 extern void sysv_write_inode(struct inode *);
-extern int sysv_statfs(struct super_block *, struct statfs *, int);
+extern int sysv_statfs(struct super_block *, struct statfs64 *);
 extern int sysv_sync_inode(struct inode *);
 extern int sysv_sync_file(struct file *, struct dentry *);
 extern int sysv_mmap(struct file *, struct vm_area_struct *);
diff -u -r linux-22009/include/linux/types.h linux-22009m/include/linux/types.h
--- linux-22009/include/linux/types.h	Mon Dec 28 08:18:28 1998
+++ linux-22009m/include/linux/types.h	Mon May 17 00:39:54 1999
@@ -9,9 +9,11 @@
 typedef __kernel_fd_set		fd_set;
 typedef __kernel_dev_t		dev_t;
 typedef __kernel_ino_t		ino_t;
+typedef __kernel_ino64_t	ino64_t;
 typedef __kernel_mode_t		mode_t;
 typedef __kernel_nlink_t	nlink_t;
 typedef __kernel_off_t		off_t;
+typedef __kernel_off64_t	off64_t;
 typedef __kernel_pid_t		pid_t;
 typedef __kernel_uid_t		uid_t;
 typedef __kernel_gid_t		gid_t;
diff -u -r linux-22009/include/linux/unistd.h linux-22009m/include/linux/unistd.h
--- linux-22009/include/linux/unistd.h	Wed Jan 20 23:42:11 1999
+++ linux-22009m/include/linux/unistd.h	Sun May 16 15:41:23 1999
@@ -8,4 +8,350 @@
  */
 #include <asm/unistd.h>
 
+
+/* ---------- KERNEL SPACE NEEDS THESE FOR  pathconf() AND sysconf()
+              THINGS AT ALL PLATFORMS  ----------------------------- */
+/* ---------- THESE ARE PICKED FROM GLIBC 2.1(pre) HEADERFILES ----- */
+/* ---------- VALUES FOR confstr ARE REMOVED ----------------------- */
+
+/* `sysconf', `pathconf', and `confstr' NAME values.  Generic version.
+   Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifdef __KERNEL__
+
+/* Values for the NAME argument to `pathconf' and `fpathconf'.  */
+enum
+  {
+    _PC_LINK_MAX,
+#define	_PC_LINK_MAX			_PC_LINK_MAX
+    _PC_MAX_CANON,
+#define	_PC_MAX_CANON			_PC_MAX_CANON
+    _PC_MAX_INPUT,
+#define	_PC_MAX_INPUT			_PC_MAX_INPUT
+    _PC_NAME_MAX,
+#define	_PC_NAME_MAX			_PC_NAME_MAX
+    _PC_PATH_MAX,
+#define	_PC_PATH_MAX			_PC_PATH_MAX
+    _PC_PIPE_BUF,
+#define	_PC_PIPE_BUF			_PC_PIPE_BUF
+    _PC_CHOWN_RESTRICTED,
+#define	_PC_CHOWN_RESTRICTED		_PC_CHOWN_RESTRICTED
+    _PC_NO_TRUNC,
+#define	_PC_NO_TRUNC			_PC_NO_TRUNC
+    _PC_VDISABLE,
+#define _PC_VDISABLE			_PC_VDISABLE
+    _PC_SYNC_IO,
+#define	_PC_SYNC_IO			_PC_SYNC_IO
+    _PC_ASYNC_IO,
+#define	_PC_ASYNC_IO			_PC_ASYNC_IO
+    _PC_PRIO_IO,
+#define	_PC_PRIO_IO			_PC_PRIO_IO
+    _PC_SOCK_MAXBUF,
+#define	_PC_SOCK_MAXBUF			_PC_SOCK_MAXBUF
+    _PC_FILESIZEBITS
+#define _PC_FILESIZEBITS		_PC_FILESIZEBITS
+  };
+
+/* Values for the argument to `sysconf'.  */
+enum
+  {
+    _SC_ARG_MAX,
+#define	_SC_ARG_MAX			_SC_ARG_MAX
+    _SC_CHILD_MAX,
+#define	_SC_CHILD_MAX			_SC_CHILD_MAX
+    _SC_CLK_TCK,
+#define	_SC_CLK_TCK			_SC_CLK_TCK
+    _SC_NGROUPS_MAX,
+#define	_SC_NGROUPS_MAX			_SC_NGROUPS_MAX
+    _SC_OPEN_MAX,
+#define	_SC_OPEN_MAX			_SC_OPEN_MAX
+    _SC_STREAM_MAX,
+#define	_SC_STREAM_MAX			_SC_STREAM_MAX
+    _SC_TZNAME_MAX,
+#define	_SC_TZNAME_MAX			_SC_TZNAME_MAX
+    _SC_JOB_CONTROL,
+#define	_SC_JOB_CONTROL			_SC_JOB_CONTROL
+    _SC_SAVED_IDS,
+#define	_SC_SAVED_IDS			_SC_SAVED_IDS
+    _SC_REALTIME_SIGNALS,
+#define	_SC_REALTIME_SIGNALS		_SC_REALTIME_SIGNALS
+    _SC_PRIORITY_SCHEDULING,
+#define	_SC_PRIORITY_SCHEDULING		_SC_PRIORITY_SCHEDULING
+    _SC_TIMERS,
+#define	_SC_TIMERS			_SC_TIMERS
+    _SC_ASYNCHRONOUS_IO,
+#define	_SC_ASYNCHRONOUS_IO		_SC_ASYNCHRONOUS_IO
+    _SC_PRIORITIZED_IO,
+#define	_SC_PRIORITIZED_IO		_SC_PRIORITIZED_IO
+    _SC_SYNCHRONIZED_IO,
+#define	_SC_SYNCHRONIZED_IO		_SC_SYNCHRONIZED_IO
+    _SC_FSYNC,
+#define	_SC_FSYNC			_SC_FSYNC
+    _SC_MAPPED_FILES,
+#define	_SC_MAPPED_FILES		_SC_MAPPED_FILES
+    _SC_MEMLOCK,
+#define	_SC_MEMLOCK			_SC_MEMLOCK
+    _SC_MEMLOCK_RANGE,
+#define	_SC_MEMLOCK_RANGE		_SC_MEMLOCK_RANGE
+    _SC_MEMORY_PROTECTION,
+#define	_SC_MEMORY_PROTECTION		_SC_MEMORY_PROTECTION
+    _SC_MESSAGE_PASSING,
+#define	_SC_MESSAGE_PASSING		_SC_MESSAGE_PASSING
+    _SC_SEMAPHORES,
+#define	_SC_SEMAPHORES			_SC_SEMAPHORES
+    _SC_SHARED_MEMORY_OBJECTS,
+#define	_SC_SHARED_MEMORY_OBJECTS	_SC_SHARED_MEMORY_OBJECTS
+    _SC_AIO_LISTIO_MAX,
+#define	_SC_AIO_LISTIO_MAX		_SC_AIO_LISTIO_MAX
+    _SC_AIO_MAX,
+#define	_SC_AIO_MAX			_SC_AIO_MAX
+    _SC_AIO_PRIO_DELTA_MAX,
+#define	_SC_AIO_PRIO_DELTA_MAX		_SC_AIO_PRIO_DELTA_MAX
+    _SC_DELAYTIMER_MAX,
+#define	_SC_DELAYTIMER_MAX		_SC_DELAYTIMER_MAX
+    _SC_MQ_OPEN_MAX,
+#define	_SC_MQ_OPEN_MAX			_SC_MQ_OPEN_MAX
+    _SC_MQ_PRIO_MAX,
+#define	_SC_MQ_PRIO_MAX			_SC_MQ_PRIO_MAX
+    _SC_VERSION,
+#define	_SC_VERSION			_SC_VERSION
+    _SC_PAGESIZE,
+#define	_SC_PAGESIZE			_SC_PAGESIZE
+#define	_SC_PAGE_SIZE			_SC_PAGESIZE
+    _SC_RTSIG_MAX,
+#define	_SC_RTSIG_MAX			_SC_RTSIG_MAX
+    _SC_SEM_NSEMS_MAX,
+#define	_SC_SEM_NSEMS_MAX		_SC_SEM_NSEMS_MAX
+    _SC_SEM_VALUE_MAX,
+#define	_SC_SEM_VALUE_MAX		_SC_SEM_VALUE_MAX
+    _SC_SIGQUEUE_MAX,
+#define	_SC_SIGQUEUE_MAX		_SC_SIGQUEUE_MAX
+    _SC_TIMER_MAX,
+#define	_SC_TIMER_MAX			_SC_TIMER_MAX
+
+    /* Values for the argument to `sysconf'
+       corresponding to _POSIX2_* symbols.  */
+    _SC_BC_BASE_MAX,
+#define	_SC_BC_BASE_MAX			_SC_BC_BASE_MAX
+    _SC_BC_DIM_MAX,
+#define	_SC_BC_DIM_MAX			_SC_BC_DIM_MAX
+    _SC_BC_SCALE_MAX,
+#define	_SC_BC_SCALE_MAX		_SC_BC_SCALE_MAX
+    _SC_BC_STRING_MAX,
+#define	_SC_BC_STRING_MAX		_SC_BC_STRING_MAX
+    _SC_COLL_WEIGHTS_MAX,
+#define	_SC_COLL_WEIGHTS_MAX		_SC_COLL_WEIGHTS_MAX
+    _SC_EQUIV_CLASS_MAX,
+#define	_SC_EQUIV_CLASS_MAX		_SC_EQUIV_CLASS_MAX
+    _SC_EXPR_NEST_MAX,
+#define	_SC_EXPR_NEST_MAX		_SC_EXPR_NEST_MAX
+    _SC_LINE_MAX,
+#define	_SC_LINE_MAX			_SC_LINE_MAX
+    _SC_RE_DUP_MAX,
+#define	_SC_RE_DUP_MAX			_SC_RE_DUP_MAX
+    _SC_CHARCLASS_NAME_MAX,
+#define	_SC_CHARCLASS_NAME_MAX		_SC_CHARCLASS_NAME_MAX
+
+    _SC_2_VERSION,
+#define	_SC_2_VERSION			_SC_2_VERSION
+    _SC_2_C_BIND,
+#define	_SC_2_C_BIND			_SC_2_C_BIND
+    _SC_2_C_DEV,
+#define	_SC_2_C_DEV			_SC_2_C_DEV
+    _SC_2_FORT_DEV,
+#define	_SC_2_FORT_DEV			_SC_2_FORT_DEV
+    _SC_2_FORT_RUN,
+#define	_SC_2_FORT_RUN			_SC_2_FORT_RUN
+    _SC_2_SW_DEV,
+#define	_SC_2_SW_DEV			_SC_2_SW_DEV
+    _SC_2_LOCALEDEF,
+#define	_SC_2_LOCALEDEF			_SC_2_LOCALEDEF
+
+    _SC_PII,
+#define	_SC_PII				_SC_PII
+    _SC_PII_XTI,
+#define	_SC_PII_XTI			_SC_PII_XTI
+    _SC_PII_SOCKET,
+#define	_SC_PII_SOCKET			_SC_PII_SOCKET
+    _SC_PII_INTERNET,
+#define	_SC_PII_INTERNET		_SC_PII_INTERNET
+    _SC_PII_OSI,
+#define	_SC_PII_OSI			_SC_PII_OSI
+    _SC_POLL,
+#define	_SC_POLL			_SC_POLL
+    _SC_SELECT,
+#define	_SC_SELECT			_SC_SELECT
+    _SC_UIO_MAXIOV,
+#define	_SC_UIO_MAXIOV			_SC_UIO_MAXIOV
+    _SC_PII_INTERNET_STREAM,
+#define	_SC_PII_INTERNET_STREAM		_SC_PII_INTERNET_STREAM
+    _SC_PII_INTERNET_DGRAM,
+#define	_SC_PII_INTERNET_DGRAM		_SC_PII_INTERNET_DGRAM
+    _SC_PII_OSI_COTS,
+#define	_SC_PII_OSI_COTS		_SC_PII_OSI_COTS
+    _SC_PII_OSI_CLTS,
+#define	_SC_PII_OSI_CLTS		_SC_PII_OSI_CLTS
+    _SC_PII_OSI_M,
+#define	_SC_PII_OSI_M			_SC_PII_OSI_M
+    _SC_T_IOV_MAX,
+#define	_SC_T_IOV_MAX			_SC_T_IOV_MAX
+
+    /* Values according to POSIX 1003.1c (POSIX threads).  */
+    _SC_THREADS,
+#define	_SC_THREADS			_SC_THREADS
+    _SC_THREAD_SAFE_FUNCTIONS,
+#define _SC_THREAD_SAFE_FUNCTIONS	_SC_THREAD_SAFE_FUNCTIONS
+    _SC_GETGR_R_SIZE_MAX,
+#define	_SC_GETGR_R_SIZE_MAX		_SC_GETGR_R_SIZE_MAX
+    _SC_GETPW_R_SIZE_MAX,
+#define	_SC_GETPW_R_SIZE_MAX		_SC_GETPW_R_SIZE_MAX
+    _SC_LOGIN_NAME_MAX,
+#define	_SC_LOGIN_NAME_MAX		_SC_LOGIN_NAME_MAX
+    _SC_TTY_NAME_MAX,
+#define	_SC_TTY_NAME_MAX		_SC_TTY_NAME_MAX
+    _SC_THREAD_DESTRUCTOR_ITERATIONS,
+#define	_SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS
+    _SC_THREAD_KEYS_MAX,
+#define	_SC_THREAD_KEYS_MAX		_SC_THREAD_KEYS_MAX
+    _SC_THREAD_STACK_MIN,
+#define	_SC_THREAD_STACK_MIN		_SC_THREAD_STACK_MIN
+    _SC_THREAD_THREADS_MAX,
+#define	_SC_THREAD_THREADS_MAX		_SC_THREAD_THREADS_MAX
+    _SC_THREAD_ATTR_STACKADDR,
+#define	_SC_THREAD_ATTR_STACKADDR	_SC_THREAD_ATTR_STACKADDR
+    _SC_THREAD_ATTR_STACKSIZE,
+#define	_SC_THREAD_ATTR_STACKSIZE	_SC_THREAD_ATTR_STACKSIZE
+    _SC_THREAD_PRIORITY_SCHEDULING,
+#define	_SC_THREAD_PRIORITY_SCHEDULING	_SC_THREAD_PRIORITY_SCHEDULING
+    _SC_THREAD_PRIO_INHERIT,
+#define	_SC_THREAD_PRIO_INHERIT		_SC_THREAD_PRIO_INHERIT
+    _SC_THREAD_PRIO_PROTECT,
+#define	_SC_THREAD_PRIO_PROTECT		_SC_THREAD_PRIO_PROTECT
+    _SC_THREAD_PROCESS_SHARED,
+#define	_SC_THREAD_PROCESS_SHARED	_SC_THREAD_PROCESS_SHARED
+
+    _SC_NPROCESSORS_CONF,
+#define _SC_NPROCESSORS_CONF		_SC_NPROCESSORS_CONF
+    _SC_NPROCESSORS_ONLN,
+#define _SC_NPROCESSORS_ONLN		_SC_NPROCESSORS_ONLN
+    _SC_PHYS_PAGES,
+#define _SC_PHYS_PAGES			_SC_PHYS_PAGES
+    _SC_AVPHYS_PAGES,
+#define _SC_AVPHYS_PAGES		_SC_AVPHYS_PAGES
+    _SC_ATEXIT_MAX,
+#define _SC_ATEXIT_MAX			_SC_ATEXIT_MAX
+    _SC_PASS_MAX,
+#define _SC_PASS_MAX			_SC_PASS_MAX
+
+    _SC_XOPEN_VERSION,
+#define _SC_XOPEN_VERSION		_SC_XOPEN_VERSION
+    _SC_XOPEN_XCU_VERSION,
+#define _SC_XOPEN_XCU_VERSION		_SC_XOPEN_XCU_VERSION
+    _SC_XOPEN_UNIX,
+#define _SC_XOPEN_UNIX			_SC_XOPEN_UNIX
+    _SC_XOPEN_CRYPT,
+#define _SC_XOPEN_CRYPT			_SC_XOPEN_CRYPT
+    _SC_XOPEN_ENH_I18N,
+#define _SC_XOPEN_ENH_I18N		_SC_XOPEN_ENH_I18N
+    _SC_XOPEN_SHM,
+#define _SC_XOPEN_SHM			_SC_XOPEN_SHM
+
+    _SC_2_CHAR_TERM,
+#define _SC_2_CHAR_TERM			_SC_2_CHAR_TERM
+    _SC_2_C_VERSION,
+#define _SC_2_C_VERSION			_SC_2_C_VERSION
+    _SC_2_UPE,
+#define _SC_2_UPE			_SC_2_UPE
+
+    _SC_XOPEN_XPG2,
+#define _SC_XOPEN_XPG2			_SC_XOPEN_XPG2
+    _SC_XOPEN_XPG3,
+#define _SC_XOPEN_XPG3			_SC_XOPEN_XPG3
+    _SC_XOPEN_XPG4,
+#define _SC_XOPEN_XPG4			_SC_XOPEN_XPG4
+
+    _SC_CHAR_BIT,
+#define	_SC_CHAR_BIT			_SC_CHAR_BIT
+    _SC_CHAR_MAX,
+#define	_SC_CHAR_MAX			_SC_CHAR_MAX
+    _SC_CHAR_MIN,
+#define	_SC_CHAR_MIN			_SC_CHAR_MIN
+    _SC_INT_MAX,
+#define	_SC_INT_MAX			_SC_INT_MAX
+    _SC_INT_MIN,
+#define	_SC_INT_MIN			_SC_INT_MIN
+    _SC_LONG_BIT,
+#define	_SC_LONG_BIT			_SC_LONG_BIT
+    _SC_WORD_BIT,
+#define	_SC_WORD_BIT			_SC_WORD_BIT
+    _SC_MB_LEN_MAX,
+#define	_SC_MB_LEN_MAX			_SC_MB_LEN_MAX
+    _SC_NZERO,
+#define	_SC_NZERO			_SC_NZERO
+    _SC_SSIZE_MAX,
+#define	_SC_SSIZE_MAX			_SC_SSIZE_MAX
+    _SC_SCHAR_MAX,
+#define	_SC_SCHAR_MAX			_SC_SCHAR_MAX
+    _SC_SCHAR_MIN,
+#define	_SC_SCHAR_MIN			_SC_SCHAR_MIN
+    _SC_SHRT_MAX,
+#define	_SC_SHRT_MAX			_SC_SHRT_MAX
+    _SC_SHRT_MIN,
+#define	_SC_SHRT_MIN			_SC_SHRT_MIN
+    _SC_UCHAR_MAX,
+#define	_SC_UCHAR_MAX			_SC_UCHAR_MAX
+    _SC_UINT_MAX,
+#define	_SC_UINT_MAX			_SC_UINT_MAX
+    _SC_ULONG_MAX,
+#define	_SC_ULONG_MAX			_SC_ULONG_MAX
+    _SC_USHRT_MAX,
+#define	_SC_USHRT_MAX			_SC_USHRT_MAX
+
+    _SC_NL_ARGMAX,
+#define	_SC_NL_ARGMAX			_SC_NL_ARGMAX
+    _SC_NL_LANGMAX,
+#define	_SC_NL_LANGMAX			_SC_NL_LANGMAX
+    _SC_NL_MSGMAX,
+#define	_SC_NL_MSGMAX			_SC_NL_MSGMAX
+    _SC_NL_NMAX,
+#define	_SC_NL_NMAX			_SC_NL_NMAX
+    _SC_NL_SETMAX,
+#define	_SC_NL_SETMAX			_SC_NL_SETMAX
+    _SC_NL_TEXTMAX,
+#define	_SC_NL_TEXTMAX			_SC_NL_TEXTMAX
+
+    _SC_XBS5_ILP32_OFF32,
+#define _SC_XBS5_ILP32_OFF32		_SC_XBS5_ILP32_OFF32
+    _SC_XBS5_ILP32_OFFBIG,
+#define _SC_XBS5_ILP32_OFFBIG		_SC_XBS5_ILP32_OFFBIG
+    _SC_XBS5_LP64_OFF64,
+#define _SC_XBS5_LP64_OFF64		_SC_XBS5_LP64_OFF64
+    _SC_XBS5_LPBIG_OFFBIG,
+#define _SC_XBS5_LPBIG_OFFBIG		_SC_XBS5_LPBIG_OFFBIG
+
+    _SC_XOPEN_LEGACY,
+#define _SC_XOPEN_LEGACY		_SC_XOPEN_LEGACY
+    _SC_XOPEN_REALTIME,
+#define _SC_XOPEN_REALTIME		_SC_XOPEN_REALTIME
+    _SC_XOPEN_REALTIME_THREADS
+#define _SC_XOPEN_REALTIME_THREADS	_SC_XOPEN_REALTIME_THREADS
+  };
+#endif
+
 #endif /* _LINUX_UNISTD_H_ */
diff -u -r linux-22009/kernel/acct.c linux-22009m/kernel/acct.c
--- linux-22009/kernel/acct.c	Wed Mar 24 02:57:38 1999
+++ linux-22009m/kernel/acct.c	Sun May 16 15:41:23 1999
@@ -88,8 +88,7 @@
  */
 static int check_free_space(struct file *file)
 {
-	mm_segment_t fs;
-	struct statfs sbuf;
+	struct statfs64 sbuf;
 	struct super_block *sb;
 	int res = acct_active;
 	int act;
@@ -101,15 +100,12 @@
 	if (!sb->s_op || !sb->s_op->statfs)
 		return res;
 
-	fs = get_fs();
-	set_fs(KERNEL_DS);
 	/* May block */
-	sb->s_op->statfs(sb, &sbuf, sizeof(struct statfs));
-	set_fs(fs);
+	sb->s_op->statfs(sb, &sbuf);
 
-	if (sbuf.f_bavail <= SUSPEND * sbuf.f_blocks / 100)
+	if (sbuf.f_bavail <= ((u_long)(SUSPEND * sbuf.f_blocks)) / 100)
 		act = -1;
-	else if (sbuf.f_bavail >= RESUME * sbuf.f_blocks / 100)
+	else if (sbuf.f_bavail >= ((u_long)(RESUME * sbuf.f_blocks)) / 100)
 		act = 1;
 	else
 		act = 0;
diff -u -r linux-22009/kernel/sys.c linux-22009m/kernel/sys.c
--- linux-22009/kernel/sys.c	Fri Nov 20 21:43:19 1998
+++ linux-22009m/kernel/sys.c	Sun May 16 15:41:23 1999
@@ -11,6 +11,7 @@
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/prctl.h>
+#include <linux/unistd.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -885,11 +886,44 @@
 
 asmlinkage int 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 int 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);
 }
 
 asmlinkage int sys_setrlimit(unsigned int resource, struct rlimit *rlim)
@@ -909,10 +943,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 int 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
@@ -1000,3 +1086,70 @@
 	return error;
 }
 
+
+/*
+ * POSIX sysconf() things
+ *
+ * There are things for which the existence of this makes
+ * a lot of sense; Adding new facilities to the system allows
+ * things like libc to detect availability of those way easier
+ * thru  sysconf(),  than by any other means.
+ * Mostly these are for other than POSIX.1 things, e.g. for
+ * POSIX.1b, POSIX.1b (aka REAL TIME and THREADS, respectively)
+ *
+ * sysconf() returns -1 for all those option values it does
+ * not recognize.  *Never* shall it set errno!
+ *
+ * Returning ``-1'' without errno is indicated by returning ``-INT_MAX''
+ */
+
+asmlinkage int sys_sysconf(int option)
+{
+	switch(option) {
+#if 0 /* Drepper thinking: These shouldn't be in kernel */
+	case _SC_JOB_CONTROL:		/* POSIX.1 */
+		return 1;
+	case _SC_SAVED_IDS:
+		return -INT_MAX; /* FIXME! What the value *should* be ? */
+	case _SC_VERSION:
+		return -INT_MAX; /* FIXME! What _POSIX_VERSION we have
+				   in the kernel proper ? */
+#endif
+	case _SC_ARG_MAX:
+		return ARG_MAX;
+
+	case _SC_CHILD_MAX:
+		return -INT_MAX;
+
+	case _SC_CLK_TCK:
+		return HZ;
+
+	case _SC_NGROUPS_MAX:
+		return NGROUPS_MAX;
+
+	case _SC_OPEN_MAX:	/* POSIX.1  Max simultaneous files   */
+	case _SC_STREAM_MAX:	/* POSIX.1: Max simultaneous streams */
+		return NR_OPEN; /* The upper hard limit; Normally something
+				   like 1024, but insanely large file arrays
+				   can also be supported in the system giving
+				   this here 1024*1024 (yep, MILLION!) */
+
+#if 0	/* Library thing */
+	case _SC_TZNAME_MAX:
+		return -INT_MAX;
+#endif
+#if 0 /* Drepper thinking: Most of these are library things, and don't
+	 belong to kernel..  Must sort them out someday.. */
+	case _SC_ASYNCHRONOUS_IO:	/* POSIX.4 */
+	case _SC_MAPPED_FILES:
+	case _SC_MEMLOCK:
+	case _SC_MEMLOCK_RANGE:
+	case _SC_MEMORY_PROTECTION:
+		/* ... more! ... */
+		break;
+#endif
+	default:	/* Anything not considered in kernel -> EINVAL */
+		break;
+	}
+	return -EINVAL;
+}
diff -u -r linux-22009/lib/vsprintf.c linux-22009m/lib/vsprintf.c
--- linux-22009/lib/vsprintf.c	Mon Mar 15 21:19:05 1999
+++ linux-22009m/lib/vsprintf.c	Sun May 16 15:41:23 1999
@@ -67,10 +67,106 @@
 #define LARGE	64		/* use 'ABCDEF' instead of 'abcdef' */
 
 #define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long) n) % (unsigned) base; \
-n = ((unsigned long) n) / (unsigned) base; \
-__res; })
+  int __res; \
+  __res = ((unsigned long) n) % (unsigned) base; \
+  n = ((unsigned long) n) / (unsigned) base; \
+  __res; })
+
+#if BITS_PER_LONG < 64
+
+/* Note: do_ldiv assumes that unsigned long long is a 64 bit long
+ * and unsigned long is at least a 32 bits long.
+ */
+#define do_ldiv(n, base) \
+({ \
+	unsigned long long value = n; \
+	unsigned long long leftover; \
+	unsigned long temp; \
+	unsigned long result_div1, result_div2, result_div3, result_mod; \
+\
+	temp = value >> 32; \
+	result_div1 = temp/(base); \
+	result_mod = temp%(base); \
+\
+	temp = (result_mod << 24) | ((value >> 8) & 0xFFFFFF); \
+	result_div2 = temp/(base); \
+	result_mod = temp%(base); \
+\
+	temp = (result_mod << 8) | (value & 0xFF); \
+	result_div3 = temp/(base); \
+	result_mod = temp%(base);\
+\
+	leftover = ((unsigned long long)result_div1 << 32) | \
+		((unsigned long long)result_div2 << 8) | (result_div3); \
+\
+	n = leftover; \
+	result_mod; \
+})
+
+
+static char * lnumber(char * str, long long num, int base, int size,
+		      int precision, int type)
+{
+	char c,sign,tmp[66];
+	const char *digits="0123456789abcdef";
+	int i;
+
+	if (type & LARGE)
+		digits = "0123456789ABCDEF";
+	if (type & LEFT)
+		type &= ~ZEROPAD;
+	if (base < 2 || base > 36)
+		return 0;
+	c = (type & ZEROPAD) ? '0' : ' ';
+	sign = 0;
+	if (type & SIGN) {
+		if (num < 0) {
+			sign = '-';
+			num = -num;
+			size--;
+		} else if (type & PLUS) {
+			sign = '+';
+			size--;
+		} else if (type & SPACE) {
+			sign = ' ';
+			size--;
+		}
+	}
+	if (type & SPECIAL) {
+		if (base == 16)
+			size -= 2;
+	}
+	i = 0;
+	if (num == 0)
+		tmp[i++]='0';
+	else while (num != 0)
+		tmp[i++] = digits[do_ldiv(num,base)];
+	if (i > precision)
+		precision = i;
+	size -= precision;
+	if (!(type&(ZEROPAD+LEFT)))
+		while(size-->0)
+			*str++ = ' ';
+	if (sign)
+		*str++ = sign;
+	if (type & SPECIAL) {
+		if (base==16) {
+			*str++ = '0';
+			*str++ = digits[33];
+		}
+	}
+	if (!(type & LEFT))
+		while (size-- > 0)
+			*str++ = c;
+	while (i < precision--)
+		*str++ = '0';
+	while (i-- > 0)
+		*str++ = tmp[i];
+	while (size-- > 0)
+		*str++ = ' ';
+	return str;
+}
+#endif
 
 static char * number(char * str, long num, int base, int size, int precision
 	,int type)
@@ -207,7 +303,10 @@
 		/* get the conversion qualifier */
 		qualifier = -1;
 		if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
-			qualifier = *fmt;
+			if (*fmt == 'l' && qualifier == 'l')
+				qualifier = 'L';
+			else
+				qualifier = *fmt;
 			++fmt;
 		}
 
@@ -290,7 +389,22 @@
 				--fmt;
 			continue;
 		}
-		if (qualifier == 'l')
+		if (qualifier == 'L') {
+
+#if BITS_PER_LONG < 64
+		/* 64-bit printout in 32-bit systems !!
+		   Needed at some point for 64-bit file offsets and
+		   mmap() reporting functions. */
+
+			unsigned long long lnum;
+			lnum = va_arg(args, unsigned long long);
+			str = lnumber(str, lnum, base, field_width,
+				      precision, flags);
+			continue;
+#else
+			num = va_arg(args, unsigned long); /* 64-bit longs..*/
+#endif
+		} else if (qualifier == 'l')
 			num = va_arg(args, unsigned long);
 		else if (qualifier == 'h') {
 			num = (unsigned short) va_arg(args, int);
diff -u -r linux-22009/mm/filemap.c linux-22009m/mm/filemap.c
--- linux-22009/mm/filemap.c	Tue May 11 18:51:13 1999
+++ linux-22009m/mm/filemap.c	Mon May 17 01:04:37 1999
@@ -86,7 +86,7 @@
  * Truncate the page cache at a set offset, removing the pages
  * that are beyond that offset (and zeroing out partial pages).
  */
-void truncate_inode_pages(struct inode * inode, unsigned long start)
+void truncate_inode_pages(struct inode * inode, loff_t start)
 {
 	struct page ** p;
 	struct page * page;
@@ -94,10 +94,10 @@
 repeat:
 	p = &inode->i_pages;
 	while ((page = *p) != NULL) {
-		unsigned long offset = page->offset;
+		loff_t loffset = pgoff2loff(page->pg_offset);
 
 		/* page wholly truncated - free it */
-		if (offset >= start) {
+		if (loffset >= start) {
 			if (PageLocked(page)) {
 				wait_on_page(page);
 				goto repeat;
@@ -113,9 +113,10 @@
 			continue;
 		}
 		p = &page->next;
-		offset = start - offset;
+		loffset = start - loffset;
 		/* partial truncate, clear end of page */
-		if (offset < PAGE_CACHE_SIZE) {
+		if (loffset < PAGE_CACHE_SIZE) {
+			unsigned int  offset  = loffset; /* truncate ok */
 			unsigned long address = page_address(page);
 			memset((void *) (offset + address), 0, PAGE_CACHE_SIZE - offset);
 			flush_page_to_ram(address);
@@ -182,7 +183,8 @@
 		 * were to be marked referenced..
 		 */
 		if (PageSwapCache(page)) {
-			if (referenced && swap_count(page->offset) != 1)
+			if (referenced &&
+			    swap_count(pgoff2ulong(page->pg_offset)) != 1)
 				continue;
 			delete_from_swap_cache(page);
 			return 1;
@@ -216,11 +218,12 @@
  * Update a page cache copy, when we're doing a "write()" system call
  * See also "update_vm_cache()".
  */
-void update_vm_cache(struct inode * inode, unsigned long pos, const char * buf, int count)
+void update_vm_cache(struct inode * inode, loff_t pos, const char * buf, int count)
 {
-	unsigned long offset, len;
+	unsigned long offset, len; /* 32 bit signed int would be enough */
+	pgoff_t pgoff = loff2pgoff(pos);
 
-	offset = (pos & ~PAGE_CACHE_MASK);
+	offset = (pos & ~PAGE_CACHE_MASK); /* Byte offset for start within page*/
 	pos = pos & PAGE_CACHE_MASK;
 	len = PAGE_CACHE_SIZE - offset;
 	do {
@@ -228,7 +231,7 @@
 
 		if (len > count)
 			len = count;
-		page = find_page(inode, pos);
+		page = find_page(inode, pgoff);
 		if (page) {
 			wait_on_page(page);
 			memcpy((void *) (offset + page_address(page)), buf, len);
@@ -243,12 +246,13 @@
 }
 
 static inline void add_to_page_cache(struct page * page,
-	struct inode * inode, unsigned long offset,
-	struct page **hash)
+				     struct inode * inode,
+				     pgoff_t pgoff,
+				     struct page **hash)
 {
 	atomic_inc(&page->count);
 	page->flags = (page->flags & ~((1 << PG_uptodate) | (1 << PG_error))) | (1 << PG_referenced);
-	page->offset = offset;
+	page->pg_offset = pgoff;
 	add_page_to_inode_queue(inode, page);
 	__add_page_to_hash_queue(page, hash);
 }
@@ -259,29 +263,32 @@
  * this is all overlapped with the IO on the previous page finishing anyway)
  */
 static unsigned long try_to_read_ahead(struct file * file,
-				unsigned long offset, unsigned long page_cache)
+				       pgoff_t pgoff, unsigned long page_cache)
 {
 	struct inode *inode = file->f_dentry->d_inode;
-	struct page * page;
-	struct page ** hash;
+	pgoff_t pg_size;
+
+	/* Calculate file size in 'pages' -- if even one byte (according to
+	   the 'i_size') exceeds the final page-size block, round up. */
+	pg_size = loff2pgoff(inode->i_size+(PAGE_SIZE-1));
 
-	offset &= PAGE_CACHE_MASK;
-	switch (page_cache) {
-	case 0:
+	if (!page_cache) {
 		page_cache = page_cache_alloc();
 		if (!page_cache)
-			break;
-	default:
-		if (offset >= inode->i_size)
-			break;
-		hash = page_hash(inode, offset);
-		page = __find_page(inode, offset, *hash);
+			return 0; /* Can't allocate! */
+	}
+	/* Ok, we have a page, make sure it is in the page cache */
+	if (pgoff2ulong(pgoff) < pgoff2ulong(pg_size)) {
+		struct page * page;
+		struct page ** hash;
+		hash = page_hash(inode, pgoff);
+		page = __find_page(inode, pgoff, *hash);
 		if (!page) {
 			/*
 			 * Ok, add the new page to the hash-queues...
 			 */
 			page = page_cache_entry(page_cache);
-			add_to_page_cache(page, inode, offset, hash);
+			add_to_page_cache(page, inode, pgoff, hash);
 			inode->i_op->readpage(file, page);
 			page_cache = 0;
 		}
@@ -335,11 +342,11 @@
 
 #define PROFILE_MAXREADCOUNT 1000
 
-static unsigned long total_reada;
-static unsigned long total_async;
-static unsigned long total_ramax;
-static unsigned long total_ralen;
-static unsigned long total_rawin;
+static u_long total_reada;
+static u_long total_async;
+static u_long total_ramax;
+static u_long total_ralen;
+static u_long total_rawin;
 
 static void profile_readahead(int async, struct file *filp)
 {
@@ -447,13 +454,13 @@
 
 static inline unsigned long generic_file_readahead(int reada_ok,
 	struct file * filp, struct inode * inode,
-	unsigned long ppos, struct page * page, unsigned long page_cache)
+	loff_t ppos, struct page * page, unsigned long page_cache)
 {
-	unsigned long max_ahead, ahead;
-	unsigned long raend;
+	loff_t max_ahead, ahead;
+	loff_t raend;
 	int max_readahead = get_max_readahead(inode);
 
-	raend = filp->f_raend & PAGE_CACHE_MASK;
+	raend = filp->f_raend & PAGE_CACHE_MASK_loff;
 	max_ahead = 0;
 
 /*
@@ -511,7 +518,7 @@
 	ahead = 0;
 	while (ahead < max_ahead) {
 		ahead += PAGE_CACHE_SIZE;
-		page_cache = try_to_read_ahead(filp, raend + ahead,
+		page_cache = try_to_read_ahead(filp, loff2pgoff(raend + ahead),
 						page_cache);
 	}
 /*
@@ -577,14 +584,17 @@
 {
 	struct dentry *dentry = filp->f_dentry;
 	struct inode *inode = dentry->d_inode;
-	size_t pos, pgpos, page_cache;
+	size_t page_cache;
+	pgoff_t pgpos;
+	loff_t pos, posp;
 	int reada_ok;
 	int max_readahead = get_max_readahead(inode);
 
 	page_cache = 0;
 
 	pos = *ppos;
-	pgpos = pos & PAGE_CACHE_MASK;
+	posp = pos & PAGE_CACHE_MASK_loff;
+	pgpos = loff2pgoff(pos);
 /*
  * If the current position is outside the previous read-ahead window, 
  * we reset the current read-ahead context and set read ahead max to zero
@@ -592,7 +602,7 @@
  * otherwise, we assume that the file accesses are sequential enough to
  * continue read-ahead.
  */
-	if (pgpos > filp->f_raend || pgpos + filp->f_rawin < filp->f_raend) {
+	if (posp > filp->f_raend || posp + filp->f_rawin < filp->f_raend) {
 		reada_ok = 0;
 		filp->f_raend = 0;
 		filp->f_ralen = 0;
@@ -608,12 +618,12 @@
  * Then, at least MIN_READAHEAD if read ahead is ok,
  * and at most MAX_READAHEAD in all cases.
  */
-	if (pos + desc->count <= (PAGE_CACHE_SIZE >> 1)) {
+	if (pos + desc->count <= (loff_t)(PAGE_CACHE_SIZE >> 1)) {
 		filp->f_ramax = 0;
 	} else {
-		unsigned long needed;
+		loff_t needed;
 
-		needed = ((pos + desc->count) & PAGE_CACHE_MASK) - pgpos;
+		needed = ((pos + desc->count) & PAGE_CACHE_MASK) - posp;
 
 		if (filp->f_ramax < needed)
 			filp->f_ramax = needed;
@@ -626,6 +636,7 @@
 
 	for (;;) {
 		struct page *page, **hash;
+		pgoff_t pgoff;
 
 		if (pos >= inode->i_size)
 			break;
@@ -633,8 +644,9 @@
 		/*
 		 * Try to find the data in the page cache..
 		 */
-		hash = page_hash(inode, pos & PAGE_CACHE_MASK);
-		page = __find_page(inode, pos & PAGE_CACHE_MASK, *hash);
+		pgoff = loff2pgoff(pos);
+		hash = page_hash(inode, pgoff);
+		page = __find_page(inode, pgoff, *hash);
 		if (!page)
 			goto no_cached_page;
 
@@ -647,7 +659,7 @@
  * the page has been rewritten.
  */
 		if (PageUptodate(page) || PageLocked(page))
-			page_cache = generic_file_readahead(reada_ok, filp, inode, pos & PAGE_CACHE_MASK, page, page_cache);
+			page_cache = generic_file_readahead(reada_ok, filp, inode, pos & PAGE_CACHE_MASK_loff, page, page_cache);
 		else if (reada_ok && filp->f_ramax > MIN_READAHEAD)
 				filp->f_ramax = MIN_READAHEAD;
 
@@ -665,8 +677,8 @@
 		unsigned long offset, nr;
 
 		offset = pos & ~PAGE_CACHE_MASK;
-		nr = PAGE_CACHE_SIZE - offset;
-		if (nr > inode->i_size - pos)
+		nr = PAGE_CACHE_SIZE - offset; /* small value */
+		if ((loff_t)nr > (inode->i_size - pos))
 			nr = inode->i_size - pos;
 
 		/*
@@ -706,7 +718,7 @@
 		 */
 		page = page_cache_entry(page_cache);
 		page_cache = 0;
-		add_to_page_cache(page, inode, pos & PAGE_CACHE_MASK, hash);
+		add_to_page_cache(page, inode, pgoff, hash);
 
 		/*
 		 * Error handling is tricky. If we get a read error,
@@ -787,10 +799,26 @@
 ssize_t generic_file_read(struct file * filp, char * buf, size_t count, loff_t *ppos)
 {
 	ssize_t retval;
+	struct inode *inode = filp->f_dentry->d_inode;
 
 	retval = -EFAULT;
 	if (access_ok(VERIFY_WRITE, buf, count)) {
 		retval = 0;
+
+		/* L-F-S spec 2.2.1.25: */
+		if (count && !(filp->f_flags & O_LARGEFILE) &&
+		    S_ISREG(inode->i_mode) &&
+		    (*ppos < inode->i_size) &&
+		    !off_t_presentable(1 + *ppos)) /* pos@LONG_MAX forbidden */
+			return -EOVERFLOW;
+		if (count && !(filp->f_flags & O_LARGEFILE) &&
+		    S_ISREG(inode->i_mode) &&
+		    (*ppos < inode->i_size) &&
+		    !off_t_presentable(*ppos + count)) {
+			/* Read only until end of allowed region */
+			count = LONG_MAX - *ppos;
+		}
+
 		if (count) {
 			read_descriptor_t desc;
 
@@ -932,20 +960,25 @@
 	struct file * file = area->vm_file;
 	struct dentry * dentry = file->f_dentry;
 	struct inode * inode = dentry->d_inode;
-	unsigned long offset, reada, i;
+	loff_t offset;
+	pgoff_t pgoff, reada;
+	int i;
 	struct page * page, **hash;
 	unsigned long old_page, new_page;
 
 	new_page = 0;
-	offset = (address & PAGE_MASK) - area->vm_start + area->vm_offset;
+	offset = ((loff_t)((address & PAGE_MASK) - area->vm_start) +
+		  area->vm_offset);
+
 	if (offset >= inode->i_size && (area->vm_flags & VM_SHARED) && area->vm_mm == current->mm)
 		goto no_page;
 
 	/*
 	 * Do we have something in the page cache already?
 	 */
-	hash = page_hash(inode, offset);
-	page = __find_page(inode, offset, *hash);
+	pgoff = loff2pgoff(offset);
+	hash = page_hash(inode, pgoff);
+	page = __find_page(inode, pgoff, *hash);
 	if (!page)
 		goto no_cached_page;
 
@@ -996,11 +1029,12 @@
 	/*
 	 * Try to read in an entire cluster at once.
 	 */
-	reada   = offset;
-	reada >>= PAGE_CACHE_SHIFT + page_cluster;
-	reada <<= PAGE_CACHE_SHIFT + page_cluster;
+	reada   = loff2pgoff(offset);
+	/* Mask lowest  'page_cluster'  worth of the lowest bits */
+	reada   = ulong2pgoff(pgoff2ulong(reada) & ((~(0UL)) << page_cluster));
 
-	for (i = 1 << page_cluster; i > 0; --i, reada += PAGE_CACHE_SIZE)
+	for (i = 1 << page_cluster; i > 0;
+	     --i, reada = ulong2pgoff(pgoff2ulong(reada)+1))
 		new_page = try_to_read_ahead(file, reada, new_page);
 
 	if (!new_page)
@@ -1014,7 +1048,7 @@
 	 * cache.. The page we just got may be useful if we
 	 * can't share, so don't get rid of it here.
 	 */
-	page = find_page(inode, offset);
+	page = find_page(inode, pgoff);
 	if (page)
 		goto found_page;
 
@@ -1023,7 +1057,7 @@
 	 */
 	page = page_cache_entry(new_page);
 	new_page = 0;
-	add_to_page_cache(page, inode, offset, hash);
+	add_to_page_cache(page, inode, pgoff, hash);
 
 	if (inode->i_op->readpage(file, page) != 0)
 		goto failure;
@@ -1067,10 +1101,10 @@
  * if the disk is full.
  */
 static inline int do_write_page(struct inode * inode, struct file * file,
-	const char * page, unsigned long offset)
+				const char * page, loff_t offset)
 {
 	int retval;
-	unsigned long size;
+	loff_t size;
 	loff_t loff = offset;
 	mm_segment_t old_fs;
 
@@ -1094,7 +1128,7 @@
 }
 
 static int filemap_write_page(struct vm_area_struct * vma,
-			      unsigned long offset,
+			      loff_t offset,
 			      unsigned long page,
 			      int wait)
 {
@@ -1140,7 +1174,7 @@
  */
 int filemap_swapout(struct vm_area_struct * vma, struct page * page)
 {
-	return filemap_write_page(vma, page->offset, page_address(page), 0);
+	return filemap_write_page(vma, pgoff2loff(page->pg_offset), page_address(page), 0);
 }
 
 static inline int filemap_sync_pte(pte_t * ptep, struct vm_area_struct *vma,
@@ -1439,8 +1473,8 @@
 {
 	struct dentry	*dentry = file->f_dentry; 
 	struct inode	*inode = dentry->d_inode; 
-	unsigned long	pos = *ppos;
-	unsigned long	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	loff_t		pos = *ppos;
+	loff_t		limit = current->rlimfsz.rlim_cur;
 	struct page	*page, **hash;
 	unsigned long	page_cache = 0;
 	unsigned long	written;
@@ -1481,19 +1515,20 @@
 	}
 
 	while (count) {
-		unsigned long bytes, pgpos, offset;
+		unsigned long bytes, offset;
+		pgoff_t pgoffset;
 		/*
 		 * Try to find the page in the cache. If it isn't there,
 		 * allocate a free page.
 		 */
 		offset = (pos & ~PAGE_CACHE_MASK);
-		pgpos = pos & PAGE_CACHE_MASK;
+		pgoffset = loff2pgoff(pos);
 		bytes = PAGE_CACHE_SIZE - offset;
 		if (bytes > count)
 			bytes = count;
 
-		hash = page_hash(inode, pgpos);
-		page = __find_page(inode, pgpos, *hash);
+		hash = page_hash(inode, pgoffset);
+		page = __find_page(inode, pgoffset, *hash);
 		if (!page) {
 			if (!page_cache) {
 				page_cache = page_cache_alloc();
@@ -1503,7 +1538,7 @@
 				break;
 			}
 			page = page_cache_entry(page_cache);
-			add_to_page_cache(page, inode, pgpos, hash);
+			add_to_page_cache(page, inode, pgoffset, hash);
 			page_cache = 0;
 		}
 
@@ -1555,15 +1590,14 @@
  * Note: we don't have to worry about races here, as the caller
  * is holding the inode semaphore.
  */
-unsigned long get_cached_page(struct inode * inode, unsigned long offset,
-				int new)
+unsigned long get_cached_page(struct inode * inode, pgoff_t pgoff, int new)
 {
 	struct page * page;
 	struct page ** hash;
 	unsigned long page_cache = 0;
 
-	hash = page_hash(inode, offset);
-	page = __find_page(inode, offset, *hash);
+	hash = page_hash(inode, pgoff);
+	page = __find_page(inode, pgoff, *hash);
 	if (!page) {
 		if (!new)
 			goto out;
@@ -1572,7 +1606,7 @@
 			goto out;
 		clear_page(page_cache);
 		page = page_cache_entry(page_cache);
-		add_to_page_cache(page, inode, offset, hash);
+		add_to_page_cache(page, inode, pgoff, hash);
 	}
 	if (atomic_read(&page->count) != 2)
 		printk(KERN_ERR "get_cached_page: page count=%d\n",
diff -u -r linux-22009/mm/memory.c linux-22009m/mm/memory.c
--- linux-22009/mm/memory.c	Tue Apr 13 02:18:26 1999
+++ linux-22009m/mm/memory.c	Sun May 16 15:41:23 1999
@@ -647,7 +647,7 @@
 	case 2:
 		if (!PageSwapCache(page_map))
 			break;
-		if (swap_count(page_map->offset) != 1)
+		if (swap_count(pgoff2ulong(page_map->pg_offset)) != 1)
 			break;
 		delete_from_swap_cache(page_map);
 		/* FallThrough */
@@ -733,7 +733,7 @@
  * between the file and the memory map for a potential last
  * incomplete page.  Ugly, but necessary.
  */
-void vmtruncate(struct inode * inode, unsigned long offset)
+void vmtruncate(struct inode * inode, loff_t offset)
 {
 	struct vm_area_struct * mpnt;
 
diff -u -r linux-22009/mm/mmap.c linux-22009m/mm/mmap.c
--- linux-22009/mm/mmap.c	Wed May  5 01:44:38 1999
+++ linux-22009m/mm/mmap.c	Sun May 16 15:41:23 1999
@@ -170,7 +170,7 @@
 }
 
 unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
-	unsigned long prot, unsigned long flags, unsigned long off)
+	unsigned long prot, unsigned long flags, loff_t off)
 {
 	struct mm_struct * mm = current->mm;
 	struct vm_area_struct * vma;
@@ -830,7 +830,8 @@
 		 * the offsets must be contiguous..
 		 */
 		if ((mpnt->vm_file != NULL) || (mpnt->vm_flags & VM_SHM)) {
-			unsigned long off = prev->vm_offset+prev->vm_end-prev->vm_start;
+			loff_t off = (prev->vm_offset +
+				      (loff_t)(prev->vm_end - prev->vm_start));
 			if (off != mpnt->vm_offset)
 				continue;
 		}
diff -u -r linux-22009/mm/page_io.c linux-22009m/mm/page_io.c
--- linux-22009/mm/page_io.c	Mon Dec 28 23:56:29 1998
+++ linux-22009m/mm/page_io.c	Sun May 16 15:41:23 1999
@@ -99,7 +99,7 @@
 		 * as if it were: we are not allowed to manipulate the inode
 		 * hashing for locked pages.
 		 */
-		if (page->offset != entry) {
+		if (pgoff2ulong(page->pg_offset) != entry) {
 			printk ("swap entry mismatch");
 			return;
 		}
@@ -252,8 +252,8 @@
 		printk("VM: swap page is not in swap cache\n");
 		return;
 	}
-	if (page->offset != entry) {
-		printk ("swap entry mismatch");
+	if (pgoff2ulong(page->pg_offset) != entry) {
+		printk ("VM: swap entry mismatch");
 		return;
 	}
 	rw_swap_page_base(rw, entry, page, wait);
@@ -278,12 +278,12 @@
 		printk ("VM: read_swap_page: page already in page cache!\n");
 		return;
 	}
-	page->inode = &swapper_inode;
-	page->offset = entry;
+	page->inode     = &swapper_inode;
+	page->pg_offset = ulong2pgoff(entry);
 	atomic_inc(&page->count);	/* Protect from shrink_mmap() */
 	rw_swap_page(rw, entry, buffer, 1);
 	atomic_dec(&page->count);
-	page->inode = 0;
+	page->inode     = 0;
 	clear_bit(PG_swap_cache, &page->flags);
 }
 
diff -u -r linux-22009/mm/swap_state.c linux-22009m/mm/swap_state.c
--- linux-22009/mm/swap_state.c	Wed Jan 13 19:54:50 1999
+++ linux-22009m/mm/swap_state.c	Sun May 16 15:41:23 1999
@@ -54,7 +54,7 @@
 	if (PageTestandSetSwapCache(page)) {
 		printk(KERN_ERR "swap_cache: replacing non-empty entry %08lx "
 		       "on page %08lx\n",
-		       page->offset, page_address(page));
+		       pgoff2ulong(page->pg_offset), page_address(page));
 		return 0;
 	}
 	if (page->inode) {
@@ -64,8 +64,8 @@
 	}
 	atomic_inc(&page->count);
 	page->inode = &swapper_inode;
-	page->offset = entry;
-	add_page_to_hash_queue(page, &swapper_inode, entry);
+	page->pg_offset = ulong2pgoff(entry);
+	add_page_to_hash_queue(page, &swapper_inode, ulong2pgoff(entry));
 	add_page_to_inode_queue(&swapper_inode, page);
 	return 1;
 }
@@ -203,7 +203,7 @@
  */
 void delete_from_swap_cache(struct page *page)
 {
-	long entry = page->offset;
+	long entry = pgoff2ulong(page->pg_offset);
 
 #ifdef SWAP_CACHE_INFO
 	swap_cache_del_total++;
@@ -251,7 +251,7 @@
 	swap_cache_find_total++;
 #endif
 	while (1) {
-		found = find_page(&swapper_inode, entry);
+		found = find_page(&swapper_inode, ulong2pgoff(entry));
 		if (!found)
 			return 0;
 		if (found->inode != &swapper_inode || !PageSwapCache(found))
diff -u -r linux-22009/mm/vmscan.c linux-22009m/mm/vmscan.c
--- linux-22009/mm/vmscan.c	Fri Apr 23 21:07:30 1999
+++ linux-22009m/mm/vmscan.c	Sun May 16 15:41:23 1999
@@ -71,7 +71,7 @@
 	 * memory, and we should just continue our scan.
 	 */
 	if (PageSwapCache(page_map)) {
-		entry = page_map->offset;
+		entry = pgoff2ulong(page_map->pg_offset);
 		swap_duplicate(entry);
 		set_pte(page_table, __pte(entry));
 drop_pte:
diff -u -r linux-22009/net/irda/iriap.c linux-22009m/net/irda/iriap.c
--- linux-22009/net/irda/iriap.c	Sun Apr 25 03:50:06 1999
+++ linux-22009m/net/irda/iriap.c	Sun May 16 15:41:23 1999
@@ -28,7 +28,7 @@
 #include <linux/skbuff.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/irda.h>
+/* #include <linux/irda.h> */ /* No such include ?? */
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
