0

How to check in linux kernel at vfs layer whether the file object is for a directory or a file?

I have found that there is a function called is_dx(dir) which checks for this but it is present in namei.c in ext3 or ext4. I need to do this at vfs layer that is independent of the file system.

Jayan
  • 18,003
  • 15
  • 89
  • 143

2 Answers2

2

How about the S_ISDIR() macro defined in include/linux/stat.h? It takesinode->i_mode field to check if the inode in question belongs to a directory or a file.

itisravi
  • 3,406
  • 3
  • 23
  • 30
0

Having in hand the inode of the initial directory, the code

examines the entry matching the first name to get the

corresponding inode.

q Then the directory file having that node is read from disk and

the entry matching the second name is examined to derive the

corresponding inode.

q This procedure is repeated for each name included in the path.

The dentry cache considerably speeds up the procedure

File system operations are mostly done at the dcache level , so

they are all under kernel lock.