diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:49:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:49:25 +0000 |
commit | 464df1d5e5ab1322e2dd0a7796939fff1aeefa9a (patch) | |
tree | 6a403684e0978f0287d7f0ec0e5aab1fd31a59e1 /ext2ed/ext2_com.c | |
parent | Initial commit. (diff) | |
download | e2fsprogs-upstream/1.47.0.tar.xz e2fsprogs-upstream/1.47.0.zip |
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ext2ed/ext2_com.c')
-rw-r--r-- | ext2ed/ext2_com.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/ext2ed/ext2_com.c b/ext2ed/ext2_com.c new file mode 100644 index 0000000..ed004f2 --- /dev/null +++ b/ext2ed/ext2_com.c @@ -0,0 +1,98 @@ +/* + +/usr/src/ext2ed/ext2_com.c + +A part of the extended file system 2 disk editor. + +-------------------------------------- +Extended-2 filesystem General commands +-------------------------------------- + +The commands here will be registered when we are editing an ext2 filesystem + +First written on: July 28 1995 + +Copyright (C) 1995 Gadi Oxman + +*/ + +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "ext2ed.h" + +void type_ext2___super (char *command_line) + +/* + +We are moving to the superblock - Just use setoffset and settype. The offset was gathered in the +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); +} + +void type_ext2___cd (char *command_line) + +/* + +A global cd command - The path should start with /. + +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; + } + + /* Note the various dispatches below - They should be intuitive if you know the ext2 filesystem structure */ + + dispatch ("super");dispatch ("group");dispatch ("inode");dispatch ("next");dispatch ("dir"); + if (buffer [1] != 0) { + sprintf (temp,"cd %s",buffer+1);dispatch (temp); + } +} + +void type_ext2___group (char *command_line) + +/* + +We go to the group descriptors. +First, we go to the first group descriptor in the main copy. +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); + group_num=atol (buffer); + } + + group_info.copy_num=0;group_info.group_num=0; + sprintf (buffer,"setoffset %ld",file_system_info.first_group_desc_offset);dispatch (buffer); + sprintf (buffer,"settype ext2_group_desc");dispatch (buffer); + sprintf (buffer,"entry %ld",group_num);dispatch (buffer); +} |