1 diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
2 index 200c8a5..00b97f4 100644
3 --- a/mkfs.ubifs/mkfs.ubifs.c
4 +++ b/mkfs.ubifs/mkfs.ubifs.c
5 @@ -286,6 +286,22 @@ out_free:
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
14 +static int same_device(const char *dir_name, const char *file_name)
16 + struct stat stat1, stat2;
18 + if (stat(dir_name, &stat1) == -1)
20 + if (stat(file_name, &stat2) == -1)
22 + return stat1.st_dev == stat2.st_dev;
26 * calc_min_log_lebs - calculate the minimum number of log LEBs needed.
27 * @max_bud_bytes: journal size (buds only)
28 @@ -338,7 +354,7 @@ static int validate_options(void)
31 return err_msg("no output file or UBI volume specified");
33 + if (root && same_device(root, output)) {
34 tmp = is_contained(output, root);
36 return err_msg("failed to perform output file root check");