]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blobdiff - misc/tune2fs.c
tune2fs, mke2fs: add the ability to control the location of the journal
[thirdparty/e2fsprogs.git] / misc / tune2fs.c
index 3730821a67653c0392019bb115943bcd96a1fb6b..64a76f1e4864889ef1c0561ee3e6cda67adaf248 100644 (file)
@@ -26,7 +26,6 @@
  */
 
 #define _XOPEN_SOURCE 600 /* for inclusion of strptime() */
-#define _BSD_SOURCE /* for inclusion of strcasecmp() */
 #include "config.h"
 #include <fcntl.h>
 #include <grp.h>
@@ -41,6 +40,11 @@ extern int optind;
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>   /* for strcasecmp() */
+#else
+#define _BSD_SOURCE    /* for inclusion of strcasecmp() via <string.h> */
+#endif
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
@@ -94,6 +98,7 @@ static int usrquota, grpquota;
 
 int journal_size, journal_flags;
 char *journal_device;
+static blk64_t journal_location = ~0LL;
 
 static struct list_head blk_move_list;
 
@@ -690,8 +695,13 @@ static int add_journal(ext2_filsys fs)
                fflush(stdout);
                journal_blocks = figure_journal_size(journal_size, fs);
 
-               retval = ext2fs_add_journal_inode(fs, journal_blocks,
-                                                 journal_flags);
+               if (journal_location_string)
+                       journal_location =
+                               parse_num_blocks2(journal_location_string,
+                                                 fs->super->s_log_block_size);
+               retval = ext2fs_add_journal_inode2(fs, journal_blocks,
+                                                  journal_location,
+                                                  journal_flags);
                if (retval) {
                        fprintf(stderr, "\n");
                        com_err(program_name, retval, "%s",
@@ -765,6 +775,7 @@ static void handle_quota_options(ext2_filsys fs)
        return;
 }
 
+#ifdef CONFIG_QUOTA
 static void parse_quota_opts(const char *opts)
 {
        char    *buf, *token, *next, *p;
@@ -807,8 +818,7 @@ static void parse_quota_opts(const char *opts)
        }
        free(buf);
 }
-
-
+#endif
 
 static void parse_e2label_options(int argc, char ** argv)
 {
@@ -1852,15 +1862,12 @@ static int tune2fs_setup_tdb(const char *name, io_manager *io_ptr)
                goto alloc_fn_fail;
        sprintf(tdb_file, "%s/tune2fs-%s.e2undo", tdb_dir, dev_name);
 
-       if (!access(tdb_file, F_OK)) {
-               if (unlink(tdb_file) < 0) {
-                       retval = errno;
-                       com_err(program_name, retval,
-                               _("while trying to delete %s"),
-                               tdb_file);
-                       free(tdb_file);
-                       return retval;
-               }
+       if ((unlink(tdb_file) < 0) && (errno != ENOENT)) {
+               retval = errno;
+               com_err(program_name, retval,
+                       _("while trying to delete %s"), tdb_file);
+               free(tdb_file);
+               return retval;
        }
 
        set_undo_io_backing_manager(*io_ptr);