Whamcloud - gitweb
e2fsck: map PROMPT_* values to prompt messages
[tools/e2fsprogs.git] / ext2ed / blockbitmap_com.c
index 355feb0..53e61dc 100644 (file)
@@ -16,6 +16,7 @@ Copyright (C) 1995 Gadi Oxman
 
 */
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -41,9 +42,9 @@ and dispatches a show command to show the new entry.
 {
        unsigned long entry_num;
        char *ptr,buffer [80];
-       
-       
-       
+
+
+
        ptr=parse_word (command_line,buffer);                                   /* Get the requested entry */
        if (*ptr==0) {
                wprintw (command_win,"Error - No argument specified\n");
@@ -53,15 +54,15 @@ and dispatches a show command to show the new entry.
 
        entry_num=atol (buffer);
 
-       
+
        if (entry_num >= file_system_info.super_block.s_blocks_per_group) {     /* Check if it is a valid entry number */
 
                wprintw (command_win,"Error - Entry number out of bounds\n");
                refresh_command_win ();return;
        }
-       
-       
-       
+
+
+
        block_bitmap_info.entry_num=entry_num;                                  /* If it is, just change entry_num and */
        strcpy (buffer,"show");dispatch (buffer);                               /* dispatch a show command */
 }
@@ -77,7 +78,7 @@ This function passes to the next entry in the bitmap. We just call the above ent
 {
        long entry_offset=1;
        char *ptr,buffer [80];
-       
+
        ptr=parse_word (command_line,buffer);
        if (*ptr!=0) {
                ptr=parse_word (ptr,buffer);
@@ -93,7 +94,7 @@ void type_ext2_block_bitmap___prev (char *command_line)
 {
        long entry_offset=1;
        char *ptr,buffer [80];
-       
+
        ptr=parse_word (command_line,buffer);
        if (*ptr!=0) {
                ptr=parse_word (ptr,buffer);
@@ -117,25 +118,25 @@ we need to allocate, and call allocate_block for each one.
 {
        long entry_num,num=1;
        char *ptr,buffer [80];
-       
+
        ptr=parse_word (command_line,buffer);                                   /* Get the number of blocks to allocate */
        if (*ptr!=0) {
                ptr=parse_word (ptr,buffer);
                num=atol (buffer);
        }
-       
+
        entry_num=block_bitmap_info.entry_num;
                                                                                /* Check for limits */
        if (num > file_system_info.super_block.s_blocks_per_group-entry_num) {
-               wprintw (command_win,"Error - There aren't that much blocks in the group\n");   
-               refresh_command_win ();return;                          
+               wprintw (command_win,"Error - There aren't that much blocks in the group\n");
+               refresh_command_win ();return;
        }
-       
+
        while (num) {                                                           /* And call allocate_block */
                allocate_block (entry_num);                                     /* for each block */
                num--;entry_num++;
        }
-       
+
        dispatch ("show");                                                      /* Show the result */
 }
 
@@ -146,24 +147,24 @@ void type_ext2_block_bitmap___deallocate (char *command_line)
 {
        long entry_num,num=1;
        char *ptr,buffer [80];
-       
+
        ptr=parse_word (command_line,buffer);
        if (*ptr!=0) {
                ptr=parse_word (ptr,buffer);
                num=atol (buffer);
        }
-       
+
        entry_num=block_bitmap_info.entry_num;
        if (num > file_system_info.super_block.s_blocks_per_group-entry_num) {
-               wprintw (command_win,"Error - There aren't that much blocks in the group\n");   
-               refresh_command_win ();return;                          
+               wprintw (command_win,"Error - There aren't that much blocks in the group\n");
+               refresh_command_win ();return;
        }
-       
+
        while (num) {
                deallocate_block (entry_num);
                num--;entry_num++;
        }
-       
+
        dispatch ("show");
 }
 
@@ -175,7 +176,7 @@ void allocate_block (long entry_num)
 {
        unsigned char bit_mask=1;
        int byte_offset,j;
-       
+
        byte_offset=entry_num/8;                                        /* Find the correct byte - entry_num/8 */
                                                                        /* The position inside the byte is entry_num %8 */
        for (j=0;j<entry_num%8;j++)
@@ -190,12 +191,12 @@ void deallocate_block (long entry_num)
 {
        unsigned char bit_mask=1;
        int byte_offset,j;
-       
+
        byte_offset=entry_num/8;
        for (j=0;j<entry_num%8;j++)
                bit_mask*=2;
        bit_mask^=0xff;
-       
+
        type_data.u.buffer [byte_offset] &= bit_mask;
 }
 
@@ -215,7 +216,7 @@ The current position (as known from block_bitmap_info.entry_num) is highlighted.
 
        ptr=type_data.u.buffer;
        show_pad_info.line=0;show_pad_info.max_line=-1;
-       
+
        wmove (show_pad,0,0);
        for (i=0,entry_num=0;i<file_system_info.super_block.s_blocks_per_group/8;i++,ptr++) {
                for (j=1;j<=128;j*=2) {                                         /* j contains the and bit mask */
@@ -240,24 +241,24 @@ The current position (as known from block_bitmap_info.entry_num) is highlighted.
                        show_pad_info.max_line++;
                }
        }
-       
-       refresh_show_pad ();    
+
+       refresh_show_pad ();
        show_info ();                                                           /* Show the usual information */
 
                                                                                /* Show the group number */
        wmove (show_win,1,0);
        wprintw (show_win,"Block bitmap of block group %ld\n",block_bitmap_info.group_num);
                                                                                /* Show the block number */
-                                                                               
+
        block_num=block_bitmap_info.entry_num+block_bitmap_info.group_num*file_system_info.super_block.s_blocks_per_group;
-       block_num+=file_system_info.super_block.s_first_data_block;     
+       block_num+=file_system_info.super_block.s_first_data_block;
 
        wprintw (show_win,"Status of block %ld - ",block_num);                  /* and the allocation status */
        ptr=type_data.u.buffer+block_bitmap_info.entry_num/8;
        j=1;
        for (i=block_bitmap_info.entry_num % 8;i>0;i--)
                j*=2;
-       if ((*ptr) & j)                                         
+       if ((*ptr) & j)
                wprintw (show_win,"Allocated\n");
        else
                wprintw (show_win,"Free\n");