342
343
*----------------------------------------------------------------------------
345
static struct dentry *
346
HgfsGetRootDentry(struct super_block *sb) // IN: Super block object
347
HgfsGetRootDentry(struct super_block *sb, // IN: Super block object
348
struct dentry **rootDentry) // OUT: Root dentry
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;
353
359
LOG(6, (KERN_DEBUG "VMware hgfs: %s: entered\n", __func__));
355
361
rootInode = HgfsGetInode(sb, HGFS_ROOT_INO);
357
HgfsInodeInfo *iinfo;
358
static const HgfsAttrInfo attr = {
359
.type = HGFS_FILE_TYPE_DIRECTORY,
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,
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.
378
if (is_bad_inode(rootInode)) {
379
LOG(6, (KERN_DEBUG "VMware hgfs: %s: encountered bad inode\n",
385
HgfsChangeFileAttributes(rootInode, &attr);
387
iinfo = INODE_GET_II_P(rootInode);
388
iinfo->isFakeInodeNumber = FALSE;
389
iinfo->isReferencedInode = TRUE;
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",
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.
373
if (is_bad_inode(rootInode)) {
374
LOG(6, (KERN_DEBUG "VMware hgfs: %s: encountered bad inode\n",
379
tempRootDentry = d_make_root(rootInode);
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.
387
if (tempRootDentry == NULL) {
394
388
LOG(4, (KERN_WARNING "VMware hgfs: %s: Could not get "
395
389
"root dentry\n", __func__));
393
result = HgfsPrivateGetattr(tempRootDentry, &rootDentryAttr, NULL);
395
LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not"
396
"instantiate the root dentry\n"));
400
iinfo = INODE_GET_II_P(tempRootDentry->d_inode);
401
iinfo->isFakeInodeNumber = FALSE;
402
iinfo->isReferencedInode = TRUE;
404
if (rootDentryAttr.mask & HGFS_ATTR_VALID_FILEID) {
405
iinfo->hostFileId = rootDentryAttr.hostFileId;
408
HgfsChangeFileAttributes(tempRootDentry->d_inode, &rootDentryAttr);
409
HgfsDentryAgeReset(tempRootDentry);
410
tempRootDentry->d_op = &HgfsDentryOperations;
412
*rootDentry = tempRootDentry;
399
415
LOG(6, (KERN_DEBUG "VMware hgfs: %s: finished\n", __func__));
419
dput(tempRootDentry);