summaryrefslogtreecommitdiffstats
path: root/include/common.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-09-21 14:21:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-09-26 08:55:00 +0200
commitb234a6da331fa9ec656f2d278adafdeea45f9073 (patch)
tree9bd39a9df35d2da6c1be33339b54cf6c2ee56aca /include/common.h
parentc6bdbf6e93a11227f91fbf15b7a36dceb60c526d (diff)
downloadbarebox-b234a6da331fa9ec656f2d278adafdeea45f9073.tar.gz
barebox-b234a6da331fa9ec656f2d278adafdeea45f9073.tar.xz
environment: Do not use environment when overlapping with other partitions
Environment partitions are usually specified with their hardcoded offset and size, either in the device tree or the board file. These partitions potentially overlap with other partitions read from the partition table. Overlapping partitions for sure have bad effects. Be more friendly to our users and warn them when such a situation occurs and stop using that partition for storing the environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index abbe73fd36..f52c7e430c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -157,4 +157,14 @@ static inline bool region_overlap(unsigned long starta, unsigned long lena,
return 1;
}
+static inline bool lregion_overlap(loff_t starta, loff_t lena,
+ loff_t startb, loff_t lenb)
+{
+ if (starta + lena <= startb)
+ return 0;
+ if (startb + lenb <= starta)
+ return 0;
+ return 1;
+}
+
#endif /* __COMMON_H_ */