#include <fcntl.h>
#include <sys/ioctl.h>
-
#include "resize2fs.h"
-#include "../version.h"
+#include "./version.h"
+
+#define EXPIRE_TIME 905835600
+
+#ifdef EXPIRE_TIME
+static void check_expire_time(const char *progname);
+#endif
char *program_name, *device_name;
static volatile void usage (char *prog)
{
- fprintf (stderr, "usage: %s [-d debug_flags] [-f] [-F] [-p] device new-size\n", prog);
+ fprintf (stderr, "usage: %s [-d debug_flags] [-f] [-F] [-p] device new-size\n\n", prog);
+
+#ifdef EXPIRE_TIME
+ check_expire_time(program_name);
+#endif
exit (1);
}
return 0;
}
-static void check_mount(char *device_name)
+static void check_mount(char *device)
{
errcode_t retval;
int mount_flags;
- retval = ext2fs_check_if_mounted(device_name, &mount_flags);
+ retval = ext2fs_check_if_mounted(device, &mount_flags);
if (retval) {
com_err("ext2fs_check_if_mount", retval,
"while determining whether %s is mounted.",
- device_name);
+ device);
return;
}
if (!(mount_flags & EXT2_MF_MOUNTED))
return;
fprintf(stderr, "%s is mounted; can't resize a "
- "mounted filesystem!\n\n", device_name);
+ "mounted filesystem!\n\n", device);
exit(1);
}
+#ifdef EXPIRE_TIME
+static void check_expire_time(const char *progname)
+{
+ time_t timenow;
+
+ timenow = time(0);
+
+ if (timenow > EXPIRE_TIME) {
+ fprintf(stderr, "This beta-test version of %s is expired.\n"
+ "Please contact PowerQuest to get an updated version "
+ "of this program.\n\n", progname);
+ exit(1);
+ } else {
+ fprintf(stderr, "Please note this is a beta-test version of "
+ "%s which will\nexpire in %d days.\n\n", progname,
+ (EXPIRE_TIME - timenow) / (60*60*24));
+ }
+}
+#endif
+
+
void main (int argc, char ** argv)
{
blk_t max_size = 0;
io_manager io_ptr;
char *tmp;
-
+ struct ext2fs_sb *s;
+
initialize_ext2_error_table();
- fprintf (stderr, "resize2fs %s, %s for EXT2 FS %s, %s\n",
- E2FSPROGS_VERSION, E2FSPROGS_DATE,
- EXT2FS_VERSION, EXT2FS_DATE);
+ fprintf (stderr, "resize2fs %s (%s)\n",
+ E2FSPROGS_VERSION, E2FSPROGS_DATE);
+ fprintf(stderr, "Copyright 1998 by Theodore Ts'o and PowerQuest, Inc. All Rights Reserved.\n\n");
if (argc && *argv)
program_name = *argv;
-
+
while ((c = getopt (argc, argv, "d:fFhp")) != EOF) {
switch (c) {
case 'h':
}
if (optind == argc)
usage(program_name);
+
+#ifdef EXPIRE_TIME
+ check_expire_time(program_name);
+#endif
+
device_name = argv[optind++];
if (optind < argc) {
new_size = strtoul(argv[optind++], &tmp, 0);
printf ("Couldn't find valid filesystem superblock.\n");
exit (1);
}
-
+ /*
+ * Check for compatibility with the feature sets. We need to
+ * be more stringent than ext2fs_open().
+ */
+ s = (struct ext2fs_sb *) fs->super;
+ if ((s->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
+ (s->s_feature_incompat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
+ com_err(program_name, EXT2_ET_UNSUPP_FEATURE,
+ "(%s)", device_name);
+ exit(1);
+ }
+
/*
* Get the size of the containing partition, and use this for
* defaults and for making sure the new filesystme doesn't