aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2019-08-22 01:15:06 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2019-08-22 01:15:06 +0000
commitdf9bc7df422a3c517817d1739504e0c8c8185d5a (patch)
tree984cc6a96524e9d7135d2e294f4309ea76472ea0 /sys/kern/vfs_vnops.c
parent5df6fa43443a87421b54c9517808c816b5e4cd98 (diff)
downloadsrc-df9bc7df422a3c517817d1739504e0c8c8185d5a.tar.gz
src-df9bc7df422a3c517817d1739504e0c8c8185d5a.zip
Map ENOTTY to EINVAL for lseek(SEEK_DATA/SEEK_HOLE).
Without this patch, when an application performed lseek(SEEK_DATA/SEEK_HOLE) on a file in a file system that does not have its own VOP_IOCTL(), the lseek(2) fails with errno ENOTTY. This didn't seem appropriate, since ENOTTY is not listed as an error return by either the lseek(2) man page nor the POSIX draft for lseek(2). This was discussed on freebsd-current@ here: http://docs.FreeBSD.org/cgi/mid.cgi?CAOtMX2iiQdv1+15e1N_r7V6aCx_VqAJCTP1AW+qs3Yg7sPg9wA This trivial patch maps ENOTTY to EINVAL for lseek(SEEK_DATA/SEEK_HOLE). Reviewed by: markj Relnotes: yes Differential Revision: https://reviews.freebsd.org/D21300
Notes
Notes: svn path=/head/; revision=351372
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 1c911123930c..af581f0f5125 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -2275,9 +2275,13 @@ vn_seek(struct file *fp, off_t offset, int whence, struct thread *td)
break;
case SEEK_DATA:
error = fo_ioctl(fp, FIOSEEKDATA, &offset, cred, td);
+ if (error == ENOTTY)
+ error = EINVAL;
break;
case SEEK_HOLE:
error = fo_ioctl(fp, FIOSEEKHOLE, &offset, cred, td);
+ if (error == ENOTTY)
+ error = EINVAL;
break;
default:
error = EINVAL;