1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker
3*6a54128fSAndroid Build Coastguard Worker /usr/src/ext2ed/ext2_com.c
4*6a54128fSAndroid Build Coastguard Worker
5*6a54128fSAndroid Build Coastguard Worker A part of the extended file system 2 disk editor.
6*6a54128fSAndroid Build Coastguard Worker
7*6a54128fSAndroid Build Coastguard Worker --------------------------------------
8*6a54128fSAndroid Build Coastguard Worker Extended-2 filesystem General commands
9*6a54128fSAndroid Build Coastguard Worker --------------------------------------
10*6a54128fSAndroid Build Coastguard Worker
11*6a54128fSAndroid Build Coastguard Worker The commands here will be registered when we are editing an ext2 filesystem
12*6a54128fSAndroid Build Coastguard Worker
13*6a54128fSAndroid Build Coastguard Worker First written on: July 28 1995
14*6a54128fSAndroid Build Coastguard Worker
15*6a54128fSAndroid Build Coastguard Worker Copyright (C) 1995 Gadi Oxman
16*6a54128fSAndroid Build Coastguard Worker
17*6a54128fSAndroid Build Coastguard Worker */
18*6a54128fSAndroid Build Coastguard Worker
19*6a54128fSAndroid Build Coastguard Worker #include "config.h"
20*6a54128fSAndroid Build Coastguard Worker #include <stdio.h>
21*6a54128fSAndroid Build Coastguard Worker #include <stdlib.h>
22*6a54128fSAndroid Build Coastguard Worker #include <string.h>
23*6a54128fSAndroid Build Coastguard Worker
24*6a54128fSAndroid Build Coastguard Worker #include "ext2ed.h"
25*6a54128fSAndroid Build Coastguard Worker
type_ext2___super(char * command_line)26*6a54128fSAndroid Build Coastguard Worker void type_ext2___super (char *command_line)
27*6a54128fSAndroid Build Coastguard Worker
28*6a54128fSAndroid Build Coastguard Worker /*
29*6a54128fSAndroid Build Coastguard Worker
30*6a54128fSAndroid Build Coastguard Worker We are moving to the superblock - Just use setoffset and settype. The offset was gathered in the
31*6a54128fSAndroid Build Coastguard Worker initialization phase (but is constant - 1024).
32*6a54128fSAndroid Build Coastguard Worker
33*6a54128fSAndroid Build Coastguard Worker */
34*6a54128fSAndroid Build Coastguard Worker
35*6a54128fSAndroid Build Coastguard Worker {
36*6a54128fSAndroid Build Coastguard Worker char buffer [80];
37*6a54128fSAndroid Build Coastguard Worker
38*6a54128fSAndroid Build Coastguard Worker super_info.copy_num=0;
39*6a54128fSAndroid Build Coastguard Worker sprintf (buffer,"setoffset %ld",file_system_info.super_block_offset);dispatch (buffer);
40*6a54128fSAndroid Build Coastguard Worker sprintf (buffer,"settype ext2_super_block");dispatch (buffer);
41*6a54128fSAndroid Build Coastguard Worker }
42*6a54128fSAndroid Build Coastguard Worker
type_ext2___cd(char * command_line)43*6a54128fSAndroid Build Coastguard Worker void type_ext2___cd (char *command_line)
44*6a54128fSAndroid Build Coastguard Worker
45*6a54128fSAndroid Build Coastguard Worker /*
46*6a54128fSAndroid Build Coastguard Worker
47*6a54128fSAndroid Build Coastguard Worker A global cd command - The path should start with /.
48*6a54128fSAndroid Build Coastguard Worker
49*6a54128fSAndroid Build Coastguard Worker We implement it through dispatching to our primitive functions.
50*6a54128fSAndroid Build Coastguard Worker
51*6a54128fSAndroid Build Coastguard Worker */
52*6a54128fSAndroid Build Coastguard Worker
53*6a54128fSAndroid Build Coastguard Worker {
54*6a54128fSAndroid Build Coastguard Worker char temp [80],buffer [80],*ptr;
55*6a54128fSAndroid Build Coastguard Worker
56*6a54128fSAndroid Build Coastguard Worker ptr=parse_word (command_line,buffer);
57*6a54128fSAndroid Build Coastguard Worker if (*ptr==0) {
58*6a54128fSAndroid Build Coastguard Worker wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
59*6a54128fSAndroid Build Coastguard Worker }
60*6a54128fSAndroid Build Coastguard Worker ptr=parse_word (ptr,buffer);
61*6a54128fSAndroid Build Coastguard Worker
62*6a54128fSAndroid Build Coastguard Worker if (buffer [0] != '/') {
63*6a54128fSAndroid Build Coastguard Worker wprintw (command_win,"Error - Use a full pathname (begin with '/')\n");refresh_command_win ();return;
64*6a54128fSAndroid Build Coastguard Worker }
65*6a54128fSAndroid Build Coastguard Worker
66*6a54128fSAndroid Build Coastguard Worker /* Note the various dispatches below - They should be intuitive if you know the ext2 filesystem structure */
67*6a54128fSAndroid Build Coastguard Worker
68*6a54128fSAndroid Build Coastguard Worker dispatch ("super");dispatch ("group");dispatch ("inode");dispatch ("next");dispatch ("dir");
69*6a54128fSAndroid Build Coastguard Worker if (buffer [1] != 0) {
70*6a54128fSAndroid Build Coastguard Worker sprintf (temp,"cd %s",buffer+1);dispatch (temp);
71*6a54128fSAndroid Build Coastguard Worker }
72*6a54128fSAndroid Build Coastguard Worker }
73*6a54128fSAndroid Build Coastguard Worker
type_ext2___group(char * command_line)74*6a54128fSAndroid Build Coastguard Worker void type_ext2___group (char *command_line)
75*6a54128fSAndroid Build Coastguard Worker
76*6a54128fSAndroid Build Coastguard Worker /*
77*6a54128fSAndroid Build Coastguard Worker
78*6a54128fSAndroid Build Coastguard Worker We go to the group descriptors.
79*6a54128fSAndroid Build Coastguard Worker First, we go to the first group descriptor in the main copy.
80*6a54128fSAndroid Build Coastguard Worker Then, we use the group's entry command to pass to another group.
81*6a54128fSAndroid Build Coastguard Worker
82*6a54128fSAndroid Build Coastguard Worker */
83*6a54128fSAndroid Build Coastguard Worker
84*6a54128fSAndroid Build Coastguard Worker {
85*6a54128fSAndroid Build Coastguard Worker long group_num=0;
86*6a54128fSAndroid Build Coastguard Worker char *ptr,buffer [80];
87*6a54128fSAndroid Build Coastguard Worker
88*6a54128fSAndroid Build Coastguard Worker ptr=parse_word (command_line,buffer);
89*6a54128fSAndroid Build Coastguard Worker if (*ptr!=0) {
90*6a54128fSAndroid Build Coastguard Worker ptr=parse_word (ptr,buffer);
91*6a54128fSAndroid Build Coastguard Worker group_num=atol (buffer);
92*6a54128fSAndroid Build Coastguard Worker }
93*6a54128fSAndroid Build Coastguard Worker
94*6a54128fSAndroid Build Coastguard Worker group_info.copy_num=0;group_info.group_num=0;
95*6a54128fSAndroid Build Coastguard Worker sprintf (buffer,"setoffset %ld",file_system_info.first_group_desc_offset);dispatch (buffer);
96*6a54128fSAndroid Build Coastguard Worker sprintf (buffer,"settype ext2_group_desc");dispatch (buffer);
97*6a54128fSAndroid Build Coastguard Worker sprintf (buffer,"entry %ld",group_num);dispatch (buffer);
98*6a54128fSAndroid Build Coastguard Worker }
99