"Fossies" - the Fresh Open Source Software Archive

Member "giis_4.6.2/src/group.c" (6 Nov 2012, 1567 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/group.c This file sets the group descriptor for processing.
    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 * get_group_desc() This procedure sets the group number into global structure.
   13 */
   14 
   15 int get_group_desc ()
   16 {
   17   int i;
   18   if (fs.group_offset <= RANGE)
   19     lseek (fd, fs.group_offset, 0);     /* fd is global */
   20   else
   21     lseek64 (fd, fs.group_offset, 0);
   22   i = read (fd, igd.buffer, GROUP_DESC_SIZE);
   23   if (i == -1)
   24   {
   25     perror ("");
   26     printf ("Error Number:%d", errno);
   27     return -1;
   28   }
   29   fs.block_bitmap = igd.gd.bg_block_bitmap;
   30   fs.inode_bitmap = igd.gd.bg_inode_bitmap;
   31   fs.inode_table = igd.gd.bg_inode_table;
   32   fs.free_blocks_count = igd.gd.bg_free_blocks_count;
   33   fs.free_inodes_count = igd.gd.bg_free_inodes_count;
   34   return 1;
   35 }
   36 
   37 /*
   38 * eye_on_gd() : Check Group descriptor of the block.
   39 */
   40 int eye_on_gd ()
   41 {
   42   int i;
   43   /* Check all */
   44   gd++;
   45   fs.group_number = 0;
   46   while (fs.group_number < fs.groups_count)
   47   {
   48     fs.group_offset = fs.first_group_desc + fs.group_number * GROUP_DESC_SIZE;
   49     i = get_group_desc ();
   50     if (i == -1)
   51     {
   52       perror ("");
   53       printf ("Error Number:%d", errno);
   54       return -1;
   55     }
   56     if ((fs.block_number > fs.block_bitmap)
   57         && (fs.block_number < (fs.block_bitmap + fs.blocks_per_group)))
   58       return 1;
   59     else
   60       fs.group_number++;
   61   }
   62   return -1;
   63 }