1221807Sstas/*
2221807Sstas * Copyright (c) 2000 Peter Edwards
3221807Sstas * Copyright (c) 1988, 1993
4221807Sstas *	The Regents of the University of California.  All rights reserved.
5221807Sstas *
6221807Sstas * This code is derived from software contributed to Berkeley by Peter Edwards
7221807Sstas *
8221807Sstas * Redistribution and use in source and binary forms, with or without
9221807Sstas * modification, are permitted provided that the following conditions
10221807Sstas * are met:
11221807Sstas * 1. Redistributions of source code must retain the above copyright
12221807Sstas *    notice, this list of conditions and the following disclaimer.
13221807Sstas * 2. Redistributions in binary form must reproduce the above copyright
14221807Sstas *    notice, this list of conditions and the following disclaimer in the
15221807Sstas *    documentation and/or other materials provided with the distribution.
16221807Sstas * 3. All advertising materials mentioning features or use of this software
17221807Sstas *    must display the following acknowledgement:
18221807Sstas *	This product includes software developed by the University of
19221807Sstas *	California, Berkeley and its contributors.
20221807Sstas * 4. Neither the name of the University nor the names of its contributors
21221807Sstas *    may be used to endorse or promote products derived from this software
22221807Sstas *    without specific prior written permission.
23221807Sstas *
24221807Sstas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25221807Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26221807Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27221807Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28221807Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29221807Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30221807Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31221807Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32221807Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33221807Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34221807Sstas * SUCH DAMAGE.
35221807Sstas */
36221807Sstas
37221807Sstas/*
38221807Sstas * XXX -
39221807Sstas * This had to be separated from fstat.c because cd9660s has namespace
40221807Sstas * conflicts with UFS.
41221807Sstas */
42221807Sstas
43221807Sstas#include <sys/cdefs.h>
44221807Sstas__FBSDID("$FreeBSD$");
45221807Sstas
46221807Sstas#include <sys/param.h>
47221807Sstas#include <sys/stat.h>
48221807Sstas#include <sys/time.h>
49221807Sstas#include <sys/vnode.h>
50221807Sstas#include <sys/mount.h>
51221807Sstas
52221807Sstas#include <netinet/in.h>
53221807Sstas
54221807Sstas#include <err.h>
55221807Sstas
56221807Sstas#include <isofs/cd9660/cd9660_node.h>
57221807Sstas#define _KERNEL
58221807Sstas#include <isofs/cd9660/iso.h>
59221807Sstas#undef _KERNEL
60221807Sstas
61221807Sstas#include <kvm.h>
62221807Sstas#include <stdio.h>
63221807Sstas
64221807Sstas#include "libprocstat.h"
65221807Sstas#include "common_kvm.h"
66221807Sstas
67221807Sstasint
68221807Sstasisofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
69221807Sstas{
70221807Sstas	struct iso_node isonode;
71221807Sstas	struct iso_mnt mnt;
72221807Sstas
73221807Sstas	if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &isonode,
74221807Sstas	    sizeof(isonode))) {
75221807Sstas		warnx("can't read iso_node at %p",
76221807Sstas		    (void *)VTOI(vp));
77221807Sstas		return (1);
78221807Sstas	}
79221807Sstas	if (!kvm_read_all(kd, (unsigned long)isonode.i_mnt, &mnt,
80221807Sstas	    sizeof(mnt))) {
81221807Sstas		warnx("can't read iso_mnt at %p",
82221807Sstas		    (void *)VTOI(vp));
83221807Sstas		return (1);
84221807Sstas	}
85221807Sstas	vn->vn_fsid = dev2udev(kd, mnt.im_dev);
86221807Sstas	vn->vn_mode = (mode_t)isonode.inode.iso_mode;
87235602Sgleb	vn->vn_fileid = isonode.i_number;
88235602Sgleb	vn->vn_size = isonode.i_size;
89221807Sstas	return (0);
90221807Sstas}
91