2 * fino.c -- find inode functions for lsof library
7 * Copyright 1997 Purdue Research Foundation, West Lafayette, Indiana
8 * 47907. All rights reserved.
10 * Written by Victor A. Abell
12 * This software is not subject to any license of the American Telephone
13 * and Telegraph Company or the Regents of the University of California.
15 * Permission is granted to anyone to use this software for any purpose on
16 * any computer system, and to alter it and redistribute it freely, subject
17 * to the following restrictions:
19 * 1. Neither the authors nor Purdue University are responsible for any
20 * consequences of the use of this software.
22 * 2. The origin of this software must not be misrepresented, either by
23 * explicit claim or by omission. Credit to the authors and Purdue
24 * University must appear in documentation and sources.
26 * 3. Altered versions must be plainly marked as such, and must not be
27 * misrepresented as being the original software.
29 * 4. This notice may not be removed or altered.
34 * fino.c -- find block (optional) and character device file inode numbers
36 * The caller must define:
38 * HASBLKDEV to activate the block device inode lookup
42 #include "../machine.h"
44 #if defined(HASBLKDEV) || defined(USE_LIB_FIND_CH_INO)
47 static char copyright[] =
48 "@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
49 static char *rcsid = "$Id: fino.c,v 1.5 2008/10/21 16:12:36 abe Exp $";
50 # endif /* !defined(lint) */
54 #else /* !defined(HASBLKDEV) && !defined(USE_LIB_FIND_CH_INO) */
55 char fino_d1[] = "d"; char *fino_d2 = fino_d1;
56 #endif /* defined(HASBLKDEV) || defined(USE_LIB_FIND_CH_INO) */
59 #if defined(HASBLKDEV)
61 * find_bl_ino() - find the inode number for a block device file
72 # if defined(HASDCACHE)
74 # endif /* defined(HASDCACHE) */
78 if (!Lf->dev_def || (Lf->dev != DevDev) || !Lf->rdev_def)
83 tdev = BSdev[mid]->rdev;
90 # if defined(HASDCACHE)
91 if (DCunsafe && !BSdev[mid]->v && !vfy_dev(BSdev[mid]))
92 goto find_bl_ino_again;
93 # endif /* defined(HASDCACHE) */
95 Lf->inode = BSdev[mid]->inode;
102 #endif /* defined(HASBLKDEV) */
105 #if defined(USE_LIB_FIND_CH_INO)
107 * find_ch_ino() - find the inode number for a character device file
118 # if defined(HASDCACHE)
120 # endif /* defined(HASDCACHE) */
124 if (!Lf->dev_def || (Lf->dev != DevDev) || !Lf->rdev_def)
128 mid = (low + hi) / 2;
129 tdev = Sdev[mid]->rdev;
132 else if (ldev > tdev)
136 # if defined(HASDCACHE)
137 if (DCunsafe && !Sdev[mid]->v && !vfy_dev(Sdev[mid]))
138 goto find_ch_ino_again;
139 # endif /* defined(HASDCACHE) */
141 Lf->inode = Sdev[mid]->inode;
148 #endif /* defined(USE_LIB_FIND_CH_INO) */