84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * CDDL HEADER START
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * The contents of this file are subject to the terms of the
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * Common Development and Distribution License, Version 1.0 only
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * (the "License"). You may not use this file except in compliance
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * with the License.
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * See the License for the specific language governing permissions
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * and limitations under the License.
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * When distributing Covered Code, include this CDDL HEADER in each
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * If applicable, add the following below this CDDL HEADER, with the
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * fields enclosed by brackets "[]" replaced with your own identifying
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * information: Portions Copyright [yyyy] [name of copyright owner]
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * CDDL HEADER END
e4586ebf2f01666696316c178da243993b1a0c04mws * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws * Use is subject to license terms.
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws#pragma ident "%Z%%M% %I% %E% SMI"
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mwsstatic void
e4586ebf2f01666696316c178da243993b1a0c04mws if ((n = pread64(fd, ep, sizeof (*ep), 0)) != sizeof (*ep))
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws return (smb_open_error(shp, errp, n < 0 ? errno : ESMB_NOHDR));
e4586ebf2f01666696316c178da243993b1a0c04mws if (strncmp(ep->smbe_eanchor, SMB_ENTRY_EANCHOR, SMB_ENTRY_EANCHORLEN))
e4586ebf2f01666696316c178da243993b1a0c04mws return (smb_open_error(shp, errp, n < 0 ? errno : ESMB_NOHDR));
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws return (smb_open_error(shp, errp, n < 0 ? errno : ESMB_NOSTAB));
e4586ebf2f01666696316c178da243993b1a0c04mws shp = smbios_bufopen(ep, stbuf, ep->smbe_stlen, version, flags, errp);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws bios = mmap(NULL, SMB_RANGE_LIMIT - SMB_RANGE_START + 1,
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws q = (void *)((uintptr_t)bios + SMB_RANGE_LIMIT - SMB_RANGE_START + 1);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws for (p = bios; p < q; p = (void *)((uintptr_t)p + 16)) {
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws if (strncmp(p, SMB_ENTRY_EANCHOR, SMB_ENTRY_EANCHORLEN) == 0)
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws if (p >= q) {
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws (void) munmap(bios, SMB_RANGE_LIMIT - SMB_RANGE_START + 1);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws (void) munmap(bios, SMB_RANGE_LIMIT - SMB_RANGE_START + 1);
e4586ebf2f01666696316c178da243993b1a0c04mws shp = smbios_bufopen(ep, stbuf, ep->smbe_stlen, version, flags, errp);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws if (stat64(SMB_BIOS_DEVICE, &st1) == 0 && fstat64(fd, &st2) == 0 &&
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mwssmbios_open(const char *file, int version, int flags, int *errp)
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws if ((fd = open64(file ? file : SMB_SMBIOS_DEVICE, O_RDONLY)) == -1) {
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mwssmbios_xwrite(smbios_hdl_t *shp, int fd, const void *buf, size_t buflen)
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws while (resid != 0) {
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws return (0);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws off64_t off = lseek64(fd, 0, SEEK_CUR) + P2ROUNDUP(sizeof (ep), 16);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws smbios_xwrite(shp, fd, shp->sh_buf, shp->sh_buflen) == -1)
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws return (-1);
84ab085a13f931bc78e7415e7ce921dbaa14fcb3mws return (0);