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

add freeze

parent 0f543980
......@@ -37,6 +37,9 @@ extern char *optarg;
#include "jfs_user.h"
#include "support/plausible.h"
#include <linux/fs.h>
#include <sys/ioctl.h>
#ifndef BUFSIZ
#define BUFSIZ 8192
#endif
......@@ -53,6 +56,9 @@ ext2_filsys current_fs;
quota_ctx_t current_qctx;
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,
io_manager *io_ptr)
{
......@@ -129,7 +135,8 @@ err:
static void open_filesystem(char *device, int open_flags, blk64_t superblock,
blk64_t blocksize, int catastrophic,
char *data_filename, char *undo_file)
char *data_filename, char *undo_file,
char *mnt_pt)
{
int retval;
io_channel data_io = 0;
......@@ -170,7 +177,16 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock,
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,
io_ptr, &current_fs);
......@@ -211,6 +227,12 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock,
return;
errout:
if (fdDev) {
retval = ioctl(fdDev, FITHAW, 0);
if (retval)
com_err(device, retval, "thaw filesystem failed");
}
retval = ext2fs_close_free(&current_fs);
if (retval)
com_err(device, retval, "while trying to close filesystem");
......@@ -225,9 +247,10 @@ void do_open_filesys(int argc, char **argv)
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
char *data_filename = 0;
char *undo_file = NULL;
char *mnt_pt = NULL;
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) {
case 'i':
open_flags |= EXT2_FLAG_IMAGE_FILE;
......@@ -251,6 +274,9 @@ void do_open_filesys(int argc, char **argv)
case 'd':
data_filename = optarg;
break;
case 'm':
mnt_pt = optarg;
break;
case 'D':
open_flags |= EXT2_FLAG_DIRECT_IO;
break;
......@@ -280,11 +306,11 @@ void do_open_filesys(int argc, char **argv)
return;
open_filesystem(argv[optind], open_flags,
superblock, blocksize, catastrophic,
data_filename, undo_file);
data_filename, undo_file, mnt_pt);
return;
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] "
#ifndef READ_ONLY
"[-w] "
......@@ -297,6 +323,14 @@ print_usage:
static void close_filesystem(NOARGS)
{
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) {
retval = ext2fs_write_inode_bitmap(current_fs);
......@@ -1845,7 +1879,7 @@ int main(int argc, char **argv)
{
int retval;
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] ["
#ifndef READ_ONLY
"[-w] [-z undo_file] "
......@@ -1854,6 +1888,7 @@ int main(int argc, char **argv)
int c;
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
char *request = 0;
char *mnt_pt = 0;
int exit_status = 0;
char *cmd_file = 0;
blk64_t superblock = 0;
......@@ -1861,9 +1896,9 @@ int main(int argc, char **argv)
int catastrophic = 0;
char *data_filename = 0;
#ifdef READ_ONLY
const char *opt_string = "nicR:f:b:s:Vd:D";
const char *opt_string = "nicR:f:b:s:Vd:Dm:";
#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;
#endif
#ifdef CONFIG_JBD_DEBUG
......@@ -1898,6 +1933,9 @@ int main(int argc, char **argv)
case 'R':
request = optarg;
break;
case 'm':
mnt_pt = optarg;
break;
case 'f':
cmd_file = optarg;
break;
......@@ -1948,7 +1986,7 @@ int main(int argc, char **argv)
if (optind < argc)
open_filesystem(argv[optind], open_flags,
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,
&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