/* /usr/src/ext2ed/inodebitmap_com.c A part of the extended file system 2 disk editor. ------------------------- Handles the inode bitmap. ------------------------- Please refer to the documentation in blockbitmap_com.c - Those two files are almost equal. First written on: July 25 1995 Copyright (C) 1995 Gadi Oxman */ #include "config.h" #include #include #include #include "ext2ed.h" void type_ext2_inode_bitmap___entry (char *command_line) { unsigned long entry_num; char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return; } ptr=parse_word (ptr,buffer); entry_num=atol (buffer); if (entry_num >= file_system_info.super_block.s_inodes_per_group) { wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return; } inode_bitmap_info.entry_num=entry_num; strcpy (buffer,"show");dispatch (buffer); } void type_ext2_inode_bitmap___next (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); entry_offset=atol (buffer); } sprintf (buffer,"entry %ld",inode_bitmap_info.entry_num+entry_offset); dispatch (buffer); } void type_ext2_inode_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); entry_offset=atol (buffer); } sprintf (buffer,"entry %ld",inode_bitmap_info.entry_num-entry_offset); dispatch (buffer); } void type_ext2_inode_bitmap___allocate (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=inode_bitmap_info.entry_num; if (num > file_system_info.super_block.s_inodes_per_group-entry_num) { wprintw (command_win,"Error - There aren't that much inodes in the group\n"); refresh_command_win ();return; } while (num) { allocate_inode (entry_num); num--;entry_num++; } dispatch ("show"); } void type_ext2_inode_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=inode_bitmap_info.entry_num; if (num > file_system_info.super_block.s_inodes_per_group-entry_num) { wprintw (command_win,"Error - There aren't that much inodes in the group\n"); refresh_command_win ();return; } while (num) { deallocate_inode (entry_num); num--;entry_num++; } dispatch ("show"); } void allocate_inode (long entry_num) { unsigned char bit_mask=1; int byte_offset,j; byte_offset=entry_num/8; for (j=0;j0;i--) j*=2; if ((*ptr) & j) wprintw (show_win,"Allocated\n"); else wprintw (show_win,"Free\n"); refresh_show_win (); }