summaryrefslogtreecommitdiff
path: root/resize/main.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1997-06-07 20:42:58 +0000
committerTheodore Ts'o <tytso@mit.edu>1997-06-07 20:42:58 +0000
commit24b2c7a7a14cec8480a75af7d535cf267e6abe1f (patch)
tree39dd3de021111ff7f59817761098bdbb864a0517 /resize/main.c
parent5972d0d6444bd3085ba198ed9281d9105105d821 (diff)
downloade2fsprogs-24b2c7a7a14cec8480a75af7d535cf267e6abe1f.tar.gz
ChangeLog, Makefile.in, configure.in:
configure.in (rmakefile): Added (optional) private directory for resize2fs. Makefile.in: Change recursive descent rules to check to see if a directory exists before trying to make it. Many files: Initial checkin of work done to date.
Diffstat (limited to 'resize/main.c')
-rw-r--r--resize/main.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/resize/main.c b/resize/main.c
new file mode 100644
index 00000000..b664664c
--- /dev/null
+++ b/resize/main.c
@@ -0,0 +1,76 @@
+/*
+ * main.c --- ext2 resizer main program
+ *
+ * Copyright (C) 1997 Theodore Ts'o
+ *
+ * %Begin-Header%
+ * All rights reserved.
+ * %End-Header%
+ */
+
+#include "resize2fs.h"
+
+#define E2FSPROGS_VERSION "1.10"
+#define E2FSPROGS_DATE "27-Apr-97"
+
+char *program_name, *device_name;
+
+static volatile void usage (char *program_name)
+{
+ fprintf (stderr, "usage: %s device new-size\n", program_name);
+ exit (1);
+}
+
+void main (int argc, char ** argv)
+{
+ errcode_t retval;
+ ext2_filsys fs;
+ int c;
+ blk_t new_size;
+ io_manager io_ptr;
+
+ fprintf (stderr, "resize2fs %s, %s for EXT2 FS %s, %s\n",
+ E2FSPROGS_VERSION, E2FSPROGS_DATE,
+ EXT2FS_VERSION, EXT2FS_DATE);
+ if (argc && *argv)
+ program_name = *argv;
+
+ while ((c = getopt (argc, argv, "h")) != EOF) {
+ switch (c) {
+ case 'h':
+ usage(program_name);
+ break;
+ default:
+ usage (program_name);
+ }
+ }
+ if (optind > argc - 2)
+ usage (program_name);
+ device_name = argv[optind++];
+ new_size = atoi(argv[optind++]);
+ initialize_ext2_error_table();
+#if 1
+ io_ptr = unix_io_manager;
+#else
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+#endif
+ retval = ext2fs_open (device_name, 0, 0, 0,
+ io_ptr, &fs);
+ if (retval) {
+ com_err (program_name, retval, "while trying to open %s",
+ device_name);
+ printf ("Couldn't find valid filesystem superblock.\n");
+ exit (1);
+ }
+ retval = ext2fs_read_bitmaps(fs);
+ if (retval) {
+ com_err (program_name, retval,
+ "while trying to read the bitmaps", device_name);
+ ext2fs_close (fs);
+ exit (1);
+ }
+ resize_fs(fs, new_size);
+ ext2fs_close (fs);
+ exit (0);
+}