17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*4a634bb8Sga159272 * Common Development and Distribution License (the "License"). 6*4a634bb8Sga159272 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*4a634bb8Sga159272 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_BOOTVFS_H 277c478bd9Sstevel@tonic-gate #define _SYS_BOOTVFS_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/filep.h> 367c478bd9Sstevel@tonic-gate #include <sys/dirent.h> 377c478bd9Sstevel@tonic-gate #include <sys/bootstat.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* same as those in /usr/include/unistd.h */ 407c478bd9Sstevel@tonic-gate #define SEEK_SET 0 /* Offset */ 417c478bd9Sstevel@tonic-gate #define SEEK_CUR 1 /* Current + Offset */ 427c478bd9Sstevel@tonic-gate #define SEEK_END 2 /* EOF + Offset */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* mountroot/unmountroot return values */ 457c478bd9Sstevel@tonic-gate #define VFS_SUCCESS 0 467c478bd9Sstevel@tonic-gate #define VFS_FAILURE -1 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * unified (vfs-like) file system operations for booters 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate struct boot_fs_ops { 537c478bd9Sstevel@tonic-gate char *fsw_name; 547c478bd9Sstevel@tonic-gate int (*fsw_mountroot)(char *str); 557c478bd9Sstevel@tonic-gate int (*fsw_unmountroot)(void); 567c478bd9Sstevel@tonic-gate int (*fsw_open)(char *filename, int flags); 577c478bd9Sstevel@tonic-gate int (*fsw_close)(int fd); 587c478bd9Sstevel@tonic-gate ssize_t (*fsw_read)(int fd, caddr_t buf, size_t size); 597c478bd9Sstevel@tonic-gate off_t (*fsw_lseek)(int filefd, off_t addr, int whence); 607c478bd9Sstevel@tonic-gate int (*fsw_fstat)(int filefd, struct bootstat *buf); 617c478bd9Sstevel@tonic-gate void (*fsw_closeall)(int flag); 627c478bd9Sstevel@tonic-gate int (*fsw_getdents)(int fd, struct dirent *buf, unsigned size); 637c478bd9Sstevel@tonic-gate }; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Function prototypes 677c478bd9Sstevel@tonic-gate * 687c478bd9Sstevel@tonic-gate * fstat() (if exists) supports size and mode right now. 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate extern int mountroot(char *str); 727c478bd9Sstevel@tonic-gate extern int unmountroot(void); 737c478bd9Sstevel@tonic-gate extern int open(const char *filename, int flags); 747c478bd9Sstevel@tonic-gate extern int close(int fd); 757c478bd9Sstevel@tonic-gate extern ssize_t read(int fd, void *buf, size_t size); 767c478bd9Sstevel@tonic-gate extern off_t lseek(int filefd, off_t addr, int whence); 777c478bd9Sstevel@tonic-gate extern int fstat(int fd, struct stat *buf); 787c478bd9Sstevel@tonic-gate extern int stat(const char *filename, struct stat *buf); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * The compfs filesystem provides additional fsswitch-like entry points, 827c478bd9Sstevel@tonic-gate * though these are not yet hooked properly into the fsswitch. 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate extern void closeall(int flag); 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate extern ssize_t kern_read(int fd, caddr_t buf, size_t size); 887c478bd9Sstevel@tonic-gate extern int kern_open(char *filename, int flags); 897c478bd9Sstevel@tonic-gate extern off_t kern_seek(int fd, off_t hi, off_t lo); 907c478bd9Sstevel@tonic-gate extern off_t kern_lseek(int fd, off_t hi, off_t lo); 917c478bd9Sstevel@tonic-gate extern int kern_close(int fd); 927c478bd9Sstevel@tonic-gate extern int kern_fstat(int fd, struct bootstat *buf); 937c478bd9Sstevel@tonic-gate extern int kern_getdents(int fd, struct dirent *buf, size_t size); 947c478bd9Sstevel@tonic-gate extern int kern_mountroot(char *path); 957c478bd9Sstevel@tonic-gate extern int kern_unmountroot(void); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * these are for common fs switch interface routines 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate extern int boot_no_ops(void); /* no ops entry */ 1017c478bd9Sstevel@tonic-gate extern void boot_no_ops_void(void); /* no ops entry */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate extern struct boot_fs_ops *get_default_fs(void); 1047c478bd9Sstevel@tonic-gate extern struct boot_fs_ops *get_fs_ops_pointer(char *fsw_name); 1057c478bd9Sstevel@tonic-gate extern void set_default_fs(char *fsw_name); 1067c478bd9Sstevel@tonic-gate extern void clr_default_fs(void); 1077c478bd9Sstevel@tonic-gate extern char *set_fstype(char *v2path, char *bpath); 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate #endif 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #endif /* _SYS_BOOTVFS_H */ 114