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

	This file contains flock64 things (no new syscalls!)


diff -ur linux-23027p1/fs/fcntl.c linux-23027p1m1/fs/fcntl.c
--- linux-23027p1/fs/fcntl.c	Mon Oct 11 20:13:25 1999
+++ linux-23027p1m1/fs/fcntl.c	Mon Nov  8 22:58:51 1999
@@ -215,6 +215,15 @@
 		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 -ur linux-23027p1/include/linux/fs.h linux-23027p1m1/include/linux/fs.h
--- linux-23027p1/include/linux/fs.h	Mon Nov  8 22:57:35 1999
+++ linux-23027p1m1/include/linux/fs.h	Mon Nov  8 22:58:52 1999
@@ -474,8 +502,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 */
 
@@ -491,6 +519,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 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);
 extern void locks_remove_flock(struct file *);
diff -ur linux-23027p1/include/asm-sparc64/fcntl.h linux-23027p1m1/include/asm-sparc64/fcntl.h
--- linux-23027p1/include/asm-sparc64/fcntl.h	Tue Oct 27 19:52:21 1998
+++ linux-23027p1m1/include/asm-sparc64/fcntl.h	Mon Nov  8 22:58:52 1999
@@ -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 -ur linux-23027p1/include/asm-sparc/fcntl.h linux-23027p1m1/include/asm-sparc/fcntl.h
--- linux-23027p1/include/asm-sparc/fcntl.h	Tue Oct 27 19:52:21 1998
+++ linux-23027p1m1/include/asm-sparc/fcntl.h	Mon Nov  8 22:58:52 1999
@@ -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 -ur linux-23027p1/include/asm-ppc/fcntl.h linux-23027p1m1/include/asm-ppc/fcntl.h
--- linux-23027p1/include/asm-ppc/fcntl.h	Wed Oct 21 23:31:06 1998
+++ linux-23027p1m1/include/asm-ppc/fcntl.h	Mon Nov  8 22:58:52 1999
@@ -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 -ur linux-23027p1/include/asm-mips/fcntl.h linux-23027p1m1/include/asm-mips/fcntl.h
--- linux-23027p1/include/asm-mips/fcntl.h	Sat Jun 26 03:37:53 1999
+++ linux-23027p1m1/include/asm-mips/fcntl.h	Mon Nov  8 22:58:52 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 -ur linux-23027p1/include/asm-m68k/fcntl.h linux-23027p1m1/include/asm-m68k/fcntl.h
--- linux-23027p1/include/asm-m68k/fcntl.h	Wed Oct 21 23:30:56 1998
+++ linux-23027p1m1/include/asm-m68k/fcntl.h	Mon Nov  8 22:58:52 1999
@@ -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 -ur linux-23027p1/include/asm-i386/fcntl.h linux-23027p1m1/include/asm-i386/fcntl.h
--- linux-23027p1/include/asm-i386/fcntl.h	Wed Oct 21 20:02:48 1998
+++ linux-23027p1m1/include/asm-i386/fcntl.h	Mon Nov  8 22:58:52 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 -ur linux-23027p1/include/asm-arm/fcntl.h linux-23027p1m1/include/asm-arm/fcntl.h
--- linux-23027p1/include/asm-arm/fcntl.h	Wed Oct 21 23:30:46 1998
+++ linux-23027p1m1/include/asm-arm/fcntl.h	Mon Nov  8 22:58:52 1999
@@ -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 -ur linux-23027p1/include/asm-alpha/fcntl.h linux-23027p1m1/include/asm-alpha/fcntl.h
--- linux-23027p1/include/asm-alpha/fcntl.h	Wed Oct 21 20:02:48 1998
+++ linux-23027p1m1/include/asm-alpha/fcntl.h	Mon Nov  8 22:58:52 1999
@@ -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 -ur linux-23027p1/fs/locks.c linux-23027p1m1/fs/locks.c
--- linux-23027p1/fs/locks.c	Mon Aug 23 21:15:53 1999
+++ linux-23027p1m1/fs/locks.c	Mon Nov  8 22:58:51 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,
@@ -195,7 +195,7 @@
 
 	if (waiter->fl_prevblock) {
 		printk(KERN_ERR "locks_insert_block: remove duplicated lock "
-			"(pid=%d %ld-%ld type=%d)\n",
+			"(pid=%d %Ld-%Ld type=%d)\n",
 			waiter->fl_pid, waiter->fl_start,
 			waiter->fl_end, waiter->fl_type);
 		locks_delete_block(waiter->fl_prevblock, waiter);
@@ -323,7 +323,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;
@@ -380,11 +565,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;
@@ -647,9 +832,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));
 	
@@ -1200,7 +1385,7 @@
 		p += sprintf(p, "FLOCK  ADVISORY  ");
 	}
 	p += sprintf(p, "%s ", (fl->fl_type == F_RDLCK) ? "READ " : "WRITE");
-	p += sprintf(p, "%d %s:%ld %ld %ld ",
+	p += sprintf(p, "%d %s:%ld %Ld %Ld ",
 		     fl->fl_pid,
 		     kdevname(inode->i_dev), inode->i_ino, fl->fl_start,
 		     fl->fl_end);
diff -ur linux-23027p1/fs/lockd/svclock.c linux-23027p1m1/fs/lockd/svclock.c
--- linux-23027p1/fs/lockd/svclock.c	Mon Aug 23 20:16:34 1999
+++ linux-23027p1m1/fs/lockd/svclock.c	Mon Nov  8 22:58:51 1999
@@ -93,12 +93,12 @@
 	struct nlm_block	**head, *block;
 	struct file_lock	*fl;
 
-	dprintk("lockd: nlmsvc_lookup_block f=%p pd=%d %ld-%ld ty=%d\n",
+	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);
 	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",
+		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);
 		if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) {
@@ -282,7 +282,7 @@
 	struct nlm_block	*block;
 	int			error;
 
-	dprintk("lockd: nlmsvc_lock(%04x/%ld, ty=%d, pi=%d, %ld-%ld, bl=%d)\n",
+	dprintk("lockd: nlmsvc_lock(%04x/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
 				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,
@@ -355,7 +355,7 @@
 {
 	struct file_lock	*fl;
 
-	dprintk("lockd: nlmsvc_testlock(%04x/%ld, ty=%d, %ld-%ld)\n",
+	dprintk("lockd: nlmsvc_testlock(%04x/%ld, ty=%d, %Ld-%Ld)\n",
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_type,
@@ -363,7 +363,7 @@
 				lock->fl.fl_end);
 
 	if ((fl = posix_test_lock(&file->f_file, &lock->fl)) != NULL) {
-		dprintk("lockd: conflicting lock(ty=%d, %ld-%ld)\n",
+		dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
 				fl->fl_type, fl->fl_start, fl->fl_end);
 		conflock->caller = "somehost";	/* FIXME */
 		conflock->oh.len = 0;		/* don't return OH info */
@@ -386,7 +386,7 @@
 {
 	int	error;
 
-	dprintk("lockd: nlmsvc_unlock(%04x/%ld, pi=%d, %ld-%ld)\n",
+	dprintk("lockd: nlmsvc_unlock(%04x/%ld, pi=%d, %Ld-%Ld)\n",
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_pid,
@@ -414,7 +414,7 @@
 {
 	struct nlm_block	*block;
 
-	dprintk("lockd: nlmsvc_cancel(%04x/%ld, pi=%d, %ld-%ld)\n",
+	dprintk("lockd: nlmsvc_cancel(%04x/%ld, pi=%d, %Ld-%Ld)\n",
 				file->f_file.f_dentry->d_inode->i_dev,
 				file->f_file.f_dentry->d_inode->i_ino,
 				lock->fl.fl_pid,
diff -ur linux-23027p1/fs/lockd/xdr.c linux-23027p1m1/fs/lockd/xdr.c
--- linux-23027p1/fs/lockd/xdr.c	Sat Feb  6 22:46:21 1999
+++ linux-23027p1m1/fs/lockd/xdr.c	Mon Nov  8 22:58:51 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++); // Up to 4G-1
 	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;
