diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-23 14:14:54 +0200 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-23 14:14:54 +0200 |
commit | 233824d00b526d82dd2ef05d6dad4dbc5b4cc943 (patch) | |
tree | 05d993e982949d7d1cffca497c969b19ecccd3a9 /ubi-utils/src | |
parent | 9b5008d4874eecf802e9cb292bba79c7c462e816 (diff) |
ubi-utils: be backward-compatible
Since control device is not supported by UBI in mainline kernels,
we should not panic if it is absent.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src')
-rw-r--r-- | ubi-utils/src/libubi.c | 11 | ||||
-rw-r--r-- | ubi-utils/src/ubinfo.c | 7 |
2 files changed, 14 insertions, 4 deletions
diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c index e754747..9aa7847 100644 --- a/ubi-utils/src/libubi.c +++ b/ubi-utils/src/libubi.c @@ -749,8 +749,15 @@ int ubi_get_info(libubi_t desc, struct ubi_info *info) memset(info, '\0', sizeof(struct ubi_info)); - if (read_major(lib->ctrl_dev, &info->ctrl_major, &info->ctrl_minor)) - return -1; + if (read_major(lib->ctrl_dev, &info->ctrl_major, &info->ctrl_minor)) { + /* + * Older UBI versions did not have control device, so we do not + * panic here for compatibility reasons. May be few years later + * we could return -1 here, but for now just set major:minor to + * -1. + */ + info->ctrl_major = info->ctrl_minor = -1; + } /* * We have to scan the UBI sysfs directory to identify how many UBI diff --git a/ubi-utils/src/ubinfo.c b/ubi-utils/src/ubinfo.c index a0bbbec..280c770 100644 --- a/ubi-utils/src/ubinfo.c +++ b/ubi-utils/src/ubinfo.c @@ -335,8 +335,11 @@ static int print_general_info(libubi_t libubi, int all) printf("UBI version: %d\n", ubi_info.version); printf("Count of UBI devices: %d\n", ubi_info.dev_count); - printf("UBI control device major/minor: %d:%d\n", - ubi_info.ctrl_major, ubi_info.ctrl_minor); + if (ubi_info.ctrl_major != -1) + printf("UBI control device major/minor: %d:%d\n", + ubi_info.ctrl_major, ubi_info.ctrl_minor); + else + printf("UBI control device is not supported by this kernel\n"); if (ubi_info.dev_count == 0) return 0; |