aboutsummaryrefslogtreecommitdiff
path: root/ubifs-utils/libubifs
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-11-11 17:01:01 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-11-11 10:32:45 +0100
commit0fb533f5695837f49f3c62c82999b37fa4f244af (patch)
tree2b49660817baf73c61e3bf1cadd4d8d4e03ab231 /ubifs-utils/libubifs
parent665c44e7c9135a58847ab0773fc7977929d1497c (diff)
ubifs-utils: open_ubi: Set errno if the target is not char device
Set errno if the target is not char device. It will be useful for fsck to print error message if open_ubi failed. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/libubifs')
-rw-r--r--ubifs-utils/libubifs/super.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ubifs-utils/libubifs/super.c b/ubifs-utils/libubifs/super.c
index 1cbbfca..9fa366f 100644
--- a/ubifs-utils/libubifs/super.c
+++ b/ubifs-utils/libubifs/super.c
@@ -43,9 +43,14 @@ int open_ubi(struct ubifs_info *c, const char *node)
{
struct stat st;
- if (stat(node, &st) || !S_ISCHR(st.st_mode))
+ if (stat(node, &st))
return -1;
+ if (!S_ISCHR(st.st_mode)) {
+ errno = ENODEV;
+ return -1;
+ }
+
c->libubi = libubi_open();
if (!c->libubi)
return -1;