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.
Tags
None
Referenced Files
Unknown Object (File)
Mar 19 2024, 10:28 PM
Unknown Object (File)
Feb 4 2024, 3:25 PM
Unknown Object (File)
Jan 30 2024, 7:52 AM
Unknown Object (File)
Jan 16 2024, 5:31 AM
Unknown Object (File)
Jan 7 2024, 1:22 PM
Unknown Object (File)
Jan 7 2024, 1:22 PM
Unknown Object (File)
Jan 7 2024, 1:22 PM
Unknown Object (File)
Jan 7 2024, 1:09 PM
Subscribers

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 - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 25939

Event Timeline

kib added inline comments.
kern/vfs_default.c
1155

I think you may check v_type before calling VOP_GETATTR()

1166

Add break; for consistency.

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().

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