~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.march-merge

« back to all changes in this revision

Viewing changes to modules/linux/vmhgfs/filesystem.c

  • Committer: Nate Muench
  • Date: 2012-03-22 17:50:13 UTC
  • mfrom: (1.4.7)
  • Revision ID: nowiwilldestroyabydos@gmail.com-20120322175013-0jh30wfk7ut20rdj
Tags: 2012.03.13-651368-0ubuntu1
* Merge latest upstream git tag.
* debian/rules: Removed glib2.0 compatibility CFLAG.
  - Packaging can now build without it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
static inline unsigned long HgfsComputeBlockBits(unsigned long blockSize);
84
84
static compat_kmem_cache_ctor HgfsInodeCacheCtor;
85
85
static HgfsSuperInfo *HgfsInitSuperInfo(HgfsMountInfo *mountInfo);
86
 
static struct dentry *HgfsGetRootDentry(struct super_block *sb);
 
86
static int HgfsGetRootDentry(struct super_block *sb, struct dentry **rootDentry);
87
87
static int HgfsReadSuper(struct super_block *sb,
88
88
                         void *rawData,
89
89
                         int flags);
334
334
 *    Gets the root dentry for a given super block.
335
335
 *
336
336
 * Results:
337
 
 *    A valid root dentry on success, NULL otherwise.
 
337
 *    zero and a valid root dentry on success
 
338
 *    negative value on failure
338
339
 *
339
340
 * Side effects:
340
341
 *    None.
342
343
 *----------------------------------------------------------------------------
343
344
 */
344
345
 
345
 
static struct dentry *
346
 
HgfsGetRootDentry(struct super_block *sb)       // IN: Super block object
 
346
static int
 
347
HgfsGetRootDentry(struct super_block *sb,       // IN: Super block object
 
348
                  struct dentry **rootDentry)   // OUT: Root dentry
347
349
{
348
 
   struct dentry *rootDentry = NULL;
 
350
   int result = -ENOMEM;
349
351
   struct inode *rootInode;
 
352
   struct dentry *tempRootDentry = NULL;
 
353
   struct HgfsAttrInfo rootDentryAttr;
 
354
   HgfsInodeInfo *iinfo;
350
355
 
351
356
   ASSERT(sb);
 
357
   ASSERT(rootDentry);
352
358
 
353
359
   LOG(6, (KERN_DEBUG "VMware hgfs: %s: entered\n", __func__));
354
360
 
355
361
   rootInode = HgfsGetInode(sb, HGFS_ROOT_INO);
356
 
   if (rootInode) {
357
 
      HgfsInodeInfo *iinfo;
358
 
      static const HgfsAttrInfo attr = {
359
 
         .type             = HGFS_FILE_TYPE_DIRECTORY,
360
 
         .size             = 4192,
361
 
         .specialPerms     = 0,
362
 
         .ownerPerms       = HGFS_PERM_READ | HGFS_PERM_EXEC,
363
 
         .groupPerms       = HGFS_PERM_READ | HGFS_PERM_EXEC,
364
 
         .otherPerms       = HGFS_PERM_READ | HGFS_PERM_EXEC,
365
 
         .mask             = HGFS_ATTR_VALID_TYPE |
366
 
                             HGFS_ATTR_VALID_SIZE |
367
 
                             HGFS_ATTR_VALID_SPECIAL_PERMS |
368
 
                             HGFS_ATTR_VALID_OWNER_PERMS |
369
 
                             HGFS_ATTR_VALID_GROUP_PERMS |
370
 
                             HGFS_ATTR_VALID_OTHER_PERMS,
371
 
      };
372
 
 
373
 
      /*
374
 
       * On an allocation failure in read_super, the inode will have been
375
 
       * marked "bad". If it was, we certainly don't want to start playing with
376
 
       * the HgfsInodeInfo. So quietly put the inode back and fail.
377
 
       */
378
 
      if (is_bad_inode(rootInode)) {
379
 
         LOG(6, (KERN_DEBUG "VMware hgfs: %s: encountered bad inode\n",
380
 
                 __func__));
381
 
         iput(rootInode);
382
 
         goto exit;
383
 
      }
384
 
 
385
 
      HgfsChangeFileAttributes(rootInode, &attr);
386
 
 
387
 
      iinfo = INODE_GET_II_P(rootInode);
388
 
      iinfo->isFakeInodeNumber = FALSE;
389
 
      iinfo->isReferencedInode = TRUE;
390
 
   }
391
 
 
392
 
   rootDentry = d_alloc_root(rootInode);
393
 
   if (rootDentry == NULL) {
 
362
   if (rootInode == NULL) {
 
363
      LOG(6, (KERN_DEBUG "VMware hgfs: %s: Could not get the root inode\n",
 
364
             __func__));
 
365
      goto exit;
 
366
   }
 
367
 
 
368
   /*
 
369
    * On an allocation failure in read_super, the inode will have been
 
370
    * marked "bad". If it was, we certainly don't want to start playing with
 
371
    * the HgfsInodeInfo. So quietly put the inode back and fail.
 
372
    */
 
373
   if (is_bad_inode(rootInode)) {
 
374
      LOG(6, (KERN_DEBUG "VMware hgfs: %s: encountered bad inode\n",
 
375
             __func__));
 
376
      goto exit;
 
377
   }
 
378
 
 
379
   tempRootDentry = d_alloc_root(rootInode);
 
380
   if (tempRootDentry == NULL) {
394
381
      LOG(4, (KERN_WARNING "VMware hgfs: %s: Could not get "
395
382
              "root dentry\n", __func__));
396
383
      goto exit;
397
384
   }
398
385
 
 
386
   rootInode = NULL;
 
387
 
 
388
   result = HgfsPrivateGetattr(tempRootDentry, &rootDentryAttr, NULL);
 
389
   if (result) {
 
390
      LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not"
 
391
             "instantiate the root dentry\n"));
 
392
      goto exit;
 
393
   }
 
394
 
 
395
   iinfo = INODE_GET_II_P(tempRootDentry->d_inode);
 
396
   iinfo->isFakeInodeNumber = FALSE;
 
397
   iinfo->isReferencedInode = TRUE;
 
398
 
 
399
   if (rootDentryAttr.mask & HGFS_ATTR_VALID_FILEID) {
 
400
      iinfo->hostFileId = rootDentryAttr.hostFileId;
 
401
   }
 
402
 
 
403
   HgfsChangeFileAttributes(tempRootDentry->d_inode, &rootDentryAttr);
 
404
   HgfsDentryAgeReset(tempRootDentry);
 
405
   tempRootDentry->d_op = &HgfsDentryOperations;
 
406
 
 
407
   *rootDentry = tempRootDentry;
 
408
   result = 0;
 
409
 
399
410
   LOG(6, (KERN_DEBUG "VMware hgfs: %s: finished\n", __func__));
400
411
exit:
401
 
   return rootDentry;
 
412
   if (result) {
 
413
      iput(rootInode);
 
414
      dput(tempRootDentry);
 
415
      *rootDentry = NULL;
 
416
   }
 
417
   return result;
402
418
}
403
419
 
404
420
 
461
477
   sb->s_magic = HGFS_SUPER_MAGIC;
462
478
   sb->s_op = &HgfsSuperOperations;
463
479
 
 
480
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
 
481
   sb->s_d_op = &HgfsDentryOperations;
 
482
#endif
 
483
 
464
484
   /*
465
485
    * If s_maxbytes isn't initialized, the generic write path may fail. In
466
486
    * most kernels, s_maxbytes is initialized by the kernel's superblock
478
498
   sb->s_blocksize_bits = HgfsComputeBlockBits(HGFS_BLOCKSIZE);
479
499
   sb->s_blocksize = 1 << sb->s_blocksize_bits;
480
500
 
481
 
   rootDentry = HgfsGetRootDentry(sb);
482
 
   if (rootDentry == NULL) {
 
501
   result = HgfsGetRootDentry(sb, &rootDentry);
 
502
   if (result) {
483
503
      LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not instantiate "
484
504
              "root dentry\n"));
485
 
      result = -ENOMEM;
486
505
      goto exit;
487
506
   }
 
507
 
488
508
   sb->s_root = rootDentry;
489
509
 
490
510
   LOG(6, (KERN_DEBUG "VMware hgfs: HgfsReadSuper: finished %s\n", si->shareName));