Binary files 2.3.99-pre7-pre3/ID and lfs-2.3.x/ID differ
diff -urN 2.3.99-pre7-pre3/arch/i386/kernel/entry.S lfs-2.3.x/arch/i386/kernel/entry.S
--- 2.3.99-pre7-pre3/arch/i386/kernel/entry.S	Thu Apr 27 17:56:37 2000
+++ lfs-2.3.x/arch/i386/kernel/entry.S	Thu May  4 02:24:23 2000
@@ -635,6 +635,7 @@
 	.long SYMBOL_NAME(sys_pivot_root)
 	.long SYMBOL_NAME(sys_mincore)
 	.long SYMBOL_NAME(sys_madvise)
+	.long SYMBOL_NAME(sys_fcntl64)		/* 220 */
 
 
 	/*
@@ -643,6 +644,6 @@
 	 * entries. Don't panic if you notice that this hasn't
 	 * been shrunk every time we add a new system call.
 	 */
-	.rept NR_syscalls-219
+	.rept NR_syscalls-220
 		.long SYMBOL_NAME(sys_ni_syscall)
 	.endr
diff -urN 2.3.99-pre7-pre3/arch/sparc/kernel/systbls.S lfs-2.3.x/arch/sparc/kernel/systbls.S
--- 2.3.99-pre7-pre3/arch/sparc/kernel/systbls.S	Thu Apr 27 17:56:38 2000
+++ lfs-2.3.x/arch/sparc/kernel/systbls.S	Thu May  4 02:37:24 2000
@@ -46,7 +46,7 @@
 /*125*/	.long sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate
 /*130*/	.long sys_ftruncate, sys_flock, sys_lstat64, sys_nis_syscall, sys_nis_syscall
 /*135*/	.long sys_nis_syscall, sys_mkdir, sys_rmdir, sys_utimes, sys_stat64
-/*140*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getrlimit
+/*140*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_fcntl64, sys_getrlimit
 /*145*/	.long sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
 /*150*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
 /*155*/	.long sys_nis_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
diff -urN 2.3.99-pre7-pre3/arch/sparc64/kernel/sys_sparc32.c lfs-2.3.x/arch/sparc64/kernel/sys_sparc32.c
--- 2.3.99-pre7-pre3/arch/sparc64/kernel/sys_sparc32.c	Thu Apr 27 17:56:38 2000
+++ lfs-2.3.x/arch/sparc64/kernel/sys_sparc32.c	Thu May  4 02:00:23 2000
@@ -889,6 +889,30 @@
 	return err;
 }
 
+static inline int get_flock64(struct flock *kfl, struct flock32_64 *ufl)
+{
+	int err;
+	
+	err = get_user(kfl->l_type, &ufl->l_type);
+	err |= __get_user(kfl->l_whence, &ufl->l_whence);
+	err |= __get_user(kfl->l_start, &ufl->l_start);
+	err |= __get_user(kfl->l_len, &ufl->l_len);
+	err |= __get_user(kfl->l_pid, &ufl->l_pid);
+	return err;
+}
+
+static inline int put_flock64(struct flock *kfl, struct flock32_64 *ufl)
+{
+	int err;
+	
+	err = __put_user(kfl->l_type, &ufl->l_type);
+	err |= __put_user(kfl->l_whence, &ufl->l_whence);
+	err |= __put_user(kfl->l_start, &ufl->l_start);
+	err |= __put_user(kfl->l_len, &ufl->l_len);
+	err |= __put_user(kfl->l_pid, &ufl->l_pid);
+	return err;
+}
+
 extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
 
 asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
@@ -907,7 +931,61 @@
 			old_fs = get_fs(); set_fs (KERNEL_DS);
 			ret = sys_fcntl(fd, cmd, (unsigned long)&f);
 			set_fs (old_fs);
+			if (f.l_start >= 0x7fffffffUL ||
+			    f.l_len >= 0x7fffffffUL ||
+			    f.l_start + f.l_len >= 0x7fffffffUL)
+				return -EOVERFLOW;
 			if(put_flock(&f, (struct flock32 *)arg))
+				return -EFAULT;
+			return ret;
+		}
+	case F_GETLK64:
+	case F_SETLK64:
+	case F_SETLKW64:
+		return -EINVAL;
+	default:
+		return sys_fcntl(fd, cmd, (unsigned long)arg);
+	}
+}
+
+asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case F_GETLK:
+	case F_SETLK:
+	case F_SETLKW:
+		{
+			struct flock f;
+			mm_segment_t old_fs;
+			long ret;
+			
+			if(get_flock(&f, (struct flock32 *)arg))
+				return -EFAULT;
+			old_fs = get_fs(); set_fs (KERNEL_DS);
+			ret = sys_fcntl(fd, cmd, (unsigned long)&f);
+			set_fs (old_fs);
+			if (f.l_start >= 0x7fffffffUL ||
+			    f.l_len >= 0x7fffffffUL ||
+			    f.l_start + f.l_len >= 0x7fffffffUL)
+				return -EOVERFLOW;
+			if(put_flock(&f, (struct flock32 *)arg))
+				return -EFAULT;
+			return ret;
+		}
+	case F_GETLK64:
+	case F_SETLK64:
+	case F_SETLKW64:
+		{
+			struct flock f;
+			mm_segment_t old_fs;
+			long ret;
+			
+			if(get_flock64(&f, (struct flock32_64 *)arg))
+				return -EFAULT;
+			old_fs = get_fs(); set_fs (KERNEL_DS);
+			ret = sys_fcntl(fd, cmd + F_GETLK - F_GETLK64, (unsigned long)&f);
+			set_fs (old_fs);
+			if(put_flock64(&f, (struct flock32_64 *)arg))
 				return -EFAULT;
 			return ret;
 		}
diff -urN 2.3.99-pre7-pre3/arch/sparc64/kernel/systbls.S lfs-2.3.x/arch/sparc64/kernel/systbls.S
--- 2.3.99-pre7-pre3/arch/sparc64/kernel/systbls.S	Thu Apr 27 17:56:38 2000
+++ lfs-2.3.x/arch/sparc64/kernel/systbls.S	Thu May  4 02:53:23 2000
@@ -47,7 +47,7 @@
 	.word sys_nis_syscall, sys32_setreuid16, sys32_setregid16, sys_rename, sys_truncate
 /*130*/	.word sys_ftruncate, sys_flock, sys_lstat64, sys_nis_syscall, sys_nis_syscall
 	.word sys_nis_syscall, sys_mkdir, sys_rmdir, sys32_utimes, sys_stat64
-/*140*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getrlimit
+/*140*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_fcntl64, sys32_getrlimit
 	.word sys32_setrlimit, sys_pivot_root, sys32_prctl, sys32_pciconfig_read, sys32_pciconfig_write
 /*150*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
 	.word sys_nis_syscall, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
diff -urN 2.3.99-pre7-pre3/fs/fcntl.c lfs-2.3.x/fs/fcntl.c
--- 2.3.99-pre7-pre3/fs/fcntl.c	Sun Feb 27 06:19:43 2000
+++ lfs-2.3.x/fs/fcntl.c	Thu May  4 02:00:23 2000
@@ -173,16 +173,11 @@
 	return 0;
 }
 
-asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{	
-	struct file * filp;
-	long err = -EBADF;
+static long do_fcntl(unsigned int fd, unsigned int cmd,
+		     unsigned long arg, struct file * filp)
+{
+	long err = 0;
 
-	filp = fget(fd);
-	if (!filp)
-		goto out;
-	err = 0;
-	lock_kernel();
 	switch (cmd) {
 		case F_DUPFD:
 			err = -EINVAL;
@@ -215,6 +210,7 @@
 		case F_SETLKW:
 			err = fcntl_setlk(fd, cmd, (struct flock *) arg);
 			break;
+
 		case F_GETOWN:
 			/*
 			 * XXX If f_owner is a process group, the
@@ -251,11 +247,60 @@
 				err = sock_fcntl (filp, cmd, arg);
 			break;
 	}
+
+	return err;
+}
+
+asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{	
+	struct file * filp;
+	long err = -EBADF;
+
+	filp = fget(fd);
+	if (!filp)
+		goto out;
+
+	lock_kernel();
+	err = do_fcntl(fd, cmd, arg, filp);
+	unlock_kernel();
+
 	fput(filp);
+out:
+	return err;
+}
+
+#if BITS_PER_LONG == 32
+asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
+{	
+	struct file * filp;
+	long err;
+
+	err = -EBADF;
+	filp = fget(fd);
+	if (!filp)
+		goto out;
+
+	lock_kernel();
+	switch (cmd) {
+		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;
+		default:
+			err = do_fcntl(fd, cmd, arg, filp);
+			break;
+	}
 	unlock_kernel();
+	fput(filp);
 out:
 	return err;
 }
+#endif
 
 /* Table to convert sigio signal codes into poll band bitmaps */
 
diff -urN 2.3.99-pre7-pre3/fs/locks.c lfs-2.3.x/fs/locks.c
--- 2.3.99-pre7-pre3/fs/locks.c	Thu Apr 27 17:56:42 2000
+++ lfs-2.3.x/fs/locks.c	Thu May  4 02:00:23 2000
@@ -114,7 +114,7 @@
 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,
@@ -321,11 +321,16 @@
 {
 	struct file *filp;
 	struct file_lock *fl,file_lock;
-	struct flock flock;
+	struct flock64 flock;
 	int error;
 
 	error = -EFAULT;
-	if (copy_from_user(&flock, l, sizeof(flock)))
+	if (verify_area(VERIFY_READ, l, sizeof(*l))
+	    || __get_user(flock.l_type, &l->l_type)
+	    || __get_user(flock.l_whence, &l->l_whence)
+	    || __get_user(flock.l_start, &l->l_start)
+	    || __get_user(flock.l_len, &l->l_len)
+	    || __get_user(flock.l_pid, &l->l_pid))
 		goto out;
 	error = -EINVAL;
 	if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
@@ -336,6 +341,7 @@
 	if (!filp)
 		goto out;
 
+	error = -EINVAL;
 	if (!posix_make_lock(filp, &file_lock, &flock))
 		goto out_putf;
 
@@ -361,9 +367,24 @@
 		flock.l_whence = 0;
 		flock.l_type = fl->fl_type;
 	}
-	error = -EFAULT;
-	if (!copy_to_user(l, &flock, sizeof(flock)))
-		error = 0;
+
+	/* 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;
+	}
+
+	error = 0;
+	if (verify_area(VERIFY_WRITE, l, sizeof(*l))
+	    || __put_user(flock.l_type, &l->l_type)
+	    || __put_user(flock.l_whence, &l->l_whence)
+	    || __put_user(flock.l_start, &l->l_start)
+	    || __put_user(flock.l_len, &l->l_len)
+	    || __put_user(flock.l_pid, &l->l_pid))
+		error = -EFAULT;
   
 out_putf:
 	fput(filp);
@@ -378,7 +399,7 @@
 {
 	struct file *filp;
 	struct file_lock file_lock;
-	struct flock flock;
+	struct flock64 flock;
 	struct inode *inode;
 	int error;
 
@@ -386,7 +407,12 @@
 	 * This might block, so we do it before checking the inode.
 	 */
 	error = -EFAULT;
-	if (copy_from_user(&flock, l, sizeof(flock)))
+	if (verify_area(VERIFY_READ, l, sizeof(*l))
+	    || __get_user(flock.l_type, &l->l_type)
+	    || __get_user(flock.l_whence, &l->l_whence)
+	    || __get_user(flock.l_start, &l->l_start)
+	    || __get_user(flock.l_len, &l->l_len)
+	    || __get_user(flock.l_pid, &l->l_pid))
 		goto out;
 
 	/* Get arguments and validate them ...
@@ -469,6 +495,149 @@
 	return error;
 }
 
+#if BITS_PER_LONG == 32
+/* 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;
+	if (copy_from_user(&flock, l, sizeof(flock)))
+		goto out;
+	error = -EINVAL;
+	if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
+		goto out;
+
+	error = -EBADF;
+	filp = fget(fd);
+	if (!filp)
+		goto out;
+
+	error = -EINVAL;
+	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;
+		else if (error == LOCK_USE_CLNT)
+		  /* Bypass for NFS with no locking - 2.0.36 compat */
+		  fl = posix_test_lock(filp, &file_lock);
+		else
+		  fl = (file_lock.fl_type == F_UNLCK ? NULL : &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;
+	}
+	error = -EFAULT;
+	if (!copy_to_user(l, &flock, sizeof(flock)))
+		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_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l)
+{
+	struct file *filp;
+	struct file_lock file_lock;
+	struct flock64 flock;
+	struct inode *inode;
+	int error;
+
+	/*
+	 * This might block, so we do it before checking the inode.
+	 */
+	error = -EFAULT;
+	if (copy_from_user(&flock, l, sizeof(flock)))
+		goto out;
+
+	/* Get arguments and validate them ...
+	 */
+
+	error = -EBADF;
+	filp = fget(fd);
+	if (!filp)
+		goto out;
+
+	error = -EINVAL;
+	inode = filp->f_dentry->d_inode;
+
+	/* 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) {
+		struct vm_area_struct *vma;
+		struct address_space *mapping = inode->i_mapping;
+		spin_lock(&mapping->i_shared_lock);
+		for(vma = mapping->i_mmap;vma;vma = vma->vm_next_share) {
+			if (!(vma->vm_flags & VM_MAYSHARE))
+				continue;
+			spin_unlock(&mapping->i_shared_lock);
+			error = -EAGAIN;
+			goto out_putf;
+		}
+		spin_unlock(&mapping->i_shared_lock);
+	}
+
+	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:
+	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;
+}
+#endif /* BITS_PER_LONG == 32 */
+
 /*
  * This function is called when the file is being removed
  * from the task's fd array.
@@ -638,7 +807,7 @@
  * style lock.
  */
 static int posix_make_lock(struct file *filp, struct file_lock *fl,
-			   struct flock *l)
+			   struct flock64 *l)
 {
 	loff_t start;
 
diff -urN 2.3.99-pre7-pre3/fs/stat.c lfs-2.3.x/fs/stat.c
--- 2.3.99-pre7-pre3/fs/stat.c	Thu Apr 27 17:56:42 2000
+++ lfs-2.3.x/fs/stat.c	Thu May  4 04:33:12 2000
@@ -49,6 +49,10 @@
 	SET_OLDSTAT_UID(tmp, inode->i_uid);
 	SET_OLDSTAT_GID(tmp, inode->i_gid);
 	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
+#if BITS_PER_LONG == 32
+	if (inode->i_size > 0x7fffffff)
+		return -EOVERFLOW;
+#endif	
 	tmp.st_size = inode->i_size;
 	tmp.st_atime = inode->i_atime;
 	tmp.st_mtime = inode->i_mtime;
@@ -71,6 +75,10 @@
 	SET_STAT_UID(tmp, inode->i_uid);
 	SET_STAT_GID(tmp, inode->i_gid);
 	tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
+#if BITS_PER_LONG == 32
+	if (inode->i_size > 0x7fffffff)
+		return -EOVERFLOW;
+#endif	
 	tmp.st_size = inode->i_size;
 	tmp.st_atime = inode->i_atime;
 	tmp.st_mtime = inode->i_mtime;
diff -urN 2.3.99-pre7-pre3/include/asm-alpha/fcntl.h lfs-2.3.x/include/asm-alpha/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-alpha/fcntl.h	Sun Jan  9 20:45:31 2000
+++ lfs-2.3.x/include/asm-alpha/fcntl.h	Thu May  4 02:00:23 2000
@@ -63,4 +63,8 @@
 	__kernel_pid_t l_pid;
 };
 
+#ifdef __KERNEL__
+#define flock64	flock
+#endif
+
 #endif
diff -urN 2.3.99-pre7-pre3/include/asm-i386/fcntl.h lfs-2.3.x/include/asm-i386/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-i386/fcntl.h	Mon Jan 18 02:27:15 1999
+++ lfs-2.3.x/include/asm-i386/fcntl.h	Thu May  4 02:00:23 2000
@@ -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 {
+	short  l_type;
+	short  l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	pid_t  l_pid;
 };
 
 #endif
diff -urN 2.3.99-pre7-pre3/include/asm-i386/unistd.h lfs-2.3.x/include/asm-i386/unistd.h
--- 2.3.99-pre7-pre3/include/asm-i386/unistd.h	Wed Mar 15 16:45:13 2000
+++ lfs-2.3.x/include/asm-i386/unistd.h	Thu May  4 02:24:04 2000
@@ -225,6 +225,7 @@
 #define __NR_mincore		218
 #define __NR_madvise		219
 #define __NR_madvise1		219	/* delete when C lib stub is removed */
+#define __NR_fcntl64		220
 
 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
 
diff -urN 2.3.99-pre7-pre3/include/asm-ia64/fcntl.h lfs-2.3.x/include/asm-ia64/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-ia64/fcntl.h	Fri Feb 11 00:05:38 2000
+++ lfs-2.3.x/include/asm-ia64/fcntl.h	Thu May  4 03:00:25 2000
@@ -70,4 +70,8 @@
 	pid_t l_pid;
 };
 
+#ifdef __KERNEL__
+#define flock64        flock
+#endif
+
 #endif /* _ASM_IA64_FCNTL_H */
diff -urN 2.3.99-pre7-pre3/include/asm-m68k/fcntl.h lfs-2.3.x/include/asm-m68k/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-m68k/fcntl.h	Sun Jan 30 15:43:39 2000
+++ lfs-2.3.x/include/asm-m68k/fcntl.h	Thu May  4 02:00:23 2000
@@ -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 {
+	short  l_type;
+	short  l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	pid_t  l_pid;
 };
 
 #endif /* _M68K_FCNTL_H */
diff -urN 2.3.99-pre7-pre3/include/asm-mips/fcntl.h lfs-2.3.x/include/asm-mips/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-mips/fcntl.h	Sun Feb 27 06:19:44 2000
+++ lfs-2.3.x/include/asm-mips/fcntl.h	Thu May  4 02:00:23 2000
@@ -44,6 +44,10 @@
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
 
+#define F_GETLK64	33	/*  using 'struct flock64' */
+#define F_SETLK64	34
+#define F_SETLKW64	35
+
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
@@ -72,5 +76,13 @@
 	__kernel_pid_t l_pid;
 	long  pad[4];			/* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
 } flock_t;
+
+typedef struct flock64 {
+	short  l_type;
+	short  l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	pid_t  l_pid;
+} flock64_t;
 
 #endif /* __ASM_MIPS_FCNTL_H */
diff -urN 2.3.99-pre7-pre3/include/asm-mips64/fcntl.h lfs-2.3.x/include/asm-mips64/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-mips64/fcntl.h	Sun Feb 27 06:19:44 2000
+++ lfs-2.3.x/include/asm-mips64/fcntl.h	Thu May  4 02:00:23 2000
@@ -73,4 +73,8 @@
 	long  pad[4];			/* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
 } flock_t;
 
+#ifdef __KERNEL__
+#define flock64	flock
+#endif
+
 #endif /* _ASM_FCNTL_H */
diff -urN 2.3.99-pre7-pre3/include/asm-ppc/fcntl.h lfs-2.3.x/include/asm-ppc/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-ppc/fcntl.h	Sun Nov 21 03:20:20 1999
+++ lfs-2.3.x/include/asm-ppc/fcntl.h	Thu May  4 02:00:23 2000
@@ -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 */
 
@@ -66,6 +70,14 @@
 	off_t l_start;
 	off_t l_len;
 	pid_t l_pid;
+};
+
+struct flock64 {
+	short  l_type;
+	short  l_whence;
+	loff_t l_start;
+	loff_t l_len;
+	pid_t  l_pid;
 };
 
 #endif
diff -urN 2.3.99-pre7-pre3/include/asm-sparc/fcntl.h lfs-2.3.x/include/asm-sparc/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-sparc/fcntl.h	Wed Jan  5 17:42:52 2000
+++ lfs-2.3.x/include/asm-sparc/fcntl.h	Thu May  4 02:00:24 2000
@@ -33,6 +33,9 @@
 #define F_SETLKW	9
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
+#define F_GETLK64	12
+#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 +61,15 @@
 	short l_whence;
 	off_t l_start;
 	off_t l_len;
+	pid_t l_pid;
+	short __unused;
+};
+
+struct flock64 {
+	short l_type;
+	short l_whence;
+	loff_t l_start;
+	loff_t l_len;
 	pid_t l_pid;
 	short __unused;
 };
diff -urN 2.3.99-pre7-pre3/include/asm-sparc/unistd.h lfs-2.3.x/include/asm-sparc/unistd.h
--- 2.3.99-pre7-pre3/include/asm-sparc/unistd.h	Thu Feb  3 06:05:58 2000
+++ lfs-2.3.x/include/asm-sparc/unistd.h	Thu May  4 02:38:49 2000
@@ -158,7 +158,7 @@
 /* #define __NR_adjtime         140    SunOS Specific                              */
 #define __NR_getpeername        141 /* Common                                      */
 /* #define __NR_gethostid       142    SunOS Specific                              */
-/* #define __NR_ni_syscall      143    ENOSYS under SunOS                          */
+#define __NR_fcntl64		143 /* Linux sparc32 Specific			   */
 #define __NR_getrlimit          144 /* Common                                      */
 #define __NR_setrlimit          145 /* Common                                      */
 #define __NR_pivot_root		146 /* Linux Specific, killpg under SunOS          */
diff -urN 2.3.99-pre7-pre3/include/asm-sparc64/fcntl.h lfs-2.3.x/include/asm-sparc64/fcntl.h
--- 2.3.99-pre7-pre3/include/asm-sparc64/fcntl.h	Sun Jan  9 20:45:31 2000
+++ lfs-2.3.x/include/asm-sparc64/fcntl.h	Thu May  4 02:00:24 2000
@@ -33,6 +33,11 @@
 #define F_SETLKW	9
 #define F_SETSIG	10	/*  for sockets. */
 #define F_GETSIG	11	/*  for sockets. */
+#ifdef __KERNEL__
+#define F_GETLK64	12
+#define F_SETLK64	13
+#define F_SETLKW64	14
+#endif
 
 /* for F_[GET|SET]FL */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
@@ -71,6 +76,17 @@
 	__kernel_pid_t32 l_pid;
 	short __unused;
 };
+
+struct flock32_64 {
+	short l_type;
+	short l_whence;
+	__kernel_loff_t32 l_start;
+	__kernel_loff_t32 l_len;
+	__kernel_pid_t32 l_pid;
+	short __unused;
+};
+
+#define flock64 flock
 #endif
 
 #endif /* !(_SPARC64_FCNTL_H) */
diff -urN 2.3.99-pre7-pre3/include/asm-sparc64/unistd.h lfs-2.3.x/include/asm-sparc64/unistd.h
--- 2.3.99-pre7-pre3/include/asm-sparc64/unistd.h	Thu Feb  3 06:05:58 2000
+++ lfs-2.3.x/include/asm-sparc64/unistd.h	Thu May  4 02:37:58 2000
@@ -158,7 +158,7 @@
 /* #define __NR_adjtime         140    SunOS Specific                              */
 #define __NR_getpeername        141 /* Common                                      */
 /* #define __NR_gethostid       142    SunOS Specific                              */
-/* #define __NR_ni_syscall      143    ENOSYS under SunOS                          */
+/* #define __NR_fcntl64		143    Linux sparc32 Specific			   */
 #define __NR_getrlimit		144 /* Common                                      */
 #define __NR_setrlimit          145 /* Common                                      */
 #define __NR_pivot_root		146 /* Linux Specific, killpg under SunOS          */
diff -urN 2.3.99-pre7-pre3/include/linux/fs.h lfs-2.3.x/include/linux/fs.h
--- 2.3.99-pre7-pre3/include/linux/fs.h	Wed May  3 20:38:34 2000
+++ lfs-2.3.x/include/linux/fs.h	Thu May  4 03:23:19 2000
@@ -253,6 +253,12 @@
 
 #define touch_buffer(bh)	set_bit(PG_referenced, &bh->b_page->flags)
 
+static int off_t_presentable(loff_t) __attribute((const));
+static __inline__ int off_t_presentable(loff_t loff)
+{
+	return loff > 0 && loff <= (~0UL >> 1);
+}
+
 
 #include <linux/pipe_fs_i.h>
 #include <linux/minix_fs_i.h>
@@ -534,6 +540,9 @@
 
 extern int fcntl_getlk(unsigned int, struct flock *);
 extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
+
+extern int fcntl_getlk64(unsigned int, struct flock64 *);
+extern int fcntl_setlk64(unsigned int, unsigned int, struct flock64 *);
 
 /* fs/locks.c */
 extern void locks_remove_posix(struct file *, fl_owner_t);