Commit 824620a9 authored by Tigerly's avatar Tigerly
Browse files

add freeze

parent 0f543980
...@@ -37,6 +37,9 @@ extern char *optarg; ...@@ -37,6 +37,9 @@ extern char *optarg;
#include "jfs_user.h" #include "jfs_user.h"
#include "support/plausible.h" #include "support/plausible.h"
#include <linux/fs.h>
#include <sys/ioctl.h>
#ifndef BUFSIZ #ifndef BUFSIZ
#define BUFSIZ 8192 #define BUFSIZ 8192
#endif #endif
...@@ -53,6 +56,9 @@ ext2_filsys current_fs; ...@@ -53,6 +56,9 @@ ext2_filsys current_fs;
quota_ctx_t current_qctx; quota_ctx_t current_qctx;
ext2_ino_t root, cwd; ext2_ino_t root, cwd;
static int fdDev = 0;
static int g_open_flags = 0;
static int debugfs_setup_tdb(const char *device_name, char *undo_file, static int debugfs_setup_tdb(const char *device_name, char *undo_file,
io_manager *io_ptr) io_manager *io_ptr)
{ {
...@@ -129,7 +135,8 @@ err: ...@@ -129,7 +135,8 @@ err:
static void open_filesystem(char *device, int open_flags, blk64_t superblock, static void open_filesystem(char *device, int open_flags, blk64_t superblock,
blk64_t blocksize, int catastrophic, blk64_t blocksize, int catastrophic,
char *data_filename, char *undo_file) char *data_filename, char *undo_file,
char *mnt_pt)
{ {
int retval; int retval;
io_channel data_io = 0; io_channel data_io = 0;
...@@ -170,7 +177,16 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock, ...@@ -170,7 +177,16 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock,
exit(1); exit(1);
} }
printf("1%s 2%d 3%llu 4%llu \n", device, open_flags, superblock, blocksize); //printf("1%s 2%d 3%llu 4%llu \n", device, open_flags, superblock, blocksize);
if (mnt_pt) {
fdDev = open(mnt_pt, O_RDONLY);
retval = ioctl(fdDev, FIFREEZE, 0);
if (retval) {
com_err(device, retval, "freezing filesystem failed");
return;
}
}
g_open_flags = open_flags;
retval = ext2fs_open(device, open_flags, superblock, blocksize, retval = ext2fs_open(device, open_flags, superblock, blocksize,
io_ptr, &current_fs); io_ptr, &current_fs);
...@@ -211,6 +227,12 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock, ...@@ -211,6 +227,12 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock,
return; return;
errout: errout:
if (fdDev) {
retval = ioctl(fdDev, FITHAW, 0);
if (retval)
com_err(device, retval, "thaw filesystem failed");
}
retval = ext2fs_close_free(&current_fs); retval = ext2fs_close_free(&current_fs);
if (retval) if (retval)
com_err(device, retval, "while trying to close filesystem"); com_err(device, retval, "while trying to close filesystem");
...@@ -225,9 +247,10 @@ void do_open_filesys(int argc, char **argv) ...@@ -225,9 +247,10 @@ void do_open_filesys(int argc, char **argv)
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS; int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
char *data_filename = 0; char *data_filename = 0;
char *undo_file = NULL; char *undo_file = NULL;
char *mnt_pt = NULL;
reset_getopt(); reset_getopt();
while ((c = getopt(argc, argv, "iwfecb:s:d:Dz:")) != EOF) { while ((c = getopt(argc, argv, "iwfecb:s:d:Dz:m:")) != EOF) {
switch (c) { switch (c) {
case 'i': case 'i':
open_flags |= EXT2_FLAG_IMAGE_FILE; open_flags |= EXT2_FLAG_IMAGE_FILE;
...@@ -251,6 +274,9 @@ void do_open_filesys(int argc, char **argv) ...@@ -251,6 +274,9 @@ void do_open_filesys(int argc, char **argv)
case 'd': case 'd':
data_filename = optarg; data_filename = optarg;
break; break;
case 'm':
mnt_pt = optarg;
break;
case 'D': case 'D':
open_flags |= EXT2_FLAG_DIRECT_IO; open_flags |= EXT2_FLAG_DIRECT_IO;
break; break;
...@@ -280,11 +306,11 @@ void do_open_filesys(int argc, char **argv) ...@@ -280,11 +306,11 @@ void do_open_filesys(int argc, char **argv)
return; return;
open_filesystem(argv[optind], open_flags, open_filesystem(argv[optind], open_flags,
superblock, blocksize, catastrophic, superblock, blocksize, catastrophic,
data_filename, undo_file); data_filename, undo_file, mnt_pt);
return; return;
print_usage: print_usage:
fprintf(stderr, "%s: Usage: open [-s superblock] [-b blocksize] " fprintf(stderr, "%s: Usage: open [-s superblock][-m mnt_point] [-b blocksize] "
"[-d image_filename] [-c] [-i] [-f] [-e] [-D] " "[-d image_filename] [-c] [-i] [-f] [-e] [-D] "
#ifndef READ_ONLY #ifndef READ_ONLY
"[-w] " "[-w] "
...@@ -297,6 +323,14 @@ print_usage: ...@@ -297,6 +323,14 @@ print_usage:
static void close_filesystem(NOARGS) static void close_filesystem(NOARGS)
{ {
int retval; int retval;
g_open_flags = 0;
if (fdDev) {
retval = ioctl(fdDev, FITHAW, 0);
if (retval)
com_err("thaw filesystem failed", retval, 0);
fdDev = 0;
}
if (current_fs->flags & EXT2_FLAG_IB_DIRTY) { if (current_fs->flags & EXT2_FLAG_IB_DIRTY) {
retval = ext2fs_write_inode_bitmap(current_fs); retval = ext2fs_write_inode_bitmap(current_fs);
...@@ -1845,7 +1879,7 @@ int main(int argc, char **argv) ...@@ -1845,7 +1879,7 @@ int main(int argc, char **argv)
{ {
int retval; int retval;
const char *usage = const char *usage =
"Usage: %s [-b blocksize] [-s superblock] [-f cmd_file] " "Usage: %s [-b blocksize] [-m mnt_point] [-s superblock] [-f cmd_file] "
"[-R request] [-V] [" "[-R request] [-V] ["
#ifndef READ_ONLY #ifndef READ_ONLY
"[-w] [-z undo_file] " "[-w] [-z undo_file] "
...@@ -1854,6 +1888,7 @@ int main(int argc, char **argv) ...@@ -1854,6 +1888,7 @@ int main(int argc, char **argv)
int c; int c;
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS; int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
char *request = 0; char *request = 0;
char *mnt_pt = 0;
int exit_status = 0; int exit_status = 0;
char *cmd_file = 0; char *cmd_file = 0;
blk64_t superblock = 0; blk64_t superblock = 0;
...@@ -1861,9 +1896,9 @@ int main(int argc, char **argv) ...@@ -1861,9 +1896,9 @@ int main(int argc, char **argv)
int catastrophic = 0; int catastrophic = 0;
char *data_filename = 0; char *data_filename = 0;
#ifdef READ_ONLY #ifdef READ_ONLY
const char *opt_string = "nicR:f:b:s:Vd:D"; const char *opt_string = "nicR:f:b:s:Vd:Dm:";
#else #else
const char *opt_string = "niwcR:f:b:s:Vd:Dz:"; const char *opt_string = "niwcR:f:b:s:Vd:Dz:m:";
char *undo_file = NULL; char *undo_file = NULL;
#endif #endif
#ifdef CONFIG_JBD_DEBUG #ifdef CONFIG_JBD_DEBUG
...@@ -1898,6 +1933,9 @@ int main(int argc, char **argv) ...@@ -1898,6 +1933,9 @@ int main(int argc, char **argv)
case 'R': case 'R':
request = optarg; request = optarg;
break; break;
case 'm':
mnt_pt = optarg;
break;
case 'f': case 'f':
cmd_file = optarg; cmd_file = optarg;
break; break;
...@@ -1948,7 +1986,7 @@ int main(int argc, char **argv) ...@@ -1948,7 +1986,7 @@ int main(int argc, char **argv)
if (optind < argc) if (optind < argc)
open_filesystem(argv[optind], open_flags, open_filesystem(argv[optind], open_flags,
superblock, blocksize, catastrophic, superblock, blocksize, catastrophic,
data_filename, undo_file); data_filename, undo_file, mnt_pt);
sci_idx = ss_create_invocation(debug_prog_name, "0.0", (char *) NULL, sci_idx = ss_create_invocation(debug_prog_name, "0.0", (char *) NULL,
&debug_cmds, &retval); &debug_cmds, &retval);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment