Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7734325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:13:19+00:00 2026-06-01T07:13:19+00:00

What values in the inode struct of the linux kernel can I look at

  • 0

What values in the inode struct of the linux kernel can I look at to tell if the inode I am currently looking at is for a directory or a regular file?

I have searched through the inode but can’t really seem to find a member to looks like it has what I want, since I am using an older kernel version, I will post the struct below (2.6.24)

struct inode 
  {
     struct hlist_node  i_hash;
     struct list_head   i_list;
     struct list_head   i_sb_list;
     struct list_head   i_dentry;
     unsigned long      i_ino;
     atomic_t           i_count;
     unsigned int       i_nlink;
     uid_t              i_uid;
     gid_t              i_gid;
     dev_t              i_rdev;
     unsigned long      i_version;
     loff_t             i_size;
     struct timespec    i_atime;
     struct timespec    i_mtime;
     struct timespec    i_ctime;
     unsigned int       i_blkbits;
     blkcnt_t           i_blocks;
     unsigned short     i_bytes;
     umode_t            i_mode;
     spinlock_t         i_lock;
     struct mutex       i_mutex;
     struct rw_semaphore              i_alloc_sem;
     const struct inode_operations   *i_op;
     const struct file_operations    *i_fop;
     struct super_block              *i_sb;
     struct file_lock                *i_flock;
     struct address_space            *i_mapping;
     struct address_space             i_data;
     struct list_head                 i_devices;

     union {
               struct pipe_inode_info *i_pipe;
               struct block_device    *i_bdev;
               struct cdev            *i_cdev;
            };

     int            i_cindex;
     __u32          i_generation;
     unsigned long  i_state;
     unsigned long  dirtied_when;   
     unsigned int   i_flags;
     atomic_t       i_writecount;
     void           *i_private;
   };

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:13:21+00:00Added an answer on June 1, 2026 at 7:13 am

    I believe it’s the mode of the inode…

    umode_t            i_mode;
    

    To access the field see stat(2) man page:

       The following POSIX macros are defined to check the file type using the st_mode field:
    
           S_ISREG(m)  is it a regular file?
    
           S_ISDIR(m)  directory?
    
           S_ISCHR(m)  character device?
    
           S_ISBLK(m)  block device?
    
           S_ISFIFO(m) FIFO (named pipe)?
    
           S_ISLNK(m)  symbolic link? (Not in POSIX.1-1996.)
    
           S_ISSOCK(m) socket? (Not in POSIX.1-1996.)
    

    Here is some example code from the Linux driver for minix FS:

    434 void minix_set_inode(struct inode *inode, dev_t rdev)
    435 {
    436         if (S_ISREG(inode->i_mode)) {
    437                 inode->i_op = &minix_file_inode_operations;
    438                 inode->i_fop = &minix_file_operations;
    439                 inode->i_mapping->a_ops = &minix_aops;
    440         } else if (S_ISDIR(inode->i_mode)) {
    441                 inode->i_op = &minix_dir_inode_operations;
    442                 inode->i_fop = &minix_dir_operations;
    443                 inode->i_mapping->a_ops = &minix_aops;
    444         } else if (S_ISLNK(inode->i_mode)) {
    445                 inode->i_op = &minix_symlink_inode_operations;
    446                 inode->i_mapping->a_ops = &minix_aops;
    447         } else
    448                 init_special_inode(inode, inode->i_mode, rdev);
    449 }
    450 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The values in a file are read as string and can be double, string
I have some values in a configuration file (XML file) with some values like
In one of my sample Linux kernel module, I have a variable Device_Open declared
I have created an XML file and DTD which can be found at the
I have id values for products that I need store. Right now they are
Exposure values from camera can be acquired when you take picture (without saving it
var values = new NameValueCollection { { key, ConfigurationSettings.AppSettings[API-Key].ToString() }, { image, Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) }
How can a md5sum of a file be appended to the list of the
I was just reading The Linux Kernel Module Programming Guide and and got stuck
I have developed an RIA for a company's external sales force where they can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.