diff options
Diffstat (limited to 'usr/src/lib/libzpool/common/kernel.c')
| -rw-r--r-- | usr/src/lib/libzpool/common/kernel.c | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/usr/src/lib/libzpool/common/kernel.c b/usr/src/lib/libzpool/common/kernel.c index 83155b480f..01dafade29 100644 --- a/usr/src/lib/libzpool/common/kernel.c +++ b/usr/src/lib/libzpool/common/kernel.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -43,6 +42,7 @@ uint64_t physmem; vnode_t *rootdir = (vnode_t *)0xabcd1234; +int modrootloaded = 0; /* * ========================================================================= @@ -562,6 +562,57 @@ cmn_err(int ce, const char *fmt, ...) /* * ========================================================================= + * kobj interfaces + * ========================================================================= + */ +struct _buf * +kobj_open_file(char *name) +{ + struct _buf *file; + vnode_t *vp; + + /* set vp as the _fd field of the file */ + if (vn_openat(name, UIO_SYSSPACE, FREAD, 0, &vp, 0, 0, rootdir) != 0) + return ((void *)-1UL); + + file = umem_zalloc(sizeof (struct _buf), UMEM_NOFAIL); + file->_fd = (intptr_t)vp; + return (file); +} + +int +kobj_read_file(struct _buf *file, char *buf, unsigned size, unsigned off) +{ + ssize_t resid; + + vn_rdwr(UIO_READ, (vnode_t *)file->_fd, buf, size, (offset_t)off, + UIO_SYSSPACE, 0, 0, 0, &resid); + + return (0); +} + +void +kobj_close_file(struct _buf *file) +{ + vn_close((vnode_t *)file->_fd); + umem_free(file, sizeof (struct _buf)); +} + +int +kobj_fstat(intptr_t fd, struct bootstat *bst) +{ + struct stat64 st; + vnode_t *vp = (vnode_t *)fd; + if (fstat64(vp->v_fd, &st) == -1) { + vn_close(vp); + return (errno); + } + bst->st_size = (uint64_t)st.st_size; + return (0); +} + +/* + * ========================================================================= * misc routines * ========================================================================= */ |
