~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-06-20 15:59:51 UTC
  • mfrom: (1.4.8)
  • Revision ID: package-import@ubuntu.com-20120620155951-6rupmpb0f70b52zr
Tags: 2012.05.21-724730-0ubuntu1
* Merging upstream version 2012.05.21-724730.
  - Fixes building against the current Quantal kernel. (LP: #1000344)
  - Fixes Quantal installation issues. (LP: #1019031)

* Sync with Debian
  - Updating to debhelper version 9.
  - Updating to standards version 3.9.3.
  - Updating copyright file machine-readable format version 1.0.
  - Building without multiarch paths for now

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_make_root(rootInode);
 
380
   /*
 
381
    * d_make_root() does iput() on failure; if d_make_root() completes
 
382
    * successfully then subsequent dput() will do iput() for us, so we
 
383
    * should just ignore root inode from now on.
 
384
    */
 
385
   rootInode = NULL;
 
386
 
 
387
   if (tempRootDentry == NULL) {
394
388
      LOG(4, (KERN_WARNING "VMware hgfs: %s: Could not get "
395
389
              "root dentry\n", __func__));
396
390
      goto exit;
397
391
   }
398
392
 
 
393
   result = HgfsPrivateGetattr(tempRootDentry, &rootDentryAttr, NULL);
 
394
   if (result) {
 
395
      LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not"
 
396
             "instantiate the root dentry\n"));
 
397
      goto exit;
 
398
   }
 
399
 
 
400
   iinfo = INODE_GET_II_P(tempRootDentry->d_inode);
 
401
   iinfo->isFakeInodeNumber = FALSE;
 
402
   iinfo->isReferencedInode = TRUE;
 
403
 
 
404
   if (rootDentryAttr.mask & HGFS_ATTR_VALID_FILEID) {
 
405
      iinfo->hostFileId = rootDentryAttr.hostFileId;
 
406
   }
 
407
 
 
408
   HgfsChangeFileAttributes(tempRootDentry->d_inode, &rootDentryAttr);
 
409
   HgfsDentryAgeReset(tempRootDentry);
 
410
   tempRootDentry->d_op = &HgfsDentryOperations;
 
411
 
 
412
   *rootDentry = tempRootDentry;
 
413
   result = 0;
 
414
 
399
415
   LOG(6, (KERN_DEBUG "VMware hgfs: %s: finished\n", __func__));
400
416
exit:
401
 
   return rootDentry;
 
417
   if (result) {
 
418
      iput(rootInode);
 
419
      dput(tempRootDentry);
 
420
      *rootDentry = NULL;
 
421
   }
 
422
   return result;
402
423
}
403
424
 
404
425
 
461
482
   sb->s_magic = HGFS_SUPER_MAGIC;
462
483
   sb->s_op = &HgfsSuperOperations;
463
484
 
 
485
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
 
486
   sb->s_d_op = &HgfsDentryOperations;
 
487
#endif
 
488
 
464
489
   /*
465
490
    * If s_maxbytes isn't initialized, the generic write path may fail. In
466
491
    * most kernels, s_maxbytes is initialized by the kernel's superblock
478
503
   sb->s_blocksize_bits = HgfsComputeBlockBits(HGFS_BLOCKSIZE);
479
504
   sb->s_blocksize = 1 << sb->s_blocksize_bits;
480
505
 
481
 
   rootDentry = HgfsGetRootDentry(sb);
482
 
   if (rootDentry == NULL) {
 
506
   result = HgfsGetRootDentry(sb, &rootDentry);
 
507
   if (result) {
483
508
      LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not instantiate "
484
509
              "root dentry\n"));
485
 
      result = -ENOMEM;
486
510
      goto exit;
487
511
   }
 
512
 
488
513
   sb->s_root = rootDentry;
489
514
 
490
515
   LOG(6, (KERN_DEBUG "VMware hgfs: HgfsReadSuper: finished %s\n", si->shareName));