Add an option to debugfs to open filesystems in exclusive mode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog
index f5bc001..83844ed 100644
--- a/debugfs/ChangeLog
+++ b/debugfs/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-18  Theodore Ts'o  <tytso@mit.edu>
+
+	* debugfs.c (do_open_filesys), debugfs.8.in: Add the -e option to
+		the open_filesystem command, which requests that the
+		filesystem be opened in exclusive mode.
+
 2006-03-08  Theodore Ts'o  <tytso@mit.edu>
 
 	* Fix bug in icheck which incorrectly reports the last valid inode
diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in
index e9b06d6..8db23d5 100644
--- a/debugfs/debugfs.8.in
+++ b/debugfs/debugfs.8.in
@@ -335,18 +335,17 @@
 Take the requested list of inode numbers, and print a listing of pathnames
 to those inodes.
 .TP
-.I open [-w] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
+.I open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
 Open a filesystem for editing.  The 
-.I -w 
-flag causes the filesystem to be opened for writing.  The 
 .I -f 
 flag forces the filesystem to be opened even if there are some unknown 
 or incompatible filesystem features which would normally 
 prevent the filesystem from being opened.  The
-.IR -c ", " -b ", " -i ", " and " -s
-options behave the same as those to
-.B debugfs
-itself.
+.I -e
+flag causes the filesystem to be opened in exclusive mode.  The
+.IR -b ", " -c ", " -i ", " -s ", and " -w
+options behave the same as the command-line options to 
+.BR debugfs .
 .TP
 .I pwd
 Print the current working directory.
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 7eb7dc6..992a2b7 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -128,7 +128,7 @@
 	char	*data_filename = 0;
 	
 	reset_getopt();
-	while ((c = getopt (argc, argv, "iwfcb:s:d:")) != EOF) {
+	while ((c = getopt (argc, argv, "iwfecb:s:d:")) != EOF) {
 		switch (c) {
 		case 'i':
 			open_flags |= EXT2_FLAG_IMAGE_FILE;
@@ -139,6 +139,9 @@
 		case 'f':
 			open_flags |= EXT2_FLAG_FORCE;
 			break;
+		case 'e':
+			open_flags |= EXT2_FLAG_EXCLUSIVE;
+			break;
 		case 'c':
 			catastrophic = 1;
 			break;