GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libkvm/kvm_ntfs.c Lines: 0 20 0.0 %
Date: 2017-11-13 Branches: 0 6 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: kvm_ntfs.c,v 1.5 2016/10/02 23:11:55 guenther Exp $	*/
2
3
/*-
4
 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5
 * All rights reserved.
6
 *
7
 * This code is derived from software contributed to The NetBSD Foundation
8
 * by Jaromir Dolecek.
9
 *
10
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions
12
 * are met:
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in the
17
 *    documentation and/or other materials provided with the distribution.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
 * POSSIBILITY OF SUCH DAMAGE.
30
 */
31
32
#include <sys/param.h>
33
#include <sys/ucred.h>
34
#define _KERNEL
35
#include <sys/mount.h>
36
#undef _KERNEL
37
#include <sys/vnode.h>
38
#include <sys/sysctl.h>
39
40
#include <ntfs/ntfs.h>
41
#include <ntfs/ntfs_inode.h>
42
43
#include <limits.h>
44
#include <kvm.h>
45
#include <db.h>
46
47
#include "kvm_private.h"
48
#include "kvm_file.h"
49
50
int
51
_kvm_stat_ntfs(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
52
{
53
	struct ntnode ntnode;
54
	struct fnode fn;
55
	struct ntfsmount ntm;
56
57
	/*
58
	 * To get the ntnode, we have to go in two steps - firstly
59
	 * to read appropriate struct fnode and then getting the address
60
	 * of ntnode and reading it's contents
61
	 */
62
	if (KREAD(kd, (u_long)VTOF(vp), &fn)) {
63
		_kvm_err(kd, kd->program, "can't read fnode at %p", VTOF(vp));
64
		return (-1);
65
	}
66
	if (KREAD(kd, (u_long)FTONT(&fn), &ntnode)) {
67
		_kvm_err(kd, kd->program, "can't read ntnode at %p", FTONT(&fn));
68
		return (-1);
69
	}
70
	if (KREAD(kd, (u_long)ntnode.i_mp, &ntm)) {
71
		_kvm_err(kd, kd->program, "can't read ntfsmount at %p",
72
			ntnode.i_mp);
73
		return (-1);
74
	}
75
76
	kf->va_fsid = ntnode.i_dev & 0xffff;
77
	kf->va_fileid = (long)ntnode.i_number;
78
	kf->va_mode = (mode_t)ntm.ntm_mode | _kvm_getftype(vp->v_type);
79
	kf->va_size = fn.f_size;
80
	kf->va_rdev = 0;  /* XXX */
81
	kf->va_nlink = 1;
82
83
	return (0);
84
}