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

	This file contains missing loff_t things at the VM layer,
	and read/write fixes

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
@@ -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 */
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
@@ -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 */
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
@@ -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 */
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
@@ -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 */
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
@@ -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 */
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
@@ -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 */
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
@@ -249,6 +249,16 @@
 #define buffer_page(bh)		(mem_map + MAP_NR((bh)->b_data))
 #define touch_buffer(bh)	set_bit(PG_referenced, &buffer_page(bh)->flags)
 
+static int off_t_presentable(loff_t) __attribute__ ((const));
+static __inline__ int off_t_presentable(loff_t loff)
+{
+#if BITS_PER_LONG < 64
+	return (loff <= (loff_t)LONG_MAX);
+#else
+	return 1;
+#endif
+}
+
 #include <linux/pipe_fs_i.h>
 #include <linux/minix_fs_i.h>
 #include <linux/ext2_fs_i.h>
@@ -730,8 +762,8 @@
 
 asmlinkage long sys_open(const char *, int, int);
 asmlinkage long sys_close(unsigned int);	/* yes, it's really unsigned */
-extern int do_close(unsigned int, int);		/* yes, it's really unsigned */
-extern int do_truncate(struct dentry *, unsigned long);
+extern long do_close(unsigned int, int);	/* yes, it's really unsigned */
+extern long do_truncate(struct dentry *, loff_t);
 extern int get_unused_fd(void);
 extern void put_unused_fd(unsigned int);
 
@@ -978,7 +1010,7 @@
 
 extern int block_fsync(struct file *, struct dentry *);
 extern int file_fsync(struct file *, struct dentry *);
-extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start, unsigned long end);
+extern int generic_buffer_fdatasync(struct inode *inode, loff_t start, loff_t end);
 
 extern int inode_change_ok(struct inode *, struct iattr *);
 extern void inode_setattr(struct inode *, struct iattr *);
diff -ur linux-23027p1/include/linux/mm.h linux-23027p1m1/include/linux/mm.h
--- linux-23027p1/include/linux/mm.h	Mon Nov  8 14:11:15 1999
+++ linux-23027p1m1/include/linux/mm.h	Mon Nov  8 22:58:52 1999
@@ -324,7 +324,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 int make_pages_present(unsigned long addr, unsigned long end);
 extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
@@ -351,7 +351,7 @@
 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);
 extern unsigned long do_brk(unsigned long, unsigned long);
 
@@ -359,7 +359,7 @@
 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 void truncate_inode_pages(struct inode *, loff_t);
 extern void put_cached_page(unsigned long);
 
 /*
diff -ur linux-23027p1/fs/proc/array.c linux-23027p1m1/fs/proc/array.c
--- linux-23027p1/fs/proc/array.c	Mon Nov  8 22:57:35 1999
+++ linux-23027p1m1/fs/proc/array.c	Mon Nov  8 22:58:51 1999
@@ -498,11 +498,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 %16Lx %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
@@ -580,7 +580,7 @@
 
 		len = sprintf(line,
 			      sizeof(void*) == 4 ? MAPS_LINE_FORMAT4 : MAPS_LINE_FORMAT8,
-			      map->vm_start, map->vm_end, str, map->vm_pgoff << PAGE_SHIFT,
+			      map->vm_start, map->vm_end, str, ((loff_t)(long)map->vm_pgoff) << PAGE_SHIFT,
 			      kdevname(dev), ino);
 
 		if(map->vm_file) {
diff -ur linux-23027p1/mm/filemap.c linux-23027p1m1/mm/filemap.c
--- linux-23027p1/mm/filemap.c	Sat Nov  6 02:16:48 1999
+++ linux-23027p1m1/mm/filemap.c	Mon Nov  8 22:58:52 1999
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/highmem.h>
+#include <linux/unistd.h>
 
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
@@ -122,13 +123,14 @@
  * 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 lstart)
 {
 	struct list_head *head, *curr;
 	struct page * page;
-	unsigned partial = start & (PAGE_CACHE_SIZE - 1);
+	unsigned partial = lstart & (PAGE_CACHE_SIZE - 1);
+	unsigned long start;
 
-	start = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+	start = (lstart + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 
 repeat:
 	head = &inode->i_data.pages;
@@ -412,7 +414,7 @@
 	return error;
 }
 
-static int do_buffer_fdatasync(struct inode *inode, unsigned long start, unsigned long end, int (*fn)(struct page *))
+static int do_buffer_fdatasync(struct inode *inode, unsigned long startidx, unsigned long endidx, int (*fn)(struct page *))
 {
 	struct list_head *head, *curr;
 	struct page *page;
@@ -427,9 +429,9 @@
 		curr = curr->next;
 		if (!page->buffers)
 			continue;
-		if (page->index >= end)
+		if (page->index >= endidx)
 			continue;
-		if (page->index < start)
+		if (page->index < startidx)
 			continue;
 
 		get_page(page);
@@ -454,7 +456,7 @@
  * Two-stage data sync: first start the IO, then go back and
  * collect the information..
  */
-int generic_buffer_fdatasync(struct inode *inode, unsigned long start, unsigned long end)
+int generic_buffer_fdatasync(struct inode *inode, loff_t start, loff_t end)
 {
 	unsigned long start_idx = start >> PAGE_CACHE_SHIFT;
 	unsigned long end_idx = (end + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
@@ -550,19 +552,19 @@
 
 /*
  * Read in an entire cluster at once.  A cluster is usually a 64k-
- * aligned block that includes the address requested in "offset."
+ * aligned block that includes the address requested in "index."
  */
-static int read_cluster_nonblocking(struct file * file, unsigned long offset)
+static int read_cluster_nonblocking(struct file * file, unsigned long index)
 {
 	int error = 0;
 	unsigned long filesize = (file->f_dentry->d_inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	unsigned long pages = CLUSTER_PAGES;
 
-	offset = CLUSTER_OFFSET(offset);
-	while ((pages-- > 0) && (offset < filesize)) {
-		error = page_cache_read(file, offset);
+	index = CLUSTER_OFFSET(index);
+	while ((pages-- > 0) && (index < filesize)) {
+		error = page_cache_read(file, index);
 		if (error >= 0)
-			offset ++;
+			index ++;
 		else
 			break;
 	}
@@ -776,8 +778,7 @@
  * Read-ahead context:
  * -------------------
  * The read ahead context fields of the "struct file" are the following:
- * - f_raend : position of the first byte after the last page we tried to
- *	       read ahead.
+ * - f_raend : index of the last page+1 we tried to read ahead.
  * - f_ramax : current read-ahead maximum size.
  * - f_ralen : length of the current IO read block we tried to read-ahead.
  * - f_rawin : length of the current read-ahead window.
@@ -1166,11 +1167,23 @@
 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(*ppos + count)) {
+			if (*ppos >= LONG_MAX) /* pos@LONG_MAX forbidden! */
+			  return -EOVERFLOW;
+			/* Read only until end of allowed region */
+			count = LONG_MAX - *ppos;
+		}
+
 		if (count) {
 			read_descriptor_t desc;
 
@@ -1213,6 +1226,10 @@
 	return written;
 }
 
+/*
+ *  sys_sendfile() isn't LARGEFILE compatible in all systems
+ */
+
 asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
 {
 	ssize_t retval;
@@ -1261,12 +1278,14 @@
 	if (count) {
 		read_descriptor_t desc;
 		loff_t pos = 0, *ppos;
+		off_t posp;
 
 		retval = -EFAULT;
 		ppos = &in_file->f_pos;
 		if (offset) {
-			if (get_user(pos, offset))
+			if (get_user(posp, offset))
 				goto fput_out;
+			pos = posp;
 			ppos = &pos;
 		}
 
@@ -1279,8 +1298,9 @@
 		retval = desc.written;
 		if (!retval)
 			retval = desc.error;
+		posp = pos;
 		if (offset)
-			put_user(pos, offset);
+			put_user(posp, offset);
 	}
 
 fput_out:
@@ -1434,19 +1454,18 @@
  * if the disk is full.
  */
 static inline int do_write_page(struct inode * inode, struct file * file,
-	struct page * page, unsigned long offset)
+	struct page * page, unsigned long pgindex)
 {
 	int retval;
-	unsigned long size;
 	int (*writepage) (struct file *, struct page *);
 
-	size = (offset << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE;
 	/* refuse to extend file size.. */
 	if (S_ISREG(inode->i_mode)) {
-		if (size > inode->i_size)
-			size = inode->i_size;
 		/* Ho humm.. We should have tested for this earlier */
-		if (size < offset)
+		unsigned long pgsize;
+		pgsize = inode->i_size >> PAGE_CACHE_SHIFT;
+		/* This is a matter of full cluster blocks */
+		if (pgindex >= pgsize)
 			return -EIO;
 	}
 	retval = -EIO;
@@ -1460,7 +1479,7 @@
 }
 
 static int filemap_write_page(struct file *file,
-			      unsigned long offset,
+			      unsigned long pgindex,
 			      struct page * page,
 			      int wait)
 {
@@ -1477,7 +1496,7 @@
 	 * vma/file is guaranteed to exist in the unmap/sync cases because
 	 * mmap_sem is held.
 	 */
-	result = do_write_page(inode, file, page, offset);
+	result = do_write_page(inode, file, page, pgindex);
 	return result;
 }
 
diff -ur linux-23027p1/mm/memory.c linux-23027p1m1/mm/memory.c
--- linux-23027p1/mm/memory.c	Fri Nov  5 05:36:33 1999
+++ linux-23027p1m1/mm/memory.c	Mon Nov  8 22:58:52 1999
@@ -885,7 +885,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)
 {
 	unsigned long partial, pgoff;
 	struct vm_area_struct * mpnt;
diff -ur linux-23027p1/mm/mmap.c linux-23027p1m1/mm/mmap.c
--- linux-23027p1/mm/mmap.c	Thu Oct 28 23:03:38 1999
+++ linux-23027p1m1/mm/mmap.c	Mon Nov  8 22:58:52 1999
@@ -161,11 +161,12 @@
 }
 
 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 loff)
 {
 	struct mm_struct * mm = current->mm;
 	struct vm_area_struct * vma;
 	int error;
+	unsigned long off;
 
 	if (file && (!file->f_op || !file->f_op->mmap))
 		return -ENODEV;
@@ -176,14 +177,14 @@
 	if (len > TASK_SIZE || addr > TASK_SIZE-len)
 		return -EINVAL;
 
-	if (off & ~PAGE_MASK)
+	if (loff & ~PAGE_MASK)
 		return -EINVAL;
 
-	/* offset overflow? */
-	if (off + len < off)
+	/* offset overflow? (propably not..) */
+	if (loff + len < loff)
 		return -EINVAL;
 
-	off = off >> PAGE_SHIFT;
+	off = loff >> PAGE_SHIFT;
 
 	/* Too many mappings? */
 	if (mm->map_count > MAX_MAP_COUNT)
diff -ur linux-23027p1/fs/read_write.c linux-23027p1m1/fs/read_write.c
--- linux-23027p1/fs/read_write.c	Fri Nov  5 19:57:30 1999
+++ linux-23027p1m1/fs/read_write.c	Mon Nov  8 22:58:51 1999
@@ -39,6 +39,11 @@
 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;
+
+	/* SUS: Seek done at pipe/fifo/socket must yield ESPIPE .. */
+	if (S_ISFIFO(mode) || S_ISSOCK(mode))
+	  return -ESPIPE;
 
 	fn = default_llseek;
 	if (file->f_op && file->f_op->llseek)
@@ -49,6 +54,7 @@
 asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
 {
 	off_t retval;
+	loff_t oldpos;
 	struct file * file;
 	struct dentry * dentry;
 	struct inode * inode;
@@ -62,13 +68,25 @@
 	if (!(dentry = file->f_dentry) ||
 	    !(inode = dentry->d_inode))
 		goto out_putf;
+
+	oldpos = file->f_pos;
 	retval = -EINVAL;
 	if (origin <= 2) {
-		loff_t res = llseek(file, offset, origin);
+		loff_t res = llseek(file, (loff_t)offset, origin);
 		retval = res;
-		if (res != (loff_t)retval)
-			retval = -EOVERFLOW;	/* LFS: should only happen on 32 bit platforms */
+
+		/* Demand L-F-S compliance only from normal files,
+		   thus raw devices can do whatever they please.. */
+		if (res >= 0 && S_ISREG(inode->i_mode) &&
+		    !(file->f_flags & O_LARGEFILE) &&
+		    !off_t_presentable(file->f_pos+1LL)) {
+			printk("sys_lseek(.., %ld, %d) (oldpos=%Ld) -> %Ld - EOVERFLOW!\n",
+			       offset, origin, oldpos, file->f_pos);
+			file->f_pos = oldpos;
+			retval = -EOVERFLOW;
+		}
 	}
+
 out_putf:
 	fput(file);
 bad:
@@ -85,7 +103,7 @@
 	struct file * file;
 	struct dentry * dentry;
 	struct inode * inode;
-	loff_t offset;
+	loff_t offset, oldpos;
 
 	lock_kernel();
 	retval = -EBADF;
@@ -100,6 +118,7 @@
 	if (origin > 2)
 		goto out_putf;
 
+	oldpos = file->f_pos;
 	offset = llseek(file, ((loff_t) offset_high << 32) | offset_low,
 			origin);
 
@@ -109,6 +128,18 @@
 		if (!copy_to_user(result, &offset, sizeof(offset)))
 			retval = 0;
 	}
+
+#if 0 /* With *THIS* call the resulting offset *IS* presentable */
+	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;
+	}
+#endif
+
 out_putf:
 	fput(file);
 bad:
@@ -311,6 +342,7 @@
 	ssize_t ret;
 	struct file * file;
 	ssize_t (*read)(struct file *, char *, size_t, loff_t *);
+	struct inode * inode;
 
 	lock_kernel();
 
@@ -318,10 +350,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;
@@ -343,6 +395,7 @@
 	ssize_t ret;
 	struct file * file;
 	ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
+	struct inode * inode;
 
 	lock_kernel();
 
@@ -352,8 +405,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;
