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 9270149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:17:57+00:00 2026-06-18T15:17:57+00:00

I am taking in an inode number from a user and I have to

  • 0

I am taking in an inode number from a user and I have to search the file system for that file. How do I search through inode numbers. I have to do this using C and unix.

Here is my code so far:

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(){

    int inodeNumber;
    printf("Please enter the inode you wish to view:\n");
    scanf("%d",&inodeNumber);

    struct stat fileStat;
    int temp_file;
    temp_file = system("find/fs/root -inum inodeNumber");
    fstat(temp_file, &fileStat);
    //printf("Information for %s\n",argv[1]);
    printf("---------------------------\n");
    printf("File Size: \t\t%d bytes\n",(int)fileStat.st_size);
    printf("Number of Links: \t%d\n",(int)fileStat.st_nlink);
    printf("File inode: \t\t%d\n",(int)fileStat.st_ino);
}  

Thanks

  • 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-18T15:17:58+00:00Added an answer on June 18, 2026 at 3:17 pm

    Traverse your filesystem’s directories recursively, doing stat (or probably lstat) on each file, comparing st_ino member of struct stat to the inode number you’re searching.

    If you didn’t have to do it in C, I would recommend find /fs/root -inum N instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Taking this into consideration that: My cube's DSV reads only from views on the
Taking this file as an example, I'm trying to read the data in a
Taking this as an example: I have 20 structs. I access all of the
Taking into account that some Windows Installer products from independent vendors (for example IstallShield)
Taking this snippet from the famous agile web development with rails book (most recent
Taking my first stab as using the OnSelecting method of LinqDataSource so that I
Taking photos using system provided component(MediaStore.ACTION_IMAGE_CAPTURE) is quit common. As I ve experimented, with
Taking Fabien Potencier's example : class User { function __construct($storage) { $this->storage = $storage;
Taking over some code from my predecessor and I found a query that uses
Taking advice from this post , I purchased a copy of 'The C Programming

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.