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_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__));
388
result = HgfsPrivateGetattr(tempRootDentry, &rootDentryAttr, NULL);
390
LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not"
391
"instantiate the root dentry\n"));
395
iinfo = INODE_GET_II_P(tempRootDentry->d_inode);
396
iinfo->isFakeInodeNumber = FALSE;
397
iinfo->isReferencedInode = TRUE;
399
if (rootDentryAttr.mask & HGFS_ATTR_VALID_FILEID) {
400
iinfo->hostFileId = rootDentryAttr.hostFileId;
403
HgfsChangeFileAttributes(tempRootDentry->d_inode, &rootDentryAttr);
404
HgfsDentryAgeReset(tempRootDentry);
405
tempRootDentry->d_op = &HgfsDentryOperations;
407
*rootDentry = tempRootDentry;
399
410
LOG(6, (KERN_DEBUG "VMware hgfs: %s: finished\n", __func__));
414
dput(tempRootDentry);