10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1544Seschrock * Common Development and Distribution License (the "License"). 6*1544Seschrock * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1544Seschrock * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_BOOTVFS_H 270Sstevel@tonic-gate #define _SYS_BOOTVFS_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/bootstat.h> 360Sstevel@tonic-gate #include <sys/dirent.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* same as those in /usr/include/unistd.h */ 390Sstevel@tonic-gate #define SEEK_SET 0 /* Offset */ 400Sstevel@tonic-gate #define SEEK_CUR 1 /* Current + Offset */ 410Sstevel@tonic-gate #define SEEK_END 2 /* EOF + Offset */ 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* mountroot/unmountroot return values */ 440Sstevel@tonic-gate #define VFS_SUCCESS 0 450Sstevel@tonic-gate #define VFS_FAILURE -1 460Sstevel@tonic-gate 470Sstevel@tonic-gate /* 480Sstevel@tonic-gate * unified (vfs-like) file system operations for booters 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate 510Sstevel@tonic-gate struct boot_fs_ops { 520Sstevel@tonic-gate char *fsw_name; 530Sstevel@tonic-gate int (*fsw_mountroot)(char *str); 540Sstevel@tonic-gate int (*fsw_unmountroot)(void); 550Sstevel@tonic-gate int (*fsw_open)(char *filename, int flags); 560Sstevel@tonic-gate int (*fsw_close)(int fd); 570Sstevel@tonic-gate ssize_t (*fsw_read)(int fd, caddr_t buf, size_t size); 580Sstevel@tonic-gate off_t (*fsw_lseek)(int filefd, off_t addr, int whence); 590Sstevel@tonic-gate int (*fsw_fstat)(int filefd, struct bootstat *buf); 600Sstevel@tonic-gate void (*fsw_closeall)(int flag); 610Sstevel@tonic-gate int (*fsw_getdents)(int fd, struct dirent *buf, unsigned size); 620Sstevel@tonic-gate }; 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * Function prototypes 660Sstevel@tonic-gate * 670Sstevel@tonic-gate * fstat() (if exists) supports size and mode right now. 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate extern struct boot_fs_ops *bfs_ops; 710Sstevel@tonic-gate 720Sstevel@tonic-gate #define BRD_MOUNTROOT(ops, str) ((ops)->fsw_mountroot)(str) 730Sstevel@tonic-gate #define BRD_UNMOUNTROOT(ops) ((ops)->fsw_unmountroot)() 740Sstevel@tonic-gate #define BRD_OPEN(ops, file, flag) ((ops)->fsw_open)(file, flag) 750Sstevel@tonic-gate #define BRD_CLOSE(ops, fd) ((ops)->fsw_close)(fd) 760Sstevel@tonic-gate #define BRD_READ(ops, fd, buf, s) ((ops)->fsw_read)(fd, buf, s) 770Sstevel@tonic-gate #define BRD_SEEK(ops, fd, addr, w) ((ops)->fsw_lseek)(fd, addr, w) 78*1544Seschrock #define BRD_FSTAT(ops, fd, stp) ((ops)->fsw_fstat)(fd, stp) 790Sstevel@tonic-gate 800Sstevel@tonic-gate #ifdef _BOOT 810Sstevel@tonic-gate 820Sstevel@tonic-gate extern int mountroot(char *str); 830Sstevel@tonic-gate extern int unmountroot(void); 840Sstevel@tonic-gate extern int open(const char *filename, int flags); 850Sstevel@tonic-gate extern int close(int fd); 860Sstevel@tonic-gate extern ssize_t read(int fd, void *buf, size_t size); 870Sstevel@tonic-gate extern off_t lseek(int filefd, off_t addr, int whence); 880Sstevel@tonic-gate extern void closeall(int flag); 890Sstevel@tonic-gate 900Sstevel@tonic-gate #endif /* _BOOT */ 910Sstevel@tonic-gate 920Sstevel@tonic-gate #ifdef __cplusplus 930Sstevel@tonic-gate } 940Sstevel@tonic-gate #endif 950Sstevel@tonic-gate 960Sstevel@tonic-gate #endif /* _SYS_BOOTVFS_H */ 97