Getting file type from inode of fd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

  I was wondering, how I can tell a file is a regular file ("-" when
you run ls -l) or a socket ("s" when you run ls -l). I think I can use
sockfd_lookup on the fd to check if a fd points to a socket (NULL if
it doesn't).

   But I see these macros in stat.h (S_ISREG, S_ISSOCK) that takes an
inode's umode and returns true if the inode is a specific file type.
But I was wondering, if I use fget() to get the file of a fd, can I
get the inode from the file from f_inode? I see the comment says it is
a cached value. So what would go wrong if I went something like
S_ISREG(file->f_inode) or is this the correct way to do this?

Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux