svn commit: r204971 - stable/7/sys/kern
John Baldwin
jhb at FreeBSD.org
Wed Mar 10 19:49:33 UTC 2010
Author: jhb
Date: Wed Mar 10 19:49:33 2010
New Revision: 204971
URL: http://svn.freebsd.org/changeset/base/204971
Log:
MFC 204638:
Allow lseek(SEEK_END) to work on disk devices by using the DIOCGMEDIASIZE
to determine the media size.
Modified:
stable/7/sys/kern/vfs_syscalls.c
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/kern/vfs_syscalls.c
==============================================================================
--- stable/7/sys/kern/vfs_syscalls.c Wed Mar 10 19:47:05 2010 (r204970)
+++ stable/7/sys/kern/vfs_syscalls.c Wed Mar 10 19:49:33 2010 (r204971)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/buf.h>
+#include <sys/disk.h>
#include <sys/sysent.h>
#include <sys/malloc.h>
#include <sys/mount.h>
@@ -1762,7 +1763,7 @@ lseek(td, uap)
struct file *fp;
struct vnode *vp;
struct vattr vattr;
- off_t offset;
+ off_t offset, size;
int error, noneg;
int vfslocked;
@@ -1792,6 +1793,15 @@ lseek(td, uap)
VOP_UNLOCK(vp, 0, td);
if (error)
break;
+
+ /*
+ * If the file references a disk device, then fetch
+ * the media size and use that to determine the ending
+ * offset.
+ */
+ if (vattr.va_size == 0 && vp->v_type == VCHR &&
+ fo_ioctl(fp, DIOCGMEDIASIZE, &size, cred, td) == 0)
+ vattr.va_size = size;
if (noneg &&
(vattr.va_size > OFF_MAX ||
(offset > 0 && vattr.va_size > OFF_MAX - offset))) {
More information about the svn-src-stable-7
mailing list