This file is indexed.

/usr/src/open-vm-tools-10.0.7/vmblock/linux/inode.c is in open-vm-tools-dkms 2:10.0.7-3227872-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*********************************************************
 * Copyright (C) 2006 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation version 2 and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 *********************************************************/

/*
 * inode.c --
 *
 *   Inode operations for the file system of the vmblock driver.
 *
 */

#include "driver-config.h"
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/namei.h>

#include "vmblockInt.h"
#include "filesystem.h"
#include "block.h"


/* Inode operations */
static struct dentry *InodeOpLookup(struct inode *dir,
                                    struct dentry *dentry, struct nameidata *nd);
static int InodeOpReadlink(struct dentry *dentry, char __user *buffer, int buflen);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
static void *InodeOpFollowlink(struct dentry *dentry, struct nameidata *nd);
#else
static int InodeOpFollowlink(struct dentry *dentry, struct nameidata *nd);
#endif


struct inode_operations RootInodeOps = {
   .lookup = InodeOpLookup,
};

static struct inode_operations LinkInodeOps = {
   .readlink    = InodeOpReadlink,
   .follow_link = InodeOpFollowlink,
};


/*
 *----------------------------------------------------------------------------
 *
 * InodeOpLookup --
 *
 *    Looks up a name (dentry) in provided directory.  Invoked every time
 *    a directory entry is traversed in path lookups.
 *
 * Results:
 *    NULL on success, negative error code on error.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

static struct dentry *
InodeOpLookup(struct inode *dir,      // IN: parent directory's inode
              struct dentry *dentry,  // IN: dentry to lookup
              struct nameidata *nd)   // IN: lookup intent and information
{
   char *filename;
   struct inode *inode;
   int ret;

   if (!dir || !dentry) {
      Warning("InodeOpLookup: invalid args from kernel\n");
      return ERR_PTR(-EINVAL);
   }

   /* The kernel should only pass us our own inodes, but check just to be safe. */
   if (!INODE_TO_IINFO(dir)) {
      Warning("InodeOpLookup: invalid inode provided\n");
      return ERR_PTR(-EINVAL);
   }

   /* Get a slab from the kernel's names_cache of PATH_MAX-sized buffers. */
   filename = __getname();
   if (!filename) {
      Warning("InodeOpLookup: unable to obtain memory for filename.\n");
      return ERR_PTR(-ENOMEM);
   }

   ret = MakeFullName(dir, dentry, filename, PATH_MAX);
   if (ret < 0) {
      Warning("InodeOpLookup: could not construct full name\n");
      __putname(filename);
      return ERR_PTR(ret);
   }

   /* Block if there is a pending block on this file */
   BlockWaitOnFile(filename, NULL);
   __putname(filename);

   inode = Iget(dir->i_sb, dir, dentry, GetNextIno());
   if (!inode) {
      Warning("InodeOpLookup: failed to get inode\n");
      return ERR_PTR(-ENOMEM);
   }

   dentry->d_op = &LinkDentryOps;
   dentry->d_time = jiffies;

   /*
    * If the actual file's dentry doesn't have an inode, it means the file we
    * are redirecting to doesn't exist.  Give back the inode that was created
    * for this and add a NULL dentry->inode entry in the dcache.  (The NULL
    * entry is added so ops to create files/directories are invoked by VFS.)
    */
   if (!INODE_TO_ACTUALDENTRY(inode) || !INODE_TO_ACTUALINODE(inode)) {
      iput(inode);
      d_add(dentry, NULL);
      return NULL;
   }

   inode->i_mode = S_IFLNK | S_IRWXUGO;
   inode->i_size = INODE_TO_IINFO(inode)->nameLen;
   inode->i_version = 1;
   inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
   inode->i_uid = inode->i_gid = 0;
   inode->i_op = &LinkInodeOps;

   d_add(dentry, inode);
   return NULL;
}


/*
 *----------------------------------------------------------------------------
 *
 * InodeOpReadlink --
 *
 *    Provides the symbolic link's contents to the user.  Invoked when
 *    readlink(2) is invoked on our symlinks.
 *
 * Results:
 *    0 on success, negative error code on failure.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

static int
InodeOpReadlink(struct dentry *dentry,  // IN : dentry of symlink
                char __user *buffer,    // OUT: output buffer (user space)
                int buflen)             // IN : length of output buffer
{
   VMBlockInodeInfo *iinfo;

   if (!dentry || !buffer) {
      Warning("InodeOpReadlink: invalid args from kernel\n");
      return -EINVAL;
   }

   iinfo = INODE_TO_IINFO(dentry->d_inode);
   if (!iinfo) {
      return -EINVAL;
   }

   return vfs_readlink(dentry, buffer, buflen, iinfo->name);
}


/*
 *----------------------------------------------------------------------------
 *
 * InodeOpFollowlink --
 *
 *    Provides the inode corresponding to this symlink through the nameidata
 *    structure.
 *
 * Results:
 *    0 on success, negative error on failure.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
static void *
#else
static int
#endif
InodeOpFollowlink(struct dentry *dentry,  // IN : dentry of symlink
                  struct nameidata *nd)   // OUT: stores result
{
   int ret;
   VMBlockInodeInfo *iinfo;

   if (!dentry) {
      Warning("InodeOpReadlink: invalid args from kernel\n");
      ret = -EINVAL;
      goto out;
   }

   iinfo = INODE_TO_IINFO(dentry->d_inode);
   if (!iinfo) {
      ret = -EINVAL;
      goto out;
   }

   ret = vfs_follow_link(nd, iinfo->name);

out:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
   return ERR_PTR(ret);
#else
   return ret;
#endif
}