3 /usr/src/ext2ed/inodebitmap_com.c
5 A part of the extended file system 2 disk editor.
7 -------------------------
8 Handles the inode bitmap.
9 -------------------------
11 Please refer to the documentation in blockbitmap_com.c - Those two files are almost equal.
13 First written on: July 25 1995
15 Copyright (C) 1995 Gadi Oxman
26 void type_ext2_inode_bitmap___entry (char *command_line)
29 unsigned long entry_num;
30 char *ptr,buffer [80];
32 ptr=parse_word (command_line,buffer);
34 wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
36 ptr=parse_word (ptr,buffer);
38 entry_num=atol (buffer);
40 if (entry_num >= file_system_info.super_block.s_inodes_per_group) {
41 wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return;
44 inode_bitmap_info.entry_num=entry_num;
45 strcpy (buffer,"show");dispatch (buffer);
48 void type_ext2_inode_bitmap___next (char *command_line)
52 char *ptr,buffer [80];
54 ptr=parse_word (command_line,buffer);
56 ptr=parse_word (ptr,buffer);
57 entry_offset=atol (buffer);
60 sprintf (buffer,"entry %ld",inode_bitmap_info.entry_num+entry_offset);
64 void type_ext2_inode_bitmap___prev (char *command_line)
68 char *ptr,buffer [80];
70 ptr=parse_word (command_line,buffer);
72 ptr=parse_word (ptr,buffer);
73 entry_offset=atol (buffer);
76 sprintf (buffer,"entry %ld",inode_bitmap_info.entry_num-entry_offset);
80 void type_ext2_inode_bitmap___allocate (char *command_line)
84 char *ptr,buffer [80];
86 ptr=parse_word (command_line,buffer);
88 ptr=parse_word (ptr,buffer);
92 entry_num=inode_bitmap_info.entry_num;
93 if (num > file_system_info.super_block.s_inodes_per_group-entry_num) {
94 wprintw (command_win,"Error - There aren't that much inodes in the group\n");
95 refresh_command_win ();return;
99 allocate_inode (entry_num);
106 void type_ext2_inode_bitmap___deallocate (char *command_line)
109 long entry_num,num=1;
110 char *ptr,buffer [80];
112 ptr=parse_word (command_line,buffer);
114 ptr=parse_word (ptr,buffer);
118 entry_num=inode_bitmap_info.entry_num;
119 if (num > file_system_info.super_block.s_inodes_per_group-entry_num) {
120 wprintw (command_win,"Error - There aren't that much inodes in the group\n");
121 refresh_command_win ();return;
125 deallocate_inode (entry_num);
133 void allocate_inode (long entry_num)
136 unsigned char bit_mask=1;
139 byte_offset=entry_num/8;
140 for (j=0;j<entry_num%8;j++)
142 type_data.u.buffer [byte_offset] |= bit_mask;
145 void deallocate_inode (long entry_num)
148 unsigned char bit_mask=1;
151 byte_offset=entry_num/8;
152 for (j=0;j<entry_num%8;j++)
156 type_data.u.buffer [byte_offset] &= bit_mask;
159 void type_ext2_inode_bitmap___show (char *command_line)
164 unsigned long inode_num,entry_num;
166 ptr=type_data.u.buffer;
167 show_pad_info.line=0;show_pad_info.max_line=-1;
169 wmove (show_pad,0,0);
170 for (i=0,entry_num=0;i<file_system_info.super_block.s_inodes_per_group/8;i++,ptr++) {
171 for (j=1;j<=128;j*=2) {
172 if (entry_num==inode_bitmap_info.entry_num) {
173 wattrset (show_pad,A_REVERSE);
174 show_pad_info.line=show_pad_info.max_line-show_pad_info.display_lines/2;
178 wprintw (show_pad,"1");
180 wprintw (show_pad,"0");
182 if (entry_num==inode_bitmap_info.entry_num)
183 wattrset (show_pad,A_NORMAL);
187 wprintw (show_pad," ");
189 wprintw (show_pad,"\n");
190 show_pad_info.max_line++;
195 wprintw (show_pad,"\n");
196 show_pad_info.max_line++;
201 wmove (show_win,1,0);wprintw (show_win,"Inode bitmap of block group %ld\n",inode_bitmap_info.group_num);
203 inode_num=1+inode_bitmap_info.entry_num+inode_bitmap_info.group_num*file_system_info.super_block.s_inodes_per_group;
204 wprintw (show_win,"Status of inode %ld - ",inode_num);
205 ptr=type_data.u.buffer+inode_bitmap_info.entry_num/8;
207 for (i=inode_bitmap_info.entry_num % 8;i>0;i--)
210 wprintw (show_win,"Allocated\n");
212 wprintw (show_win,"Free\n");