Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* btrfs-tools: debian/patches/08-fsck.patch
@ 2013-05-20 15:00 Holger Fischer
  0 siblings, 0 replies; only message in thread
From: Holger Fischer @ 2013-05-20 15:00 UTC (permalink / raw)
  To: linux-btrfs

Dear BTRFS-Community,

this patch is a reworked one of the debian-original to address the latest changes in the btrfs-tools source code.

It fixes problems that can occur when you boot a machine with btrfs root filesystem.
Boot can stop, because fsck of the btrfs-root-filesystem fails.

Here the patch:
 >cat 08-fsck.patch
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -3549,6 +3549,12 @@ const char * const cmd_check_usage[] = {
         NULL
  };

+static void cmd_check_info(void)
+{
+       fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+       exit(0);
+}
+
  int cmd_check(int argc, char **argv)
  {
         struct cache_tree root_cache;
@@ -3566,12 +3572,11 @@ int cmd_check(int argc, char **argv)

         while(1) {
                 int c;
-               c = getopt_long(argc, argv, "as:", long_options,
+               c = getopt_long(argc, argv, "as:nry", long_options,
                                 &option_index);
                 if (c < 0)
                         break;
                 switch(c) {
-                       case 'a': /* ignored */ break;
                         case 's':
                                 num = atol(optarg);
                                 bytenr = btrfs_sb_offset(num);
@@ -3581,6 +3586,13 @@ int cmd_check(int argc, char **argv)
                         case '?':
                         case 'h':
                                 usage(cmd_check_usage);
+                               break;
+                       case 'a':
+                       case 'n':
+                       case 'r':
+                       case 'y':
+                               cmd_check_info();
+
                 }
                 if (option_index == 1) {
                         printf("enabling repair mode\n");
--- a/btrfs.c
+++ b/btrfs.c
@@ -270,7 +270,8 @@ int main(int argc, char **argv)
         else
                 bname = argv[0];

-       if (!strcmp(bname, "btrfsck")) {
+       if (!strcmp(bname, "btrfsck") ||
+           !strcmp(bname, "fsck.btrfs")) {
                 argv[0] = "check";
         } else {
                 argc--;


It addresses 2 issues:


- fsck.btrfs is not working anymore:
   to make it work again:
   - fsck.btrfs must be a (sym)link to btrfs (should be fixed in the Makefile which I did not do)
   - when calling $BINPATH/fsck.btrfs the main-function in btrfs.c must add the option "check" as 1st argument
     or described in a 2nd way: do "btrfs check" when basename of executable is fsck.btrfs

   this is equal to the behaviour of btrfsck

   the changes to btrfs.c resolve this issue


- "fsck -a <btrfsroot> (done during boot of at least ubuntu 12.04 with standard settings)
   does not return 0
   -> boot fails:
   to make it work the debian maintainers decided to create a patch which
   - prints an info (btrfs version) and return 0 when
     fsck.btrfs is called with one of the options
     "-a", "-n", "-r" or "-y"

   I rewrote the original patch to make this work again with newer versions of btrfs-tools

   Somebody upstream already cared about including "-a", so it seems somebody already tried to address this issue.


I would be happy to see these patches (or the thoughts behind, if you don't like how it's made) included upstream.

Best Regards
Holger Fischer


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-20 15:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-20 15:00 btrfs-tools: debian/patches/08-fsck.patch Holger Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox