1*a158dd7eSjmcneill /* $NetBSD: devopen.c,v 1.4 2018/11/15 23:52:33 jmcneill Exp $ */
236105be2Sjmcneill
336105be2Sjmcneill /*-
436105be2Sjmcneill * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
536105be2Sjmcneill * All rights reserved.
636105be2Sjmcneill *
736105be2Sjmcneill * Redistribution and use in source and binary forms, with or without
836105be2Sjmcneill * modification, are permitted provided that the following conditions
936105be2Sjmcneill * are met:
1036105be2Sjmcneill * 1. Redistributions of source code must retain the above copyright
1136105be2Sjmcneill * notice, this list of conditions and the following disclaimer.
1236105be2Sjmcneill * 2. Redistributions in binary form must reproduce the above copyright
1336105be2Sjmcneill * notice, this list of conditions and the following disclaimer in the
1436105be2Sjmcneill * documentation and/or other materials provided with the distribution.
1536105be2Sjmcneill *
1636105be2Sjmcneill * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1736105be2Sjmcneill * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1836105be2Sjmcneill * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1936105be2Sjmcneill * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2036105be2Sjmcneill * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2136105be2Sjmcneill * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2236105be2Sjmcneill * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2336105be2Sjmcneill * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2436105be2Sjmcneill * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2536105be2Sjmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2636105be2Sjmcneill * SUCH DAMAGE.
2736105be2Sjmcneill */
2836105be2Sjmcneill
2936105be2Sjmcneill #include "efiboot.h"
3036105be2Sjmcneill #include "efifile.h"
31d8588d75Sjmcneill #include "efiblock.h"
3236105be2Sjmcneill
3336105be2Sjmcneill int
devopen(struct open_file * f,const char * fname,char ** file)3436105be2Sjmcneill devopen(struct open_file *f, const char *fname, char **file)
3536105be2Sjmcneill {
3636105be2Sjmcneill int error;
3736105be2Sjmcneill
3813f5d069Sjmcneill error = efi_net_open(f, fname, file);
39*a158dd7eSjmcneill if (error)
40*a158dd7eSjmcneill file_system[0] = null_fs_ops;
41*a158dd7eSjmcneill else if (rootpath[0] != '\0')
42*a158dd7eSjmcneill file_system[0] = nfs_fs_ops;
43*a158dd7eSjmcneill else
44*a158dd7eSjmcneill file_system[0] = tftp_fs_ops;
4513f5d069Sjmcneill
4613f5d069Sjmcneill if (error)
47d8588d75Sjmcneill error = efi_block_open(f, fname, file);
48d8588d75Sjmcneill if (error)
4936105be2Sjmcneill error = efi_file_open(f, fname);
5036105be2Sjmcneill
5136105be2Sjmcneill return error;
5236105be2Sjmcneill }
53