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