summaryrefslogtreecommitdiff
path: root/ext2ed
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-08-27 23:07:54 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-08-27 23:07:54 -0400
commitefc6f628e15de95bcd13e4f0ee223cb42115d520 (patch)
tree7f486b4bc1a4c8fc47f236f1e95e33feee745f7c /ext2ed
parent4690e621acd4579dae60b6f55f58284ee805e86d (diff)
Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'ext2ed')
-rw-r--r--ext2ed/blockbitmap_com.c60
-rw-r--r--ext2ed/dir_com.c112
-rw-r--r--ext2ed/disk.c44
-rw-r--r--ext2ed/ext2_com.c8
-rw-r--r--ext2ed/ext2ed.h8
-rw-r--r--ext2ed/file_com.c114
-rw-r--r--ext2ed/general_com.c128
-rw-r--r--ext2ed/group_com.c36
-rw-r--r--ext2ed/init.c98
-rw-r--r--ext2ed/inode_com.c70
-rw-r--r--ext2ed/inodebitmap_com.c46
-rw-r--r--ext2ed/main.c102
-rw-r--r--ext2ed/super_com.c24
-rw-r--r--ext2ed/win.c18
14 files changed, 434 insertions, 434 deletions
diff --git a/ext2ed/blockbitmap_com.c b/ext2ed/blockbitmap_com.c
index 355feb03..996bbeb4 100644
--- a/ext2ed/blockbitmap_com.c
+++ b/ext2ed/blockbitmap_com.c
@@ -41,9 +41,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 +53,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 +77,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 +93,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 +117,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 +146,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 +175,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 +190,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 +215,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 +240,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");
diff --git a/ext2ed/dir_com.c b/ext2ed/dir_com.c
index c6b194e0..b023e7a3 100644
--- a/ext2ed/dir_com.c
+++ b/ext2ed/dir_com.c
@@ -49,20 +49,20 @@ directories.
{
struct ext2_inode *ptr;
-
+
ptr=&type_data.u.t_ext2_inode; /* type_data contains the inode */
-
+
info_ptr->inode_ptr=ptr;
info_ptr->inode_offset=device_offset; /* device offset contains the inode's offset */
-
+
/* Reset the current position to the start */
- info_ptr->global_block_num=ptr->i_block [0];
+ info_ptr->global_block_num=ptr->i_block [0];
info_ptr->global_block_offset=ptr->i_block [0]*file_system_info.block_size;
info_ptr->block_num=0;
info_ptr->file_offset=0;
/* Set the size of the directory */
-
+
info_ptr->blocks_count=(ptr->i_size+file_system_info.block_size-1)/file_system_info.block_size;
info_ptr->file_length=ptr->i_size;
@@ -73,9 +73,9 @@ directories.
info_ptr->dir_entry_offset=0;
/* Find dir_entries_count */
-
+
info_ptr->dir_entries_count=count_dir_entries (); /* Set the total number of entries */
-
+
return (1);
}
@@ -86,34 +86,34 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in
This routine runs on all directory entries in the current directory.
For each entry, action is called. We'll act according to the return code of action:
-
+
ABORT - Current dir entry is returned.
CONTINUE - Continue searching.
FOUND - Current dir entry is returned.
-
+
If the last entry is reached, it is returned, along with an ABORT status.
-
- status is updated to the returned code of action.
+
+ status is updated to the returned code of action.
*/
{
struct struct_file_info info; /* Temporary variables used to */
struct ext2_dir_entry_2 *dir_entry_ptr; /* contain the current search entries */
int return_code, next;
-
+
info=first_file_info; /* Start from the first entry - Read it */
low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
-
+
while (info.file_offset < info.file_length) { /* While we haven't reached the end */
-
+
*status=return_code=action (&info); /* Call the client function to test */
- /* the current entry */
+ /* the current entry */
if (return_code==ABORT || return_code==FOUND)
return (info); /* Stop, if so asked */
/* Pass to the next entry */
-
+
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
info.dir_entry_num++;
@@ -131,16 +131,16 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in
info.global_block_num=file_block_to_global_block (info.block_num,&info);
info.global_block_offset=info.global_block_num*file_system_info.block_size;
info.file_offset=info.block_num*file_system_info.block_size;
- info.dir_entry_offset=0;
+ info.dir_entry_offset=0;
/* read it and update the pointer */
-
+
low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
-
+
}
-
+
}
-
+
*status=ABORT;return (info); /* There was no match */
}
@@ -155,7 +155,7 @@ The client function is action_count, which just tell search_dir_entries to conti
{
int status;
-
+
return (search_dir_entries (&action_count,&status).dir_entry_num);
}
@@ -187,7 +187,7 @@ void type_dir___cd (char *command_line)
1 and into 2/3/4.
3. It is the first part of the path that we need to search for in the current directory. We search for it using
- search_dir_entries, which accepts the action_name function as the client function.
+ search_dir_entries, which accepts the action_name function as the client function.
4. search_dir_entries will scan the entire entries and will call our action_name function for each entry.
In action_name, the required name will be checked against the name of the current entry, and FOUND will be
@@ -205,7 +205,7 @@ void type_dir___cd (char *command_line)
7. We check the inode's type to see if it is a directory. If it is, we dispatch a dir command to "enter the directory",
and recursively call ourself (The type is dir again) by dispatching a cd command, with the rest of the path
as an argument.
-
+
8. If the inode's type is a symbolic link (only fast symbolic link were meanwhile implemented. I guess this is
typically the case.), we note the path it is pointing at, the saved inode is recalled, we dispatch dir to
get back to the original directory, and we call ourself again with the link path/rest of the path argument.
@@ -221,9 +221,9 @@ void type_dir___cd (char *command_line)
struct ext2_dir_entry_2 *dir_entry_ptr;
dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset);
-
+
ptr=parse_word (command_line,dir_name);
-
+
if (*ptr==0) { /* cd alone will enter the highlighted directory */
strncpy (full_dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len);
full_dir_name [dir_entry_ptr->name_len]=0;
@@ -232,11 +232,11 @@ void type_dir___cd (char *command_line)
ptr=parse_word (ptr,full_dir_name);
ptr=strchr (full_dir_name,'/');
-
+
if (ptr==full_dir_name) { /* Pathname is from root - Let the general cd do the job */
sprintf (temp,"cd %s",full_dir_name);type_ext2___cd (temp);return;
}
-
+
if (ptr==NULL) {
strcpy (dir_name,full_dir_name);
full_dir_name [0]=0;
@@ -251,7 +251,7 @@ void type_dir___cd (char *command_line)
/* full_dir_name contains the rest */
strcpy (name_search,dir_name); /* name_search is used to hold the required entry name */
-
+
if (dir_entry_ptr->name_len != strlen (dir_name) ||
strncmp (dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len)!=0)
info=search_dir_entries (&action_name,&status); /* Search for the entry. Answer in info. */
@@ -262,15 +262,15 @@ void type_dir___cd (char *command_line)
if (status==FOUND) { /* If found */
file_info=info; /* Switch to it, by setting the global file_info */
dispatch ("remember internal_variable"); /* Move the inode into the objects memory */
-
+
dispatch ("followinode"); /* Go to the inode pointed by this directory entry */
-
+
if (S_ISLNK (type_data.u.t_ext2_inode.i_mode)) {/* Symbolic link ? */
if (type_data.u.t_ext2_inode.i_size > 60) { /* I'm lazy, I guess :-) */
wprintw (command_win,"Error - Sorry, Only fast symbolic link following is currently supported\n");
refresh_command_win ();
- return;
+ return;
}
/* Get the pointed name and append the previous path */
@@ -280,10 +280,10 @@ void type_dir___cd (char *command_line)
dispatch ("recall internal_variable"); /* Return to the original inode */
dispatch ("dir"); /* and to the directory */
-
+
sprintf (temp,"cd %s",temp2); /* And continue from there by dispatching a cd command */
dispatch (temp); /* (which can call ourself or the general cd) */
-
+
return;
}
@@ -295,16 +295,16 @@ void type_dir___cd (char *command_line)
sprintf (temp,"cd %s",full_dir_name);
dispatch (temp);
}
-
+
return;
}
-
+
else { /* If we can't continue from here, we'll just stop */
wprintw (command_win,"Can\'t continue - Stopping at last inode\n");refresh_command_win ();
return;
}
}
-
+
wprintw (command_win,"Error - Directory entry %s not found.\n",dir_name); /* Hmm, an invalid path somewhere */
refresh_command_win ();
}
@@ -325,7 +325,7 @@ Returns FOUND if found, or CONTINUE if not found.
if (dir_entry_ptr->name_len != strlen (name_search))
return (CONTINUE);
-
+
if (strncmp (dir_entry_ptr->name,name_search,dir_entry_ptr->name_len)==0)
return (FOUND);
@@ -345,7 +345,7 @@ search_dir_entries is used along with action_entry_num, in the same fashion as t
int status;
struct struct_file_info info;
char *ptr,buffer [80];
-
+
ptr=parse_word (command_line,buffer);
if (*ptr==0) {
wprintw (command_win,"Error - Argument_not_specified\n");wrefresh (command_win);
@@ -353,7 +353,7 @@ search_dir_entries is used along with action_entry_num, in the same fashion as t
}
ptr=parse_word (ptr,buffer);
entry_num_search=atol (buffer);
-
+
if (entry_num_search < 0 || entry_num_search >= file_info.dir_entries_count) {
wprintw (command_win,"Error - Entry number out of range\n");wrefresh (command_win);
return;
@@ -431,7 +431,7 @@ We use search_dir_entries to run on all the entries. Each time, action_show will
{
int status;
-
+
wmove (show_pad,0,0);
show_pad_info.max_line=-1;
@@ -452,7 +452,7 @@ Show the current search entry (info) in one line. If the entry happens to be the
{
unsigned char temp [80];
struct ext2_dir_entry_2 *dir_entry_ptr;
-
+
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info->buffer+info->dir_entry_offset);
if (info->dir_entry_num == file_info.dir_entry_num) /* Highlight the current entry */
@@ -486,7 +486,7 @@ This function moves to the next directory entry. It just uses the current inform
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset*=atol (buffer);
@@ -503,7 +503,7 @@ void type_dir___prev (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset*=atol (buffer);
@@ -522,12 +522,12 @@ Various statistics about the directory.
{
long inode_num;
-
+
wmove (show_win,0,0);
wprintw (show_win,"Directory listing. Block %ld. ",file_info.global_block_num);
wprintw (show_win,"Directory entry %ld of %ld.\n",file_info.dir_entry_num,file_info.dir_entries_count-1);
wprintw (show_win,"Directory Offset %ld of %ld. ",file_info.file_offset,file_info.file_length-1);
-
+
inode_num=inode_offset_to_inode_num (file_info.inode_offset);
wprintw (show_win,"File inode %ld. Indirection level %ld.\n",inode_num,file_info.level);
@@ -548,14 +548,14 @@ inode of the current directory.
long entry_num;
char *ptr,buffer [80];
struct struct_descriptor *descriptor_ptr;
-
+
ptr=parse_word (command_line,buffer);
-
+
if (*ptr==0) {
wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win);
- return;
+ return;
}
-
+
ptr=parse_word (ptr,buffer);
entry_num=remember_lifo.entries_count++;
@@ -563,7 +563,7 @@ inode of the current directory.
entry_num=0;
remember_lifo.entries_count--;
}
-
+
descriptor_ptr=first_type;
while (descriptor_ptr!=NULL && !found) {
if (strcmp (descriptor_ptr->name,"ext2_inode")==0)
@@ -576,7 +576,7 @@ inode of the current directory.
remember_lifo.offset [entry_num]=device_offset;
remember_lifo.type [entry_num]=descriptor_ptr;
strcpy (remember_lifo.name [entry_num],buffer);
-
+
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer);
wrefresh (command_win);
}
@@ -594,9 +594,9 @@ because it is of variable length.
int found=0;
unsigned char *ptr,buffer [80],variable [80],value [80],temp [80];
struct ext2_dir_entry_2 *dir_entry_ptr;
-
+
dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset);
-
+
ptr=parse_word (command_line,buffer);
if (*ptr==0) {
wprintw (command_win,"Error - Missing arguments\n");refresh_command_win ();
@@ -641,7 +641,7 @@ because it is of variable length.
wprintw (command_win,"Variable %s set to %s\n",variable,value);refresh_command_win ();
}
-
+
if (found) {
wattrset (show_pad,A_REVERSE);
strncpy (temp,dir_entry_ptr->name,dir_entry_ptr->name_len);
@@ -654,7 +654,7 @@ because it is of variable length.
refresh_show_pad ();
show_dir_status ();
}
-
+
else {
wprintw (command_win,"Error - Variable %s not found\n",variable);
refresh_command_win ();
diff --git a/ext2ed/disk.c b/ext2ed/disk.c
index d29c7194..5e1cd7e2 100644
--- a/ext2ed/disk.c
+++ b/ext2ed/disk.c
@@ -55,7 +55,7 @@ This function is used when we need to read something from the filesystem.
return (0);
}
-#endif
+#endif
if ( (fseek (device_handle,offset,SEEK_SET))==-1) { /* Seek to the required offset */
wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",offset,device_name);
@@ -67,7 +67,7 @@ This function is used when we need to read something from the filesystem.
wprintw (command_win,"Error - Failed to read from offset %ld in device %s\n",offset,device_name);
refresh_command_win ();return (0);
};
-
+
return (1);
}
@@ -83,7 +83,7 @@ If logging is enabled, we log the change before writing it to the device.
*/
{
char temp [80];
-
+
if (!write_access) {
wprintw (command_win,"Error - Write access not aviable (use enablewrite)\n");
return (0);
@@ -95,7 +95,7 @@ If logging is enabled, we log the change before writing it to the device.
internal_error ("AllowChanges=0 yet enablewrite succeeded","disk","low_write");
return (0);
}
-
+
if (device_handle==NULL) {
internal_error ("No device opened yet read requested","disk","low_write");
return (0);
@@ -107,7 +107,7 @@ If logging is enabled, we log the change before writing it to the device.
return (0);
}
-#endif
+#endif
if (LogChanges)
if (!log_changes (buffer,length,offset))
@@ -124,7 +124,7 @@ If logging is enabled, we log the change before writing it to the device.
refresh_command_win ();return (0);
};
- wprintw (command_win,"Data written");refresh_command_win ();
+ wprintw (command_win,"Data written");refresh_command_win ();
return (1);
}
@@ -139,29 +139,29 @@ The hex bytes are converted to text, so that they will be readable with a standa
{
unsigned char *original;
-
+
int i;
time_t current_time;
FILE *fp;
-
+
if ((fp=fopen (LogFile,"a+"))==NULL) {
wprintw (command_win,"Error - Unable to open log file %s\n",LogFile);
refresh_command_win ();return (0);
};
current_time=time (NULL);
-
+
fprintf (fp,"\n----- EXT2ED log begin -----\n\n");
fprintf (fp,"Time: %s\nDevice: %s\n",ctime ((time_t *) &current_time),device_name);
fprintf (fp,"Offset: %lu\nLength: %lu\n",offset,length);
-
+
original=(unsigned char *) malloc (length*sizeof (unsigned char));
if (original==NULL) {
wprintw (command_win,"Fatal error - Can\'t allocate %lu bytes!");
refresh_command_win ();fclose (fp);return (0);
}
-
+
if (!low_read (original,length,offset)) {
fclose (fp);return (0);
}
@@ -172,17 +172,17 @@ The hex bytes are converted to text, so that they will be readable with a standa
if (i%16==0 && i!=0) fprintf (fp,"\n");
fprintf (fp,"%02x ",original [i]);
}
-
- fprintf (fp,"\n\nNew data:\n\n");
-
+
+ fprintf (fp,"\n\nNew data:\n\n");
+
for (i=0;i<length;i++) {
if (i%16==0 && i!=0) fprintf (fp,"\n");
fprintf (fp,"%02x ",buffer [i]);
}
-
+
fprintf (fp,"\n----- EXT2ED log end -----\n");
- fclose (fp);
+ fclose (fp);
return (1);
}
@@ -197,17 +197,17 @@ Just read from the current position into type data.
{
if (device_handle==NULL) {
printf ("Error - No device opened\n");
- return (0);
+ return (0);
}
if (device_offset==-1) {
printf ("Error - No offset set\n");
return (0);
}
-
+
if (low_read (type_data.u.buffer,EXT2_MAX_BLOCK_SIZE,device_offset)==0)
return (0);
-
+
if (current_type!=NULL)
if (strcmp (current_type->name,"ext2_dir_entry")==0)
current_type->length=type_data.u.t_ext2_dir_entry.rec_len;
@@ -221,7 +221,7 @@ int write_type_data (void)
if (device_handle==NULL) {
wprintw (command_win,"Error - No device opened\n");
refresh_command_win ();
- return (0);
+ return (0);
}
if (device_offset==-1) {
@@ -229,10 +229,10 @@ int write_type_data (void)
refresh_command_win ();
return (0);
}
-
+
if (low_write (type_data.u.buffer,file_system_info.block_size,device_offset)==0)
return (0);
-
+
return (1);
}
diff --git a/ext2ed/ext2_com.c b/ext2ed/ext2_com.c
index b4d2a661..2f20a28d 100644
--- a/ext2ed/ext2_com.c
+++ b/ext2ed/ext2_com.c
@@ -33,7 +33,7 @@ initialization phase (but is constant - 1024).
{
char buffer [80];
-
+
super_info.copy_num=0;
sprintf (buffer,"setoffset %ld",file_system_info.super_block_offset);dispatch (buffer);
sprintf (buffer,"settype ext2_super_block");dispatch (buffer);
@@ -51,13 +51,13 @@ We implement it through dispatching to our primitive functions.
{
char temp [80],buffer [80],*ptr;
-
+
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);
-
+
if (buffer [0] != '/') {
wprintw (command_win,"Error - Use a full pathname (begin with '/')\n");refresh_command_win ();return;
}
@@ -83,7 +83,7 @@ Then, we use the group's entry command to pass to another group.
{
long group_num=0;
char *ptr,buffer [80];
-
+
ptr=parse_word (command_line,buffer);
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
diff --git a/ext2ed/ext2ed.h b/ext2ed/ext2ed.h
index deae516b..2ee483e8 100644
--- a/ext2ed/ext2ed.h
+++ b/ext2ed/ext2ed.h
@@ -45,14 +45,14 @@ Copyright (C) 1995 Gadi Oxman
#define MAX_COMMANDS_NUM 30 /* Maximum number of commands of one type */
#define REMEMBER_COUNT 30 /* Object memory size */
-/*
+/*
The user screen consists of four parts:
1. Title window (title_win).
2. Show (status) window (show_win).
3. Main show pad (show_pad).
4. Command window (command_win).
-
+
*/
/*
@@ -133,7 +133,7 @@ struct struct_file_system_info { /* Important information about the filesystem
struct struct_file_info { /* Used to handle files and directories */
struct ext2_inode *inode_ptr;
-
+
long inode_offset;
long global_block_num,global_block_offset;
long block_num,blocks_count;
@@ -144,7 +144,7 @@ struct struct_file_info { /* Used to handle files and directories */
int display;
/* The following is used if the file is a directory */
-
+
long dir_entry_num,dir_entries_count;
long dir_entry_offset;
};
diff --git a/ext2ed/file_com.c b/ext2ed/file_com.c
index 898df657..9772f66d 100644
--- a/ext2ed/file_com.c
+++ b/ext2ed/file_com.c
@@ -24,9 +24,9 @@ int init_file_info (void)
{
struct ext2_inode *ptr;
-
+
ptr=&type_data.u.t_ext2_inode;
-
+
file_info.inode_ptr=ptr;
file_info.inode_offset=device_offset;
@@ -38,11 +38,11 @@ int init_file_info (void)
file_info.file_length=ptr->i_size;
file_info.level=0;
file_info.offset_in_block=0;
-
+
file_info.display=HEX;
low_read (file_info.buffer,file_system_info.block_size,file_info.global_block_offset);
-
+
return (1);
}
@@ -69,7 +69,7 @@ void type_file___nextblock (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
block_offset*=atol (buffer);
@@ -79,7 +79,7 @@ void type_file___nextblock (char *command_line)
wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
return;
}
-
+
file_info.block_num+=block_offset;
file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
@@ -97,17 +97,17 @@ void type_file___next (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset*=atol (buffer);
}
-
+
if (file_info.offset_in_block+offset < file_system_info.block_size) {
file_info.offset_in_block+=offset;
sprintf (buffer,"show");dispatch (buffer);
}
-
+
else {
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
}
@@ -120,7 +120,7 @@ void type_file___offset (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset=atol (buffer);
@@ -129,7 +129,7 @@ void type_file___offset (char *command_line)
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
return;
}
-
+
if (offset < file_system_info.block_size) {
file_info.offset_in_block=offset;
sprintf (buffer,"show");dispatch (buffer);
@@ -147,17 +147,17 @@ void type_file___prev (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset*=atol (buffer);
}
-
+
if (file_info.offset_in_block-offset >= 0) {
file_info.offset_in_block-=offset;
sprintf (buffer,"show");dispatch (buffer);
}
-
+
else {
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
}
@@ -170,7 +170,7 @@ void type_file___prevblock (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
block_offset*=atol (buffer);
@@ -180,7 +180,7 @@ void type_file___prevblock (char *command_line)
wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
return;
}
-
+
file_info.block_num-=block_offset;
file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
@@ -198,12 +198,12 @@ void type_file___block (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr==0) {
wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win);
return;
}
-
+
ptr=parse_word (ptr,buffer);
block_offset=atol (buffer);
@@ -226,25 +226,25 @@ void type_file___display (char *command_line)
{
char *ptr,buffer [80];
-
+
ptr=parse_word (command_line,buffer);
- if (*ptr==0)
+ if (*ptr==0)
strcpy (buffer,"hex");
else
ptr=parse_word (ptr,buffer);
-
+
if (strcasecmp (buffer,"hex")==0) {
wprintw (command_win,"Display set to hex\n");wrefresh (command_win);
file_info.display=HEX;
sprintf (buffer,"show");dispatch (buffer);
}
-
+
else if (strcasecmp (buffer,"text")==0) {
wprintw (command_win,"Display set to text\n");wrefresh (command_win);
file_info.display=TEXT;
sprintf (buffer,"show");dispatch (buffer);
}
-
+
else {
wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win);
}
@@ -255,22 +255,22 @@ void file_show_hex (void)
{
long offset=0,l,i;
unsigned char *ch_ptr;
-
+
/* device_offset and type_data points to the inode */
show_pad_info.line=0;
-
+
wmove (show_pad,0,0);
ch_ptr=file_info.buffer;
for (l=0;l<file_system_info.block_size/16;l++) {
if (file_info.file_offset+offset>file_info.file_length-1) break;
wprintw (show_pad,"%08ld : ",offset);
for (i=0;i<16;i++) {
-
+
if (file_info.file_offset+offset+i>file_info.file_length-1) {
wprintw (show_pad," ");
}
-
+
else {
if (file_info.offset_in_block==offset+i)
wattrset (show_pad,A_REVERSE);
@@ -297,20 +297,20 @@ void file_show_hex (void)
wattrset (show_pad,A_NORMAL);
show_pad_info.line=l-l % show_pad_info.display_lines;
}
-
+
wprintw (show_pad," ");
-
+
}
wprintw (show_pad,"\n");
offset+=i;
ch_ptr+=i;
}
-
+
show_pad_info.max_line=l-1;
-
+
refresh_show_pad ();
-
+
show_status ();
}
@@ -319,7 +319,7 @@ void file_show_text (void)
{
long offset=0,last_offset,l=0,cols=0;
unsigned char *ch_ptr;
-
+
/* device_offset and type_data points to the inode */
show_pad_info.line=0;
@@ -330,14 +330,14 @@ void file_show_text (void)
if (file_info.file_offset+last_offset > file_info.file_length-1)
last_offset=file_info.file_length-1-file_info.file_offset;
-
+
while ( (offset <= last_offset) && l<SHOW_PAD_LINES) {
if (cols==SHOW_PAD_COLS-1) {
wprintw (show_pad,"\n");
l++;cols=0;
}
-
+
if (file_info.offset_in_block==offset)
wattrset (show_pad,A_REVERSE);
@@ -354,7 +354,7 @@ void file_show_text (void)
else if (*ch_ptr == 0x9)
wprintw (show_pad," ");
-
+
else
wprintw (show_pad,".");
}
@@ -363,29 +363,29 @@ void file_show_text (void)
wattrset (show_pad,A_NORMAL);
show_pad_info.line=l-l % show_pad_info.display_lines;
}
-
+
offset++;cols++;ch_ptr++;
}
-
+
wprintw (show_pad,"\n");
show_pad_info.max_line=l;
-
+
refresh_show_pad ();
-
- show_status ();
+
+ show_status ();
}
void show_status (void)
{
long inode_num;
-
+
werase (show_win);wmove (show_win,0,0);
wprintw (show_win,"File contents. Block %ld. ",file_info.global_block_num);
wprintw (show_win,"File block %ld of %ld. ",file_info.block_num,file_info.blocks_count-1);
wprintw (show_win,"File Offset %ld of %ld.",file_info.file_offset,file_info.file_length-1);
-
+
wmove (show_win,1,0);
inode_num=inode_offset_to_inode_num (file_info.inode_offset);
wprintw (show_win,"File inode %ld. Indirection level %ld.",inode_num,file_info.level);
@@ -400,14 +400,14 @@ void type_file___remember (char *command_line)
long entry_num;
char *ptr,buffer [80];
struct struct_descriptor *descriptor_ptr;
-
+
ptr=parse_word (command_line,buffer);
-
+
if (*ptr==0) {
wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win);
- return;
+ return;
}
-
+
ptr=parse_word (ptr,buffer);
entry_num=remember_lifo.entries_count++;
@@ -415,7 +415,7 @@ void type_file___remember (char *command_line)
entry_num=0;
remember_lifo.entries_count--;
}
-
+
descriptor_ptr=first_type;
while (descriptor_ptr!=NULL && !found) {
if (strcmp (descriptor_ptr->name,"ext2_inode")==0)
@@ -428,7 +428,7 @@ void type_file___remember (char *command_line)
remember_lifo.offset [entry_num]=device_offset;
remember_lifo.type [entry_num]=descriptor_ptr;
strcpy (remember_lifo.name [entry_num],buffer);
-
+
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer);
wrefresh (command_win);
}
@@ -439,7 +439,7 @@ void type_file___set (char *command_line)
unsigned char tmp;
char *ptr,buffer [80],*ch_ptr;
int mode=HEX;
-
+
ptr=parse_word (command_line,buffer);
if (*ptr==0) {
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
@@ -492,7 +492,7 @@ void type_file___set (char *command_line)
}
}
}
-
+
strcpy (buffer,"show");dispatch (buffer);
}
@@ -507,7 +507,7 @@ long file_block_to_global_block (long file_block,struct struct_file_info *file_i
{
long last_direct,last_indirect,last_dindirect;
-
+
last_direct=EXT2_NDIR_BLOCKS-1;
last_indirect=last_direct+file_system_info.block_size/4;
last_dindirect=last_indirect+(file_system_info.block_size/4)*(file_system_info.block_size/4);
@@ -516,7 +516,7 @@ long file_block_to_global_block (long file_block,struct struct_file_info *file_i
file_info_ptr->level=0;
return (file_info_ptr->inode_ptr->i_block [file_block]);
}
-
+
if (file_block <= last_indirect) {
file_info_ptr->level=1;
file_block=file_block-last_direct-1;
@@ -538,16 +538,16 @@ long return_indirect (long table_block,long block_num)
{
long block_table [EXT2_MAX_BLOCK_SIZE/4];
-
+
low_read ((char *) block_table,file_system_info.block_size,table_block*file_system_info.block_size);
- return (block_table [block_num]);
+ return (block_table [block_num]);
}
long return_dindirect (long table_block,long block_num)
{
long f_indirect;
-
+
f_indirect=block_num/(file_system_info.block_size/4);
f_indirect=return_indirect (table_block,f_indirect);
return (return_indirect (f_indirect,block_num%(file_system_info.block_size/4)));
@@ -557,7 +557,7 @@ long return_tindirect (long table_block,long block_num)
{
long s_indirect;
-
+
s_indirect=block_num/((file_system_info.block_size/4)*(file_system_info.block_size/4));
s_indirect=return_indirect (table_block,s_indirect);
return (return_dindirect (s_indirect,block_num%((file_system_info.block_size/4)*(file_system_info.block_size/4))));
diff --git a/ext2ed/general_com.c b/ext2ed/general_com.c
index 679f1775..03dc2615 100644
--- a/ext2ed/general_com.c
+++ b/ext2ed/general_com.c
@@ -33,16 +33,16 @@ void help (char *command_line)
if (*ptr!=0) {
ptr=parse_word (ptr,argument);
- if (*argument!=0) {
+ if (*argument!=0) {
detailed_help (argument);
return;
}
}
if (current_type!=NULL) {
-
+
wprintw (show_pad,"Type %s specific commands:\n",current_type->name);max_line++;
-
+
if (current_type->type_commands.last_command==-1) {
wprintw (show_pad,"\nnone\n");max_line+=2;
}
@@ -53,11 +53,11 @@ void help (char *command_line)
}
wprintw (show_pad,"%-13s",current_type->type_commands.names [i]);
if (i%5!=4)
- wprintw (show_pad,"; ");
+ wprintw (show_pad,"; ");
}
-
+
wprintw (show_pad,"\n\n");max_line+=2;
- }
+ }
if (ext2_commands.last_command != -1) {
wprintw (show_pad,"ext2 filesystem general commands: \n");max_line++;
@@ -67,25 +67,25 @@ void help (char *command_line)
}
wprintw (show_pad,"%-13s",ext2_commands.names [i]);
if (i%5!=4)
- wprintw (show_pad,"; ");
+ wprintw (show_pad,"; ");
}
wprintw (show_pad,"\n\n");max_line+=2;
}
wprintw (show_pad,"General commands: \n");
-
+
for (i=0;i<=general_commands.last_command;i++) {
if (i%5==0) {
wprintw (show_pad,"\n");max_line++;
}
wprintw (show_pad,"%-13s",general_commands.names [i]);
if (i%5!=4)
- wprintw (show_pad,"; ");
+ wprintw (show_pad,"; ");
}
-
+
wprintw (show_pad,"\n\n");max_line+=2;
-
+
wprintw (show_pad,"EXT2ED ver %s (%s)\n",E2FSPROGS_VERSION, E2FSPROGS_DATE);
wprintw (show_pad,"Copyright (C) 1995 Gadi Oxman\n");
wprintw (show_pad,"Reviewed 2001 Christian Bac\n");
@@ -97,12 +97,12 @@ void help (char *command_line)
wprintw (show_pad,"with the guide of Avner Lottem and Dr. Ilana David.\n");
max_line+=10;
-
+
show_pad_info.line=0;show_pad_info.max_line=max_line;
werase (show_win);wmove (show_win,0,0);
wprintw (show_win,"EXT2ED help");
-
+
refresh_show_win ();
refresh_show_pad ();
}
@@ -111,7 +111,7 @@ void detailed_help (char *text)
{
int i;
-
+
if (current_type != NULL)
for (i=0;i<=current_type->type_commands.last_command;i++) {
if (strcmp (current_type->type_commands.names [i],text)==0) {
@@ -149,20 +149,20 @@ void set_device (char *command_line)
{
char *ptr,new_device [80];
-
+
ptr=parse_word (command_line,new_device);
if (*ptr==0) {
wprintw (command_win,"Error - Device name not specified\n");
refresh_command_win ();return;
}
- parse_word (ptr,new_device);
+ parse_word (ptr,new_device);
check_mounted (new_device);
if (mounted && !AllowMountedRead) {
wprintw (command_win,"Error - Filesystem is mounted, aborting\n");
wprintw (command_win,"You may wish to use the AllowMountedRead on configuration option\n");
refresh_command_win ();return;
}
-
+
if (mounted && AllowMountedRead) {
wprintw (command_win,"Warning - Filesystem is mounted. Displayed data may be unreliable.\n");
refresh_command_win ();
@@ -170,7 +170,7 @@ void set_device (char *command_line)
if (device_handle!=NULL)
fclose (device_handle);
-
+
if ( (device_handle=fopen (new_device,"rb"))==NULL) {
wprintw (command_win,"Error - Can not open device %s\n",new_device);refresh_command_win ();
return;
@@ -204,14 +204,14 @@ void set_offset (char *command_line)
long mult=1;
long new_offset;
char *ptr,new_offset_buffer [80];
-
+
if (device_handle==NULL) {
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
return;
}
-
+
ptr=parse_word (command_line,new_offset_buffer);
-
+
if (*ptr==0) {
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();
return;
@@ -246,7 +246,7 @@ void set_offset (char *command_line)
}
new_offset=device_offset+atol (new_offset_buffer+1)*mult;
}
-
+
else if (new_offset_buffer [0]=='-') {
if (device_offset==-1) {
wprintw (command_win,"Error - Select a fixed offset first\n");refresh_command_win ();
@@ -255,10 +255,10 @@ void set_offset (char *command_line)
new_offset=device_offset-atol (new_offset_buffer+1)*mult;
if (new_offset<0) new_offset=0;
}
-
- else
+
+ else
new_offset=atol (new_offset_buffer)*mult;
-
+
if ( (fseek (device_handle,new_offset,SEEK_SET))==-1) {
wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",new_offset,device_name);
refresh_command_win ();
@@ -362,7 +362,7 @@ void set (char *command_line)
unsigned long *long_ptr,offset=0;
int i,len, found=0;
char *ptr,buffer [80],variable [80],value [80];
-
+
if (device_handle==NULL) {
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
return;
@@ -389,7 +389,7 @@ void set (char *command_line)
if (current_type==NULL) {
wprintw (command_win,"Sorry, not yet supported\n");refresh_command_win ();return;
}
-
+
for (i=0;i<current_type->fields_num && !found;i++) {
if (strcmp (current_type->field_names [i],variable)==0) {
found=1;
@@ -429,7 +429,7 @@ void hex_set (char *command_line)
unsigned char tmp;
char *ptr,buffer [80],*ch_ptr;
int mode=HEX;
-
+
ptr=parse_word (command_line,buffer);
if (*ptr==0) {
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
@@ -482,7 +482,7 @@ void hex_set (char *command_line)
}
}
}
-
+
strcpy (buffer,"show");dispatch (buffer);
}
@@ -500,14 +500,14 @@ void set_type (char *command_line)
ptr=parse_word (command_line,buffer);
parse_word (ptr,buffer);
-
+
if (strcmp (buffer,"none")==0 || strcmp (buffer,"hex")==0) {
wprintw (command_win,"Data will be shown as hex dump\n");refresh_command_win ();
current_type=NULL;
sprintf (tmp_buffer,"show");dispatch (tmp_buffer);
return;
}
-
+
descriptor_ptr=first_type;
while (descriptor_ptr!=NULL && !found) {
if (strcmp (descriptor_ptr->name,buffer)==0)
@@ -523,7 +523,7 @@ void set_type (char *command_line)
else {
wprintw (command_win,"Error - %s is not a valid type\n",buffer);refresh_command_win ();
}
-}
+}
void show_int(short len, void *ptr)
{
@@ -584,7 +584,7 @@ void show_char(short len, void *ptr)
int i,j;
wprintw(show_pad, "\"");
-
+
for (i=0; i < len; i++) {
ch = *cp++;
if (ch == 0) {
@@ -604,17 +604,17 @@ void show_char(short len, void *ptr)
}
wprintw(show_pad, "%c", ch);
}
-
+
wprintw(show_pad, "\"\n");
}
-
+
void show (char *command_line)
{
unsigned int i,l,len,temp_int;
- unsigned long offset=0,temp_long;
+ unsigned long offset=0,temp_long;
unsigned char temp_char,*ch_ptr;
void *ptr;
@@ -622,7 +622,7 @@ void show (char *command_line)
return;
show_pad_info.line=0;
-
+
if (current_type==NULL) {
wmove (show_pad,0,0);
ch_ptr=type_data.u.buffer;
@@ -631,7 +631,7 @@ void show (char *command_line)
for (i=0;i<16;i++) {
if (type_data.offset_in_block==offset+i)
wattrset (show_pad,A_REVERSE);
-
+
if (ch_ptr [i]>=' ' && ch_ptr [i]<='z')
wprintw (show_pad,"%c",ch_ptr [i]);
else
@@ -643,7 +643,7 @@ void show (char *command_line)
for (i=0;i<16;i++) {
if (type_data.offset_in_block==offset+i)
wattrset (show_pad,A_REVERSE);
-
+
wprintw (show_pad,"%02x",ch_ptr [i]);
if (type_data.offset_in_block==offset+i) {
@@ -696,12 +696,12 @@ void next (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset*=atol (buffer);
}
-
+
if (current_type!=NULL) {
sprintf (buffer,"setoffset type +%ld",offset);
dispatch (buffer);
@@ -712,7 +712,7 @@ void next (char *command_line)
type_data.offset_in_block+=offset;
sprintf (buffer,"show");dispatch (buffer);
}
-
+
else {
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
}
@@ -725,12 +725,12 @@ void prev (char *command_line)
char *ptr,buffer [80];
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
offset*=atol (buffer);
}
-
+
if (current_type!=NULL) {
sprintf (buffer,"setoffset type -%ld",offset);
dispatch (buffer);
@@ -741,13 +741,13 @@ void prev (char *command_line)
type_data.offset_in_block-=offset;
sprintf (buffer,"show");dispatch (buffer);
}
-
+
else {
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
}
}
-void pgdn (char *commnad_line)
+void pgdn (char *commnad_line)
{
show_pad_info.line+=show_pad_info.display_lines;
@@ -773,19 +773,19 @@ void remember (char *command_line)
{
long entry_num;
char *ptr,buffer [80];
-
+
if (device_handle==NULL) {
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
return;
}
ptr=parse_word (command_line,buffer);
-
+
if (*ptr==0) {
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
- return;
+ return;
}
-
+
ptr=parse_word (ptr,buffer);
entry_num=remember_lifo.entries_count++;
@@ -793,16 +793,16 @@ void remember (char *command_line)
entry_num=0;
remember_lifo.entries_count--;
}
-
+
remember_lifo.offset [entry_num]=device_offset;
remember_lifo.type [entry_num]=current_type;
strcpy (remember_lifo.name [entry_num],buffer);
-
+
if (current_type!=NULL)
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",current_type->name,device_offset,buffer);
else
wprintw (command_win,"Offset %ld remembered as %s\n",device_offset,buffer);
-
+
refresh_command_win ();
}
@@ -821,17 +821,17 @@ void recall (char *command_line)
if (*ptr==0) {
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
- return;
+ return;
}
ptr=parse_word (ptr,buffer);
-
+
for (entry_num=remember_lifo.entries_count-1;entry_num>=0;entry_num--) {
if (strcmp (remember_lifo.name [entry_num],buffer)==0)
- break;
+ break;
}
-
+
if (entry_num==-1) {
wprintw (command_win,"Error - Can not recall %s\n",buffer);refresh_command_win ();
return;
@@ -839,13 +839,13 @@ void recall (char *command_line)
sprintf (buffer,"setoffset %ld",remember_lifo.offset [entry_num]);dispatch (buffer);
if (remember_lifo.type [entry_num] != NULL) {
- sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer);
+ sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer);
}
else {
- sprintf (buffer,"settype none");dispatch (buffer);
+ sprintf (buffer,"settype none");dispatch (buffer);
}
-
+
wprintw (command_win,"Object %s in Offset %ld recalled\n",current_type->name,device_offset);
refresh_command_win ();
}
@@ -864,12 +864,12 @@ void enable_write (char *command_line)
wprintw (command_win,"Sorry, write access is not allowed\n");
return;
}
-
+
if (mounted) {
wprintw (command_win,"Error - Filesystem is mounted\n");
- return;
+ return;
}
-
+
if ( (fp=fopen (device_name,"r+b"))==NULL) {
wprintw (command_win,"Error - Can not open device %s for reading and writing\n",device_name);refresh_command_win ();
return;
@@ -893,7 +893,7 @@ void disable_write (char *command_line)
wprintw (command_win,"Error - Can not open device %s\n",device_name);refresh_command_win ();
return;
}
-
+
fclose (device_handle);
device_handle=fp;write_access=0;
wprintw (command_win,"Write access disabled\n");refresh_command_win ();
diff --git a/ext2ed/group_com.c b/ext2ed/group_com.c
index ee6aabc1..25325533 100644
--- a/ext2ed/group_com.c
+++ b/ext2ed/group_com.c
@@ -19,11 +19,11 @@ Copyright (C) 1995 Gadi Oxman
#include "ext2ed.h"
void type_ext2_group_desc___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);
@@ -39,7 +39,7 @@ void type_ext2_group_desc___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);
@@ -55,7 +55,7 @@ void type_ext2_group_desc___entry (char *command_line)
{
long group_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;
@@ -63,11 +63,11 @@ void type_ext2_group_desc___entry (char *command_line)
ptr=parse_word (ptr,buffer);
group_num=atol (buffer);
-
+
if (group_num < 0 || group_num >= file_system_info.groups_count) {
wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return;
}
-
+
device_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
@@ -81,7 +81,7 @@ void type_ext2_group_desc___gocopy (char *command_line)
{
unsigned long copy_num,offset;
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;
@@ -89,12 +89,12 @@ void type_ext2_group_desc___gocopy (char *command_line)
ptr=parse_word (ptr,buffer);
copy_num=atol (buffer);
-
+
offset=file_system_info.first_group_desc_offset+copy_num*file_system_info.super_block.s_blocks_per_group*file_system_info.block_size;
-
+
if (offset > file_system_info.file_system_size) {
wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return;
- }
+ }
group_info.copy_num=copy_num;
device_offset=offset+group_info.group_num*sizeof (struct ext2_group_desc);
@@ -108,12 +108,12 @@ void type_ext2_group_desc___show (char *command_line)
{
long group_num,temp;
-
+
temp=(device_offset-file_system_info.first_group_desc_offset) % (file_system_info.super_block.s_blocks_per_group*file_system_info.block_size);
group_num=temp/sizeof (struct ext2_group_desc);
show (command_line);
-
+
wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0);
wprintw (show_win,"Group %ld of %ld ",group_num,file_system_info.groups_count-1);
wprintw (show_win,"in copy %ld ",group_info.copy_num);
@@ -136,7 +136,7 @@ void type_ext2_group_desc___inode (char *command_line)
{
long inode_offset;
char buffer [80];
-
+
inode_offset=type_data.u.t_ext2_group_desc.bg_inode_table;
sprintf (buffer,"setoffset block %ld",inode_offset);dispatch (buffer);
sprintf (buffer,"settype ext2_inode");dispatch (buffer);
@@ -147,10 +147,10 @@ void type_ext2_group_desc___blockbitmap (char *command_line)
{
long block_bitmap_offset;
char buffer [80];
-
+
block_bitmap_info.entry_num=0;
block_bitmap_info.group_num=group_info.group_num;
-
+
block_bitmap_offset=type_data.u.t_ext2_group_desc.bg_block_bitmap;
sprintf (buffer,"setoffset block %ld",block_bitmap_offset);dispatch (buffer);
sprintf (buffer,"settype block_bitmap");dispatch (buffer);
@@ -161,10 +161,10 @@ void type_ext2_group_desc___inodebitmap (char *command_line)
{
long inode_bitmap_offset;
char buffer [80];
-
+
inode_bitmap_info.entry_num=0;
inode_bitmap_info.group_num=group_info.group_num;
-
+
inode_bitmap_offset=type_data.u.t_ext2_group_desc.bg_inode_bitmap;
sprintf (buffer,"setoffset block %ld",inode_bitmap_offset);dispatch (buffer);
sprintf (buffer,"settype inode_bitmap");dispatch (buffer);
@@ -174,7 +174,7 @@ void type_ext2_group_desc___setactivecopy (char *command_line)
{
struct ext2_group_desc gd;
-
+
gd=type_data.u.t_ext2_group_desc;
dispatch ("gocopy 0");
type_data.u.t_ext2_group_desc=gd;
diff --git a/ext2ed/init.c b/ext2ed/init.c
index 7ab2e28c..41c2a398 100644
--- a/ext2ed/init.c
+++ b/ext2ed/init.c
@@ -48,12 +48,12 @@ int init (void)
{
printf ("Initializing ...\n");
-
+
if (!process_configuration_file ()) {
fprintf (stderr,"Error - Unable to complete configuration. Quitting.\n");
- return (0);
+ return (0);
};
-
+
general_commands.last_command=-1; /* No commands whatsoever meanwhile */
ext2_commands.last_command=-1;
add_general_commands (); /* Add the general commands, aviable always */
@@ -62,12 +62,12 @@ int init (void)
current_type=NULL; /* No filesystem specific types yet */
remember_lifo.entries_count=0; /* Object memory is empty */
-
+
init_windows (); /* Initialize the NCURSES interface */
init_readline (); /* Initialize the READLINE interface */
init_signals (); /* Initialize the signal handlers */
write_access=0; /* Write access disabled */
-
+
strcpy (last_command_line,"help"); /* Show the help screen to the user */
dispatch ("help");
return (1); /* Success */
@@ -109,26 +109,26 @@ int set_struct_descriptors (char *file_name)
char current_line [500],current_word [50],*ch;
char variable_name [50],variable_type [20];
struct struct_descriptor *current_descriptor;
-
+
if ( (fp=fopen (file_name,"rt"))==NULL) {
wprintw (command_win,"Error - Failed to open descriptors file %s\n",file_name);
refresh_command_win (); return (0);
};
-
+
while (!feof (fp)) {
fgets (current_line,500,fp);
- if (feof (fp)) break;
+ if (feof (fp)) break;
ch=parse_word (current_line,current_word);
if (strcmp (current_word,"struct")==0) {
ch=parse_word (ch,current_word);
current_descriptor=add_new_descriptor (current_word);
-
+
while (strchr (current_line,'{')==NULL) {
fgets (current_line,500,fp);
if (feof (fp)) break;
};
if (feof (fp)) break;
-
+
fgets (current_line,500,fp);
while (strchr (current_line,'}')==NULL) {
@@ -147,9 +147,9 @@ int set_struct_descriptors (char *file_name)
add_new_variable (current_descriptor,variable_type,variable_name);
fgets (current_line,500,fp);
};
- };
+ };
};
-
+
fclose (fp);
return (1);
}
@@ -158,7 +158,7 @@ void free_struct_descriptors (void)
{
struct struct_descriptor *ptr,*next;
-
+
ptr=first_type;
while (ptr!=NULL) {
next=ptr->next;
@@ -173,12 +173,12 @@ void free_user_commands (struct struct_commands *ptr)
{
int i;
-
+
for (i=0;i<=ptr->last_command;i++) {
free (ptr->names [i]);
free (ptr->descriptions [i]);
}
-
+
ptr->last_command=-1;
}
@@ -186,7 +186,7 @@ struct struct_descriptor *add_new_descriptor (char *name)
{
struct struct_descriptor *ptr;
-
+
ptr = malloc (sizeof (struct struct_descriptor));
if (ptr == NULL) {
printf ("Error - Can not allocate memory - Quitting\n");
@@ -232,7 +232,7 @@ void add_new_variable (struct struct_descriptor *ptr,char *v_type,char *v_name)
short len=1;
char field_type=FIELD_TYPE_INT;
struct type_table *p;
-
+
strcpy (ptr->field_names [ptr->fields_num],v_name);
ptr->field_positions [ptr->fields_num]=ptr->length;
@@ -257,7 +257,7 @@ void add_new_variable (struct struct_descriptor *ptr,char *v_type,char *v_name)
ptr->field_types [ptr->fields_num] = field_type;
ptr->length+=len;
- ptr->fields_num++;
+ ptr->fields_num++;
}
void fill_type_commands (struct struct_descriptor *ptr)
@@ -294,7 +294,7 @@ Set specific type user commands.
add_user_command (&ptr->type_commands,"file","Display file data of the current inode",type_ext2_inode___file);
add_user_command (&ptr->type_commands,"dir","Display directory data of the current inode",type_ext2_inode___dir);
}
-
+
if (strcmp ((ptr->name),"dir")==0) {
add_user_command (&ptr->type_commands,"show","Shows current directory data",type_dir___show);
add_user_command (&ptr->type_commands,"inode","Returns to the inode of the current directory",type_dir___inode);
@@ -307,7 +307,7 @@ Set specific type user commands.
add_user_command (&ptr->type_commands,"writedata","Writes the current entry to the disk",type_dir___writedata);
add_user_command (&ptr->type_commands,"set","Changes a variable in the current directory entry",type_dir___set);
}
-
+
if (strcmp ((ptr->name),"ext2_super_block")==0) {
add_user_command (&ptr->type_commands,"show","Displays the super block data",type_ext2_super_block___show);
add_user_command (&ptr->type_commands,"gocopy","Move to another backup copy of the superblock",type_ext2_super_block___gocopy);
@@ -343,30 +343,30 @@ Set specific type user commands.
add_user_command (&ptr->type_commands,"allocate","Allocates the current inode",type_ext2_inode_bitmap___allocate);
add_user_command (&ptr->type_commands,"deallocate","Deallocates the current inode",type_ext2_inode_bitmap___deallocate);
}
-
+
}
void add_user_command (struct struct_commands *ptr,char *name,char *description,PF callback)
{
int num;
-
+
num=ptr->last_command;
if (num+1==MAX_COMMANDS_NUM) {
printf ("Internal Error - Can't add command %s\n",name);
return;
}
-
+
ptr->last_command=++num;
ptr->names [num]=(char *) malloc (strlen (name)+1);
strcpy (ptr->names [num],name);
-
+
if (*description!=0) {
ptr->descriptions [num]=(char *) malloc (strlen (description)+1);
strcpy (ptr->descriptions [num],description);
}
-
+
ptr->callback [num]=callback;
}
@@ -382,7 +382,7 @@ int set_file_system_info (void)
{
int ext2_detected=0;
struct ext2_super_block *sb;
-
+
file_system_info.super_block_offset=1024;
file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize;
@@ -390,7 +390,7 @@ int set_file_system_info (void)
sb=&file_system_info.super_block;
- if (sb->s_magic == EXT2_SUPER_MAGIC)
+ if (sb->s_magic == EXT2_SUPER_MAGIC)
ext2_detected=1;
if (ext2_detected)
@@ -403,7 +403,7 @@ int set_file_system_info (void)
if (ForceExt2 && !ext2_detected)
wprintw (command_win,"Forcing extended 2 filesystem\n");
-
+
if (ForceDefault || !ext2_detected)
wprintw (command_win,"Forcing default parameters\n");
@@ -414,17 +414,17 @@ int set_file_system_info (void)
if (!set_struct_descriptors (Ext2Descriptors))
return (0);
}
-
+
if (!ForceDefault && ext2_detected) {
-
+
file_system_info.block_size=EXT2_MIN_BLOCK_SIZE << sb->s_log_block_size;
if (file_system_info.block_size == EXT2_MIN_BLOCK_SIZE)
file_system_info.first_group_desc_offset=2*EXT2_MIN_BLOCK_SIZE;
else
file_system_info.first_group_desc_offset=file_system_info.block_size;
- file_system_info.groups_count = div_ceil(sb->s_blocks_count,
+ file_system_info.groups_count = div_ceil(sb->s_blocks_count,
sb->s_blocks_per_group);
-
+
file_system_info.inodes_per_block=file_system_info.block_size/sizeof (struct ext2_inode);
file_system_info.blocks_per_group=sb->s_inodes_per_group/file_system_info.inodes_per_block;
file_system_info.no_blocks_in_group=sb->s_blocks_per_group;
@@ -433,10 +433,10 @@ int set_file_system_info (void)
else {
file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize;
- file_system_info.block_size=DefaultBlockSize;
+ file_system_info.block_size=DefaultBlockSize;
file_system_info.no_blocks_in_group=DefaultBlocksInGroup;
}
-
+
if (file_system_info.file_system_size > 2147483647) {
wprintw (command_win,"Sorry, filesystems bigger than 2 GB are currently not supported\n");
return (0);
@@ -458,17 +458,17 @@ void init_signals (void)
signal (SIGWINCH, signal_SIGWINCH_handler); /* Catch SIGWINCH */
signal (SIGTERM, signal_SIGTERM_handler);
signal (SIGSEGV, signal_SIGSEGV_handler);
-
+
}
void signal_SIGWINCH_handler (int sig_num)
{
redraw_request=1; /* We will handle it in main.c */
-
- /* Reset signal handler */
- signal (SIGWINCH, signal_SIGWINCH_handler);
-
+
+ /* Reset signal handler */
+ signal (SIGWINCH, signal_SIGWINCH_handler);
+
}
void signal_SIGTERM_handler (int sig_num)
@@ -496,12 +496,12 @@ int process_configuration_file (void)
strcpy (buffer, ETC_DIR);
strcat (buffer,"/ext2ed.conf");
-
+
if ((fp=fopen (buffer,"rt"))==NULL) {
fprintf (stderr,"Error - Unable to open configuration file %s\n",buffer);
return (0);
}
-
+
while (get_next_option (fp,option,value)) {
if (strcasecmp (option,"Ext2Descriptors")==0) {
strcpy (Ext2Descriptors,value);
@@ -581,7 +581,7 @@ int process_configuration_file (void)
fclose (fp);return (0);
}
}
-
+
else {
fprintf (stderr,"Error - Unknown option: %s\n",option);
fclose (fp);return (0);
@@ -598,13 +598,13 @@ int get_next_option (FILE *fp,char *option,char *value)
{
char *ptr;
char buffer [600];
-
+
if (feof (fp)) return (0);
do{
if (feof (fp)) return (0);
fgets (buffer,500,fp);
} while (buffer [0]=='#' || buffer [0]=='\n');
-
+
ptr=parse_word (buffer,option);
ptr=parse_word (ptr,value);
return (1);
@@ -618,15 +618,15 @@ void check_mounted (char *name)
char current_line [500],current_word [200];
mounted=0;
-
+
if ( (fp=fopen ("/etc/mtab","rt"))==NULL) {
wprintw (command_win,"Error - Failed to open /etc/mtab. Assuming filesystem is mounted.\n");
refresh_command_win ();mounted=1;return;
};
-
+
while (!feof (fp)) {
fgets (current_line,500,fp);
- if (feof (fp)) break;
+ if (feof (fp)) break;
ptr=parse_word (current_line,current_word);
if (strcasecmp (current_word,name)==0) {
mounted=1;fclose (fp);return;
@@ -634,6 +634,6 @@ void check_mounted (char *name)
};
fclose (fp);
-
- return;
+
+ return;
}
diff --git a/ext2ed/inode_com.c b/ext2ed/inode_com.c
index 0f14d118..843286c5 100644
--- a/ext2ed/inode_com.c
+++ b/ext2ed/inode_com.c
@@ -51,7 +51,7 @@ void type_ext2_inode___prev (char *command_line)
if (entry_num-mult+1>0) {
device_offset-=sizeof (struct ext2_inode)*mult;
entry_num-=mult;
-
+
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
strcpy (buffer,"show");dispatch (buffer);
}
@@ -59,7 +59,7 @@ void type_ext2_inode___prev (char *command_line)
else {
wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win ();
}
-
+
if (entry_num==0) {
wprintw (command_win,"Reached first inode in current group descriptor\n");
refresh_command_win ();
@@ -77,7 +77,7 @@ void type_ext2_inode___next (char *command_line)
struct ext2_group_desc desc;
ptr=parse_word (command_line,buffer);
-
+
if (*ptr!=0) {
ptr=parse_word (ptr,buffer);
mult=atol (buffer);
@@ -99,7 +99,7 @@ void type_ext2_inode___next (char *command_line)
if (entry_num+mult-1<last_entry) {
device_offset+=sizeof (struct ext2_inode)*mult;
entry_num+=mult;
-
+
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
strcpy (buffer,"show");dispatch (buffer);
}
@@ -107,7 +107,7 @@ void type_ext2_inode___next (char *command_line)
else {
wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win ();
}
-
+
if (entry_num==last_entry) {
wprintw (command_win,"Reached last inode in current group descriptor\n");
refresh_command_win ();
@@ -119,10 +119,10 @@ void type_ext2_inode___show (char *command_line)
{
struct ext2_inode *inode_ptr;
-
+
unsigned short temp;
int i;
-
+
long group_num,group_offset,entry_num,block_num,first_entry,last_entry,inode_num;
struct ext2_group_desc desc;
@@ -150,7 +150,7 @@ void type_ext2_inode___show (char *command_line)
wprintw (show_pad,"r");
else
wprintw (show_pad,"-");
-
+
if (temp & 2)
wprintw (show_pad,"w");
else
@@ -168,7 +168,7 @@ void type_ext2_inode___show (char *command_line)
wmove (show_pad,10,40);
temp=inode_ptr->i_flags;
-
+
if (temp & EXT2_SECRM_FL)
wprintw (show_pad,"s");
else
@@ -204,14 +204,14 @@ void type_ext2_inode___show (char *command_line)
wprintw (show_pad,"d");
else
wprintw (show_pad,"-");
-
+
refresh_show_pad ();
wmove (show_win,1,0);
wprintw (show_win,"Inode %ld of %ld. Entry %ld of %ld in group descriptor %ld.\n"
,inode_num,file_system_info.super_block.s_inodes_count,entry_num,last_entry,group_num);
-
+
wprintw (show_win,"Inode type: ");
if (inode_num < EXT2_GOOD_OLD_FIRST_INO) {
@@ -241,7 +241,7 @@ void type_ext2_inode___show (char *command_line)
}
if (type_data.u.t_ext2_inode.i_mode==0)
wprintw (show_win,"Free. ");
-
+
if (S_ISREG (type_data.u.t_ext2_inode.i_mode))
wprintw (show_win,"File. ");
@@ -255,7 +255,7 @@ void type_ext2_inode___show (char *command_line)
if (inode_ptr->i_size <= 60)
wprintw (show_pad,"-> %s",(char *) &type_data.u.t_ext2_inode.i_block [0]);
else
- wprintw (show_pad,"Slow symbolic link\n");
+ wprintw (show_pad,"Slow symbolic link\n");
refresh_show_pad ();
}
@@ -266,7 +266,7 @@ void type_ext2_inode___show (char *command_line)
wprintw (show_win,"Block device. ");
wprintw (show_win,"\n");refresh_show_win ();
-
+
if (entry_num==last_entry) {
wprintw (command_win,"Reached last inode in current group descriptor\n");
refresh_command_win ();
@@ -305,7 +305,7 @@ void type_ext2_inode___entry (char *command_line)
sprintf (buffer,"next %ld",wanted_entry-entry_num);
dispatch (buffer);
}
-
+
else if (wanted_entry < entry_num) {
sprintf (buffer,"prev %ld",entry_num-wanted_entry);
dispatch (buffer);
@@ -316,12 +316,12 @@ void type_ext2_inode___group (char *command_line)
{
char buffer [80];
-
+
long group_num,group_offset;
-
+
group_num=inode_offset_to_group_num (device_offset);
group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
-
+
sprintf (buffer,"setoffset %ld",group_offset);dispatch (buffer);
sprintf (buffer,"settype ext2_group_desc");dispatch (buffer);
}
@@ -330,17 +330,17 @@ void type_ext2_inode___file (char *command_line)
{
char buffer [80];
-
+
if (!S_ISREG (type_data.u.t_ext2_inode.i_mode)) {
wprintw (command_win,"Error - Inode type is not file\n");refresh_command_win ();
- return;
+ return;
}
-
+
if (!init_file_info ()) {
wprintw (command_win,"Error - Unable to show file\n");refresh_command_win ();
- return;
+ return;
}
-
+
sprintf (buffer,"settype file");dispatch (buffer);
}
@@ -348,21 +348,21 @@ void type_ext2_inode___dir (char *command_line)
{
char buffer [80];
-
+
if (!S_ISDIR (type_data.u.t_ext2_inode.i_mode)) {
wprintw (command_win,"Error - Inode type is not directory\n");refresh_command_win ();
- return;
+ return;
}
-/* It is very important to init first_file_info first, as search_dir_entries relies on it */
+/* It is very important to init first_file_info first, as search_dir_entries relies on it */
if (!init_dir_info (&first_file_info)) {
wprintw (command_win,"Error - Unable to show directory\n");refresh_command_win ();
- return;
+ return;
}
-
+
file_info=first_file_info;
-
+
sprintf (buffer,"settype dir");dispatch (buffer);
}
@@ -371,9 +371,9 @@ long inode_offset_to_group_num (long inode_offset)
{
int found=0;
struct ext2_group_desc desc;
-
+
long block_num,group_offset,group_num;
-
+
block_num=inode_offset/file_system_info.block_size;
group_offset=file_system_info.first_group_desc_offset;
@@ -387,14 +387,14 @@ long inode_offset_to_group_num (long inode_offset)
group_offset+=sizeof (struct ext2_group_desc);
group_num=(group_offset-file_system_info.first_group_desc_offset)/sizeof (struct ext2_group_desc);
}
-
+
if (!found)
return (-1);
return (group_num);
}
-
+
long int inode_offset_to_inode_num (long inode_offset)
@@ -413,7 +413,7 @@ long int inode_offset_to_inode_num (long inode_offset)
first_entry=0;last_entry=file_system_info.super_block.s_inodes_per_group-1;
inode_num=group_num*file_system_info.super_block.s_inodes_per_group+1;
inode_num+=entry_num;
-
+
return (inode_num);
}
@@ -424,7 +424,7 @@ long int inode_num_to_inode_offset (long inode_num)
struct ext2_group_desc desc;
inode_num--;
-
+
group_num=inode_num/file_system_info.super_block.s_inodes_per_group;
inode_entry=inode_num%file_system_info.super_block.s_inodes_per_group;
group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
diff --git a/ext2ed/inodebitmap_com.c b/ext2ed/inodebitmap_com.c
index f1fddd45..e6022344 100644
--- a/ext2ed/inodebitmap_com.c
+++ b/ext2ed/inodebitmap_com.c
@@ -28,7 +28,7 @@ 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;
@@ -36,11 +36,11 @@ void type_ext2_inode_bitmap___entry (char *command_line)
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);
}
@@ -50,7 +50,7 @@ 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);
@@ -66,7 +66,7 @@ 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);
@@ -82,24 +82,24 @@ 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;
+ 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");
}
@@ -108,24 +108,24 @@ 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;
+ 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");
}
@@ -135,7 +135,7 @@ void allocate_inode (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;
@@ -147,12 +147,12 @@ void deallocate_inode (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;
}
@@ -165,7 +165,7 @@ void type_ext2_inode_bitmap___show (char *command_line)
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_inodes_per_group/8;i++,ptr++) {
for (j=1;j<=128;j*=2) {
@@ -190,13 +190,13 @@ void type_ext2_inode_bitmap___show (char *command_line)
show_pad_info.max_line++;
}
}
-
+
if (i%8!=7) {
wprintw (show_pad,"\n");
show_pad_info.max_line++;
}
- refresh_show_pad ();
+ refresh_show_pad ();
show_info ();
wmove (show_win,1,0);wprintw (show_win,"Inode bitmap of block group %ld\n",inode_bitmap_info.group_num);
diff --git a/ext2ed/main.c b/ext2ed/main.c
index e2394546..50a3f07f 100644
--- a/ext2ed/main.c
+++ b/ext2ed/main.c
@@ -71,7 +71,7 @@ char device_name [80]; /* The location of the filesystem */
FILE *device_handle=NULL; /* This is passed to the fopen / fread ... commands */
long device_offset; /* The current position in the filesystem */
/* Note that we have a 2 GB limitation */
-
+
int mounted=0; /* This is set when we find that the filesystem is mounted */
struct struct_commands general_commands,ext2_commands; /* Used to define the general and ext2 commands */
@@ -98,7 +98,7 @@ int main (int argc, char **argv)
int write_priv = 0;
int c;
char *buf;
-
+
if (!init ())
return (1);
while ((c = getopt (argc, argv, "w")) != EOF) {
@@ -119,7 +119,7 @@ int main (int argc, char **argv)
set_device(buf);
free(buf);
if (write_priv) {
- wprintw (command_win,"\n");
+ wprintw (command_win,"\n");
enable_write("enable_write");
}
}
@@ -148,7 +148,7 @@ int command_read_key()
key = 0;
kill(getpid(), SIGTSTP);
break;
-
+
case KEY_NPAGE:
pgdn("");
refresh_command_win ();
@@ -161,7 +161,7 @@ int command_read_key()
case ERR:
key = 0;
break;
-
+
case KEY_BACKSPACE:
key = '\b';
}
@@ -203,10 +203,10 @@ void parser (void)
cbreak();
keypad(command_win, 1);
wtimeout(command_win, 100);
-
+
rl_getc_function = rl_getc_replacement;
#endif
-
+
while (!quit) {
/* Terminal screen size has changed */
if (redraw_request) {
@@ -228,7 +228,7 @@ void parser (void)
* time.
*/
mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0);
-
+
/* echo (); */
ptr=readline ("ext2ed > ");
/* noecho (); */
@@ -239,15 +239,15 @@ void parser (void)
* XXX WHY???
*/
strcpy (command_line,ptr);
- free (ptr);
+ free (ptr);
if (*command_line != 0)
add_history (command_line);
/* If only enter was pressed, recall the last command */
- if (*command_line==0)
+ if (*command_line==0)
strcpy (command_line,last_command_line);
-
+
/* Emulate readline's actions for ncurses */
mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0);
werase (command_win);
@@ -261,7 +261,7 @@ void parser (void)
/* And call dispatch to do the actual job */
quit=dispatch (command_line);
- }
+ }
}
#else
void read_line(char * foo) {
@@ -321,13 +321,13 @@ void parser (void)
if (*command_line==0)
strcpy (command_line,last_command_line);
- mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0);
+ mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0);
strcpy (last_command_line,command_line); /* Save this command in our tiny cache */
-
+
/* And call dispatch to do the actual job */
quit=dispatch (command_line);
- }
+ }
}
#endif
@@ -335,35 +335,35 @@ void parser (void)
/*
* This is a very important function. Its task is to recieve a command
* name and link it to a C function. There are three types of commands:
- *
+ *
* 1. General commands - Always available and accessed through
- * general_commands.
+ * general_commands.
* 2. Ext2 specific commands - Available when editing an ext2
- * filesystem, accessed through ext2_commands.
+ * filesystem, accessed through ext2_commands.
* 3. Type specific commands - Those are changing according to the
* current type. The global variable current_type points to the
* current object definition (of type struct_descriptor). In it, the
- * struct_commands entry contains the type specific commands links.
- *
+ * struct_commands entry contains the type specific commands links.
+ *
* Overriding is an important feature - Much like in C++ : The same
* command name can dispatch to different functions. The overriding
* priority is 3,2,1; That is - A type specific command will always
* override a general command. This is used through the program to
- * allow fine tuned operation.
- *
+ * allow fine tuned operation.
+ *
* When an handling function is found, it is called along with the
* command line that was passed to us. The handling function is then
- * free to interpert the arguments in its own style.
+ * free to interpert the arguments in its own style.
*/
int dispatch (char *command_line)
{
int i,found=0;
-
+
char command [80];
parse_word (command_line,command);
-
- if (strcasecmp (command,"quit")==0) return (1);
+
+ if (strcasecmp (command,"quit")==0) return (1);
/* 1. Search for type specific commands FIRST - Allows
overriding of a general command */
@@ -388,9 +388,9 @@ int dispatch (char *command_line)
}
}
-
+
/* 3. If not found, search the general commands */
-
+
if (!found)
for (i=0;i<=general_commands.last_command && !found;i++) {
if (strcasecmp (command,general_commands.names [i])==0) {
@@ -400,18 +400,18 @@ int dispatch (char *command_line)
}
/* 4. If not found, issue an error message and return */
-
+
if (!found) {
wprintw (command_win,"Error: Unknown command\n");
refresh_command_win ();
}
-
+
return (0);
}
/*
- *
+ *
* This function copies the next word in source to the variable dest,
* ignoring whitespaces. It returns a pointer to the next word in
* source. It is used to split the command line into command and arguments.
@@ -419,12 +419,12 @@ int dispatch (char *command_line)
char *parse_word (char *source,char *dest)
{
char ch,*source_ptr,*target_ptr;
-
+
if (*source==0) {
*dest=0;
return (source);
};
-
+
source_ptr=source;target_ptr=dest;
do {
ch=*source_ptr++;
@@ -432,7 +432,7 @@ char *parse_word (char *source,char *dest)
while (ch>' ' && ch<='z') {
*target_ptr++=ch;
- ch=*source_ptr++;
+ ch=*source_ptr++;
}
*target_ptr=0;
@@ -448,23 +448,23 @@ char *parse_word (char *source,char *dest)
/*
* text is the partial command entered by the user; We assume that it
* is a part of a command - I didn't write code for smarter completion.
- *
+ *
* The state variable is an index which tells us how many possible
- * completions we already returned to readline.
- *
+ * completions we already returned to readline.
+ *
* We return only one possible completion or (char *) NULL if there
* are no more completions. This function will be called by readline
- * over and over until we tell it to stop.
- *
+ * over and over until we tell it to stop.
+ *
* While scanning for possible completions, we use the same priority
- * definition which was used in dispatch.
+ * definition which was used in dispatch.
*/
#if HAVE_READLINE
char *complete_command (char *text,int state)
{
int state_index=-1;
int i,len;
-
+
len=strlen (text);
/* Is the command type specific ? */
@@ -480,7 +480,7 @@ char *complete_command (char *text,int state)
}
/* No, pehaps ext2 specific command then ? */
-
+
for (i=0;i<=ext2_commands.last_command;i++) {
if (strncmp (ext2_commands.names [i],text,len)==0) {
state_index++;
@@ -489,9 +489,9 @@ char *complete_command (char *text,int state)
}
}
-
+
/* Check for a general command */
-
+
for (i=0;i<=general_commands.last_command;i++) {
if (strncmp (general_commands.names [i],text,len)==0) {
state_index++;
@@ -501,27 +501,27 @@ char *complete_command (char *text,int state)
}
/* quit is handled differently */
-
+
if (strncmp ("quit",text,len)==0) {
state_index++;
if (state==state_index)
- return (dupstr ("quit"));
+ return (dupstr ("quit"));
}
/* No more completions */
-
+
return ((char *) NULL);
}
#endif
-/*
+/*
* Nothing special - Just allocates enough space and copy the string.
*/
char *dupstr (char *src)
{
char *ptr;
-
+
ptr=(char *) malloc (strlen (src)+1);
strcpy (ptr,src);
return (ptr);
@@ -531,13 +531,13 @@ char *dupstr (char *src)
/*
* This function reports an internal error. It is almost not used. One
* place in which I do check for internal errors is disk.c.
- *
+ *
* We just report the error, and try to continue ...
*/
void internal_error (char *description,char *source_name,char *function_name)
{
wprintw (command_win,"Internal error - Found by source: %s.c , function: %s\n",source_name,function_name);
- wprintw (command_win,"\t%s\n",description);
+ wprintw (command_win,"\t%s\n",description);
wprintw (command_win,"Press enter to (hopefully) continue\n");
refresh_command_win ();getch ();werase (command_win);
}
diff --git a/ext2ed/super_com.c b/ext2ed/super_com.c
index ec483513..3d30070b 100644
--- a/ext2ed/super_com.c
+++ b/ext2ed/super_com.c
@@ -26,14 +26,14 @@ void type_ext2_super_block___show (char *command_line)
{
struct ext2_super_block *super;
super=&type_data.u.t_ext2_super_block;
-
+
show (command_line);
if (super->s_blocks_count != 0) {
wmove (show_pad,2,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_r_blocks_count/ (float) super->s_blocks_count);
wmove (show_pad,3,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_blocks_count/ (float) super->s_blocks_count);
}
-
+
if (super->s_inodes_count != 0) {
wmove (show_pad,4,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_inodes_count/ (float) super->s_inodes_count);
}
@@ -60,7 +60,7 @@ void type_ext2_super_block___show (char *command_line)
wprintw (show_pad,"Unknown");
break;
}
-
+
wmove (show_pad,16,40);
if (type_data.u.t_ext2_super_block.s_state & 0x1)
wprintw (show_pad,"clean ");
@@ -71,9 +71,9 @@ void type_ext2_super_block___show (char *command_line)
wprintw (show_pad,"with errors ");
else
wprintw (show_pad,"with no errors");
-
+
wmove (show_pad,17,40);
-
+
switch (type_data.u.t_ext2_super_block.s_errors) {
case EXT2_ERRORS_CONTINUE:
wprintw (show_pad,"Continue");
@@ -90,7 +90,7 @@ void type_ext2_super_block___show (char *command_line)
}
wmove (show_pad,21,40);
-
+
switch (type_data.u.t_ext2_super_block.s_creator_os) {
case EXT2_OS_LINUX:
@@ -105,7 +105,7 @@ void type_ext2_super_block___show (char *command_line)
wprintw (show_pad,"Unknown");
break;
}
-
+
refresh_show_pad ();
wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0);
@@ -121,7 +121,7 @@ void type_ext2_super_block___gocopy (char *command_line)
{
unsigned long copy_num,offset;
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;
@@ -129,12 +129,12 @@ void type_ext2_super_block___gocopy (char *command_line)
ptr=parse_word (ptr,buffer);
copy_num=atol (buffer);
-
+
offset=file_system_info.super_block_offset+copy_num*file_system_info.no_blocks_in_group*file_system_info.block_size;
-
+
if (offset > file_system_info.file_system_size) {
wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return;
- }
+ }
super_info.copy_num=copy_num;
device_offset=offset;
@@ -147,7 +147,7 @@ void type_ext2_super_block___setactivecopy (char *command_line)
{
struct ext2_super_block sb;
-
+
sb=type_data.u.t_ext2_super_block;
dispatch ("gocopy 0");
type_data.u.t_ext2_super_block=sb;
diff --git a/ext2ed/win.c b/ext2ed/win.c
index 758bc6ad..113a28f3 100644
--- a/ext2ed/win.c
+++ b/ext2ed/win.c
@@ -30,7 +30,7 @@ Copyright (C) 1995 Gadi Oxman
struct struct_pad_info show_pad_info;
WINDOW *title_win,*show_win,*command_win,*mt_win1,*mt_win2,*show_pad;
-/* to remember configuration after initscr
+/* to remember configuration after initscr
* and modify it
*/
struct termios termioInit, termioCurrent;
@@ -56,7 +56,7 @@ void setup_show_win(void)
show_pad_info.display_cols=COLS;
show_pad_info.max_line=show_pad_info.display_lines-1;show_pad_info.max_col=show_pad_info.display_cols-1;
show_pad_info.disable_output=0;
-}
+}
void init_windows (void)
{
@@ -65,7 +65,7 @@ void init_windows (void)
termioCurrent = termioInit;
termioCurrent.c_lflag |= ECHO; /* set echo on */
tcsetattr(0,TCSANOW,&termioCurrent);
-
+
if (LINES<TITLE_WIN_LINES+SHOW_WIN_LINES+COMMAND_WIN_LINES+3) {
printf ("Sorry, your terminal screen is too small\n");
printf ("Error - Can not initialize windows\n");
@@ -105,7 +105,7 @@ void refresh_title_win (void)
void refresh_show_win (void)
{
int current_page,total_pages;
-
+
current_page=show_pad_info.line/show_pad_info.display_lines+1;
if (show_pad_info.line%show_pad_info.display_lines)
current_page++;
@@ -123,10 +123,10 @@ void refresh_show_pad (void)
{
int left,top,right,bottom,i;
-
+
if (show_pad_info.disable_output)
return;
-
+
if (show_pad_info.max_line < show_pad_info.display_lines-1) {
for (i=show_pad_info.max_line+1;i<show_pad_info.display_lines;i++) {
wmove (show_pad,i,0);wprintw (show_pad,"\n");
@@ -157,19 +157,19 @@ void close_windows (void)
{
// echo ();
tcsetattr(0,TCSANOW,&termioInit);
-
+
delwin (title_win);
delwin (command_win);
delwin (show_win);
delwin (show_pad);
-
+
endwin ();
}
void show_info (void)
{
int block_num,block_offset;
-
+
block_num=device_offset/file_system_info.block_size;
block_offset=device_offset%file_system_info.block_size;