10daf62d9SStanislav Sedov /* 2*df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3*df57947fSPedro F. Giffuni * 40daf62d9SStanislav Sedov * Copyright (c) 2000 Peter Edwards 50daf62d9SStanislav Sedov * Copyright (c) 1988, 1993 60daf62d9SStanislav Sedov * The Regents of the University of California. All rights reserved. 70daf62d9SStanislav Sedov * 80daf62d9SStanislav Sedov * This code is derived from software contributed to Berkeley by Peter Edwards 90daf62d9SStanislav Sedov * 100daf62d9SStanislav Sedov * Redistribution and use in source and binary forms, with or without 110daf62d9SStanislav Sedov * modification, are permitted provided that the following conditions 120daf62d9SStanislav Sedov * are met: 130daf62d9SStanislav Sedov * 1. Redistributions of source code must retain the above copyright 140daf62d9SStanislav Sedov * notice, this list of conditions and the following disclaimer. 150daf62d9SStanislav Sedov * 2. Redistributions in binary form must reproduce the above copyright 160daf62d9SStanislav Sedov * notice, this list of conditions and the following disclaimer in the 170daf62d9SStanislav Sedov * documentation and/or other materials provided with the distribution. 180daf62d9SStanislav Sedov * 3. All advertising materials mentioning features or use of this software 190daf62d9SStanislav Sedov * must display the following acknowledgement: 200daf62d9SStanislav Sedov * This product includes software developed by the University of 210daf62d9SStanislav Sedov * California, Berkeley and its contributors. 220daf62d9SStanislav Sedov * 4. Neither the name of the University nor the names of its contributors 230daf62d9SStanislav Sedov * may be used to endorse or promote products derived from this software 240daf62d9SStanislav Sedov * without specific prior written permission. 250daf62d9SStanislav Sedov * 260daf62d9SStanislav Sedov * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 270daf62d9SStanislav Sedov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 280daf62d9SStanislav Sedov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 290daf62d9SStanislav Sedov * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 300daf62d9SStanislav Sedov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 310daf62d9SStanislav Sedov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 320daf62d9SStanislav Sedov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 330daf62d9SStanislav Sedov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 340daf62d9SStanislav Sedov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 350daf62d9SStanislav Sedov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 360daf62d9SStanislav Sedov * SUCH DAMAGE. 370daf62d9SStanislav Sedov */ 380daf62d9SStanislav Sedov 390daf62d9SStanislav Sedov /* 400daf62d9SStanislav Sedov * XXX - 410daf62d9SStanislav Sedov * This had to be separated from fstat.c because cd9660s has namespace 420daf62d9SStanislav Sedov * conflicts with UFS. 430daf62d9SStanislav Sedov */ 440daf62d9SStanislav Sedov 450daf62d9SStanislav Sedov #include <sys/param.h> 460daf62d9SStanislav Sedov #include <sys/stat.h> 470daf62d9SStanislav Sedov #include <sys/time.h> 480daf62d9SStanislav Sedov #include <sys/vnode.h> 490daf62d9SStanislav Sedov #include <sys/mount.h> 500daf62d9SStanislav Sedov 510daf62d9SStanislav Sedov #include <netinet/in.h> 520daf62d9SStanislav Sedov 530daf62d9SStanislav Sedov #include <err.h> 540daf62d9SStanislav Sedov 550daf62d9SStanislav Sedov #define _KERNEL 560daf62d9SStanislav Sedov #include <isofs/cd9660/iso.h> 570daf62d9SStanislav Sedov #undef _KERNEL 58f9d593d7SConrad Meyer #include <isofs/cd9660/cd9660_node.h> 590daf62d9SStanislav Sedov 600daf62d9SStanislav Sedov #include <kvm.h> 610daf62d9SStanislav Sedov #include <stdio.h> 620daf62d9SStanislav Sedov 630daf62d9SStanislav Sedov #include "libprocstat.h" 640daf62d9SStanislav Sedov #include "common_kvm.h" 650daf62d9SStanislav Sedov 660daf62d9SStanislav Sedov int 670daf62d9SStanislav Sedov isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn) 680daf62d9SStanislav Sedov { 690daf62d9SStanislav Sedov struct iso_node isonode; 700daf62d9SStanislav Sedov struct iso_mnt mnt; 710daf62d9SStanislav Sedov 720daf62d9SStanislav Sedov if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &isonode, 730daf62d9SStanislav Sedov sizeof(isonode))) { 740daf62d9SStanislav Sedov warnx("can't read iso_node at %p", 750daf62d9SStanislav Sedov (void *)VTOI(vp)); 760daf62d9SStanislav Sedov return (1); 770daf62d9SStanislav Sedov } 780daf62d9SStanislav Sedov if (!kvm_read_all(kd, (unsigned long)isonode.i_mnt, &mnt, 790daf62d9SStanislav Sedov sizeof(mnt))) { 800daf62d9SStanislav Sedov warnx("can't read iso_mnt at %p", 810daf62d9SStanislav Sedov (void *)VTOI(vp)); 820daf62d9SStanislav Sedov return (1); 830daf62d9SStanislav Sedov } 840daf62d9SStanislav Sedov vn->vn_fsid = dev2udev(kd, mnt.im_dev); 850daf62d9SStanislav Sedov vn->vn_mode = (mode_t)isonode.inode.iso_mode; 86e458cb77SGleb Kurtsou vn->vn_fileid = isonode.i_number; 87e458cb77SGleb Kurtsou vn->vn_size = isonode.i_size; 880daf62d9SStanislav Sedov return (0); 890daf62d9SStanislav Sedov } 90