tizen 2.3.1 release
[external/lsof.git] / lib / cvfs.c
1 /*
2  * cvfs.c -- completevfs() function for lsof library
3  */
4
5
6 /*
7  * Copyright 1997 Purdue Research Foundation, West Lafayette, Indiana
8  * 47907.  All rights reserved.
9  *
10  * Written by Victor A. Abell
11  *
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.
14  *
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:
18  *
19  * 1. Neither the authors nor Purdue University are responsible for any
20  *    consequences of the use of this software.
21  *
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.
25  *
26  * 3. Altered versions must be plainly marked as such, and must not be
27  *    misrepresented as being the original software.
28  *
29  * 4. This notice may not be removed or altered.
30  */
31
32
33 /*
34  * The caller must define CVFS_DEVSAVE to have the device number moved
35  * from the mounts entry to the local vfs structure.
36  *
37  * The caller must define CVFS_NLKSAVE to have the link count moved from
38  * the mounts entry to the local vfs structure.
39  *
40  * The caller must define CVFS_SZSAVE to have the size moved from the
41  * mounts entry to the local vfs structure.
42  */
43
44
45 #include "../machine.h"
46
47 #if     defined(USE_LIB_COMPLETEVFS)
48
49 # if    !defined(lint)
50 static char copyright[] =
51 "@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
52 static char *rcsid = "$Id: cvfs.c,v 1.6 2008/10/21 16:12:36 abe Exp $";
53 # endif /* !defined(lint) */
54
55 #include        "../lsof.h"
56
57
58 /*
59  * completevfs() - complete local vfs structure
60  */
61
62 void
63 completevfs(vfs, dev)
64         struct l_vfs *vfs;              /* local vfs structure pointer */
65         dev_t *dev;                     /* device */
66 {
67         struct mounts *mp;
68 /*
69  * If only Internet socket files are selected, don't bother completing the
70  * local vfs structure.
71  */
72         if (Selinet)
73             return;
74 /*
75  * Search for a match on device number.
76  */
77         for (mp = readmnt(); mp; mp = mp->next) {
78             if (mp->dev == *dev) {
79
80 # if    defined(CVFS_DEVSAVE)
81                 vfs->dev = mp->dev;
82 # endif /* defined(CVFS_DEVSAVE) */
83
84 # if    defined(CVFS_NLKSAVE)
85                 vfs->nlink = mp->nlink;
86 # endif /* defined(CVFS_NLKSAVE) */
87
88 # if    defined(CVFS_SZSAVE)
89                 vfs->size = mp->size;
90 # endif /* defined(CVFS_SZSAVE) */
91
92                 vfs->dir = mp->dir;
93                 vfs->fsname = mp->fsname;
94
95 # if    defined(HASFSINO)
96                 vfs->fs_ino = mp->inode;
97 # endif /* defined(HASFSINO) */
98
99 # if    defined(HASMNTSTAT)
100                 vfs->mnt_stat = mp->stat;
101 # endif /* defined(HASMNTSTAT) */
102
103
104                 return;
105             }
106         }
107 }
108 #else   /* !defined(USE_LIB_COMPLETEVFS) */
109 char cvfs_d1[] = "d"; char *cvfs_d2 = cvfs_d1;
110 #endif  /* defined(USE_LIB_COMPLETEVFS) */