* [PATCH 1/2] libubi: make `ubi_dev_present()' a library function
@ 2012-01-26 7:31 Brian Norris
2012-01-26 7:31 ` [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers Brian Norris
2012-01-27 14:51 ` [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Artem Bityutskiy
0 siblings, 2 replies; 6+ messages in thread
From: Brian Norris @ 2012-01-26 7:31 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris, Artem Bityutskiy
We will use this function in ubinfo.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
ubi-utils/include/libubi.h | 9 +++++++++
ubi-utils/libubi.c | 12 +++---------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h
index 02017e8..dc03d02 100644
--- a/ubi-utils/include/libubi.h
+++ b/ubi-utils/include/libubi.h
@@ -346,6 +346,15 @@ int ubi_get_dev_info(libubi_t desc, const char *node,
struct ubi_dev_info *info);
/**
+ * ubi_dev_present - check whether an UBI device is present.
+ * @desc: UBI library descriptor
+ * @dev_num: UBI device number to check
+ *
+ * This function returns %1 if UBI device is present and %0 if not.
+ */
+int ubi_dev_present(libubi_t desc, int dev_num);
+
+/**
* ubi_get_dev_info1 - get UBI device information.
* @desc: UBI library descriptor
* @dev_num: UBI device number to fetch information about
diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
index 4d5f316..c898e36 100644
--- a/ubi-utils/libubi.c
+++ b/ubi-utils/libubi.c
@@ -1121,16 +1121,10 @@ int ubi_leb_change_start(libubi_t desc, int fd, int lnum, int bytes, int dtype)
return 0;
}
-/**
- * dev_present - check whether an UBI device is present.
- * @lib: libubi descriptor
- * @dev_num: UBI device number to check
- *
- * This function returns %1 if UBI device is present and %0 if not.
- */
-static int dev_present(struct libubi *lib, int dev_num)
+int ubi_dev_present(libubi_t desc, int dev_num)
{
struct stat st;
+ struct libubi *lib = (struct libubi *)desc;
char file[strlen(lib->ubi_dev) + 50];
sprintf(file, lib->ubi_dev, dev_num);
@@ -1146,7 +1140,7 @@ int ubi_get_dev_info1(libubi_t desc, int dev_num, struct ubi_dev_info *info)
memset(info, 0, sizeof(struct ubi_dev_info));
info->dev_num = dev_num;
- if (!dev_present(lib, dev_num))
+ if (!ubi_dev_present(desc, dev_num))
return -1;
sysfs_ubi = opendir(lib->sysfs_ubi);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers
2012-01-26 7:31 [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Brian Norris
@ 2012-01-26 7:31 ` Brian Norris
2012-01-26 8:53 ` Brian Foster
2012-01-27 14:51 ` [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Artem Bityutskiy
1 sibling, 1 reply; 6+ messages in thread
From: Brian Norris @ 2012-01-26 7:31 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Foster, Brian Norris, Artem Bityutskiy
When we have assigned non-consecutive device numbers to our UBI devices,
then we run `ubinfo --all', we get errors once ubinfo tries to process the
devices in the "hole". For instance, suppose there are two UBI devices,
/dev/ubi0 and /dev/ubi10; then, ubinfo will fail trying to open /dev/ubi1
with:
ubinfo: error!: cannot get information about UBI device 1
error 2 (No such file or directory)
This patch adds a check to first see if device is present, then continue
to the next ID if it doesn't exist.
Reported-by: Brian Foster <brian.foster@maxim-ic.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
ubi-utils/ubinfo.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/ubi-utils/ubinfo.c b/ubi-utils/ubinfo.c
index 7aa4aa4..cb88f53 100644
--- a/ubi-utils/ubinfo.c
+++ b/ubi-utils/ubinfo.c
@@ -362,6 +362,8 @@ static int print_general_info(libubi_t libubi, int all)
for (i = ubi_info.lowest_dev_num;
i <= ubi_info.highest_dev_num; i++) {
+ if (!ubi_dev_present(libubi, i))
+ continue;
if(!first)
printf("\n===================================\n\n");
first = 0;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers
2012-01-26 7:31 ` [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers Brian Norris
@ 2012-01-26 8:53 ` Brian Foster
2012-01-27 18:28 ` Brian Norris
0 siblings, 1 reply; 6+ messages in thread
From: Brian Foster @ 2012-01-26 8:53 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-mtd@lists.infradead.org, Artem Bityutskiy
On Thursday 26 January 2012 08:31:50 Brian Norris wrote:
> When we have assigned non-consecutive device numbers to our UBI devices [...]
> This patch adds a check to first see if device is present, then continue
> to the next ID if it doesn't exist.
>[ ... ]
Looks Ok to me (when used with part 1).
However, looking at the mtd-utils v1.4.6 ‘mtdinfo.c’,
is there a similar issue there? But I have no idea
how you could get non-consecutive MTD device numbers?
cheers!
-blf-
--
Brian Foster
Principal MTS, Software | La Ciotat, France
Maxim Integrated Products | Web: http://www.maxim-ic.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers
2012-01-26 8:53 ` Brian Foster
@ 2012-01-27 18:28 ` Brian Norris
2012-01-30 8:32 ` Brian Foster
0 siblings, 1 reply; 6+ messages in thread
From: Brian Norris @ 2012-01-27 18:28 UTC (permalink / raw)
To: Brian Foster; +Cc: linux-mtd@lists.infradead.org, Artem Bityutskiy
On Thu, Jan 26, 2012 at 12:53 AM, Brian Foster
<brian.foster@maxim-ic.com> wrote:
> On Thursday 26 January 2012 08:31:50 Brian Norris wrote:
>> When we have assigned non-consecutive device numbers to our UBI devices [...]
>> This patch adds a check to first see if device is present, then continue
>> to the next ID if it doesn't exist.
>>[ ... ]
>
> Looks Ok to me (when used with part 1).
>
> However, looking at the mtd-utils v1.4.6 ‘mtdinfo.c’,
> is there a similar issue there? But I have no idea
> how you could get non-consecutive MTD device numbers?
Yeah, there is a problem there. It's a little more difficult to see,
but it can happen.
Suppose you have /dev/mtd0 on your system, then you can get an error
with the following sequence:
# modprobe mtdram
# modprobe nandsim
# rmmod mtdram
# mtdinfo --all
...
mtdinfo: error!: mtd1 does not correspond to any existing MTD device
I'm sending a quick patch set for this.
Brian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers
2012-01-27 18:28 ` Brian Norris
@ 2012-01-30 8:32 ` Brian Foster
0 siblings, 0 replies; 6+ messages in thread
From: Brian Foster @ 2012-01-30 8:32 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-mtd@lists.infradead.org, Artem Bityutskiy
On Friday 27 January 2012 19:28:59 Brian Norris wrote:
> On Thu, Jan 26, 2012 at 12:53 AM, Brian Foster <brian.foster@maxim-ic.com> wrote:
> > [ ... ] looking at the mtd-utils v1.4.6 ‘mtdinfo.c’,
> > is there a similar issue there? But I have no idea
> > how you could get non-consecutive MTD device numbers?
>
> Yeah, there is a problem there. It's a little more difficult to see,
> but it can happen.
>
> Suppose you have /dev/mtd0 on your system, then you can get an error
> with the following sequence:
>
> # modprobe mtdram
> # modprobe nandsim
> # rmmod mtdram
> # mtdinfo --all
> ...
> mtdinfo: error!: mtd1 does not correspond to any existing MTD device
Ah, Ok! I had a similar thought over the weekend,
and before seeing your e-mail tried to set-up the
situation up on one of our SoC evaluation boards,
using our H/W drivers. But for some reason those
drivers won't unload — I should look into that —
and then saw your e-mails ....
> I'm sending a quick patch set for this.
Yeah, saw it, seemed Ok to me. Thanks.
cheers!
-blf-
--
Brian Foster
Principal MTS, Software | La Ciotat, France
Maxim Integrated Products | Web: http://www.maxim-ic.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] libubi: make `ubi_dev_present()' a library function
2012-01-26 7:31 [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Brian Norris
2012-01-26 7:31 ` [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers Brian Norris
@ 2012-01-27 14:51 ` Artem Bityutskiy
1 sibling, 0 replies; 6+ messages in thread
From: Artem Bityutskiy @ 2012-01-27 14:51 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
On Wed, 2012-01-25 at 23:31 -0800, Brian Norris wrote:
> We will use this function in ubinfo.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Many thanks Brian for the fixes, pushed to mtd-utils.git!
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-01-30 8:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-26 7:31 [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Brian Norris
2012-01-26 7:31 ` [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers Brian Norris
2012-01-26 8:53 ` Brian Foster
2012-01-27 18:28 ` Brian Norris
2012-01-30 8:32 ` Brian Foster
2012-01-27 14:51 ` [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox