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