[Ocfs2-tools-devel] [PATCH 6/7] mkfs.ocfs2: Add dry-run option
Sunil Mushran
sunil.mushran at oracle.com
Fri Mar 5 11:59:56 PST 2010
Add a dry-run option to see the various values selected by mkfs.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
mkfs.ocfs2/mkfs.c | 20 ++++++++++++++++----
mkfs.ocfs2/mkfs.h | 1 +
mkfs.ocfs2/mkfs.ocfs2.8.in | 4 ++++
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index ca88a68..ef01277 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -128,6 +128,7 @@ enum {
FEATURES_OPTION,
CLUSTER_STACK_OPTION,
CLUSTER_NAME_OPTION,
+ DRY_RUN_OPTION,
};
static uint64_t align_bytes_to_clusters_ceil(State *s,
@@ -510,15 +511,20 @@ main(int argc, char **argv)
fill_defaults(s);
- clear_both_ends(s);
-
generate_uuid (s);
create_generation(s);
print_state (s);
- check_32bit_blocks (s);
+ check_32bit_blocks(s);
+
+ if (s->dry_run) {
+ close_device(s);
+ return 0;
+ }
+
+ clear_both_ends(s);
init_record(s, &superblock_rec, SFI_OTHER, S_IFREG | 0644);
init_record(s, &root_dir_rec, SFI_OTHER, S_IFDIR | 0755);
@@ -769,7 +775,7 @@ get_state(int argc, char **argv)
State *s;
int c;
int verbose = 0, quiet = 0, force = 0, xtool = 0, hb_dev = 0;
- int show_version = 0;
+ int show_version = 0, dry_run = 0;
char *device_name;
int ret;
uint64_t val;
@@ -798,6 +804,7 @@ get_state(int argc, char **argv)
{ "fs-features=", 1, 0, FEATURES_OPTION },
{ "cluster-stack=", 1, 0, CLUSTER_STACK_OPTION },
{ "cluster-name=", 1, 0, CLUSTER_NAME_OPTION },
+ { "dry-run", 0, 0, DRY_RUN_OPTION },
{ 0, 0, 0, 0}
};
@@ -985,6 +992,10 @@ get_state(int argc, char **argv)
cluster_name = strdup(optarg);
break;
+ case DRY_RUN_OPTION:
+ dry_run = 1;
+ break;
+
default:
usage(progname);
break;
@@ -1027,6 +1038,7 @@ get_state(int argc, char **argv)
s->verbose = verbose;
s->quiet = quiet;
s->force = force;
+ s->dry_run = dry_run;
s->prompt = xtool ? 0 : 1;
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
index 9b50a9f..b702f00 100644
--- a/mkfs.ocfs2/mkfs.h
+++ b/mkfs.ocfs2/mkfs.h
@@ -188,6 +188,7 @@ struct _State {
int mount;
int no_backup_super;
int inline_data;
+ int dry_run;
uint32_t blocksize;
uint32_t blocksize_bits;
diff --git a/mkfs.ocfs2/mkfs.ocfs2.8.in b/mkfs.ocfs2/mkfs.ocfs2.8.in
index e436550..0043b0d 100644
--- a/mkfs.ocfs2/mkfs.ocfs2.8.in
+++ b/mkfs.ocfs2/mkfs.ocfs2.8.in
@@ -200,6 +200,10 @@ Choose the maximum amount of features available. This will typically provide the
This option is deprecated, please use \fB--fs-features=nobackup-super\fR instead.
.TP
+\fB--dry-run\fR
+Display the heuristically determined values without overwriting the existing file system.
+
+.TP
\fB\-q, \-\-quiet\fR
Quiet mode.
--
1.6.3.3
More information about the Ocfs2-tools-devel
mailing list