1*c25d9affSEmmanuel Vadot /*- 2*c25d9affSEmmanuel Vadot * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG 3*c25d9affSEmmanuel Vadot * 4*c25d9affSEmmanuel Vadot * Redistribution and use in source and binary forms, with or without 5*c25d9affSEmmanuel Vadot * modification, are permitted provided that the following conditions 6*c25d9affSEmmanuel Vadot * are met: 7*c25d9affSEmmanuel Vadot * 1. Redistributions of source code must retain the above copyright 8*c25d9affSEmmanuel Vadot * notice, this list of conditions and the following disclaimer. 9*c25d9affSEmmanuel Vadot * 2. Redistributions in binary form must reproduce the above copyright 10*c25d9affSEmmanuel Vadot * notice, this list of conditions and the following disclaimer in the 11*c25d9affSEmmanuel Vadot * documentation and/or other materials provided with the distribution. 12*c25d9affSEmmanuel Vadot * 13*c25d9affSEmmanuel Vadot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*c25d9affSEmmanuel Vadot * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*c25d9affSEmmanuel Vadot * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*c25d9affSEmmanuel Vadot * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*c25d9affSEmmanuel Vadot * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*c25d9affSEmmanuel Vadot * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*c25d9affSEmmanuel Vadot * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*c25d9affSEmmanuel Vadot * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*c25d9affSEmmanuel Vadot * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*c25d9affSEmmanuel Vadot * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*c25d9affSEmmanuel Vadot * SUCH DAMAGE. 24*c25d9affSEmmanuel Vadot * 25*c25d9affSEmmanuel Vadot */ 26*c25d9affSEmmanuel Vadot 27*c25d9affSEmmanuel Vadot #include <sys/cdefs.h> 28*c25d9affSEmmanuel Vadot __FBSDID("$FreeBSD$"); 29*c25d9affSEmmanuel Vadot 30*c25d9affSEmmanuel Vadot #include <sys/param.h> 31*c25d9affSEmmanuel Vadot #include "stand.h" 32*c25d9affSEmmanuel Vadot 33*c25d9affSEmmanuel Vadot void 34*c25d9affSEmmanuel Vadot preload(int fd) 35*c25d9affSEmmanuel Vadot { 36*c25d9affSEmmanuel Vadot struct open_file *f; 37*c25d9affSEmmanuel Vadot 38*c25d9affSEmmanuel Vadot f = fd2open_file(fd); 39*c25d9affSEmmanuel Vadot if (f == NULL) { 40*c25d9affSEmmanuel Vadot errno = EBADF; 41*c25d9affSEmmanuel Vadot return; 42*c25d9affSEmmanuel Vadot } 43*c25d9affSEmmanuel Vadot if (f->f_ops->fo_preload) 44*c25d9affSEmmanuel Vadot (f->f_ops->fo_preload)(f); 45*c25d9affSEmmanuel Vadot } 46