fix uno/ultimo harddisk detection
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-devtools / mtd / mtd-utils-1.4.9 / mkfs.ubifs-allow-output-file-creation-on-different-device.patch
1 diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
2 index f77e5e6..e002be5 100644
3 --- a/mkfs.ubifs/mkfs.ubifs.c
4 +++ b/mkfs.ubifs/mkfs.ubifs.c
5 @@ -324,6 +324,22 @@ static int in_path(const char *dir_name, const char *file_name)
6         return ret;
7  }
8
9 +/*
10 + * same_device - determine if a file is on the same blockdevice as a directory.
11 + * @dir_name: directory path name
12 + * @file_name: file path name
13 + */
14 +static int same_device(const char *dir_name, const char *file_name)
15 +{
16 +       struct stat stat1, stat2;
17 +
18 +       if (stat(dir_name, &stat1) == -1)
19 +               return -1;
20 +       if (stat(file_name, &stat2) == -1)
21 +               return -1;
22 +       return stat1.st_dev == stat2.st_dev;
23 +}
24 +
25  /**
26   * calc_min_log_lebs - calculate the minimum number of log LEBs needed.
27   * @max_bud_bytes: journal size (buds only)
28 @@ -376,7 +392,7 @@ static int validate_options(void)
29
30         if (!output)
31                 return err_msg("no output file or UBI volume specified");
32 -       if (root && in_path(root, output))
33 +       if (root && same_device(root, output) && in_path(root, output))
34                 return err_msg("output file cannot be in the UBIFS root "
35                                "directory");
36         if (!is_power_of_2(c->min_io_size))