Page MenuHomeFreeBSD

Add a vop_stdioctl() that does the trivial algorithm for FIOSEEKDATA/FIOSEEKHOLE
ClosedPublic

Authored by rmacklem on Aug 17 2019, 3:17 AM.

Details

Summary

For file systems that do not implement holes, Linux provides the trivial implementation
for FIOSEEKDATA/FIOSEEKHOLE that returns the offset for FIOSEEKDATA and offset == file_size
for FIOSEEKHOLE.
Also, this seemed to be the preferred choice when discussed on freebsd-current@ w.r.t. what
to do when file systems don't implement VOP_IOCTL().

This patch implements this by adding a vop_stdioctl() that does it.

Test Plan

Tested using an NFS mount (which does not support VOP_IOCTL()) and a test program that does
lseek(SEEK_DATA) and lseek(SEEK_HOLE) for various offsets.
Since it is a VOP_IOCTL(), it follows the convention of returning ENOTTY for certain failures, even
though lseek() is not documented as returning that error (and ENOTTY is not listed as an errno for POSIX).

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rmacklem created this revision.Aug 17 2019, 3:17 AM
kib added a subscriber: kib.Aug 17 2019, 10:57 AM
kib added inline comments.
kern/vfs_default.c
1155 ↗(On Diff #60925)

I think you may check v_type before calling VOP_GETATTR()

1166 ↗(On Diff #60925)

Add break; for consistency.

rmacklem updated this revision to Diff 60956.Aug 18 2019, 1:50 AM

This version of the patch has the changes suggested by kib@ incorporated in it.
The only semantic change is that it now returns whatever error VOP_GETATTR()
returns if VOP_GETATTR() fails. This is consistent with the behaviour of vn_bmap_seekhole().

kib accepted this revision.Aug 18 2019, 4:49 AM
This revision is now accepted and ready to land.Aug 18 2019, 4:49 AM