fix typo
[vuplus_openembedded] / recipes / mtd / mtd-utils-1.4.6 / 0001-mkfs.ubifs-allow-output-file-creation-on-different-device.patch
diff --git a/recipes/mtd/mtd-utils-1.4.6/0001-mkfs.ubifs-allow-output-file-creation-on-different-device.patch b/recipes/mtd/mtd-utils-1.4.6/0001-mkfs.ubifs-allow-output-file-creation-on-different-device.patch
new file mode 100644 (file)
index 0000000..d8dc249
--- /dev/null
@@ -0,0 +1,36 @@
+diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
+index ac3c8d3..b4fb32c 100644
+--- a/mkfs.ubifs/mkfs.ubifs.c
++++ b/mkfs.ubifs/mkfs.ubifs.c
+@@ -296,6 +296,22 @@ static int do_openat(int fd, const char *path, int flags)
+       return ret;
+ }
++/*
++* same_device - determine if a file is on the same blockdevice as a directory.
++* @dir_name: directory path name
++* @file_name: file path name
++*/
++static int same_device(const char *dir_name, const char *file_name)
++{
++      struct stat stat1, stat2;
++      if (stat(dir_name, &stat1) == -1)
++              return -1;
++      if (stat(file_name, &stat2) == -1)
++              return -1;
++      return stat1.st_dev == stat2.st_dev;
++}
++
++
+ /**
+  * in_path - determine if a file is beneath a directory.
+  * @dir_name: directory path name
+@@ -401,7 +417,7 @@ static int validate_options(void)
+       if (!output)
+               return err_msg("no output file or UBI volume specified");
+-      if (root && in_path(root, output))
++      if (root && same_device(root, output) && in_path(root, output))
+               return err_msg("output file cannot be in the UBIFS root "
+                              "directory");
+       if (!is_power_of_2(c->min_io_size))