neil / rpms / udisks2

Forked from rpms/udisks2 a year ago
Clone
DistroBaker 2fccc8
commit ef1979d8cbfb8ad976de0af21a70f8c0f98fbbe9
DistroBaker 2fccc8
Author: Tomas Bzatek <tbzatek@redhat.com>
DistroBaker 2fccc8
Date:   Wed Mar 17 18:50:19 2021 +0100
DistroBaker 2fccc8
DistroBaker 2fccc8
    udiskslinuxfsinfo: Add dosfstools >= 4.2 quirks
DistroBaker 2fccc8
    
DistroBaker 2fccc8
    Reverting back the legacy behaviour with no protective (fake) MBR
DistroBaker 2fccc8
    created while making new FAT filesystem on an unpartitioned block device.
DistroBaker 2fccc8
    
DistroBaker 2fccc8
    Added a label clear functionality as well.
DistroBaker 2fccc8
DistroBaker 2fccc8
diff --git a/src/udiskslinuxfsinfo.c b/src/udiskslinuxfsinfo.c
DistroBaker 2fccc8
index 15af26c8..f18b9b80 100644
DistroBaker 2fccc8
--- a/src/udiskslinuxfsinfo.c
DistroBaker 2fccc8
+++ b/src/udiskslinuxfsinfo.c
DistroBaker 2fccc8
@@ -21,6 +21,8 @@
DistroBaker 2fccc8
 #include <string.h>
DistroBaker 2fccc8
 #include <glib.h>
DistroBaker 2fccc8
 
DistroBaker 2fccc8
+#include <blockdev/exec.h>
DistroBaker 2fccc8
+
DistroBaker 2fccc8
 #include "config.h"
DistroBaker 2fccc8
 #include "udiskslinuxfsinfo.h"
DistroBaker 2fccc8
 #include "udisksconfigmanager.h"
DistroBaker 2fccc8
@@ -236,6 +238,19 @@ const FSInfo _fs_info[] =
DistroBaker 2fccc8
     },
DistroBaker 2fccc8
   };
DistroBaker 2fccc8
 
DistroBaker 2fccc8
+/* workaround for dosfstools >= 4.2 */
DistroBaker 2fccc8
+static const FSInfo vfat_dosfstools_42 =
DistroBaker 2fccc8
+    {
DistroBaker 2fccc8
+      FS_VFAT,
DistroBaker 2fccc8
+      "fatlabel $DEVICE $LABEL",
DistroBaker 2fccc8
+      "fatlabel --reset $DEVICE",
DistroBaker 2fccc8
+      FALSE, /* supports_online_label_rename */
DistroBaker 2fccc8
+      FALSE, /* supports_owners */
DistroBaker 2fccc8
+      "mkfs.vfat -I -n $LABEL --mbr=n $DEVICE",
DistroBaker 2fccc8
+      NULL,
DistroBaker 2fccc8
+      NULL, /* option_no_discard */
DistroBaker 2fccc8
+    };
DistroBaker 2fccc8
+
DistroBaker 2fccc8
 /**
DistroBaker 2fccc8
  * get_fs_info:
DistroBaker 2fccc8
  *
DistroBaker 2fccc8
@@ -248,6 +263,7 @@ const FSInfo _fs_info[] =
DistroBaker 2fccc8
 const FSInfo *
DistroBaker 2fccc8
 get_fs_info (const gchar *fstype)
DistroBaker 2fccc8
 {
DistroBaker 2fccc8
+  const FSInfo *info = NULL;
DistroBaker 2fccc8
   guint n;
DistroBaker 2fccc8
 
DistroBaker 2fccc8
   g_return_val_if_fail (fstype != NULL, NULL);
DistroBaker 2fccc8
@@ -255,10 +271,20 @@ get_fs_info (const gchar *fstype)
DistroBaker 2fccc8
   for (n = 0; n < sizeof(_fs_info)/sizeof(FSInfo); n++)
DistroBaker 2fccc8
     {
DistroBaker 2fccc8
       if (strcmp (_fs_info[n].fstype, fstype) == 0)
DistroBaker 2fccc8
-        return &_fs_info[n];
DistroBaker 2fccc8
+        {
DistroBaker 2fccc8
+          info = &_fs_info[n];
DistroBaker 2fccc8
+          break;
DistroBaker 2fccc8
+        }
DistroBaker 2fccc8
+    }
DistroBaker 2fccc8
+
DistroBaker 2fccc8
+  /* dosfstools >= 4.2 workaround */
DistroBaker 2fccc8
+  if (g_str_equal (fstype, FS_VFAT) &&
DistroBaker 2fccc8
+      bd_utils_check_util_version ("mkfs.vfat", "4.2", "--help", "mkfs.fat\\s+([\\d\\.]+).+", NULL))
DistroBaker 2fccc8
+    {
DistroBaker 2fccc8
+      info = &vfat_dosfstools_42;
DistroBaker 2fccc8
     }
DistroBaker 2fccc8
 
DistroBaker 2fccc8
-  return NULL;
DistroBaker 2fccc8
+  return info;
DistroBaker 2fccc8
 }
DistroBaker 2fccc8
 
DistroBaker 2fccc8
 /**