summaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_cd9660.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2009-06-20 19:50:06 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2009-06-20 19:50:06 +0000
commit4402975a348938d8cad34341962b18854da39d93 (patch)
tree6e28c93ca566c8d3414efdb1b380fb43722021db /lib/libkvm/kvm_cd9660.c
parentde7b3f1a5b22f9468caf434ec9772ba368c620c0 (diff)
Split out cd9660 bits into their own .c file to avoid #define collisions
with ufs and add also udf support. OK miod@
Diffstat (limited to 'lib/libkvm/kvm_cd9660.c')
-rw-r--r--lib/libkvm/kvm_cd9660.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/libkvm/kvm_cd9660.c b/lib/libkvm/kvm_cd9660.c
new file mode 100644
index 00000000000..e61079e67d7
--- /dev/null
+++ b/lib/libkvm/kvm_cd9660.c
@@ -0,0 +1,60 @@
+/* $OpenBSD: kvm_cd9660.c,v 1.1 2009/06/20 19:50:05 millert Exp $ */
+
+/*
+ * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: kvm_cd9660.c,v 1.1 2009/06/20 19:50:05 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/param.h>
+#include <sys/ucred.h>
+#define _KERNEL
+#include <sys/mount.h>
+#undef _KERNEL
+#include <sys/vnode.h>
+#include <sys/sysctl.h>
+
+#include <isofs/cd9660/iso.h>
+#include <isofs/cd9660/cd9660_extern.h>
+#include <isofs/cd9660/cd9660_node.h>
+
+#include <limits.h>
+#include <kvm.h>
+#include <db.h>
+
+#include "kvm_private.h"
+
+#define KREAD(kd, addr, obj) \
+ (kvm_read(kd, addr, obj, sizeof(*obj)) != sizeof(*obj))
+
+int
+_kvm_stat_cd9660(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+{
+ struct iso_node inode;
+
+ if (KREAD(kd, (u_long)VTOI(vp), &inode)) {
+ _kvm_err(kd, kd->program, "can't read inode at %p", VTOI(vp));
+ return (-1);
+ }
+ kf->va_fsid = inode.i_dev & 0xffff;
+ kf->va_fileid = (long)inode.i_number;
+ kf->va_mode = inode.inode.iso_mode;
+ kf->va_size = inode.i_size;
+ kf->va_rdev = inode.i_dev;
+
+ return (0);
+}