  
      def get_extra_block_count(self, current_blocks):
          """
-@@ -205,9 +207,19 @@ class Partition(object):
+@@ -205,7 +207,13 @@ class Partition(object):
          """
          Prepare content for an ext2/3/4 rootfs partition.
          """
 +        if self.submount_dir:
 +            rootfs_dir = rootfs_dir + "/" + self.submount_dir
 +
-+        exclude_size = 0
+         du_cmd = "du -ks %s" % rootfs_dir
 +        if self.exclude_dirs:
 +            for exdir in self.exclude_dirs:
-+                du_cmd = "du -ks %s" % (rootfs_dir + "/" + exdir)
-+                out = exec_cmd(du_cmd)
-+                exclude_size += int(out.split()[0])
-+
-         du_cmd = "du -ks %s" % rootfs_dir
++                du_cmd = du_cmd + " --exclude " + exdir
          out = exec_cmd(du_cmd)
--        actual_rootfs_size = int(out.split()[0])
-+        actual_rootfs_size = int(out.split()[0]) - exclude_size
-
-         extra_blocks = self.get_extra_block_count(actual_rootfs_size)
-         if extra_blocks < self.extra_space:
-@@ -231,6 +243,8 @@ class Partition(object):
+         actual_rootfs_size = int(out.split()[0])
+ 
+@@ -231,6 +239,8 @@ class Partition(object):
  
          mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \
              (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)

+            if part.submount_dir:
+                prefix = '%s' % (part.submount_dir)
+            msg += '  ROOTFS_DIR%s%s\n' % (suffix.ljust(20), (part.rootfs_dir + prefix))

         msg += '  BOOTIMG_DIR:                  %s\n' % self.bootimg_dir
         msg += '  KERNEL_DIR:                   %s\n' % self.kernel_dir
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py

         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
     def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
@@ -241,6 +251,9 @@ class Partition(object):
         Currently handles ext2/3/4 and btrfs.
         """
         du_cmd = "du -ks %s" % rootfs_dir
+        if self.exclude_dirs:
+            for exdir in self.exclude_dirs:
+                du_cmd = du_cmd + " --exclude " + exdir
         out = exec_cmd(du_cmd)
         actual_rootfs_size = int(out.split()[0])
 
@@ -262,8 +275,10 @@ class Partition(object):
         if self.label:
             label_str = "-L %s" % self.label
 
-        mkfs_cmd = "mkfs.%s -b %d -r %s %s %s" % \
-            (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs)
+        mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \
+                   (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)
+        if self.exclude_dirs:
+            mkfs_cmd = mkfs_cmd + " -w %s" % ",".join(self.exclude_dirs)
         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
     def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir,
@@ -411,4 +426,3 @@ class Partition(object):
             label_str = "-L %s" % self.label
         mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
         exec_native_cmd(mkswap_cmd, native_sysroot)
-
-- 
2.7.4

