I have questions about sysctl_file(): 1. Looks like sysctl_file() should do the same things for KERN_FILE_BYPID and KERN_FILE_BYUID cases. But pr->ps_textvp (vnode of executable) will be copied for KERN_FILE_BYPID case only. Is this copying missing for KERN_FILE_BYUID?
2. (arg < -1) check looks be missing for KERN_FILE_BYUID case kvm_getfiles(3) said that arg can -1 for all users and -1 for processes. So arg < -1 is EINVAL error for KERN_FILE_BYUID too. 3. In original code FILLIT() does copyout() call, but userland will be noticed about copyout() error only from the last copyout() call. All errors from the non-last copyout() calls will be silently dropped. It is expected behaviour?