"Fossies" - the Fresh Open Source Software Archive

Member "giis_4.6.2/src/inode.c" (6 Nov 2012, 2290 Bytes) of package /linux/misc/old/giis_4.6.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2 * /giis/inode.c -Performs inode related opertions 
    3 *
    4 * Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2012 Lakshmipathi.G <lakshmipathi.g@giis.co.in>.
    5 * This file may be redistributed  under the terms of the GNU Public License.
    6 *
    7 */
    8 
    9 #include"giis.h"
   10 
   11 /*
   12 * find_inode_offset() - Computes given inodes offset.
   13 */
   14 
   15 int find_inode_offset ()
   16 {
   17   int i;
   18   fs.group_number = (fs.inode_number - 1) / fs.inodes_per_group;
   19   fs.index_number = (fs.inode_number - 1) % fs.inodes_per_group;
   20   fs.group_offset = fs.first_group_desc + fs.group_number * GROUP_DESC_SIZE;
   21   i = get_group_desc ();        /* Get corresponding group values */
   22   if (i == -1)
   23   {
   24     perror ("");
   25     printf ("Error Number:%d", errno);
   26     return -1;
   27   }
   28   fs.inode_offset =
   29     (unsigned long long) fs.inode_table * fs.block_size + fs.index_number * fs.inode_size;
   30   if (fs.inode_number == ROOT_INODE)
   31     fs.root_inode_offset = fs.inode_offset;
   32   return 1;
   33 }
   34 
   35 /* 
   36 * read_inode() - All necessary informations is loaded so just go and read 
   37 */
   38 
   39 int read_inode ()
   40 {
   41   int i;
   42   if (fs.inode_offset <= RANGE)
   43     lseek64 (fd, fs.inode_offset, 0);
   44   else
   45     lseek64 (fd, fs.inode_offset, 0);
   46 
   47   i = read (fd, iin.buffer, fs.inode_size);
   48   if (i == -1)
   49   {
   50     perror ("");
   51     printf ("Error Number:%d", errno);
   52     return -1;
   53   }
   54   if (S_ISDIR (iin.in.i_mode))
   55     dir = 1;
   56 
   57   return 1;
   58 }
   59 
   60 /*
   61 * show_inode() - Display Some inode details 
   62 */
   63 
   64 int show_inode ()
   65 {
   66   int i;
   67 
   68   printf ("\nInode number : %lu", fs.inode_number);
   69   printf ("\nInode offset : %llu", fs.inode_offset);
   70   printf ("\nDelete time  : %u", iin.in.i_dtime);
   71   printf ("\nHard links   : %d", iin.in.i_links_count);
   72   printf ("\nSize         : %u", iin.in.i_size);
   73   printf ("\nInode type   :");
   74 
   75   if (iin.in.i_mode == 0)
   76     printf ("Free");
   77   if (S_ISREG (iin.in.i_mode))
   78     printf ("Regular file ");
   79   if (S_ISDIR (iin.in.i_mode))
   80     printf (" Directory");
   81   if (S_ISLNK (iin.in.i_mode))
   82     printf (" Symbolic Link");
   83   if (S_ISCHR (iin.in.i_mode))
   84     printf (" character device");
   85   if (S_ISBLK (iin.in.i_mode))
   86     printf (" Block device");
   87   for (i = 0; i < 15; i++)
   88     printf ("\nData blocks[%d] :%u", i, iin.in.i_block[i]);
   89 
   90   return JSJ_NO_RETURN;
   91 }