vnop_read does get called for Preview.app for my kext:
% sudo dtrace -f 'fbt::vnop_*_myfs/execname!="dtrace"/{}' -odtrace_myfs_preview_image_all_vnops.log
'open -a /System/Applications/Preview.app/Contents/MacOS/Preview /tmp/myfs/Through_the_pines.jpg'
% sed -n '/vnop_open/,${s!^[^a-z]*!!;s![^a-z]*$!!p;}' dtrace_myfs_preview_image_all_vnops.log
vnop_open_myfs:entry
vnop_open_myfs:return
vnop_close_myfs:entry
vnop_close_myfs:return
vnop_inactive_myfs:entry
vnop_inactive_myfs:return
vnop_getattr_myfs:entry
vnop_getattr_myfs:return
vnop_setxattr_myfs:entry
vnop_setxattr_myfs:return
vnop_getxattr_myfs:entry
vnop_getxattr_myfs:return
vnop_lookup_myfs:entry
vnop_lookup_myfs:return
vnop_open_myfs:entry
vnop_open_myfs:return
vnop_close_myfs:entry
vnop_close_myfs:return
vnop_inactive_myfs:entry
vnop_inactive_myfs:return
vnop_open_myfs:entry
vnop_open_myfs:return
vnop_read_myfs:entry
vnop_read_myfs:return
vnop_mmap_myfs:entry
vnop_mmap_myfs:return
vnop_close_myfs:entry
vnop_close_myfs:return
vnop_read returns success:
% sudo dtrace -n 'fbt::vnop_read_myfs:entry
/execname!="dtrace"/{
self->vnop_read_arg0 = arg0;
printf("proc: %s name: %s",
execname,
stringof(((struct vnop_read_args *)arg0)->a_vp->v_name)
);
}
fbt::vnop_read_myfs:return
/execname!="dtrace" && self->vnop_read_arg0/{
printf("proc: %s name: %s retval: %d",
execname,
stringof(((struct vnop_read_args *)self->vnop_read_arg0)->a_vp->v_name),
arg1
);
}' -odtrace_myfs_preview_image_vnop_read.log
'open -a /System/Applications/Preview.app/Contents/MacOS/Preview /tmp/myfs/Through_the_pines.jpg'
% cat dtrace_myfs_preview_image_vnop_read.log
CPU ID FUNCTION:NAME
4 146583 vnop_read_myfs:entry proc: Preview name: Through_the_pines.jpg
2 146584 vnop_read_myfs:return proc: Preview name: Through_the_pines.jpg retval: 0
The Preview.app process' state is sleeping:
% ps acx | grep -i preview
454 ?? S 0:00.30 Preview
The image is not displayed.
Incidentally, Google Chrome does succeed in displaying the contents of the image file.
The vnops being called seem very similar with vnop_read being called multiple times.
% sudo dtrace -f 'fbt::vnop_*_myfs/execname!="dtrace"/{}' -odtrace_myfs_gc_image_all_vnops.log
'open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome /tmp/myfs/Through_the_pines.jpg'
% sed -n '/vnop_open/,${s!^[^a-z]*!!;s![^a-z]*$!!p;}' dtrace_myfs_gc_image_all_vnops.log
vnop_open_myfs:entry
vnop_open_myfs:return
vnop_close_myfs:entry
vnop_close_myfs:return
vnop_inactive_myfs:entry
vnop_inactive_myfs:return
vnop_getattr_myfs:entry
vnop_getattr_myfs:return
vnop_setxattr_myfs:entry
vnop_setxattr_myfs:return
vnop_lookup_myfs:entry
vnop_lookup_myfs:return
vnop_getxattr_myfs:entry
vnop_getxattr_myfs:return
vnop_open_myfs:entry
vnop_open_myfs:return
vnop_read_myfs:entry
vnop_read_myfs:return
vnop_read_myfs:entry
vnop_read_myfs:return
vnop_read_myfs:entry
vnop_read_myfs:return
vnop_read_myfs:entry
vnop_read_myfs:return
vnop_close_myfs:entry
vnop_close_myfs:return
vnop_inactive_myfs:entry
vnop_inactive_myfs:return
vnop_pathconf_myfs:entry
vnop_pathconf_myfs:return
vnop_pathconf_myfs:entry
vnop_pathconf_myfs:return
And returning success at all times.
% sudo dtrace -n 'fbt::vnop_read_myfs:entry
/execname!="dtrace"/{
self->vnop_read_arg0 = arg0;
printf("proc: %s name: %s",
execname,
stringof(((struct vnop_read_args *)arg0)->a_vp->v_name)
);
}
fbt::vnop_read_myfs:return
/execname!="dtrace" && self->vnop_read_arg0/{
printf("proc: %s name: %s retval: %d",
execname,
stringof(((struct vnop_read_args *)self->vnop_read_arg0)->a_vp->v_name),
arg1
);
}' -odtrace_myfs_gc_image_vnop_read.log
'open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome /tmp/myfs/Through_the_pines.jpg'
% cat dtrace_myfs_gc_image_vnop_read.log
CPU ID FUNCTION:NAME
5 144179 vnop_read_myfs:entry proc: Google Chrome name: Through_the_pines.jpg
4 144180 vnop_read_myfs:return proc: Google Chrome name: Through_the_pines.jpg retval: 0
6 144179 vnop_read_myfs:entry proc: Google Chrome name: Through_the_pines.jpg
1 144180 vnop_read_myfs:return proc: Google Chrome name: Through_the_pines.jpg retval: 0
1 144179 vnop_read_myfs:entry proc: Google Chrome name: Through_the_pines.jpg
0 144180 vnop_read_myfs:return proc: Google Chrome name: Through_the_pines.jpg retval: 0
0 144179 vnop_read_myfs:entry proc: Google Chrome name: Through_the_pines.jpg
3 144180 vnop_read_myfs:return proc: Google Chrome name: Through_the_pines.jpg retval: 0
vnop_ioctl is never called for Preview.app or Google Chrome.
% grep -c vnop_ioctl dtrace_myfs_*_image_all_vnops.log
dtrace_myfs_gc_image_all_vnops.log:0
dtrace_myfs_preview_image_all_vnops.log:0
If you have any other piece of advice for me, it would be greatly appreciated.