3 /usr/src/ext2ed/super_com.c
5 A part of the extended file system 2 disk editor.
11 First written on: April 9 1995
13 Copyright (C) 1995 Gadi Oxman
25 void type_ext2_super_block___show (char *command_line
)
28 struct ext2_super_block
*super
;
29 super
=&type_data
.u
.t_ext2_super_block
;
33 if (ext2fs_blocks_count(super
) != 0) {
34 wmove (show_pad
,2,40);wprintw (show_pad
,"%2.2f%%",100*(float) ext2fs_r_blocks_count(super
)/ (float) ext2fs_blocks_count(super
));
35 wmove (show_pad
,3,40);wprintw (show_pad
,"%2.2f%%",100*(float) ext2fs_free_blocks_count(super
)/ (float) ext2fs_blocks_count(super
));
38 if (super
->s_inodes_count
!= 0) {
39 wmove (show_pad
,4,40);wprintw (show_pad
,"%2.2f%%",100*(float) super
->s_free_inodes_count
/ (float) super
->s_inodes_count
);
42 wmove (show_pad
,6,40);
43 switch (super
->s_log_block_size
) {
44 case 0: wprintw (show_pad
,"1024 bytes");break;
45 case 1: wprintw (show_pad
,"2048 bytes");break;
46 case 2: wprintw (show_pad
,"4096 bytes");break;
48 wmove (show_pad
,11,40);wprintw (show_pad
,"%s",ctime ((time_t *) &type_data
.u
.t_ext2_super_block
.s_mtime
));
49 wmove (show_pad
,12,40);wprintw (show_pad
,"%s",ctime ((time_t *) &type_data
.u
.t_ext2_super_block
.s_wtime
));
50 wmove (show_pad
,19,40);wprintw (show_pad
,"%s",ctime ((time_t *) &type_data
.u
.t_ext2_super_block
.s_lastcheck
));
51 wmove (show_pad
,15,40);
53 switch (type_data
.u
.t_ext2_super_block
.s_magic
) {
54 case EXT2_SUPER_MAGIC
:
55 wprintw (show_pad
,"ext2 >= 0.2B");
57 case EXT2_PRE_02B_MAGIC
:
58 wprintw (show_pad
,"ext2 < 0.2B (not supported)");
61 wprintw (show_pad
,"Unknown");
65 wmove (show_pad
,16,40);
66 if (type_data
.u
.t_ext2_super_block
.s_state
& 0x1)
67 wprintw (show_pad
,"clean ");
69 wprintw (show_pad
,"not clean ");
71 if (type_data
.u
.t_ext2_super_block
.s_state
& 0x2)
72 wprintw (show_pad
,"with errors ");
74 wprintw (show_pad
,"with no errors");
76 wmove (show_pad
,17,40);
78 switch (type_data
.u
.t_ext2_super_block
.s_errors
) {
79 case EXT2_ERRORS_CONTINUE
:
80 wprintw (show_pad
,"Continue");
83 wprintw (show_pad
,"Remount read only");
85 case EXT2_ERRORS_PANIC
:
86 wprintw (show_pad
,"Issue kernel panic");
89 wprintw (show_pad
,"Unknown");
93 wmove (show_pad
,21,40);
95 switch (type_data
.u
.t_ext2_super_block
.s_creator_os
) {
98 wprintw (show_pad
,"Linux :-)");
102 wprintw (show_pad
,"Hurd");
106 wprintw (show_pad
,"Unknown");
112 wmove (show_win
,1,0);wprintw (show_win
,"\n");wmove (show_win
,2,0);
113 wprintw (show_win
,"Superblock copy %ld ",super_info
.copy_num
);
114 if (super_info
.copy_num
==0)
115 wprintw (show_win
,"(main copy)");
116 wprintw (show_win
,"\n");
120 void type_ext2_super_block___gocopy (char *command_line
)
123 unsigned long copy_num
,offset
;
124 char *ptr
,buffer
[80];
126 ptr
=parse_word (command_line
,buffer
);
128 wprintw (command_win
,"Error - No argument specified\n");refresh_command_win ();return;
130 ptr
=parse_word (ptr
,buffer
);
132 copy_num
=atol (buffer
);
134 offset
=file_system_info
.super_block_offset
+copy_num
*file_system_info
.no_blocks_in_group
*file_system_info
.block_size
;
136 if (offset
> file_system_info
.file_system_size
) {
137 wprintw (command_win
,"Error - Copy number out of bounds\n");refresh_command_win ();return;
140 super_info
.copy_num
=copy_num
;
141 device_offset
=offset
;
143 sprintf (buffer
,"setoffset %ld",device_offset
);dispatch (buffer
);
144 strcpy (buffer
,"show");dispatch (buffer
);
147 void type_ext2_super_block___setactivecopy (char *command_line
)
150 struct ext2_super_block sb
;
152 sb
=type_data
.u
.t_ext2_super_block
;
153 dispatch ("gocopy 0");
154 type_data
.u
.t_ext2_super_block
=sb
;