xref: /illumos-gate/usr/src/stand/sys/bootvfs.h (revision 4a634bb8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_BOOTVFS_H
27 #define	_SYS_BOOTVFS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/filep.h>
36 #include <sys/dirent.h>
37 #include <sys/bootstat.h>
38 
39 /* same as those in /usr/include/unistd.h */
40 #define	SEEK_SET	0	/* Offset */
41 #define	SEEK_CUR	1	/* Current + Offset */
42 #define	SEEK_END	2	/* EOF + Offset */
43 
44 /* mountroot/unmountroot return values */
45 #define	VFS_SUCCESS	0
46 #define	VFS_FAILURE	-1
47 
48 /*
49  * unified (vfs-like) file system operations for booters
50  */
51 
52 struct boot_fs_ops {
53     char	*fsw_name;
54     int		(*fsw_mountroot)(char *str);
55     int		(*fsw_unmountroot)(void);
56     int		(*fsw_open)(char *filename, int flags);
57     int		(*fsw_close)(int fd);
58     ssize_t	(*fsw_read)(int fd, caddr_t buf, size_t size);
59     off_t	(*fsw_lseek)(int filefd, off_t addr, int whence);
60     int		(*fsw_fstat)(int filefd, struct bootstat *buf);
61     void	(*fsw_closeall)(int flag);
62     int		(*fsw_getdents)(int fd, struct dirent *buf, unsigned size);
63 };
64 
65 /*
66  *  Function prototypes
67  *
68  *	fstat() (if exists) supports size and mode right now.
69  */
70 
71 extern	int	mountroot(char *str);
72 extern	int	unmountroot(void);
73 extern	int	open(const char *filename, int flags);
74 extern	int	close(int fd);
75 extern	ssize_t	read(int fd, void *buf, size_t size);
76 extern	off_t	lseek(int filefd, off_t addr, int whence);
77 extern	int	fstat(int fd, struct stat *buf);
78 extern	int	stat(const char *filename, struct stat *buf);
79 
80 /*
81  * The compfs filesystem provides additional fsswitch-like entry points,
82  * though these are not yet hooked properly into the fsswitch.
83  */
84 
85 extern	void	closeall(int flag);
86 
87 extern	ssize_t	kern_read(int fd, caddr_t buf, size_t size);
88 extern	int	kern_open(char *filename, int flags);
89 extern	off_t	kern_seek(int fd, off_t hi, off_t lo);
90 extern	off_t	kern_lseek(int fd, off_t hi, off_t lo);
91 extern	int	kern_close(int fd);
92 extern	int	kern_fstat(int fd, struct bootstat *buf);
93 extern	int	kern_getdents(int fd, struct dirent *buf, size_t size);
94 extern	int	kern_mountroot(char *path);
95 extern	int	kern_unmountroot(void);
96 
97 /*
98  * these are for common fs switch interface routines
99  */
100 extern	int	boot_no_ops(void);	/* no ops entry */
101 extern	void	boot_no_ops_void(void);	/* no ops entry */
102 
103 extern	struct boot_fs_ops *get_default_fs(void);
104 extern	struct boot_fs_ops *get_fs_ops_pointer(char *fsw_name);
105 extern	void	set_default_fs(char *fsw_name);
106 extern	void	clr_default_fs(void);
107 extern	char 	*set_fstype(char *v2path, char *bpath);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _SYS_BOOTVFS_H */
114