138494Sobrien/* 2310490Scy * SPDX-License-Identifier: BSD-4-Clause 338494Sobrien * 438494Sobrien * Copyright (c) 2000 Peter Edwards 538494Sobrien * Copyright (c) 1988, 1993 638494Sobrien * The Regents of the University of California. All rights reserved. 738494Sobrien * 838494Sobrien * This code is derived from software contributed to Berkeley by Peter Edwards 938494Sobrien * 1038494Sobrien * Redistribution and use in source and binary forms, with or without 1138494Sobrien * modification, are permitted provided that the following conditions 1238494Sobrien * are met: 1338494Sobrien * 1. Redistributions of source code must retain the above copyright 1438494Sobrien * notice, this list of conditions and the following disclaimer. 1538494Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1638494Sobrien * notice, this list of conditions and the following disclaimer in the 1738494Sobrien * documentation and/or other materials provided with the distribution. 1838494Sobrien * 3. All advertising materials mentioning features or use of this software 19310490Scy * must display the following acknowledgement: 2038494Sobrien * This product includes software developed by the University of 2138494Sobrien * California, Berkeley and its contributors. 2238494Sobrien * 4. Neither the name of the University nor the names of its contributors 2338494Sobrien * may be used to endorse or promote products derived from this software 2438494Sobrien * without specific prior written permission. 2538494Sobrien * 2638494Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2738494Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2838494Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2938494Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3038494Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3138494Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3238494Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3338494Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3438494Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3538494Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36174294Sobrien * SUCH DAMAGE. 3738494Sobrien */ 3838494Sobrien 3938494Sobrien/* 40174294Sobrien * XXX - 41174294Sobrien * This had to be separated from fstat.c because cd9660s has namespace 42310490Scy * conflicts with UFS. 43310490Scy */ 44174294Sobrien 45310490Scy#include <sys/param.h> 46310490Scy#include <sys/stat.h> 47310490Scy#include <sys/time.h> 48310490Scy#include <sys/vnode.h> 49310490Scy#include <sys/mount.h> 50310490Scy 51310490Scy#include <netinet/in.h> 52310490Scy 53310490Scy#include <err.h> 54310490Scy 55310490Scy#define _KERNEL 56310490Scy#include <isofs/cd9660/iso.h> 57310490Scy#undef _KERNEL 58174294Sobrien#include <isofs/cd9660/cd9660_node.h> 59310490Scy 60310490Scy#include <kvm.h> 61310490Scy#include <stdio.h> 62310490Scy 63174294Sobrien#include "libprocstat.h" 64174294Sobrien#include "common_kvm.h" 65174294Sobrien 66174294Sobrienint 67174294Sobrienisofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn) 68174294Sobrien{ 69174294Sobrien struct iso_node isonode; 70174294Sobrien struct iso_mnt mnt; 71174294Sobrien 72174294Sobrien if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &isonode, 73174294Sobrien sizeof(isonode))) { 74174294Sobrien warnx("can't read iso_node at %p", 75174294Sobrien (void *)VTOI(vp)); 76174294Sobrien return (1); 77174294Sobrien } 78174294Sobrien if (!kvm_read_all(kd, (unsigned long)isonode.i_mnt, &mnt, 79174294Sobrien sizeof(mnt))) { 80174294Sobrien warnx("can't read iso_mnt at %p", 81174294Sobrien (void *)VTOI(vp)); 82174294Sobrien return (1); 83174294Sobrien } 84174294Sobrien vn->vn_fsid = dev2udev(kd, mnt.im_dev); 85174294Sobrien vn->vn_mode = (mode_t)isonode.inode.iso_mode; 86174294Sobrien vn->vn_fileid = isonode.i_number; 87174294Sobrien vn->vn_size = isonode.i_size; 88174294Sobrien return (0); 89174294Sobrien} 90174294Sobrien