/*
ext2_resize.c -- ext2 resizer
Copyright (C) 1998-2000, 2007, 2009-2010 Free Software Foundation,
Inc.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#ifndef DISCOVER_ONLY
#include <stdio.h>
#include <stdlib.h>
#include "ext2.h"
{
int group;
int sparse;
if (fs->opt_verbose)
return 0;
{
{
fputs ("ext2_add_group: last (existing) group "
"isn't complete!\n", stderr);
return 0;
}
}
if (!sparse)
{
{
"ext2_add_group: groups of %i blocks are "
"impossible!\n", groupsize);
return 0;
}
}
* sizeof(struct ext2_group_desc),
{
int i;
if (ext2_is_group_sparse(fs, i))
{
}
fs->adminblocks++;
if (sparse)
admin++;
}
{
off = groupstart;
if (sparse)
{
}
else
{
= PED_CPU_TO_LE32(off);
}
/* Hey, I don't know _why_ either */
}
{
blk_t i;
if (!bh)
return 0;
if (sparse)
{
}
for (i=0;i<fs->inodeblocks;i++)
{
blk_t j;
- groupstart + i;
}
}
return 0;
fs->inodeblocks))
return 0;
return 0;
return 1;
}
{
int group;
int sparse;
if (fs->opt_verbose)
if (!sparse)
{
_("File system is too full to remove a group!"));
return 0;
}
{
_("File system has too many allocated inodes to "
"remove a group!"));
return 0;
}
{
{
fputs ("ext2_del_group: this should not "
"happen anymore!\n", stderr);
return 0;
}
}
{
int i;
if (ext2_is_group_sparse(fs, i))
{
0, 1);
}
fs->adminblocks--;
if (sparse)
admin--;
}
{
{
blk_t i;
for (i=0;i<num;i++)
{
"error: block relocator "
"should have relocated "
"%i\n",
offset+i);
return 0;
}
}
}
return 1;
}
{
int group;
blk_t i;
if (fs->opt_verbose)
{
{
fputs ("ext2_grow_group: called to shrink group!\n",
stderr);
return 0;
}
{
return 0;
}
}
return 1;
}
{
int group;
blk_t i;
if (fs->opt_verbose)
{
{
"ext2_shrink_group: cant shrink a group "
"to %i blocks\n", newsize);
return 0;
}
{
fputs ("ext2_shrink_group: called to grow group!\n",
stderr);
return 0;
}
{
fputs ("ext2_shrink_group: nothing to do!\n",
stderr);
return 0;
}
}
{
{
"error: block relocator should have relocated "
"%i\n",
groupoff + i);
return 0;
}
}
return 1;
}
{
if (fs->opt_verbose)
return 0;
return 0;
{
return 0;
}
while (diff)
{
return 0;
}
return 1;
}
{
int newgroups;
if (fs->opt_verbose)
{
_("Your file system is too full to resize it to %i "
"blocks. Sorry."), newsize);
return 0;
}
{
_("Your file system has too many occupied inodes to "
"resize it to %i blocks. Sorry."), newsize);
return 0;
}
return 0;
return 0;
while (diff > 0)
{
{
return 0;
diff = 0;
}
else
{
if (!ext2_del_group(fs))
return 0;
}
}
return 1;
}
{
int i;
/*PED_DEBUG (0x20, "itoffset is %d", fs->itoffset);
PED_DEBUG (0x20, "walking %d groups", fs->numgroups);*/
{
/*PED_DEBUG (0x21, "start = %d, it = %d", start, it);*/
if (ext2_is_group_sparse(fs, i))
{
/*PED_DEBUG (0x21, "%d has a superblock copy", i);*/
}
else
{
/*PED_DEBUG (0x21, "%d doesn't have a superblock copy",
i);*/
}
{
/* ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
_("This ext2 file system has a rather strange layout! "
"Parted can't resize this (yet)."));*/
/* PED_DEBUG (0x21, "calculated block bitmap to be %d, "
"but fs says %d.", bb,
EXT2_GROUP_BLOCK_BITMAP(fs->gd[i]));
PED_DEBUG (0x21, "calculated inode bitmap to be %d, "
"but fs says %d.", ib,
EXT2_GROUP_INODE_BITMAP(fs->gd[i]));
PED_DEBUG (0x21, "calculated inode table to be %d, "
"but fs says %d.", it,
EXT2_GROUP_INODE_TABLE(fs->gd[i]));*/
return 0;
}
}
return 1;
}
{
int status;
{
_("File system has errors! You should run e2fsck."));
return 0;
}
{
_("File system was not cleanly unmounted! "
"You should run e2fsck."));
return 0;
}
if (ped_exception_throw (
_("The file system has the 'dir_index' feature "
"enabled. Parted can only resize the file system "
"if it disables this feature. You can enable it "
"later by running 'tune2fs -O dir_index DEVICE' "
"and then 'e2fsck -fD DEVICE'."))
return 0;
}
_("A resize operation on this file system will "
"use EXPERIMENTAL code\n"
"that MAY CORRUPT it (although no one has "
"reported any such damage yet).\n"
"You should at least backup your data first, "
"and run 'e2fsck -f' afterwards."))
{
return 0;
}
if (fs->opt_verbose)
return 1;
if (!fs->relocator_pool)
return 0;
else
return status;
}
#endif /* !DISCOVER_ONLY */