From 85ef4ae87a8d27d8e3a734f8b3964d6b8f39867b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 24 Oct 2000 19:33:45 +0000 Subject: [PATCH] ChangeLog, mke2fs.8.in, mke2fs.c: mke2fs.c (PRS, main), mke2fs.8.in: Add support for the -j option, which builds an ext2/3 filesystem with an ext3 journal. --- misc/ChangeLog | 6 ++++++ misc/mke2fs.8.in | 10 ++++++++++ misc/mke2fs.c | 26 +++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/misc/ChangeLog b/misc/ChangeLog index 745b25a..266e49c 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,9 @@ +2000-10-24 + + * mke2fs.c (PRS, main), mke2fs.8.in: Add support for the -j + option, which builds an ext2/3 filesystem with an ext3 + journal. + 2000-10-24 * mke2fs.c (zap_sector): Fix really stupid typo which gcc 2.95 diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 1ce7069..9c04326 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -29,6 +29,10 @@ mke2fs \- create a Linux second extended file system .I bytes-per-inode ] [ +.B \-j +.I megabytes-for-journal +] +[ .B \-N .I number-of-inodes ] @@ -134,6 +138,12 @@ Be warned that is not possible to expand the number of inodes on a filesystem after it is created, so be careful decided the correct value for this parameter. .TP +.BI \-j " megabytes-for-journal" +Build the ext2 filesystem with the ext3 journaling feature enabled. +Megabyts-for-journal specifies the size of the journal in MB +(1024*1024 bytes). Any size between 4MB and 100MB may be used. +Of course, the journal must be small enough to fit into the filesystem. +.TP .B \-n causes mke2fs to not actually create a filesystem, but display what it would do if it were to create a filesystem. diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 23e92b4..4062bb4 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -79,6 +79,7 @@ int quiet = 0; int super_only = 0; int force = 0; int noaction = 0; +int journal_size = 0; char *bad_blocks_filename = 0; __u32 fs_stride = 0; @@ -779,7 +780,7 @@ static void PRS(int argc, char *argv[]) if (argc && *argv) program_name = *argv; while ((c = getopt (argc, argv, - "b:cf:g:i:l:m:no:qr:R:s:tvI:ST:FL:M:N:O:V")) != EOF) + "b:cf:g:i:j:l:m:no:qr:R:s:tvI:ST:FL:M:N:O:V")) != EOF) switch (c) { case 'b': blocksize = strtoul(optarg, &tmp, 0); @@ -831,6 +832,14 @@ static void PRS(int argc, char *argv[]) exit(1); } break; + case 'j': + journal_size = strtoul(optarg, &tmp, 0); + if (journal_size < 4 || journal_size > 100 || *tmp) { + com_err(program_name, 0, + _("bad journal size - %s"), optarg); + exit(1); + } + break; case 'l': bad_blocks_filename = malloc(strlen(optarg)+1); if (!bad_blocks_filename) { @@ -1015,6 +1024,7 @@ int main (int argc, char *argv[]) errcode_t retval = 0; ext2_filsys fs; badblocks_list bb_list = 0; + int journal_blocks; struct ext2fs_sb *s; #ifdef ENABLE_NLS @@ -1111,6 +1121,20 @@ int main (int argc, char *argv[]) zap_sector(fs, 0); #endif } + if (journal_size) { + if (!quiet) + printf(_("Creating journal: ")); + journal_blocks = journal_size * 1024 / + (fs->blocksize / 1024); + retval = ext2fs_add_journal_fs(fs, journal_blocks); + if (retval) { + com_err (program_name, retval, + _("while trying to create journal")); + exit(1); + } + if (!quiet) + printf(_("done\n")); + } if (!quiet) printf(_("Writing superblocks and " -- 1.8.3.1