From: Artem Bityutskiy <dedekind1@gmail.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: Brian Foster <brian.foster@maxim-ic.com>, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/2] libmtd: add `mtd_dev_present()' library function
Date: Thu, 02 Feb 2012 13:33:24 +0200 [thread overview]
Message-ID: <1328182404.28171.161.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1327689046-1450-1-git-send-email-computersforpeace@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]
On Fri, 2012-01-27 at 10:30 -0800, Brian Norris wrote:
> +int mtd_dev_present(libmtd_t desc, int mtd_num) {
> + struct stat st;
> + struct libmtd *lib = (struct libmtd *)desc;
> + char file[strlen(lib->mtd) + 10];
> +
> + sprintf(file, lib->mtd, mtd_num);
> + return !stat(file, &st);
> +}
Thanks! However...
This will only work for relatively newer kernels where MTD has sysfs
support (2.6.30+). Older kernels have no MTD sysfs support and the sysfs
file you are stat()'ing won't exist, so this function will always return
an error.
I've added the following stub to 'mtd_dev_present()':
+ if (!lib->sysfs_supported)
+ /* TODO: add legacy_dev_present() function */
+ return 1;
And pushed your patches to mtd-utils.
This means old kernels won't be fixed, but at least they won't be broken
either. Do you have enough juice to add a 'legacy_def_present()'
function? Ideally, it should parse '/proc/mtd', but I think there are
functions already which just check for '/dev/mtdX' node, so you could
just stat it instead of the sysfs file, I guess. See
'legacy_get_dev_info1()' for example.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-02-02 11:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 18:30 [PATCH 1/2] libmtd: add `mtd_dev_present()' library function Brian Norris
2012-01-27 18:30 ` [PATCH 2/2] mtdinfo: fix `--all' for non-consecutive device numbers Brian Norris
2012-01-27 18:32 ` Brian Norris
2012-02-02 11:33 ` Artem Bityutskiy [this message]
2012-02-02 13:20 ` [PATCH 1/2] libmtd: add `mtd_dev_present()' library function Brian Foster
2012-02-03 9:17 ` Artem Bityutskiy
2012-02-08 21:28 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328182404.28171.161.camel@sauron.fi.intel.com \
--to=dedekind1@gmail.com \
--cc=brian.foster@maxim-ic.com \
--cc=computersforpeace@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox