8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / stand / lib / fs / common / promfs.c
blob0ed3aa4e2e634f119546712b22dfe9992ffe7dcb
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 #pragma ident "%Z%%M% %I% %E% SMI"
27 #include <sys/param.h>
28 #include <sys/sysmacros.h>
29 #include <sys/stat.h>
30 #include <sys/bootvfs.h>
31 #include <sys/bootsyms.h>
32 #include <sys/promif.h>
33 #include <sys/salib.h>
36 * Function prototypes
38 static int promfs_mountroot(char *str);
39 static int promfs_unmountroot(void);
40 static int promfs_open(char *filename, int flags);
41 static int promfs_close(int fd);
42 static ssize_t promfs_read(int fd, caddr_t buf, size_t size);
43 static off_t promfs_lseek(int fd, off_t offset, int whence);
44 static int promfs_fstat(int fd, struct bootstat *stp);
45 static void promfs_closeall(int flag);
47 struct boot_fs_ops promfs_ops = {
48 "promfs",
49 promfs_mountroot,
50 promfs_unmountroot,
51 promfs_open,
52 promfs_close,
53 promfs_read,
54 promfs_lseek,
55 promfs_fstat,
56 promfs_closeall,
57 NULL
60 static ihandle_t fsih;
62 static int
63 promfs_mountroot(char *str)
66 (void) prom_getprop(prom_chosennode(), str, (caddr_t)&fsih);
67 return (fsih == -1);
70 static int
71 promfs_unmountroot(void)
73 (void) prom_close(fsih);
74 return (0);
77 /*ARGSUSED*/
78 static int
79 promfs_open(char *filename, int flags)
81 return (prom_fopen(fsih, filename));
84 static int
85 promfs_close(int fd)
87 prom_fclose(fsih, fd);
88 return (0);
91 static ssize_t
92 promfs_read(int fd, caddr_t buf, size_t size)
94 return (prom_fread(fsih, fd, buf, size));
97 /*ARGSUSED*/
98 static off_t
99 promfs_lseek(int fd, off_t offset, int whence)
101 return (prom_fseek(fsih, fd, offset));
104 static int
105 promfs_fstat(int fd, struct bootstat *stp)
107 return (prom_fsize(fsih, fd, (size_t *)&stp->st_size));
110 /*ARGSUSED*/
111 static void
112 promfs_closeall(int flag)