File: dnode1.c

package info (click to toggle)
lsof 4.91%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,984 kB
  • sloc: ansic: 68,893; sh: 6,862; makefile: 1,682; perl: 1,099; awk: 214
file content (157 lines) | stat: -rw-r--r-- 4,080 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * dnode1.c - /dev/kmem-based HP-UX node functions for lsof
 *
 * This module must be separate to keep separate the multiple kernel inode
 * structure definitions.
 */


/*
 * Copyright 1995 Purdue Research Foundation, West Lafayette, Indiana
 * 47907.  All rights reserved.
 *
 * Written by Victor A. Abell
 *
 * This software is not subject to any license of the American Telephone
 * and Telegraph Company or the Regents of the University of California.
 *
 * Permission is granted to anyone to use this software for any purpose on
 * any computer system, and to alter it and redistribute it freely, subject
 * to the following restrictions:
 *
 * 1. Neither the authors nor Purdue University are responsible for any
 *    consequences of the use of this software.
 *
 * 2. The origin of this software must not be misrepresented, either by
 *    explicit claim or by omission.  Credit to the authors and Purdue
 *    University must appear in documentation and sources.
 *
 * 3. Altered versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 *
 * 4. This notice may not be removed or altered.
 */

#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
static char *rcsid = "$Id: dnode1.c,v 1.11 2005/08/08 19:50:23 abe Exp $";
#endif


#if	defined(HASVXFS)

# if	defined(HPUXKERNBITS) && HPUXKERNBITS>=64
#define _INO_T
typedef int ino_t;
#define _TIME_T
typedef int time_t;
# endif	/* defined(HPUXKERNBITS) && HPUXKERNBITS>=64 */

#include "lsof.h"


/*
 * HP-UX versions below 10.20:
 *
 *    The pool_id_t type does not seem to be defined in the header  files
 *    distributed by HP.  However, <sys/fs/vx_hpux.h> requires  it when
 *    _KERNEL is defined.  So we fake the pool_id_t definition.
 *
 *    <sys/fs/vx_hpux.h> also requires sv_sema_t.  It's defined in
 *    <sys/sem_alpha.h> when _KERNEL is defined, but some other header file has
 *    already included <sys/sem_alpha.h> with _KERNEL undefined.  So we fake the
 *    sv_sema_t definition.
 *
 * HP-UX version 10.20 and above:
 *
 *    The pool_id_t type is used by other header files for other purposes.
 *    Redefine it for VXFS.  Delete some other conflicting definitions.
 *    Don't #define _KERNEL.  Include a different set of VXFS header files.
 */


# if	HPUXV>=1020
#undef	te_offset
#undef	i_size
#undef	di_size
#define	pool_id_t	vx_pool_id_t

#  if	HPUXV>=1030
#define	ulong	vx_ulong		/* avoid <sys/stream.h> conflict */
#  endif	/* HPUXV>=1030 */

#include <sys/fs/vx_hpux.h>
#include <sys/fs/vx_port.h>
#include <sys/fs/vx_inode.h>

#  if	HPUXV>=1030
#undef	ulong
#  endif	/* HPUXV>=1030 */

# else	/* HPUXV<1020 */

#define	pool_id_t	caddr_t
#define	sv_sema_t	caddr_t
#define	_KERNEL
#include <sys/fs/vx_hpux.h>
#include <sys/fs/vx_inode.h>
#undef	_KERNEL
# endif	/* HPUXV>=1020 */


/*
 * read_vxnode() - read Veritas file system inode information
 */

int
read_vxnode(v, vfs, dev, devs, rdev, rdevs)
	struct vnode *v;		/* local containing vnode */
	struct l_vfs *vfs;		/* local vfs structure */
	dev_t *dev;			/* device number receiver */
	int *devs;			/* device status receiver */
	dev_t *rdev;			/* raw device number receiver */
	int *rdevs;			/* raw device status receiver */
{
	struct vx_inode i;

	if (!v->v_data || kread((KA_T)v->v_data, (char *)&i, sizeof(i)))
	    return(1);
/*
 * Return device numbers.
 */
	if (vfs && vfs->fsname)
	    *dev = vfs->dev;
	else
	    *dev = i.i_dev;
	*devs = 1;
	if ((v->v_type == VCHR) || (v->v_type == VBLK)) {
	    *rdev = v->v_rdev;
	    *rdevs = 1;
	}
/*
 * Record inode number.
 */
	Lf->inode = (INODETYPE)i.i_number;
	Lf->inp_ty = 1;
/*
 * Record size.
 */
	if (Foffset || ((v->v_type == VCHR || v->v_type == VBLK) && !Fsize))
	    Lf->off_def = 1;
	else {
	    Lf->sz = (SZOFFTYPE)i.i_size;
	    Lf->sz_def = 1;
	}
/*
 * Record link count.
 */
	if (Fnlink) {
	    Lf->nlink = (long)i.i_nlink;
	    Lf->nlink_def = 1;
	    if (Nlink && (Lf->nlink < Nlink))
		Lf->sf |= SELNLINK;
	}
	return(0);
}
#endif	/* defined(HASVXFS) */