1997-04-26 21:21:57 +08:00
|
|
|
/*
|
2001-04-24 04:58:03 +08:00
|
|
|
* tune2fs.c - Change the file system parameters on an ext2 file system
|
1997-04-26 21:21:57 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1993, 1994 Remy Card <card@masi.ibp.fr>
|
|
|
|
* Laboratoire MASI, Institut Blaise Pascal
|
|
|
|
* Universite Pierre et Marie Curie (Paris VI)
|
|
|
|
*
|
2001-04-24 04:58:03 +08:00
|
|
|
* Copyright 1995, 1996, 1997, 1998, 1999, 2000 by Theodore Ts'o.
|
1997-04-30 00:17:09 +08:00
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-26 21:21:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* History:
|
|
|
|
* 93/06/01 - Creation
|
|
|
|
* 93/10/31 - Added the -c option to change the maximal mount counts
|
|
|
|
* 93/12/14 - Added -l flag to list contents of superblock
|
|
|
|
* M.J.E. Mol (marcel@duteca.et.tudelft.nl)
|
|
|
|
* F.W. ten Wolde (franky@duteca.et.tudelft.nl)
|
|
|
|
* 93/12/29 - Added the -e option to change errors behavior
|
|
|
|
* 94/02/27 - Ported to use the ext2fs library
|
|
|
|
* 94/03/06 - Added the checks interval from Uwe Ohse (uwe@tirka.gun.de)
|
|
|
|
*/
|
|
|
|
|
2008-07-14 03:32:37 +08:00
|
|
|
#define _XOPEN_SOURCE 600 /* for inclusion of strptime() */
|
2003-12-28 20:04:35 +08:00
|
|
|
#define _BSD_SOURCE /* for inclusion of strcasecmp() */
|
2011-09-19 05:34:37 +08:00
|
|
|
#include "config.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
#include <fcntl.h>
|
1997-04-26 21:34:30 +08:00
|
|
|
#include <grp.h>
|
1997-04-26 22:00:26 +08:00
|
|
|
#ifdef HAVE_GETOPT_H
|
1997-04-26 21:21:57 +08:00
|
|
|
#include <getopt.h>
|
Many files:
badblocks.c, dumpe2fs.c, e2label.c, mke2fs.c, tune2fs.c, uuidgen.c:
For platforms that don't define optarg.h, manually define optarg and
optind.
ChangeLog, main.c:
main.c: For platforms that don't define optarg.h, manually define
optarg and optind.
ChangeLog, unix.c:
unix.c: For platforms that don't define optarg.h, manually define
optarg and optind.
2000-04-04 00:22:35 +08:00
|
|
|
#else
|
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
1997-04-26 22:00:26 +08:00
|
|
|
#endif
|
1997-04-26 21:34:30 +08:00
|
|
|
#include <pwd.h>
|
1997-04-26 21:21:57 +08:00
|
|
|
#include <stdio.h>
|
2008-09-01 23:17:29 +08:00
|
|
|
#ifdef HAVE_STDLIB_H
|
1997-04-26 21:21:57 +08:00
|
|
|
#include <stdlib.h>
|
2008-09-01 23:17:29 +08:00
|
|
|
#endif
|
1997-04-26 21:21:57 +08:00
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
1997-04-26 21:34:30 +08:00
|
|
|
#include <sys/types.h>
|
2007-08-13 18:26:24 +08:00
|
|
|
#include <libgen.h>
|
2008-06-08 10:07:50 +08:00
|
|
|
#include <limits.h>
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c,
mke2fs.c, mklost+found.c, tune2fs.c, util.c: Change location of
ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, resize2fs.h:
resize2fs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, debugfs.h:
debugfs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, e2fsck.h, scantest.c:
e2fsck.h, scantest.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
ChangeLog, Makefile.in, tst_uuid.c, uuid_time.c:
tst_uuid.c, uuid_time.c: Remove unneeded #include of ext2_fs.h
ChangeLog, Makefile.in, e2p.h:
e2p.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, test_icount.c, test_rel.c:
test_icount.c, test_rel.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
2001-05-14 19:45:38 +08:00
|
|
|
#include "ext2fs/ext2_fs.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
#include "ext2fs/ext2fs.h"
|
|
|
|
#include "et/com_err.h"
|
1997-04-29 22:53:37 +08:00
|
|
|
#include "uuid/uuid.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
#include "e2p/e2p.h"
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
#include "jfs_user.h"
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
#include "util.h"
|
2003-03-02 08:29:01 +08:00
|
|
|
#include "blkid/blkid.h"
|
2011-07-21 02:40:05 +08:00
|
|
|
#include "quota/mkquota.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
#include "../version.h"
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
#include "nls-enable.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2011-07-21 02:40:05 +08:00
|
|
|
#define QOPT_ENABLE (1)
|
|
|
|
#define QOPT_DISABLE (-1)
|
|
|
|
|
|
|
|
extern int ask_yn(const char *string, int def);
|
|
|
|
|
2009-01-20 15:34:39 +08:00
|
|
|
const char *program_name = "tune2fs";
|
|
|
|
char *device_name;
|
|
|
|
char *new_label, *new_last_mounted, *new_UUID;
|
|
|
|
char *io_options;
|
2001-04-24 04:58:03 +08:00
|
|
|
static int c_flag, C_flag, e_flag, f_flag, g_flag, i_flag, l_flag, L_flag;
|
2011-07-21 02:40:05 +08:00
|
|
|
static int m_flag, M_flag, Q_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag;
|
2007-08-13 18:26:24 +08:00
|
|
|
static int I_flag;
|
2001-12-26 21:58:01 +08:00
|
|
|
static time_t last_check_time;
|
2001-01-09 08:16:26 +08:00
|
|
|
static int print_label;
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
static int max_mount_count, mount_count, mount_flags;
|
2009-09-08 08:46:34 +08:00
|
|
|
static unsigned long interval;
|
|
|
|
static blk64_t reserved_blocks;
|
2005-07-07 00:50:08 +08:00
|
|
|
static double reserved_ratio;
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
static unsigned long resgid, resuid;
|
|
|
|
static unsigned short errors;
|
2001-01-09 08:16:26 +08:00
|
|
|
static int open_flag;
|
|
|
|
static char *features_cmd;
|
2002-10-16 05:43:43 +08:00
|
|
|
static char *mntopts_cmd;
|
2008-02-19 11:56:25 +08:00
|
|
|
static int stride, stripe_width;
|
|
|
|
static int stride_set, stripe_width_set;
|
2008-01-27 08:06:35 +08:00
|
|
|
static char *extended_cmd;
|
2008-06-07 23:51:33 +08:00
|
|
|
static unsigned long new_inode_size;
|
2011-07-05 08:14:35 +08:00
|
|
|
static char *ext_mount_opts;
|
2011-07-21 02:40:05 +08:00
|
|
|
static int usrquota, grpquota;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
int journal_size, journal_flags;
|
|
|
|
char *journal_device;
|
|
|
|
|
2007-08-13 18:26:24 +08:00
|
|
|
static struct list_head blk_move_list;
|
|
|
|
|
|
|
|
struct blk_move {
|
|
|
|
struct list_head list;
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t old_loc;
|
|
|
|
blk64_t new_loc;
|
2007-08-13 18:26:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
static const char *please_fsck = N_("Please run e2fsck on the filesystem.\n");
|
1997-04-29 22:53:37 +08:00
|
|
|
|
2009-04-22 21:18:30 +08:00
|
|
|
#ifdef CONFIG_BUILD_FINDFS
|
2002-10-14 11:56:28 +08:00
|
|
|
void do_findfs(int argc, char **argv);
|
2009-04-22 21:18:30 +08:00
|
|
|
#endif
|
2002-10-14 11:56:28 +08:00
|
|
|
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
static void usage(void)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
2001-01-01 23:26:58 +08:00
|
|
|
fprintf(stderr,
|
2005-06-20 20:35:27 +08:00
|
|
|
_("Usage: %s [-c max_mounts_count] [-e errors_behavior] "
|
2001-01-01 23:26:58 +08:00
|
|
|
"[-g group]\n"
|
2008-02-29 10:26:01 +08:00
|
|
|
"\t[-i interval[d|m|w]] [-j] [-J journal_options] [-l]\n"
|
|
|
|
"\t[-m reserved_blocks_percent] "
|
|
|
|
"[-o [^]mount_options[,...]] \n"
|
|
|
|
"\t[-r reserved_blocks_count] [-u user] [-C mount_count] "
|
|
|
|
"[-L volume_label]\n"
|
2008-01-27 08:06:35 +08:00
|
|
|
"\t[-M last_mounted_dir] [-O [^]feature[,...]]\n"
|
|
|
|
"\t[-E extended-option[,...]] [-T last_check_time] "
|
2007-08-13 18:26:24 +08:00
|
|
|
"[-U UUID]\n\t[ -I new_inode_size ] device\n"), program_name);
|
2009-01-20 15:34:39 +08:00
|
|
|
exit(1);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
1999-10-23 09:04:50 +08:00
|
|
|
static __u32 ok_features[3] = {
|
2008-02-28 04:01:19 +08:00
|
|
|
/* Compat */
|
2002-09-23 03:37:40 +08:00
|
|
|
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
|
2008-02-28 04:01:19 +08:00
|
|
|
EXT2_FEATURE_COMPAT_DIR_INDEX,
|
|
|
|
/* Incompat */
|
2008-02-28 07:53:34 +08:00
|
|
|
EXT2_FEATURE_INCOMPAT_FILETYPE |
|
|
|
|
EXT3_FEATURE_INCOMPAT_EXTENTS |
|
2007-08-14 12:32:57 +08:00
|
|
|
EXT4_FEATURE_INCOMPAT_FLEX_BG,
|
2008-02-28 04:01:19 +08:00
|
|
|
/* R/O compat */
|
|
|
|
EXT2_FEATURE_RO_COMPAT_LARGE_FILE |
|
2008-07-10 22:49:59 +08:00
|
|
|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
|
|
|
|
EXT4_FEATURE_RO_COMPAT_DIR_NLINK|
|
|
|
|
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|
|
2007-10-22 10:03:41 +08:00
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM |
|
2011-07-21 02:40:05 +08:00
|
|
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER |
|
|
|
|
EXT4_FEATURE_RO_COMPAT_QUOTA
|
1999-10-23 09:04:50 +08:00
|
|
|
};
|
|
|
|
|
2008-02-27 03:27:57 +08:00
|
|
|
static __u32 clear_ok_features[3] = {
|
2008-02-28 04:01:19 +08:00
|
|
|
/* Compat */
|
2008-02-27 03:27:57 +08:00
|
|
|
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
|
2008-02-27 06:31:06 +08:00
|
|
|
EXT2_FEATURE_COMPAT_RESIZE_INODE |
|
2008-02-28 04:01:19 +08:00
|
|
|
EXT2_FEATURE_COMPAT_DIR_INDEX,
|
|
|
|
/* Incompat */
|
2008-02-28 07:53:34 +08:00
|
|
|
EXT2_FEATURE_INCOMPAT_FILETYPE |
|
|
|
|
EXT4_FEATURE_INCOMPAT_FLEX_BG,
|
2008-02-28 04:01:19 +08:00
|
|
|
/* R/O compat */
|
2007-10-22 10:03:41 +08:00
|
|
|
EXT2_FEATURE_RO_COMPAT_LARGE_FILE |
|
2008-07-10 22:49:59 +08:00
|
|
|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
|
|
|
|
EXT4_FEATURE_RO_COMPAT_DIR_NLINK|
|
|
|
|
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|
|
2011-07-21 02:40:05 +08:00
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM |
|
|
|
|
EXT4_FEATURE_RO_COMPAT_QUOTA
|
1999-10-23 09:04:50 +08:00
|
|
|
};
|
|
|
|
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
/*
|
|
|
|
* Remove an external journal from the filesystem
|
|
|
|
*/
|
|
|
|
static void remove_journal_device(ext2_filsys fs)
|
|
|
|
{
|
2001-12-17 12:23:37 +08:00
|
|
|
char *journal_path;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
ext2_filsys jfs;
|
|
|
|
char buf[1024];
|
|
|
|
journal_superblock_t *jsb;
|
|
|
|
int i, nr_users;
|
|
|
|
errcode_t retval;
|
2001-04-24 04:58:03 +08:00
|
|
|
int commit_remove_journal = 0;
|
2003-05-06 00:08:47 +08:00
|
|
|
io_manager io_ptr;
|
2001-04-24 04:58:03 +08:00
|
|
|
|
|
|
|
if (f_flag)
|
|
|
|
commit_remove_journal = 1; /* force removal even if error */
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
|
2001-08-17 17:48:11 +08:00
|
|
|
uuid_unparse(fs->super->s_journal_uuid, buf);
|
2003-03-02 08:29:01 +08:00
|
|
|
journal_path = blkid_get_devname(NULL, "UUID", buf);
|
2001-08-17 17:48:11 +08:00
|
|
|
|
2001-12-17 12:23:37 +08:00
|
|
|
if (!journal_path) {
|
|
|
|
journal_path =
|
2001-08-17 17:48:11 +08:00
|
|
|
ext2fs_find_block_device(fs->super->s_journal_dev);
|
2001-12-17 12:23:37 +08:00
|
|
|
if (!journal_path)
|
2011-09-25 01:17:05 +08:00
|
|
|
goto no_valid_journal;
|
2001-08-17 17:48:11 +08:00
|
|
|
}
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
|
2003-05-06 00:08:47 +08:00
|
|
|
#ifdef CONFIG_TESTIO_DEBUG
|
2008-09-01 23:17:29 +08:00
|
|
|
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
|
|
|
|
io_ptr = test_io_manager;
|
|
|
|
test_io_backing_manager = unix_io_manager;
|
|
|
|
} else
|
2003-05-06 00:08:47 +08:00
|
|
|
#endif
|
2008-09-01 23:17:29 +08:00
|
|
|
io_ptr = unix_io_manager;
|
2001-12-17 12:23:37 +08:00
|
|
|
retval = ext2fs_open(journal_path, EXT2_FLAG_RW|
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
|
2003-05-06 00:08:47 +08:00
|
|
|
fs->blocksize, io_ptr, &jfs);
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while trying to open external journal"));
|
2001-04-24 04:58:03 +08:00
|
|
|
goto no_valid_journal;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
if (!(jfs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
|
2001-08-16 07:17:37 +08:00
|
|
|
fprintf(stderr, _("%s is not a journal device.\n"),
|
2001-12-17 12:23:37 +08:00
|
|
|
journal_path);
|
2001-04-24 04:58:03 +08:00
|
|
|
goto no_valid_journal;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the journal superblock */
|
2009-09-08 09:14:24 +08:00
|
|
|
if ((retval = io_channel_read_blk64(jfs->io, 1, -1024, buf))) {
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while reading journal superblock"));
|
2001-04-24 04:58:03 +08:00
|
|
|
goto no_valid_journal;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
jsb = (journal_superblock_t *) buf;
|
|
|
|
if ((jsb->s_header.h_magic != (unsigned) ntohl(JFS_MAGIC_NUMBER)) ||
|
|
|
|
(jsb->s_header.h_blocktype != (unsigned) ntohl(JFS_SUPERBLOCK_V2))) {
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("Journal superblock not found!\n"), stderr);
|
2001-04-24 04:58:03 +08:00
|
|
|
goto no_valid_journal;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the filesystem UUID */
|
|
|
|
nr_users = ntohl(jsb->s_nr_users);
|
2009-01-20 15:34:39 +08:00
|
|
|
for (i = 0; i < nr_users; i++) {
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
if (memcmp(fs->super->s_uuid,
|
|
|
|
&jsb->s_users[i*16], 16) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= nr_users) {
|
2008-08-28 11:07:54 +08:00
|
|
|
fputs(_("Filesystem's UUID not found on journal device.\n"),
|
2003-12-07 14:28:50 +08:00
|
|
|
stderr);
|
2001-04-24 04:58:03 +08:00
|
|
|
commit_remove_journal = 1;
|
|
|
|
goto no_valid_journal;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
nr_users--;
|
2009-01-20 15:34:39 +08:00
|
|
|
for (i = 0; i < nr_users; i++)
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
memcpy(&jsb->s_users[i*16], &jsb->s_users[(i+1)*16], 16);
|
|
|
|
jsb->s_nr_users = htonl(nr_users);
|
|
|
|
|
|
|
|
/* Write back the journal superblock */
|
2009-09-08 09:14:24 +08:00
|
|
|
if ((retval = io_channel_write_blk64(jfs->io, 1, -1024, buf))) {
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
com_err(program_name, retval,
|
|
|
|
"while writing journal superblock.");
|
2001-04-24 04:58:03 +08:00
|
|
|
goto no_valid_journal;
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
|
2001-04-24 04:58:03 +08:00
|
|
|
commit_remove_journal = 1;
|
|
|
|
|
|
|
|
no_valid_journal:
|
|
|
|
if (commit_remove_journal == 0) {
|
2011-09-25 01:17:05 +08:00
|
|
|
fputs(_("Cannot locate journal device. It was NOT removed\n"
|
|
|
|
"Use -f option to remove missing journal device.\n"),
|
|
|
|
stderr);
|
2001-04-24 04:58:03 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
fs->super->s_journal_dev = 0;
|
2003-03-02 08:29:01 +08:00
|
|
|
uuid_clear(fs->super->s_journal_uuid);
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("Journal removed\n"), stdout);
|
2001-12-17 12:23:37 +08:00
|
|
|
free(journal_path);
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
}
|
|
|
|
|
2001-08-01 00:03:23 +08:00
|
|
|
/* Helper function for remove_journal_inode */
|
2010-06-14 04:00:00 +08:00
|
|
|
static int release_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
|
|
|
|
e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
|
|
|
|
blk64_t ref_block EXT2FS_ATTR((unused)),
|
|
|
|
int ref_offset EXT2FS_ATTR((unused)),
|
2003-12-07 14:28:50 +08:00
|
|
|
void *private EXT2FS_ATTR((unused)))
|
2001-08-01 00:03:23 +08:00
|
|
|
{
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t block;
|
2001-08-01 00:03:23 +08:00
|
|
|
int group;
|
|
|
|
|
|
|
|
block = *blocknr;
|
2009-08-23 09:15:30 +08:00
|
|
|
ext2fs_unmark_block_bitmap2(fs->block_map, block);
|
2009-10-26 08:50:15 +08:00
|
|
|
group = ext2fs_group_of_blk2(fs, block);
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
ext2fs_bg_free_blocks_count_set(fs, group, ext2fs_bg_free_blocks_count(fs, group) + 1);
|
2007-10-22 10:03:41 +08:00
|
|
|
ext2fs_group_desc_csum_set(fs, group);
|
2011-06-16 13:38:43 +08:00
|
|
|
ext2fs_free_blocks_count_add(fs->super, EXT2FS_CLUSTER_RATIO(fs));
|
2001-08-01 00:03:23 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the journal inode from the filesystem
|
|
|
|
*/
|
|
|
|
static void remove_journal_inode(ext2_filsys fs)
|
|
|
|
{
|
|
|
|
struct ext2_inode inode;
|
|
|
|
errcode_t retval;
|
|
|
|
ino_t ino = fs->super->s_journal_inum;
|
2008-08-28 11:07:54 +08:00
|
|
|
|
2001-08-01 00:03:23 +08:00
|
|
|
retval = ext2fs_read_inode(fs, ino, &inode);
|
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while reading journal inode"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (ino == EXT2_JOURNAL_INO) {
|
|
|
|
retval = ext2fs_read_bitmaps(fs);
|
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while reading bitmaps"));
|
|
|
|
exit(1);
|
|
|
|
}
|
2010-06-14 04:00:00 +08:00
|
|
|
retval = ext2fs_block_iterate3(fs, ino,
|
|
|
|
BLOCK_FLAG_READ_ONLY, NULL,
|
|
|
|
release_blocks_proc, NULL);
|
2001-08-01 00:03:23 +08:00
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while clearing journal inode"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
memset(&inode, 0, sizeof(inode));
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
|
|
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
|
|
|
} else
|
|
|
|
inode.i_flags &= ~EXT2_IMMUTABLE_FL;
|
|
|
|
retval = ext2fs_write_inode(fs, ino, &inode);
|
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while writing journal inode"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
fs->super->s_journal_inum = 0;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
|
2002-10-16 05:43:43 +08:00
|
|
|
/*
|
|
|
|
* Update the default mount options
|
|
|
|
*/
|
|
|
|
static void update_mntopts(ext2_filsys fs, char *mntopts)
|
|
|
|
{
|
2009-01-20 15:34:39 +08:00
|
|
|
struct ext2_super_block *sb = fs->super;
|
2002-10-16 05:43:43 +08:00
|
|
|
|
|
|
|
if (e2p_edit_mntopts(mntopts, &sb->s_default_mount_opts, ~0)) {
|
|
|
|
fprintf(stderr, _("Invalid mount option set: %s\n"),
|
|
|
|
mntopts);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
|
|
|
|
2010-05-20 00:14:39 +08:00
|
|
|
static void request_fsck_afterwards(ext2_filsys fs)
|
|
|
|
{
|
|
|
|
static int requested = 0;
|
|
|
|
|
|
|
|
if (requested++)
|
|
|
|
return;
|
|
|
|
fs->super->s_state &= ~EXT2_VALID_FS;
|
|
|
|
printf("\n%s\n", _(please_fsck));
|
|
|
|
if (mount_flags & EXT2_MF_READONLY)
|
|
|
|
printf(_("(and reboot afterwards!)\n"));
|
|
|
|
}
|
|
|
|
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
/*
|
|
|
|
* Update the feature set as provided by the user.
|
|
|
|
*/
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-12 00:08:23 +08:00
|
|
|
static void update_feature_set(ext2_filsys fs, char *features)
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
{
|
2009-01-20 15:34:39 +08:00
|
|
|
struct ext2_super_block *sb = fs->super;
|
2010-05-20 00:14:39 +08:00
|
|
|
struct ext2_group_desc *gd;
|
2008-02-27 04:08:14 +08:00
|
|
|
__u32 old_features[3];
|
2010-05-20 00:14:39 +08:00
|
|
|
int i, type_err;
|
2008-02-27 03:27:57 +08:00
|
|
|
unsigned int mask_err;
|
2004-04-07 21:27:36 +08:00
|
|
|
|
2008-02-27 04:08:14 +08:00
|
|
|
#define FEATURE_ON(type, mask) (!(old_features[(type)] & (mask)) && \
|
|
|
|
((&sb->s_feature_compat)[(type)] & (mask)))
|
|
|
|
#define FEATURE_OFF(type, mask) ((old_features[(type)] & (mask)) && \
|
|
|
|
!((&sb->s_feature_compat)[(type)] & (mask)))
|
|
|
|
#define FEATURE_CHANGED(type, mask) ((mask) & \
|
|
|
|
(old_features[(type)] ^ (&sb->s_feature_compat)[(type)]))
|
|
|
|
|
|
|
|
old_features[E2P_FEATURE_COMPAT] = sb->s_feature_compat;
|
|
|
|
old_features[E2P_FEATURE_INCOMPAT] = sb->s_feature_incompat;
|
|
|
|
old_features[E2P_FEATURE_RO_INCOMPAT] = sb->s_feature_ro_compat;
|
|
|
|
|
2008-02-27 03:27:57 +08:00
|
|
|
if (e2p_edit_feature2(features, &sb->s_feature_compat,
|
|
|
|
ok_features, clear_ok_features,
|
|
|
|
&type_err, &mask_err)) {
|
|
|
|
if (!mask_err)
|
|
|
|
fprintf(stderr,
|
|
|
|
_("Invalid filesystem option set: %s\n"),
|
|
|
|
features);
|
|
|
|
else if (type_err & E2P_FEATURE_NEGATE_FLAG)
|
|
|
|
fprintf(stderr, _("Clearing filesystem feature '%s' "
|
|
|
|
"not supported.\n"),
|
|
|
|
e2p_feature2string(type_err &
|
|
|
|
E2P_FEATURE_TYPE_MASK,
|
|
|
|
mask_err));
|
|
|
|
else
|
|
|
|
fprintf(stderr, _("Setting filesystem feature '%s' "
|
|
|
|
"not supported.\n"),
|
|
|
|
e2p_feature2string(type_err, mask_err));
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-02-27 04:08:14 +08:00
|
|
|
|
|
|
|
if (FEATURE_OFF(E2P_FEATURE_COMPAT, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
if ((mount_flags & EXT2_MF_MOUNTED) &&
|
|
|
|
!(mount_flags & EXT2_MF_READONLY)) {
|
2008-07-10 22:49:59 +08:00
|
|
|
fputs(_("The has_journal feature may only be "
|
2003-12-07 14:28:50 +08:00
|
|
|
"cleared when the filesystem is\n"
|
|
|
|
"unmounted or mounted "
|
|
|
|
"read-only.\n"), stderr);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (sb->s_feature_incompat &
|
|
|
|
EXT3_FEATURE_INCOMPAT_RECOVER) {
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("The needs_recovery flag is set. "
|
|
|
|
"Please run e2fsck before clearing\n"
|
|
|
|
"the has_journal flag.\n"), stderr);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (sb->s_journal_inum) {
|
2001-08-01 00:03:23 +08:00
|
|
|
remove_journal_inode(fs);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
2001-07-31 04:31:30 +08:00
|
|
|
if (sb->s_journal_dev) {
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
remove_journal_device(fs);
|
2001-07-31 04:31:30 +08:00
|
|
|
}
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
2008-02-27 04:08:14 +08:00
|
|
|
|
|
|
|
if (FEATURE_ON(E2P_FEATURE_COMPAT, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
/*
|
|
|
|
* If adding a journal flag, let the create journal
|
2008-07-18 05:58:35 +08:00
|
|
|
* code below handle setting the flag and creating the
|
|
|
|
* journal. We supply a default size if necessary.
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
*/
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
if (!journal_size)
|
|
|
|
journal_size = -1;
|
2001-01-15 00:25:58 +08:00
|
|
|
sb->s_feature_compat &= ~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
2008-02-27 04:08:14 +08:00
|
|
|
|
|
|
|
if (FEATURE_ON(E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX)) {
|
2002-09-23 03:37:40 +08:00
|
|
|
if (!sb->s_def_hash_version)
|
2008-08-29 11:09:35 +08:00
|
|
|
sb->s_def_hash_version = EXT2_HASH_HALF_MD4;
|
2002-09-23 03:37:40 +08:00
|
|
|
if (uuid_is_null((unsigned char *) sb->s_hash_seed))
|
|
|
|
uuid_generate((unsigned char *) sb->s_hash_seed);
|
|
|
|
}
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
|
2008-02-28 07:53:34 +08:00
|
|
|
if (FEATURE_OFF(E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
|
2007-08-14 12:32:57 +08:00
|
|
|
if (ext2fs_check_desc(fs)) {
|
|
|
|
fputs(_("Clearing the flex_bg flag would "
|
|
|
|
"cause the the filesystem to be\n"
|
|
|
|
"inconsistent.\n"), stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
|
2008-07-10 22:49:59 +08:00
|
|
|
if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
|
|
|
|
if ((mount_flags & EXT2_MF_MOUNTED) &&
|
|
|
|
!(mount_flags & EXT2_MF_READONLY)) {
|
|
|
|
fputs(_("The huge_file feature may only be "
|
|
|
|
"cleared when the filesystem is\n"
|
|
|
|
"unmounted or mounted "
|
|
|
|
"read-only.\n"), stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-20 00:14:39 +08:00
|
|
|
if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
|
2010-06-14 04:00:00 +08:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
|
|
|
gd = ext2fs_group_desc(fs, fs->group_desc, i);
|
2010-05-20 00:14:39 +08:00
|
|
|
gd->bg_itable_unused = 0;
|
|
|
|
gd->bg_flags = EXT2_BG_INODE_ZEROED;
|
|
|
|
ext2fs_group_desc_csum_set(fs, i);
|
|
|
|
}
|
|
|
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
|
2010-06-14 04:00:00 +08:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
|
|
|
gd = ext2fs_group_desc(fs, fs->group_desc, i);
|
2010-05-20 00:14:39 +08:00
|
|
|
if ((gd->bg_flags & EXT2_BG_INODE_ZEROED) == 0) {
|
|
|
|
/*
|
|
|
|
* XXX what we really should do is zap
|
|
|
|
* uninitialized inode tables instead.
|
|
|
|
*/
|
|
|
|
request_fsck_afterwards(fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gd->bg_itable_unused = 0;
|
|
|
|
gd->bg_flags = 0;
|
|
|
|
gd->bg_checksum = 0;
|
|
|
|
}
|
|
|
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
|
|
|
}
|
|
|
|
|
2011-07-21 02:40:05 +08:00
|
|
|
if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_QUOTA)) {
|
|
|
|
/*
|
|
|
|
* Set the Q_flag here and handle the quota options in the code
|
|
|
|
* below.
|
|
|
|
*/
|
|
|
|
if (!Q_flag) {
|
|
|
|
Q_flag = 1;
|
|
|
|
/* Enable both user quota and group quota by default */
|
|
|
|
usrquota = QOPT_ENABLE;
|
|
|
|
grpquota = QOPT_ENABLE;
|
|
|
|
}
|
|
|
|
sb->s_feature_ro_compat &= ~EXT4_FEATURE_RO_COMPAT_QUOTA;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_QUOTA)) {
|
|
|
|
/*
|
|
|
|
* Set the Q_flag here and handle the quota options in the code
|
|
|
|
* below.
|
|
|
|
*/
|
|
|
|
if (Q_flag)
|
|
|
|
fputs(_("\nWarning: '^quota' option overrides '-Q'"
|
|
|
|
"arguments.\n"), stderr);
|
|
|
|
Q_flag = 1;
|
|
|
|
/* Disable both user quota and group quota by default */
|
|
|
|
usrquota = QOPT_DISABLE;
|
|
|
|
grpquota = QOPT_DISABLE;
|
|
|
|
}
|
|
|
|
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
|
|
|
|
(sb->s_feature_compat || sb->s_feature_ro_compat ||
|
|
|
|
sb->s_feature_incompat))
|
|
|
|
ext2fs_update_dynamic_rev(fs);
|
2008-02-27 04:08:14 +08:00
|
|
|
|
|
|
|
if (FEATURE_CHANGED(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) ||
|
2008-07-10 22:49:59 +08:00
|
|
|
FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
|
2008-02-27 04:08:14 +08:00
|
|
|
FEATURE_CHANGED(E2P_FEATURE_INCOMPAT,
|
2008-02-27 06:31:06 +08:00
|
|
|
EXT2_FEATURE_INCOMPAT_FILETYPE) ||
|
|
|
|
FEATURE_CHANGED(E2P_FEATURE_COMPAT,
|
2008-02-28 04:01:19 +08:00
|
|
|
EXT2_FEATURE_COMPAT_RESIZE_INODE) ||
|
|
|
|
FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
|
2010-05-20 00:14:39 +08:00
|
|
|
EXT2_FEATURE_RO_COMPAT_LARGE_FILE))
|
|
|
|
request_fsck_afterwards(fs);
|
2008-02-27 04:08:14 +08:00
|
|
|
|
|
|
|
if ((old_features[E2P_FEATURE_COMPAT] != sb->s_feature_compat) ||
|
|
|
|
(old_features[E2P_FEATURE_INCOMPAT] != sb->s_feature_incompat) ||
|
|
|
|
(old_features[E2P_FEATURE_RO_INCOMPAT] != sb->s_feature_ro_compat))
|
2004-04-07 21:27:36 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a journal to the filesystem.
|
|
|
|
*/
|
|
|
|
static void add_journal(ext2_filsys fs)
|
|
|
|
{
|
|
|
|
unsigned long journal_blocks;
|
|
|
|
errcode_t retval;
|
2001-01-16 15:47:31 +08:00
|
|
|
ext2_filsys jfs;
|
2003-05-06 00:08:47 +08:00
|
|
|
io_manager io_ptr;
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
|
|
|
|
if (fs->super->s_feature_compat &
|
|
|
|
EXT3_FEATURE_COMPAT_HAS_JOURNAL) {
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("The filesystem already has a journal.\n"), stderr);
|
2001-08-17 17:48:11 +08:00
|
|
|
goto err;
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
|
|
|
if (journal_device) {
|
|
|
|
check_plausibility(journal_device);
|
|
|
|
check_mount(journal_device, 0, _("journal"));
|
2003-05-06 00:08:47 +08:00
|
|
|
#ifdef CONFIG_TESTIO_DEBUG
|
2008-09-01 23:17:29 +08:00
|
|
|
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
|
|
|
|
io_ptr = test_io_manager;
|
|
|
|
test_io_backing_manager = unix_io_manager;
|
|
|
|
} else
|
2003-05-06 00:08:47 +08:00
|
|
|
#endif
|
2008-09-01 23:17:29 +08:00
|
|
|
io_ptr = unix_io_manager;
|
2001-01-16 15:47:31 +08:00
|
|
|
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
|
|
|
|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
|
2003-05-06 00:08:47 +08:00
|
|
|
fs->blocksize, io_ptr, &jfs);
|
2001-01-16 15:47:31 +08:00
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
2001-04-17 09:01:49 +08:00
|
|
|
_("\n\twhile trying to open journal on %s\n"),
|
2001-01-16 15:47:31 +08:00
|
|
|
journal_device);
|
2001-08-17 17:48:11 +08:00
|
|
|
goto err;
|
2001-01-16 15:47:31 +08:00
|
|
|
}
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
printf(_("Creating journal on device %s: "),
|
|
|
|
journal_device);
|
2001-01-15 00:11:14 +08:00
|
|
|
fflush(stdout);
|
2001-08-17 17:48:11 +08:00
|
|
|
|
2001-01-16 15:47:31 +08:00
|
|
|
retval = ext2fs_add_journal_device(fs, jfs);
|
2001-08-17 17:48:11 +08:00
|
|
|
ext2fs_close(jfs);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
if (retval) {
|
2009-01-20 15:34:39 +08:00
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while adding filesystem to journal on %s"),
|
|
|
|
journal_device);
|
2001-08-17 17:48:11 +08:00
|
|
|
goto err;
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("done\n"), stdout);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
} else if (journal_size) {
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("Creating journal inode: "), stdout);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
fflush(stdout);
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
ke2fs.8.in, tune2fs.8.in: Change man paegs to document that the
journal must be bewteen 1024 and 10,240 file system blocks.
mke2fs.c, tune2fs.c: Change to use figure_journal_size()
util.c, util.h (figure_journal_size): Change journal_default_size into
routine which also converts the requested journal size into filesystem
blocks and does bounds checking to make sure the journal is sized
reasonably. Renamed function to journal_default_size.
parse_journal_opts): Remove bounds check for the journal size, since
this is now done in figure_journal_size, and based on the number of
filesystem blocks, as opposed to using the absolute size of the
journal.
2001-03-27 04:07:13 +08:00
|
|
|
journal_blocks = figure_journal_size(journal_size, fs);
|
|
|
|
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
retval = ext2fs_add_journal_inode(fs, journal_blocks,
|
|
|
|
journal_flags);
|
|
|
|
if (retval) {
|
2001-08-16 07:17:37 +08:00
|
|
|
fprintf(stderr, "\n");
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
com_err(program_name, retval,
|
2001-04-17 09:01:49 +08:00
|
|
|
_("\n\twhile trying to create journal file"));
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
exit(1);
|
2001-04-17 09:01:49 +08:00
|
|
|
} else
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("done\n"), stdout);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
/*
|
|
|
|
* If the filesystem wasn't mounted, we need to force
|
|
|
|
* the block group descriptors out.
|
|
|
|
*/
|
|
|
|
if ((mount_flags & EXT2_MF_MOUNTED) == 0)
|
|
|
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
|
|
|
}
|
2011-09-14 10:24:11 +08:00
|
|
|
print_check_message(fs->super->s_max_mnt_count,
|
|
|
|
fs->super->s_checkinterval);
|
2001-08-17 17:48:11 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
2009-02-24 01:07:50 +08:00
|
|
|
free(journal_device);
|
2001-08-17 17:48:11 +08:00
|
|
|
exit(1);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
}
|
|
|
|
|
2011-07-21 02:40:05 +08:00
|
|
|
void handle_quota_options(ext2_filsys fs)
|
|
|
|
{
|
|
|
|
quota_ctx_t qctx;
|
|
|
|
errcode_t retval;
|
|
|
|
ext2_ino_t qf_ino;
|
|
|
|
|
|
|
|
if (!usrquota && !grpquota)
|
|
|
|
/* Nothing to do. */
|
|
|
|
return;
|
|
|
|
|
|
|
|
init_quota_context(&qctx, fs, -1);
|
|
|
|
|
|
|
|
if (usrquota == QOPT_ENABLE && !fs->super->s_usr_quota_inum) {
|
|
|
|
if ((qf_ino = quota_file_exists(fs, USRQUOTA, QFMT_VFS_V1)) > 0)
|
|
|
|
set_sb_quota_inum(fs, qf_ino, USRQUOTA);
|
|
|
|
else
|
|
|
|
write_quota_inode(qctx, USRQUOTA);
|
|
|
|
} else if (usrquota == QOPT_DISABLE) {
|
|
|
|
remove_quota_inode(fs, USRQUOTA);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grpquota == QOPT_ENABLE && !fs->super->s_grp_quota_inum) {
|
|
|
|
if ((qf_ino = quota_file_exists(fs, GRPQUOTA, QFMT_VFS_V1)) > 0)
|
|
|
|
set_sb_quota_inum(fs, qf_ino, GRPQUOTA);
|
|
|
|
else
|
|
|
|
write_quota_inode(qctx, GRPQUOTA);
|
|
|
|
} else if (grpquota == QOPT_DISABLE) {
|
|
|
|
remove_quota_inode(fs, GRPQUOTA);
|
|
|
|
}
|
|
|
|
|
|
|
|
release_quota_context(&qctx);
|
|
|
|
|
|
|
|
if ((usrquota == QOPT_ENABLE) || (grpquota == QOPT_ENABLE)) {
|
|
|
|
fs->super->s_feature_ro_compat |= EXT4_FEATURE_RO_COMPAT_QUOTA;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else if ((usrquota == QOPT_DISABLE) && (grpquota == QOPT_DISABLE)) {
|
|
|
|
fs->super->s_feature_ro_compat &= ~EXT4_FEATURE_RO_COMPAT_QUOTA;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void parse_quota_opts(const char *opts)
|
|
|
|
{
|
|
|
|
char *buf, *token, *next, *p, *arg;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = strlen(opts);
|
|
|
|
buf = malloc(len+1);
|
|
|
|
if (!buf) {
|
|
|
|
fputs(_("Couldn't allocate memory to parse quota "
|
|
|
|
"options!\n"), stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
strcpy(buf, opts);
|
|
|
|
for (token = buf; token && *token; token = next) {
|
|
|
|
p = strchr(token, ',');
|
|
|
|
next = 0;
|
|
|
|
if (p) {
|
|
|
|
*p = 0;
|
|
|
|
next = p+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(token, "usrquota") == 0) {
|
|
|
|
usrquota = QOPT_ENABLE;
|
|
|
|
} else if (strcmp(token, "^usrquota") == 0) {
|
|
|
|
usrquota = QOPT_DISABLE;
|
|
|
|
} else if (strcmp(token, "grpquota") == 0) {
|
|
|
|
grpquota = QOPT_ENABLE;
|
|
|
|
} else if (strcmp(token, "^grpquota") == 0) {
|
|
|
|
grpquota = QOPT_DISABLE;
|
|
|
|
} else {
|
|
|
|
fputs(_("\nBad quota options specified.\n\n"
|
|
|
|
"Following valid quota options are available "
|
|
|
|
"(pass by separating with comma):\n"
|
|
|
|
"\t[^]usrquota\n"
|
|
|
|
"\t[^]grpquota\n"
|
|
|
|
"\n\n"), stderr);
|
|
|
|
free(buf);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-09 08:16:26 +08:00
|
|
|
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-12 00:08:23 +08:00
|
|
|
static void parse_e2label_options(int argc, char ** argv)
|
2001-01-09 08:16:26 +08:00
|
|
|
{
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("Usage: e2label device [newlabel]\n"), stderr);
|
2001-01-09 08:16:26 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
2004-12-01 03:07:11 +08:00
|
|
|
io_options = strchr(argv[1], '?');
|
|
|
|
if (io_options)
|
|
|
|
*io_options++ = 0;
|
2003-03-07 01:58:33 +08:00
|
|
|
device_name = blkid_get_devname(NULL, argv[1], NULL);
|
2003-11-21 22:10:29 +08:00
|
|
|
if (!device_name) {
|
2008-08-28 11:07:54 +08:00
|
|
|
com_err("e2label", 0, _("Unable to resolve '%s'"),
|
2003-11-21 22:10:29 +08:00
|
|
|
argv[1]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2008-07-10 22:49:59 +08:00
|
|
|
open_flag = EXT2_FLAG_JOURNAL_DEV_OK;
|
2001-01-09 08:16:26 +08:00
|
|
|
if (argc == 3) {
|
2008-02-10 11:22:38 +08:00
|
|
|
open_flag |= EXT2_FLAG_RW;
|
2001-01-09 08:16:26 +08:00
|
|
|
L_flag = 1;
|
|
|
|
new_label = argv[2];
|
2008-08-28 11:07:54 +08:00
|
|
|
} else
|
2001-01-09 08:16:26 +08:00
|
|
|
print_label++;
|
|
|
|
}
|
|
|
|
|
2001-12-26 21:58:01 +08:00
|
|
|
static time_t parse_time(char *str)
|
|
|
|
{
|
|
|
|
struct tm ts;
|
|
|
|
|
|
|
|
if (strcmp(str, "now") == 0) {
|
|
|
|
return (time(0));
|
|
|
|
}
|
|
|
|
memset(&ts, 0, sizeof(ts));
|
2003-05-04 04:40:09 +08:00
|
|
|
#ifdef HAVE_STRPTIME
|
2004-12-22 09:40:08 +08:00
|
|
|
strptime(str, "%Y%m%d%H%M%S", &ts);
|
2003-05-04 04:40:09 +08:00
|
|
|
#else
|
2004-12-22 09:40:08 +08:00
|
|
|
sscanf(str, "%4d%2d%2d%2d%2d%2d", &ts.tm_year, &ts.tm_mon,
|
2003-05-04 04:40:09 +08:00
|
|
|
&ts.tm_mday, &ts.tm_hour, &ts.tm_min, &ts.tm_sec);
|
|
|
|
ts.tm_year -= 1900;
|
|
|
|
ts.tm_mon -= 1;
|
|
|
|
if (ts.tm_year < 0 || ts.tm_mon < 0 || ts.tm_mon > 11 ||
|
|
|
|
ts.tm_mday < 0 || ts.tm_mday > 31 || ts.tm_hour > 23 ||
|
|
|
|
ts.tm_min > 59 || ts.tm_sec > 61)
|
|
|
|
ts.tm_mday = 0;
|
|
|
|
#endif
|
2001-12-26 21:58:01 +08:00
|
|
|
if (ts.tm_mday == 0) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("Couldn't parse date/time specifier: %s"),
|
|
|
|
str);
|
|
|
|
usage();
|
|
|
|
}
|
2008-03-21 21:10:09 +08:00
|
|
|
ts.tm_isdst = -1;
|
2001-12-26 21:58:01 +08:00
|
|
|
return (mktime(&ts));
|
|
|
|
}
|
2001-01-09 08:16:26 +08:00
|
|
|
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-12 00:08:23 +08:00
|
|
|
static void parse_tune2fs_options(int argc, char **argv)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
1997-10-25 11:49:49 +08:00
|
|
|
int c;
|
2009-01-20 15:34:39 +08:00
|
|
|
char *tmp;
|
|
|
|
struct group *gr;
|
|
|
|
struct passwd *pw;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2008-07-10 22:49:59 +08:00
|
|
|
open_flag = 0;
|
2008-02-10 11:22:38 +08:00
|
|
|
|
2001-08-28 00:44:23 +08:00
|
|
|
printf("tune2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);
|
2011-07-21 02:40:05 +08:00
|
|
|
while ((c = getopt(argc, argv, "c:e:fg:i:jlm:o:r:s:u:C:E:I:J:L:M:O:Q:T:U:")) != EOF)
|
2009-01-20 15:34:39 +08:00
|
|
|
switch (c) {
|
|
|
|
case 'c':
|
|
|
|
max_mount_count = strtol(optarg, &tmp, 0);
|
|
|
|
if (*tmp || max_mount_count > 16000) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad mounts count - %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
if (max_mount_count == 0)
|
|
|
|
max_mount_count = -1;
|
|
|
|
c_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
mount_count = strtoul(optarg, &tmp, 0);
|
|
|
|
if (*tmp || mount_count > 16000) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad mounts count - %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
C_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
if (strcmp(optarg, "continue") == 0)
|
|
|
|
errors = EXT2_ERRORS_CONTINUE;
|
|
|
|
else if (strcmp(optarg, "remount-ro") == 0)
|
|
|
|
errors = EXT2_ERRORS_RO;
|
|
|
|
else if (strcmp(optarg, "panic") == 0)
|
|
|
|
errors = EXT2_ERRORS_PANIC;
|
|
|
|
else {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad error behavior - %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
e_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
extended_cmd = optarg;
|
|
|
|
open_flag |= EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'f': /* Force */
|
|
|
|
f_flag = 1;
|
|
|
|
break;
|
|
|
|
case 'g':
|
|
|
|
resgid = strtoul(optarg, &tmp, 0);
|
|
|
|
if (*tmp) {
|
|
|
|
gr = getgrnam(optarg);
|
|
|
|
if (gr == NULL)
|
|
|
|
tmp = optarg;
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
else {
|
2009-01-20 15:34:39 +08:00
|
|
|
resgid = gr->gr_gid;
|
|
|
|
*tmp = 0;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
2009-01-20 15:34:39 +08:00
|
|
|
}
|
|
|
|
if (*tmp) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad gid/group name - %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
g_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
interval = strtoul(optarg, &tmp, 0);
|
|
|
|
switch (*tmp) {
|
|
|
|
case 's':
|
|
|
|
tmp++;
|
1997-04-26 21:34:30 +08:00
|
|
|
break;
|
2009-01-20 15:34:39 +08:00
|
|
|
case '\0':
|
|
|
|
case 'd':
|
|
|
|
case 'D': /* days */
|
|
|
|
interval *= 86400;
|
|
|
|
if (*tmp != '\0')
|
1997-04-29 22:53:37 +08:00
|
|
|
tmp++;
|
|
|
|
break;
|
1997-04-26 21:21:57 +08:00
|
|
|
case 'm':
|
2009-01-20 15:34:39 +08:00
|
|
|
case 'M': /* months! */
|
|
|
|
interval *= 86400 * 30;
|
|
|
|
tmp++;
|
1997-04-26 21:21:57 +08:00
|
|
|
break;
|
2009-01-20 15:34:39 +08:00
|
|
|
case 'w':
|
|
|
|
case 'W': /* weeks */
|
|
|
|
interval *= 86400 * 7;
|
|
|
|
tmp++;
|
2002-10-16 05:43:43 +08:00
|
|
|
break;
|
2009-01-20 15:34:39 +08:00
|
|
|
}
|
|
|
|
if (*tmp) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad interval - %s"), optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
i_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'j':
|
|
|
|
if (!journal_size)
|
|
|
|
journal_size = -1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'J':
|
|
|
|
parse_journal_opts(optarg);
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
l_flag = 1;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
new_label = optarg;
|
|
|
|
L_flag = 1;
|
|
|
|
open_flag |= EXT2_FLAG_RW |
|
|
|
|
EXT2_FLAG_JOURNAL_DEV_OK;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
reserved_ratio = strtod(optarg, &tmp);
|
2009-03-06 15:23:59 +08:00
|
|
|
if (*tmp || reserved_ratio > 50 ||
|
|
|
|
reserved_ratio < 0) {
|
2009-01-20 15:34:39 +08:00
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad reserved block ratio - %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
m_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
new_last_mounted = optarg;
|
|
|
|
M_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
if (mntopts_cmd) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("-o may only be specified once"));
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
mntopts_cmd = optarg;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'O':
|
|
|
|
if (features_cmd) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("-O may only be specified once"));
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
features_cmd = optarg;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
2011-07-21 02:40:05 +08:00
|
|
|
case 'Q':
|
|
|
|
Q_flag = 1;
|
|
|
|
parse_quota_opts(optarg);
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
2009-01-20 15:34:39 +08:00
|
|
|
case 'r':
|
|
|
|
reserved_blocks = strtoul(optarg, &tmp, 0);
|
|
|
|
if (*tmp) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad reserved blocks count - %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
r_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 's': /* Deprecated */
|
|
|
|
s_flag = atoi(optarg);
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
T_flag = 1;
|
|
|
|
last_check_time = parse_time(optarg);
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
resuid = strtoul(optarg, &tmp, 0);
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
if (*tmp) {
|
2009-01-20 15:34:39 +08:00
|
|
|
pw = getpwnam(optarg);
|
1997-04-26 21:34:30 +08:00
|
|
|
if (pw == NULL)
|
|
|
|
tmp = optarg;
|
1997-04-26 22:00:26 +08:00
|
|
|
else {
|
1997-04-26 21:34:30 +08:00
|
|
|
resuid = pw->pw_uid;
|
1997-04-26 22:00:26 +08:00
|
|
|
*tmp = 0;
|
|
|
|
}
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
if (*tmp) {
|
2009-01-20 15:34:39 +08:00
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad uid/user name - %s"),
|
|
|
|
optarg);
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
usage();
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
|
|
|
u_flag = 1;
|
1997-04-29 22:53:37 +08:00
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
break;
|
2009-01-20 15:34:39 +08:00
|
|
|
case 'U':
|
|
|
|
new_UUID = optarg;
|
|
|
|
U_flag = 1;
|
|
|
|
open_flag = EXT2_FLAG_RW |
|
|
|
|
EXT2_FLAG_JOURNAL_DEV_OK;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
new_inode_size = strtoul(optarg, &tmp, 0);
|
|
|
|
if (*tmp) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("bad inode size - %s"),
|
|
|
|
optarg);
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
usage();
|
2009-01-20 15:34:39 +08:00
|
|
|
}
|
|
|
|
if (!((new_inode_size &
|
|
|
|
(new_inode_size - 1)) == 0)) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("Inode size must be a "
|
|
|
|
"power of two- %s"),
|
|
|
|
optarg);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
open_flag = EXT2_FLAG_RW;
|
|
|
|
I_flag = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
if (optind < argc - 1 || optind == argc)
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
usage();
|
1997-04-29 22:53:37 +08:00
|
|
|
if (!open_flag && !l_flag)
|
|
|
|
usage();
|
2004-12-01 03:07:11 +08:00
|
|
|
io_options = strchr(argv[optind], '?');
|
|
|
|
if (io_options)
|
|
|
|
*io_options++ = 0;
|
2003-03-07 01:58:33 +08:00
|
|
|
device_name = blkid_get_devname(NULL, argv[optind], NULL);
|
2003-11-21 22:10:29 +08:00
|
|
|
if (!device_name) {
|
2008-08-28 11:07:54 +08:00
|
|
|
com_err("tune2fs", 0, _("Unable to resolve '%s'"),
|
2003-11-21 22:10:29 +08:00
|
|
|
argv[optind]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-08-18 11:01:22 +08:00
|
|
|
}
|
|
|
|
|
2009-04-22 21:18:30 +08:00
|
|
|
#ifdef CONFIG_BUILD_FINDFS
|
2002-10-14 11:56:28 +08:00
|
|
|
void do_findfs(int argc, char **argv)
|
2002-08-18 11:01:22 +08:00
|
|
|
{
|
|
|
|
char *dev;
|
2001-01-09 08:16:26 +08:00
|
|
|
|
2002-08-18 11:01:22 +08:00
|
|
|
if ((argc != 2) ||
|
|
|
|
(strncmp(argv[1], "LABEL=", 6) && strncmp(argv[1], "UUID=", 5))) {
|
|
|
|
fprintf(stderr, "Usage: findfs LABEL=<label>|UUID=<uuid>\n");
|
|
|
|
exit(2);
|
|
|
|
}
|
2003-03-02 08:29:01 +08:00
|
|
|
dev = blkid_get_devname(NULL, argv[1], NULL);
|
2002-08-18 11:01:22 +08:00
|
|
|
if (!dev) {
|
2008-08-28 11:07:54 +08:00
|
|
|
com_err("findfs", 0, _("Unable to resolve '%s'"),
|
2002-08-18 11:01:22 +08:00
|
|
|
argv[1]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
puts(dev);
|
|
|
|
exit(0);
|
|
|
|
}
|
2009-04-22 21:18:30 +08:00
|
|
|
#endif
|
2001-01-09 08:16:26 +08:00
|
|
|
|
2008-01-27 08:06:35 +08:00
|
|
|
static void parse_extended_opts(ext2_filsys fs, const char *opts)
|
|
|
|
{
|
|
|
|
char *buf, *token, *next, *p, *arg;
|
2008-08-30 09:21:19 +08:00
|
|
|
int len, hash_alg;
|
2008-01-27 08:06:35 +08:00
|
|
|
int r_usage = 0;
|
|
|
|
|
|
|
|
len = strlen(opts);
|
|
|
|
buf = malloc(len+1);
|
|
|
|
if (!buf) {
|
|
|
|
fprintf(stderr,
|
|
|
|
_("Couldn't allocate memory to parse options!\n"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
strcpy(buf, opts);
|
|
|
|
for (token = buf; token && *token; token = next) {
|
|
|
|
p = strchr(token, ',');
|
|
|
|
next = 0;
|
|
|
|
if (p) {
|
|
|
|
*p = 0;
|
|
|
|
next = p+1;
|
|
|
|
}
|
|
|
|
arg = strchr(token, '=');
|
|
|
|
if (arg) {
|
|
|
|
*arg = 0;
|
|
|
|
arg++;
|
|
|
|
}
|
|
|
|
if (!strcmp(token, "test_fs")) {
|
|
|
|
fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
|
|
|
|
printf("Setting test filesystem flag\n");
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else if (!strcmp(token, "^test_fs")) {
|
|
|
|
fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS;
|
|
|
|
printf("Clearing test filesystem flag\n");
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
2008-02-19 11:56:25 +08:00
|
|
|
} else if (strcmp(token, "stride") == 0) {
|
|
|
|
if (!arg) {
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
stride = strtoul(arg, &p, 0);
|
2011-07-05 07:37:11 +08:00
|
|
|
if (*p) {
|
2008-02-19 11:56:25 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
_("Invalid RAID stride: %s\n"),
|
|
|
|
arg);
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
stride_set = 1;
|
|
|
|
} else if (strcmp(token, "stripe-width") == 0 ||
|
|
|
|
strcmp(token, "stripe_width") == 0) {
|
|
|
|
if (!arg) {
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
stripe_width = strtoul(arg, &p, 0);
|
2011-07-05 07:37:11 +08:00
|
|
|
if (*p) {
|
2008-02-19 11:56:25 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
_("Invalid RAID stripe-width: %s\n"),
|
|
|
|
arg);
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
stripe_width_set = 1;
|
2008-08-30 09:21:19 +08:00
|
|
|
} else if (strcmp(token, "hash_alg") == 0 ||
|
|
|
|
strcmp(token, "hash-alg") == 0) {
|
|
|
|
if (!arg) {
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
hash_alg = e2p_string2hash(arg);
|
|
|
|
if (hash_alg < 0) {
|
2009-01-20 15:34:39 +08:00
|
|
|
fprintf(stderr,
|
2008-08-30 09:21:19 +08:00
|
|
|
_("Invalid hash algorithm: %s\n"),
|
|
|
|
arg);
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
fs->super->s_def_hash_version = hash_alg;
|
|
|
|
printf(_("Setting default hash algorithm "
|
2009-01-20 15:34:39 +08:00
|
|
|
"to %s (%d)\n"),
|
2008-08-30 09:21:19 +08:00
|
|
|
arg, hash_alg);
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
2011-07-05 08:14:35 +08:00
|
|
|
} else if (!strcmp(token, "mount_opts")) {
|
2010-09-19 07:38:22 +08:00
|
|
|
if (!arg) {
|
|
|
|
r_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strlen(arg) >= sizeof(fs->super->s_mount_opts)) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"Extended mount options too long\n");
|
|
|
|
continue;
|
|
|
|
}
|
2011-07-05 08:14:35 +08:00
|
|
|
ext_mount_opts = strdup(arg);
|
2008-08-28 11:07:54 +08:00
|
|
|
} else
|
2008-01-27 08:06:35 +08:00
|
|
|
r_usage++;
|
|
|
|
}
|
|
|
|
if (r_usage) {
|
|
|
|
fprintf(stderr, _("\nBad options specified.\n\n"
|
|
|
|
"Extended options are separated by commas, "
|
|
|
|
"and may take an argument which\n"
|
|
|
|
"\tis set off by an equals ('=') sign.\n\n"
|
|
|
|
"Valid extended options are:\n"
|
2011-07-05 08:14:35 +08:00
|
|
|
"\thash_alg=<hash algorithm>\n"
|
|
|
|
"\tmount_opts=<extended default mount options>\n"
|
2008-02-19 11:56:25 +08:00
|
|
|
"\tstride=<RAID per-disk chunk size in blocks>\n"
|
2008-08-30 09:21:19 +08:00
|
|
|
"\tstripe_width=<RAID stride*data disks in blocks>\n"
|
2008-01-27 08:06:35 +08:00
|
|
|
"\ttest_fs\n"
|
|
|
|
"\t^test_fs\n"));
|
|
|
|
free(buf);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
free(buf);
|
2008-08-28 11:07:54 +08:00
|
|
|
}
|
2008-01-27 08:06:35 +08:00
|
|
|
|
2009-01-21 00:49:17 +08:00
|
|
|
/*
|
2009-08-06 14:12:29 +08:00
|
|
|
* Fill in the block bitmap bmap with the information regarding the
|
|
|
|
* blocks to be moved
|
2009-01-21 00:49:17 +08:00
|
|
|
*/
|
|
|
|
static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp,
|
2009-08-06 14:12:29 +08:00
|
|
|
ext2fs_block_bitmap bmap)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
dgrp_t i;
|
2009-08-06 14:12:31 +08:00
|
|
|
int retval;
|
|
|
|
ext2_badblocks_list bb_list = 0;
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t j, needed_blocks = 0;
|
|
|
|
blk64_t start_blk, end_blk;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
2009-08-06 14:12:31 +08:00
|
|
|
retval = ext2fs_read_bb_inode(fs, &bb_list);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
2007-08-13 18:26:24 +08:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
start_blk = ext2fs_inode_table_loc(fs, i) +
|
2007-08-13 18:26:24 +08:00
|
|
|
fs->inode_blocks_per_group;
|
|
|
|
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
end_blk = ext2fs_inode_table_loc(fs, i) +
|
2007-08-13 18:26:24 +08:00
|
|
|
new_ino_blks_per_grp;
|
|
|
|
|
|
|
|
for (j = start_blk; j < end_blk; j++) {
|
2009-08-23 09:15:30 +08:00
|
|
|
if (ext2fs_test_block_bitmap2(fs->block_map, j)) {
|
2009-08-06 14:12:31 +08:00
|
|
|
/*
|
|
|
|
* IF the block is a bad block we fail
|
2007-08-13 18:26:24 +08:00
|
|
|
*/
|
2009-08-06 14:12:31 +08:00
|
|
|
if (ext2fs_badblocks_list_test(bb_list, j)) {
|
|
|
|
ext2fs_badblocks_list_free(bb_list);
|
|
|
|
return ENOSPC;
|
|
|
|
}
|
|
|
|
|
2009-08-23 09:15:30 +08:00
|
|
|
ext2fs_mark_block_bitmap2(bmap, j);
|
2007-08-13 18:26:24 +08:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We are going to use this block for
|
|
|
|
* inode table. So mark them used.
|
|
|
|
*/
|
2009-08-23 09:15:30 +08:00
|
|
|
ext2fs_mark_block_bitmap2(fs->block_map, j);
|
2007-08-13 18:26:24 +08:00
|
|
|
}
|
|
|
|
}
|
2009-08-06 14:12:29 +08:00
|
|
|
needed_blocks += end_blk - start_blk;
|
2007-08-13 18:26:24 +08:00
|
|
|
}
|
|
|
|
|
2009-08-06 14:12:31 +08:00
|
|
|
ext2fs_badblocks_list_free(bb_list);
|
2009-09-08 08:46:34 +08:00
|
|
|
if (needed_blocks > ext2fs_free_blocks_count(fs->super))
|
2007-08-13 18:26:24 +08:00
|
|
|
return ENOSPC;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-06 14:12:30 +08:00
|
|
|
static int ext2fs_is_meta_block(ext2_filsys fs, blk_t blk)
|
|
|
|
{
|
|
|
|
dgrp_t group;
|
|
|
|
group = ext2fs_group_of_blk(fs, blk);
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
if (ext2fs_block_bitmap_loc(fs, group) == blk)
|
2009-08-06 14:12:30 +08:00
|
|
|
return 1;
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
if (ext2fs_inode_bitmap_loc(fs, group) == blk)
|
2009-08-06 14:12:30 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2fs_is_block_in_group(ext2_filsys fs, dgrp_t group, blk_t blk)
|
|
|
|
{
|
|
|
|
blk_t start_blk, end_blk;
|
|
|
|
start_blk = fs->super->s_first_data_block +
|
|
|
|
EXT2_BLOCKS_PER_GROUP(fs->super) * group;
|
|
|
|
/*
|
|
|
|
* We cannot get new block beyond end_blk for for the last block group
|
|
|
|
* so we can check with EXT2_BLOCKS_PER_GROUP even for last block group
|
|
|
|
*/
|
|
|
|
end_blk = start_blk + EXT2_BLOCKS_PER_GROUP(fs->super);
|
|
|
|
if (blk >= start_blk && blk <= end_blk)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-06 14:12:29 +08:00
|
|
|
static int move_block(ext2_filsys fs, ext2fs_block_bitmap bmap)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
2009-08-06 14:12:30 +08:00
|
|
|
|
2007-08-13 18:26:24 +08:00
|
|
|
char *buf;
|
2011-06-11 22:58:25 +08:00
|
|
|
dgrp_t group = 0;
|
2007-08-13 18:26:24 +08:00
|
|
|
errcode_t retval;
|
2009-08-06 14:12:30 +08:00
|
|
|
int meta_data = 0;
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t blk, new_blk, goal;
|
2007-08-13 18:26:24 +08:00
|
|
|
struct blk_move *bmv;
|
|
|
|
|
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &buf);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
2008-11-15 13:32:39 +08:00
|
|
|
for (new_blk = blk = fs->super->s_first_data_block;
|
2009-09-08 08:46:34 +08:00
|
|
|
blk < ext2fs_blocks_count(fs->super); blk++) {
|
2009-08-23 09:15:30 +08:00
|
|
|
if (!ext2fs_test_block_bitmap2(bmap, blk))
|
2007-08-13 18:26:24 +08:00
|
|
|
continue;
|
|
|
|
|
2009-08-06 14:12:30 +08:00
|
|
|
if (ext2fs_is_meta_block(fs, blk)) {
|
|
|
|
/*
|
|
|
|
* If the block is mapping a fs meta data block
|
|
|
|
* like group desc/block bitmap/inode bitmap. We
|
|
|
|
* should find a block in the same group and fix
|
|
|
|
* the respective fs metadata pointers. Otherwise
|
|
|
|
* fail
|
|
|
|
*/
|
|
|
|
group = ext2fs_group_of_blk(fs, blk);
|
2009-10-26 09:24:06 +08:00
|
|
|
goal = ext2fs_group_first_block2(fs, group);
|
2009-08-06 14:12:30 +08:00
|
|
|
meta_data = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
goal = new_blk;
|
|
|
|
}
|
2010-06-14 04:00:00 +08:00
|
|
|
retval = ext2fs_new_block2(fs, goal, NULL, &new_blk);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
2009-08-06 14:12:30 +08:00
|
|
|
/* new fs meta data block should be in the same group */
|
|
|
|
if (meta_data && !ext2fs_is_block_in_group(fs, group, new_blk)) {
|
|
|
|
retval = ENOSPC;
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
2007-08-13 18:26:24 +08:00
|
|
|
/* Mark this block as allocated */
|
2009-08-23 09:15:30 +08:00
|
|
|
ext2fs_mark_block_bitmap2(fs->block_map, new_blk);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
/* Add it to block move list */
|
|
|
|
retval = ext2fs_get_mem(sizeof(struct blk_move), &bmv);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
bmv->old_loc = blk;
|
|
|
|
bmv->new_loc = new_blk;
|
|
|
|
|
|
|
|
list_add(&(bmv->list), &blk_move_list);
|
|
|
|
|
2009-09-08 09:14:24 +08:00
|
|
|
retval = io_channel_read_blk64(fs->io, blk, 1, buf);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
2009-09-08 09:14:24 +08:00
|
|
|
retval = io_channel_write_blk64(fs->io, new_blk, 1, buf);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err_out:
|
|
|
|
ext2fs_free_mem(&buf);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-06-14 04:00:00 +08:00
|
|
|
static blk64_t translate_block(blk64_t blk)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
struct list_head *entry;
|
|
|
|
struct blk_move *bmv;
|
|
|
|
|
|
|
|
list_for_each(entry, &blk_move_list) {
|
|
|
|
bmv = list_entry(entry, struct blk_move, list);
|
|
|
|
if (bmv->old_loc == blk)
|
|
|
|
return bmv->new_loc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-07 23:51:33 +08:00
|
|
|
static int process_block(ext2_filsys fs EXT2FS_ATTR((unused)),
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t *block_nr,
|
2008-06-07 23:51:33 +08:00
|
|
|
e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t ref_block EXT2FS_ATTR((unused)),
|
2007-08-13 18:26:24 +08:00
|
|
|
int ref_offset EXT2FS_ATTR((unused)),
|
2008-11-15 13:32:39 +08:00
|
|
|
void *priv_data)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t new_blk;
|
2008-11-15 13:32:39 +08:00
|
|
|
ext2fs_block_bitmap bmap = (ext2fs_block_bitmap) priv_data;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
2009-08-23 09:15:30 +08:00
|
|
|
if (!ext2fs_test_block_bitmap2(bmap, *block_nr))
|
2008-11-15 13:32:39 +08:00
|
|
|
return 0;
|
2009-01-20 15:34:39 +08:00
|
|
|
new_blk = translate_block(*block_nr);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (new_blk) {
|
|
|
|
*block_nr = new_blk;
|
|
|
|
/*
|
|
|
|
* This will force the ext2fs_write_inode in the iterator
|
|
|
|
*/
|
|
|
|
ret |= BLOCK_CHANGED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-11-15 13:32:39 +08:00
|
|
|
static int inode_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
errcode_t retval = 0;
|
|
|
|
ext2_ino_t ino;
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t blk;
|
2007-08-13 18:26:24 +08:00
|
|
|
char *block_buf = 0;
|
|
|
|
struct ext2_inode inode;
|
|
|
|
ext2_inode_scan scan = NULL;
|
|
|
|
|
|
|
|
retval = ext2fs_get_mem(fs->blocksize * 3, &block_buf);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
retval = ext2fs_open_inode_scan(fs, 0, &scan);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
retval = ext2fs_get_next_inode(scan, &ino, &inode);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
if (!ino)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (inode.i_links_count == 0)
|
|
|
|
continue; /* inode not in use */
|
|
|
|
|
|
|
|
/* FIXME!!
|
|
|
|
* If we end up modifying the journal inode
|
|
|
|
* the sb->s_jnl_blocks will differ. But a
|
|
|
|
* subsequent e2fsck fixes that.
|
|
|
|
* Do we need to fix this ??
|
|
|
|
*/
|
|
|
|
|
2009-09-08 10:29:45 +08:00
|
|
|
if (ext2fs_file_acl_block(&inode) &&
|
|
|
|
ext2fs_test_block_bitmap2(bmap,
|
|
|
|
ext2fs_file_acl_block(&inode))) {
|
|
|
|
blk = translate_block(ext2fs_file_acl_block(&inode));
|
2007-08-13 18:26:24 +08:00
|
|
|
if (!blk)
|
|
|
|
continue;
|
|
|
|
|
2009-09-08 10:29:45 +08:00
|
|
|
ext2fs_file_acl_block_set(&inode, blk);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Write the inode to disk so that inode table
|
|
|
|
* resizing can work
|
|
|
|
*/
|
|
|
|
retval = ext2fs_write_inode(fs, ino, &inode);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ext2fs_inode_has_valid_blocks(&inode))
|
|
|
|
continue;
|
|
|
|
|
2010-06-14 04:00:00 +08:00
|
|
|
retval = ext2fs_block_iterate3(fs, ino, 0, block_buf,
|
2008-11-15 13:32:39 +08:00
|
|
|
process_block, bmap);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
err_out:
|
|
|
|
ext2fs_free_mem(&block_buf);
|
|
|
|
|
|
|
|
return retval;
|
2009-01-21 00:49:17 +08:00
|
|
|
}
|
|
|
|
|
2009-08-06 14:12:30 +08:00
|
|
|
/*
|
|
|
|
* We need to scan for inode and block bitmaps that may need to be
|
|
|
|
* moved. This can take place if the filesystem was formatted for
|
|
|
|
* RAID arrays using the mke2fs's extended option "stride".
|
|
|
|
*/
|
|
|
|
static int group_desc_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap)
|
|
|
|
{
|
|
|
|
dgrp_t i;
|
|
|
|
blk_t blk, new_blk;
|
|
|
|
|
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
blk = ext2fs_block_bitmap_loc(fs, i);
|
2009-08-23 09:15:30 +08:00
|
|
|
if (ext2fs_test_block_bitmap2(bmap, blk)) {
|
2009-08-06 14:12:30 +08:00
|
|
|
new_blk = translate_block(blk);
|
|
|
|
if (!new_blk)
|
|
|
|
continue;
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
ext2fs_block_bitmap_loc_set(fs, i, new_blk);
|
2009-08-06 14:12:30 +08:00
|
|
|
}
|
|
|
|
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
blk = ext2fs_inode_bitmap_loc(fs, i);
|
2009-08-23 09:15:30 +08:00
|
|
|
if (ext2fs_test_block_bitmap2(bmap, blk)) {
|
2009-08-06 14:12:30 +08:00
|
|
|
new_blk = translate_block(blk);
|
|
|
|
if (!new_blk)
|
|
|
|
continue;
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
ext2fs_inode_bitmap_loc_set(fs, i, new_blk);
|
2009-08-06 14:12:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-07 23:51:33 +08:00
|
|
|
static int expand_inode_table(ext2_filsys fs, unsigned long new_ino_size)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
dgrp_t i;
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t blk;
|
2007-08-13 18:26:24 +08:00
|
|
|
errcode_t retval;
|
2008-06-07 23:51:33 +08:00
|
|
|
int new_ino_blks_per_grp;
|
|
|
|
unsigned int j;
|
2007-08-13 18:26:24 +08:00
|
|
|
char *old_itable = NULL, *new_itable = NULL;
|
|
|
|
char *tmp_old_itable = NULL, *tmp_new_itable = NULL;
|
2008-06-07 23:51:33 +08:00
|
|
|
unsigned long old_ino_size;
|
2007-08-13 18:26:24 +08:00
|
|
|
int old_itable_size, new_itable_size;
|
|
|
|
|
|
|
|
old_itable_size = fs->inode_blocks_per_group * fs->blocksize;
|
2008-06-07 23:51:33 +08:00
|
|
|
old_ino_size = EXT2_INODE_SIZE(fs->super);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
new_ino_blks_per_grp = ext2fs_div_ceil(
|
|
|
|
EXT2_INODES_PER_GROUP(fs->super) *
|
2008-06-07 23:51:33 +08:00
|
|
|
new_ino_size,
|
2007-08-13 18:26:24 +08:00
|
|
|
fs->blocksize);
|
|
|
|
|
|
|
|
new_itable_size = new_ino_blks_per_grp * fs->blocksize;
|
|
|
|
|
|
|
|
retval = ext2fs_get_mem(old_itable_size, &old_itable);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
retval = ext2fs_get_mem(new_itable_size, &new_itable);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
tmp_old_itable = old_itable;
|
|
|
|
tmp_new_itable = new_itable;
|
|
|
|
|
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
blk = ext2fs_inode_table_loc(fs, i);
|
2009-09-08 09:14:24 +08:00
|
|
|
retval = io_channel_read_blk64(fs->io, blk,
|
2007-08-13 18:26:24 +08:00
|
|
|
fs->inode_blocks_per_group, old_itable);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
for (j = 0; j < EXT2_INODES_PER_GROUP(fs->super); j++) {
|
2008-06-07 23:51:33 +08:00
|
|
|
memcpy(new_itable, old_itable, old_ino_size);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
2008-06-07 23:51:33 +08:00
|
|
|
memset(new_itable+old_ino_size, 0,
|
|
|
|
new_ino_size - old_ino_size);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
2008-06-07 23:51:33 +08:00
|
|
|
new_itable += new_ino_size;
|
|
|
|
old_itable += old_ino_size;
|
2007-08-13 18:26:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reset the pointer */
|
|
|
|
old_itable = tmp_old_itable;
|
|
|
|
new_itable = tmp_new_itable;
|
|
|
|
|
2009-09-08 09:14:24 +08:00
|
|
|
retval = io_channel_write_blk64(fs->io, blk,
|
2007-08-13 18:26:24 +08:00
|
|
|
new_ino_blks_per_grp, new_itable);
|
|
|
|
if (retval)
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the meta data */
|
|
|
|
fs->inode_blocks_per_group = new_ino_blks_per_grp;
|
2008-06-07 23:51:33 +08:00
|
|
|
fs->super->s_inode_size = new_ino_size;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
err_out:
|
|
|
|
if (old_itable)
|
|
|
|
ext2fs_free_mem(&old_itable);
|
|
|
|
|
|
|
|
if (new_itable)
|
|
|
|
ext2fs_free_mem(&new_itable);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
|
|
|
|
{
|
2010-06-14 04:00:00 +08:00
|
|
|
blk64_t blk;
|
2007-08-13 18:26:24 +08:00
|
|
|
ext2_ino_t ino;
|
|
|
|
unsigned int group = 0;
|
|
|
|
unsigned int count = 0;
|
|
|
|
int total_free = 0;
|
|
|
|
int group_free = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First calculate the block statistics
|
|
|
|
*/
|
|
|
|
for (blk = fs->super->s_first_data_block;
|
2009-09-08 08:46:34 +08:00
|
|
|
blk < ext2fs_blocks_count(fs->super); blk++) {
|
2009-08-23 09:15:30 +08:00
|
|
|
if (!ext2fs_fast_test_block_bitmap2(fs->block_map, blk)) {
|
2007-08-13 18:26:24 +08:00
|
|
|
group_free++;
|
|
|
|
total_free++;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
if ((count == fs->super->s_blocks_per_group) ||
|
2009-09-08 08:46:34 +08:00
|
|
|
(blk == ext2fs_blocks_count(fs->super)-1)) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
ext2fs_bg_free_blocks_count_set(fs, group++,
|
|
|
|
group_free);
|
2007-08-13 18:26:24 +08:00
|
|
|
count = 0;
|
|
|
|
group_free = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 13:38:43 +08:00
|
|
|
total_free = EXT2FS_C2B(fs, total_free);
|
2009-09-08 08:46:34 +08:00
|
|
|
ext2fs_free_blocks_count_set(fs->super, total_free);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Next, calculate the inode statistics
|
|
|
|
*/
|
|
|
|
group_free = 0;
|
|
|
|
total_free = 0;
|
|
|
|
count = 0;
|
|
|
|
group = 0;
|
|
|
|
|
|
|
|
/* Protect loop from wrap-around if s_inodes_count maxed */
|
|
|
|
for (ino = 1; ino <= fs->super->s_inodes_count && ino > 0; ino++) {
|
2009-08-23 09:15:30 +08:00
|
|
|
if (!ext2fs_fast_test_inode_bitmap2(fs->inode_map, ino)) {
|
2007-08-13 18:26:24 +08:00
|
|
|
group_free++;
|
|
|
|
total_free++;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
if ((count == fs->super->s_inodes_per_group) ||
|
|
|
|
(ino == fs->super->s_inodes_count)) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 09:43:47 +08:00
|
|
|
ext2fs_bg_free_inodes_count_set(fs, group++,
|
|
|
|
group_free);
|
2007-08-13 18:26:24 +08:00
|
|
|
count = 0;
|
|
|
|
group_free = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fs->super->s_free_inodes_count = total_free;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define list_for_each_safe(pos, pnext, head) \
|
|
|
|
for (pos = (head)->next, pnext = pos->next; pos != (head); \
|
|
|
|
pos = pnext, pnext = pos->next)
|
|
|
|
|
2008-06-07 23:51:33 +08:00
|
|
|
static void free_blk_move_list(void)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
struct list_head *entry, *tmp;
|
|
|
|
struct blk_move *bmv;
|
|
|
|
|
|
|
|
list_for_each_safe(entry, tmp, &blk_move_list) {
|
|
|
|
bmv = list_entry(entry, struct blk_move, list);
|
|
|
|
list_del(entry);
|
|
|
|
ext2fs_free_mem(&bmv);
|
|
|
|
}
|
2009-01-21 00:49:17 +08:00
|
|
|
return;
|
2007-08-13 18:26:24 +08:00
|
|
|
}
|
2008-06-07 23:51:33 +08:00
|
|
|
|
|
|
|
static int resize_inode(ext2_filsys fs, unsigned long new_size)
|
2007-08-13 18:26:24 +08:00
|
|
|
{
|
|
|
|
errcode_t retval;
|
|
|
|
int new_ino_blks_per_grp;
|
2009-08-06 14:12:29 +08:00
|
|
|
ext2fs_block_bitmap bmap;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
2011-09-17 04:49:37 +08:00
|
|
|
retval = ext2fs_read_inode_bitmap(fs);
|
|
|
|
if (retval) {
|
|
|
|
fputs(_("Failed to read inode bitmap\n"), stderr);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
retval = ext2fs_read_block_bitmap(fs);
|
|
|
|
if (retval) {
|
|
|
|
fputs(_("Failed to read blockbitmap\n"), stderr);
|
|
|
|
return retval;
|
|
|
|
}
|
2007-08-13 18:26:24 +08:00
|
|
|
INIT_LIST_HEAD(&blk_move_list);
|
|
|
|
|
|
|
|
|
|
|
|
new_ino_blks_per_grp = ext2fs_div_ceil(
|
|
|
|
EXT2_INODES_PER_GROUP(fs->super)*
|
2008-06-07 23:51:33 +08:00
|
|
|
new_size,
|
2007-08-13 18:26:24 +08:00
|
|
|
fs->blocksize);
|
|
|
|
|
|
|
|
/* We may change the file system.
|
|
|
|
* Mark the file system as invalid so that
|
|
|
|
* the user is prompted to run fsck.
|
|
|
|
*/
|
|
|
|
fs->super->s_state &= ~EXT2_VALID_FS;
|
|
|
|
|
|
|
|
retval = ext2fs_allocate_block_bitmap(fs, _("blocks to be moved"),
|
|
|
|
&bmap);
|
2009-08-06 14:12:29 +08:00
|
|
|
if (retval) {
|
|
|
|
fputs(_("Failed to allocate block bitmap when "
|
|
|
|
"increasing inode size\n"), stderr);
|
2009-01-21 00:49:17 +08:00
|
|
|
return retval;
|
2009-08-06 14:12:29 +08:00
|
|
|
}
|
|
|
|
retval = get_move_bitmaps(fs, new_ino_blks_per_grp, bmap);
|
|
|
|
if (retval) {
|
|
|
|
fputs(_("Not enough space to increase inode size \n"), stderr);
|
2007-08-13 18:26:24 +08:00
|
|
|
goto err_out;
|
2009-08-06 14:12:29 +08:00
|
|
|
}
|
|
|
|
retval = move_block(fs, bmap);
|
|
|
|
if (retval) {
|
|
|
|
fputs(_("Failed to relocate blocks during inode resize \n"),
|
|
|
|
stderr);
|
2007-08-13 18:26:24 +08:00
|
|
|
goto err_out;
|
2009-08-06 14:12:29 +08:00
|
|
|
}
|
2008-11-15 13:32:39 +08:00
|
|
|
retval = inode_scan_and_fix(fs, bmap);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (retval)
|
2009-08-06 14:12:29 +08:00
|
|
|
goto err_out_undo;
|
2009-01-21 00:49:17 +08:00
|
|
|
|
2009-08-06 14:12:30 +08:00
|
|
|
retval = group_desc_scan_and_fix(fs, bmap);
|
|
|
|
if (retval)
|
|
|
|
goto err_out_undo;
|
|
|
|
|
2008-06-07 23:51:33 +08:00
|
|
|
retval = expand_inode_table(fs, new_size);
|
2007-08-13 18:26:24 +08:00
|
|
|
if (retval)
|
2009-08-06 14:12:29 +08:00
|
|
|
goto err_out_undo;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
ext2fs_calculate_summary_stats(fs);
|
|
|
|
|
|
|
|
fs->super->s_state |= EXT2_VALID_FS;
|
|
|
|
/* mark super block and block bitmap as dirty */
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
|
|
|
|
|
|
|
err_out:
|
|
|
|
free_blk_move_list();
|
|
|
|
ext2fs_free_block_bitmap(bmap);
|
|
|
|
|
|
|
|
return retval;
|
2009-08-06 14:12:29 +08:00
|
|
|
|
|
|
|
err_out_undo:
|
|
|
|
free_blk_move_list();
|
|
|
|
ext2fs_free_block_bitmap(bmap);
|
|
|
|
fputs(_("Error in resizing the inode size.\n"
|
|
|
|
"Run e2undo to undo the "
|
|
|
|
"file system changes. \n"), stderr);
|
|
|
|
|
|
|
|
return retval;
|
2007-08-13 18:26:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int tune2fs_setup_tdb(const char *name, io_manager *io_ptr)
|
|
|
|
{
|
|
|
|
errcode_t retval = 0;
|
2008-06-07 23:51:33 +08:00
|
|
|
const char *tdb_dir;
|
2009-04-18 22:53:32 +08:00
|
|
|
char *tdb_file;
|
2008-06-07 23:51:33 +08:00
|
|
|
char *dev_name, *tmp_name;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
#if 0 /* FIXME!! */
|
|
|
|
/*
|
|
|
|
* Configuration via a conf file would be
|
|
|
|
* nice
|
|
|
|
*/
|
|
|
|
profile_get_string(profile, "scratch_files",
|
|
|
|
"directory", 0, 0,
|
|
|
|
&tdb_dir);
|
|
|
|
#endif
|
|
|
|
tmp_name = strdup(name);
|
2009-04-18 22:53:32 +08:00
|
|
|
if (!tmp_name) {
|
|
|
|
alloc_fn_fail:
|
|
|
|
com_err(program_name, ENOMEM,
|
|
|
|
_("Couldn't allocate memory for tdb filename\n"));
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
2008-06-07 23:51:33 +08:00
|
|
|
dev_name = basename(tmp_name);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
tdb_dir = getenv("E2FSPROGS_UNDO_DIR");
|
|
|
|
if (!tdb_dir)
|
2009-01-20 15:34:39 +08:00
|
|
|
tdb_dir = "/var/lib/e2fsprogs";
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
if (!strcmp(tdb_dir, "none") || (tdb_dir[0] == 0) ||
|
|
|
|
access(tdb_dir, W_OK))
|
|
|
|
return 0;
|
|
|
|
|
2009-04-18 22:53:32 +08:00
|
|
|
tdb_file = malloc(strlen(tdb_dir) + 9 + strlen(dev_name) + 7 + 1);
|
|
|
|
if (!tdb_file)
|
|
|
|
goto alloc_fn_fail;
|
2008-06-07 23:51:33 +08:00
|
|
|
sprintf(tdb_file, "%s/tune2fs-%s.e2undo", tdb_dir, dev_name);
|
2007-08-13 18:26:24 +08:00
|
|
|
|
|
|
|
if (!access(tdb_file, F_OK)) {
|
|
|
|
if (unlink(tdb_file) < 0) {
|
|
|
|
retval = errno;
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while trying to delete %s"),
|
|
|
|
tdb_file);
|
2009-04-18 22:53:32 +08:00
|
|
|
free(tdb_file);
|
2007-08-13 18:26:24 +08:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_undo_io_backing_manager(*io_ptr);
|
|
|
|
*io_ptr = undo_io_manager;
|
|
|
|
set_undo_io_backup_file(tdb_file);
|
2009-01-20 14:50:07 +08:00
|
|
|
printf(_("To undo the tune2fs operation please run "
|
2008-07-18 05:24:09 +08:00
|
|
|
"the command\n e2undo %s %s\n\n"),
|
2007-08-13 18:26:24 +08:00
|
|
|
tdb_file, name);
|
2009-04-18 22:53:32 +08:00
|
|
|
free(tdb_file);
|
2007-08-13 18:26:24 +08:00
|
|
|
free(tmp_name);
|
|
|
|
return retval;
|
|
|
|
}
|
2001-01-09 08:16:26 +08:00
|
|
|
|
2009-01-20 15:34:39 +08:00
|
|
|
int main(int argc, char **argv)
|
2001-01-09 08:16:26 +08:00
|
|
|
{
|
|
|
|
errcode_t retval;
|
|
|
|
ext2_filsys fs;
|
|
|
|
struct ext2_super_block *sb;
|
2008-07-28 04:00:48 +08:00
|
|
|
io_manager io_ptr, io_ptr_orig = NULL;
|
2001-01-09 08:16:26 +08:00
|
|
|
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2002-03-05 16:26:52 +08:00
|
|
|
setlocale(LC_CTYPE, "");
|
2001-01-09 08:16:26 +08:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
|
|
|
#endif
|
|
|
|
if (argc && *argv)
|
|
|
|
program_name = *argv;
|
2006-12-26 16:38:07 +08:00
|
|
|
add_error_table(&et_ext2_error_table);
|
2001-01-09 08:16:26 +08:00
|
|
|
|
2009-04-22 21:18:30 +08:00
|
|
|
#ifdef CONFIG_BUILD_FINDFS
|
2002-08-18 11:01:22 +08:00
|
|
|
if (strcmp(get_progname(argv[0]), "findfs") == 0)
|
|
|
|
do_findfs(argc, argv);
|
2009-04-22 21:18:30 +08:00
|
|
|
#endif
|
2001-01-09 08:16:26 +08:00
|
|
|
if (strcmp(get_progname(argv[0]), "e2label") == 0)
|
|
|
|
parse_e2label_options(argc, argv);
|
|
|
|
else
|
|
|
|
parse_tune2fs_options(argc, argv);
|
2008-08-28 11:07:54 +08:00
|
|
|
|
2003-05-06 00:08:47 +08:00
|
|
|
#ifdef CONFIG_TESTIO_DEBUG
|
2008-09-01 23:17:29 +08:00
|
|
|
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_DEBUG")) {
|
|
|
|
io_ptr = test_io_manager;
|
|
|
|
test_io_backing_manager = unix_io_manager;
|
|
|
|
} else
|
2003-05-06 00:08:47 +08:00
|
|
|
#endif
|
2008-09-01 23:17:29 +08:00
|
|
|
io_ptr = unix_io_manager;
|
2007-08-13 18:26:24 +08:00
|
|
|
|
2008-07-28 04:00:48 +08:00
|
|
|
retry_open:
|
2008-08-28 11:07:54 +08:00
|
|
|
retval = ext2fs_open2(device_name, io_options, open_flag,
|
2004-12-01 03:07:11 +08:00
|
|
|
0, 0, io_ptr, &fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
if (retval) {
|
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while trying to open %s"),
|
|
|
|
device_name);
|
2001-08-16 07:17:37 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
_("Couldn't find valid filesystem superblock.\n"));
|
1997-04-26 21:21:57 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-07-28 04:00:48 +08:00
|
|
|
|
|
|
|
if (I_flag && !io_ptr_orig) {
|
|
|
|
/*
|
|
|
|
* Check the inode size is right so we can issue an
|
|
|
|
* error message and bail before setting up the tdb
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
if (new_inode_size == EXT2_INODE_SIZE(fs->super)) {
|
2009-04-23 03:13:37 +08:00
|
|
|
fprintf(stderr, _("The inode size is already %lu\n"),
|
2008-07-28 04:00:48 +08:00
|
|
|
new_inode_size);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (new_inode_size < EXT2_INODE_SIZE(fs->super)) {
|
|
|
|
fprintf(stderr, _("Shrinking the inode size is "
|
|
|
|
"not supported\n"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If inode resize is requested use the
|
|
|
|
* Undo I/O manager
|
|
|
|
*/
|
|
|
|
io_ptr_orig = io_ptr;
|
|
|
|
retval = tune2fs_setup_tdb(device_name, &io_ptr);
|
|
|
|
if (retval)
|
|
|
|
exit(1);
|
|
|
|
if (io_ptr != io_ptr_orig) {
|
|
|
|
ext2fs_close(fs);
|
|
|
|
goto retry_open;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-09 08:16:26 +08:00
|
|
|
sb = fs->super;
|
2007-06-19 06:26:50 +08:00
|
|
|
fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
|
2008-07-10 22:49:59 +08:00
|
|
|
|
2001-01-09 08:16:26 +08:00
|
|
|
if (print_label) {
|
|
|
|
/* For e2label emulation */
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-12 00:08:23 +08:00
|
|
|
printf("%.*s\n", (int) sizeof(sb->s_volume_name),
|
|
|
|
sb->s_volume_name);
|
2006-12-26 16:38:07 +08:00
|
|
|
remove_error_table(&et_ext2_error_table);
|
2001-01-09 08:16:26 +08:00
|
|
|
exit(0);
|
|
|
|
}
|
2008-07-10 22:49:59 +08:00
|
|
|
|
2004-04-13 00:37:55 +08:00
|
|
|
retval = ext2fs_check_if_mounted(device_name, &mount_flags);
|
|
|
|
if (retval) {
|
|
|
|
com_err("ext2fs_check_if_mount", retval,
|
|
|
|
_("while determining whether %s is mounted."),
|
|
|
|
device_name);
|
|
|
|
exit(1);
|
2001-01-01 23:26:58 +08:00
|
|
|
}
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
/* Normally we only need to write out the superblock */
|
|
|
|
fs->flags |= EXT2_FLAG_SUPER_ONLY;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
1997-04-29 22:53:37 +08:00
|
|
|
if (c_flag) {
|
2001-01-01 23:26:58 +08:00
|
|
|
sb->s_max_mnt_count = max_mount_count;
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting maximal mount count to %d\n"),
|
|
|
|
max_mount_count);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
1997-04-29 22:53:37 +08:00
|
|
|
if (C_flag) {
|
2001-01-01 23:26:58 +08:00
|
|
|
sb->s_mnt_count = mount_count;
|
1997-04-29 22:53:37 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting current mount count to %d\n"), mount_count);
|
1997-04-29 22:53:37 +08:00
|
|
|
}
|
|
|
|
if (e_flag) {
|
2001-01-01 23:26:58 +08:00
|
|
|
sb->s_errors = errors;
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting error behavior to %d\n"), errors);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2001-01-01 23:26:58 +08:00
|
|
|
if (g_flag) {
|
|
|
|
sb->s_def_resgid = resgid;
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting reserved blocks gid to %lu\n"), resgid);
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
if (i_flag) {
|
2011-04-19 04:11:39 +08:00
|
|
|
if (interval >= (1ULL << 32)) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("interval between checks is too big (%lu)"),
|
|
|
|
interval);
|
|
|
|
exit(1);
|
|
|
|
}
|
2001-01-01 23:26:58 +08:00
|
|
|
sb->s_checkinterval = interval;
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting interval between checks to %lu seconds\n"),
|
|
|
|
interval);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
if (m_flag) {
|
2009-09-08 08:46:34 +08:00
|
|
|
ext2fs_r_blocks_count_set(sb, reserved_ratio *
|
|
|
|
ext2fs_blocks_count(sb) / 100.0);
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-09-08 08:46:34 +08:00
|
|
|
printf (_("Setting reserved blocks percentage to %g%% (%llu blocks)\n"),
|
|
|
|
reserved_ratio, ext2fs_r_blocks_count(sb));
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
if (r_flag) {
|
2011-06-01 08:08:58 +08:00
|
|
|
if (reserved_blocks > ext2fs_blocks_count(sb)/2) {
|
2009-01-20 15:34:39 +08:00
|
|
|
com_err(program_name, 0,
|
2009-09-08 08:46:34 +08:00
|
|
|
_("reserved blocks count is too big (%llu)"),
|
2009-01-20 15:34:39 +08:00
|
|
|
reserved_blocks);
|
|
|
|
exit(1);
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
2009-09-08 08:46:34 +08:00
|
|
|
ext2fs_r_blocks_count_set(sb, reserved_blocks);
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-09-08 08:46:34 +08:00
|
|
|
printf(_("Setting reserved blocks count to %llu\n"),
|
2009-01-20 15:34:39 +08:00
|
|
|
reserved_blocks);
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-30 01:48:10 +08:00
|
|
|
if (s_flag == 1) {
|
|
|
|
if (sb->s_feature_ro_compat &
|
|
|
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)
|
2003-12-07 14:28:50 +08:00
|
|
|
fputs(_("\nThe filesystem already has sparse "
|
|
|
|
"superblocks.\n"), stderr);
|
1997-04-30 01:48:10 +08:00
|
|
|
else {
|
|
|
|
sb->s_feature_ro_compat |=
|
|
|
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
|
2001-01-01 23:26:58 +08:00
|
|
|
sb->s_state &= ~EXT2_VALID_FS;
|
1997-04-30 01:48:10 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
printf(_("\nSparse superblock flag set. %s"),
|
2000-02-09 05:35:41 +08:00
|
|
|
_(please_fsck));
|
1997-04-30 01:48:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s_flag == 0) {
|
2008-02-29 10:26:01 +08:00
|
|
|
fputs(_("\nClearing the sparse superflag not supported.\n"),
|
|
|
|
stderr);
|
|
|
|
exit(1);
|
1997-04-30 01:48:10 +08:00
|
|
|
}
|
2001-12-26 21:58:01 +08:00
|
|
|
if (T_flag) {
|
|
|
|
sb->s_lastcheck = last_check_time;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
printf(_("Setting time filesystem last checked to %s\n"),
|
|
|
|
ctime(&last_check_time));
|
|
|
|
}
|
2001-01-01 23:26:58 +08:00
|
|
|
if (u_flag) {
|
|
|
|
sb->s_def_resuid = resuid;
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting reserved blocks uid to %lu\n"), resuid);
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-29 22:53:37 +08:00
|
|
|
if (L_flag) {
|
1998-03-30 09:20:55 +08:00
|
|
|
if (strlen(new_label) > sizeof(sb->s_volume_name))
|
2008-08-28 11:07:54 +08:00
|
|
|
fputs(_("Warning: label too long, truncating.\n"),
|
2003-12-07 14:28:50 +08:00
|
|
|
stderr);
|
1997-04-29 22:53:37 +08:00
|
|
|
memset(sb->s_volume_name, 0, sizeof(sb->s_volume_name));
|
|
|
|
strncpy(sb->s_volume_name, new_label,
|
|
|
|
sizeof(sb->s_volume_name));
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
|
|
|
if (M_flag) {
|
|
|
|
memset(sb->s_last_mounted, 0, sizeof(sb->s_last_mounted));
|
|
|
|
strncpy(sb->s_last_mounted, new_last_mounted,
|
|
|
|
sizeof(sb->s_last_mounted));
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
2002-10-16 05:43:43 +08:00
|
|
|
if (mntopts_cmd)
|
|
|
|
update_mntopts(fs, mntopts_cmd);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
if (features_cmd)
|
|
|
|
update_feature_set(fs, features_cmd);
|
2008-01-27 08:06:35 +08:00
|
|
|
if (extended_cmd)
|
|
|
|
parse_extended_opts(fs, extended_cmd);
|
ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c:
tune2fs.c, mke2fs.c, tune2fs.8.in, mke2fs.8.in: Change user interface
so that -J is used to specify journal options, and -j is used to
request creation of a journal using default values. (This is a UI
change, but we haven't done a formal release, and it makes things much
more consistent with the rest of the options out there.)
tune2fs.c: Add support for removing a filesystem from an external
journal; we correctly remove the filesystem UUID from the external
journal's filesystem list.
2001-01-18 09:51:15 +08:00
|
|
|
if (journal_size || journal_device)
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
add_journal(fs);
|
2008-08-28 11:07:54 +08:00
|
|
|
|
2011-07-21 02:40:05 +08:00
|
|
|
if (Q_flag) {
|
|
|
|
if (mount_flags & EXT2_MF_MOUNTED) {
|
|
|
|
fputs(_("The quota feature may only be changed when "
|
|
|
|
"the filesystem is unmounted.\n"), stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
handle_quota_options(fs);
|
|
|
|
}
|
|
|
|
|
1997-04-29 22:53:37 +08:00
|
|
|
if (U_flag) {
|
2008-11-15 06:42:27 +08:00
|
|
|
int set_csum = 0;
|
|
|
|
dgrp_t i;
|
|
|
|
|
|
|
|
if (sb->s_feature_ro_compat &
|
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
|
2009-01-20 15:34:39 +08:00
|
|
|
/*
|
2008-11-15 06:42:27 +08:00
|
|
|
* Determine if the block group checksums are
|
|
|
|
* correct so we know whether or not to set
|
|
|
|
* them later on.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < fs->group_desc_count; i++)
|
|
|
|
if (!ext2fs_group_desc_csum_verify(fs, i))
|
|
|
|
break;
|
|
|
|
if (i >= fs->group_desc_count)
|
|
|
|
set_csum = 1;
|
|
|
|
}
|
2001-04-24 04:58:03 +08:00
|
|
|
if ((strcasecmp(new_UUID, "null") == 0) ||
|
|
|
|
(strcasecmp(new_UUID, "clear") == 0)) {
|
1997-04-29 22:53:37 +08:00
|
|
|
uuid_clear(sb->s_uuid);
|
ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:
tune2fs.c (update_feature_set, add_journal): Moved to separate
functions. Added ability to add and remove the journal while the
filesystem is live. Added support for setting a time-based UUID.
Removed zero-initialized static variables.
mke2fs.c, util.c, util.h (strcasecmp, proceed_question,
check_plausibility, parse_journal_opts, check_mount): Moved functions
to util.c so they can be used by tune2fs.
mke2fs.c (main): Change ext2fs_add_journal_fs() to
ext2fs_add_journal_inode() to reflect function renaming.
2001-01-04 01:02:13 +08:00
|
|
|
} else if (strcasecmp(new_UUID, "time") == 0) {
|
|
|
|
uuid_generate_time(sb->s_uuid);
|
1997-04-29 22:53:37 +08:00
|
|
|
} else if (strcasecmp(new_UUID, "random") == 0) {
|
|
|
|
uuid_generate(sb->s_uuid);
|
|
|
|
} else if (uuid_parse(new_UUID, sb->s_uuid)) {
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
com_err(program_name, 0, _("Invalid UUID format\n"));
|
1997-04-29 22:53:37 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-11-15 06:42:27 +08:00
|
|
|
if (set_csum) {
|
|
|
|
for (i = 0; i < fs->group_desc_count; i++)
|
|
|
|
ext2fs_group_desc_csum_set(fs, i);
|
|
|
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
|
|
|
}
|
1997-04-29 22:53:37 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
2007-08-13 18:26:24 +08:00
|
|
|
if (I_flag) {
|
|
|
|
if (mount_flags & EXT2_MF_MOUNTED) {
|
|
|
|
fputs(_("The inode size may only be "
|
|
|
|
"changed when the filesystem is "
|
|
|
|
"unmounted.\n"), stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
2009-01-20 14:50:07 +08:00
|
|
|
if (fs->super->s_feature_incompat &
|
|
|
|
EXT4_FEATURE_INCOMPAT_FLEX_BG) {
|
2009-01-20 15:34:39 +08:00
|
|
|
fputs(_("Changing the inode size not supported for "
|
|
|
|
"filesystems with the flex_bg\n"
|
|
|
|
"feature enabled.\n"),
|
2009-01-20 14:50:07 +08:00
|
|
|
stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-08-13 18:26:24 +08:00
|
|
|
/*
|
|
|
|
* We want to update group descriptor also
|
|
|
|
* with the new free inode count
|
|
|
|
*/
|
|
|
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
2009-08-06 14:12:29 +08:00
|
|
|
if (resize_inode(fs, new_inode_size) == 0) {
|
2009-01-20 15:34:39 +08:00
|
|
|
printf(_("Setting inode size %lu\n"),
|
2007-08-13 18:26:24 +08:00
|
|
|
new_inode_size);
|
2011-09-17 04:49:37 +08:00
|
|
|
} else {
|
|
|
|
printf(_("Failed to change inode size\n"));
|
|
|
|
exit(1);
|
2007-08-13 18:26:24 +08:00
|
|
|
}
|
|
|
|
}
|
1997-04-29 22:53:37 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if (l_flag)
|
2009-01-20 15:34:39 +08:00
|
|
|
list_super(sb);
|
2008-02-19 11:56:25 +08:00
|
|
|
if (stride_set) {
|
|
|
|
sb->s_raid_stride = stride;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
printf(_("Setting stride size to %d\n"), stride);
|
|
|
|
}
|
|
|
|
if (stripe_width_set) {
|
|
|
|
sb->s_raid_stripe_width = stripe_width;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
printf(_("Setting stripe width to %d\n"), stripe_width);
|
|
|
|
}
|
2011-07-05 08:14:35 +08:00
|
|
|
if (ext_mount_opts) {
|
2011-09-25 00:59:31 +08:00
|
|
|
strncpy((char *)(fs->super->s_mount_opts), ext_mount_opts,
|
2011-07-05 08:14:35 +08:00
|
|
|
sizeof(fs->super->s_mount_opts));
|
|
|
|
fs->super->s_mount_opts[sizeof(fs->super->s_mount_opts)-1] = 0;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
printf(_("Setting extended default mount options to '%s'\n"),
|
|
|
|
ext_mount_opts);
|
|
|
|
free(ext_mount_opts);
|
|
|
|
}
|
2009-06-15 15:53:04 +08:00
|
|
|
free(device_name);
|
2006-12-26 16:38:07 +08:00
|
|
|
remove_error_table(&et_ext2_error_table);
|
2009-01-20 15:34:39 +08:00
|
|
|
return (ext2fs_close(fs) ? 1 : 0);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|