public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: umar@janteq.com
To: dedekind1@gmail.com
Cc: linux-mtd@lists.infradead.org, Umar Qureshey <umar@janteq.com>
Subject: Re: Discovering current MTD partition
Date: Wed, 27 Apr 2011 03:25:22 -0400	[thread overview]
Message-ID: <896346e425b9fed6ed42ee9c4144e135.squirrel@emailmg.startlogic.com> (raw)
In-Reply-To: <1303882262.2778.51.camel@localhost>

> On Tue, 2011-04-26 at 16:43 -0700, Umar Qureshey wrote:
>> Hi,
>>
>> I searched this list's archive but did not see anything pertinent.
>>
>> I was wondering if there is a way to find out what the currently active
>> mtd
>> partition is.  In my system, I have a few flash partitions for my file
>> system and the kernel boots with the partition that is specified on the
>> kernel command line.  Aside from scanning /proc/cmdline, is there a way
>> to
>> programmatically ascertain which mtd partition is active *now*.
>> I need to find this information within a Python script but really if it
>> can
>> be done in C (perhaps a syscall?), it's all I need.
>
> What does active mean? Anyway, there is /proc/mtd at your disposal.
>
> --
> Best Regards,
> Artem Bityutskiy (Артём Битюцкий)
>
>
Hi,
I have multiple redundant partitions on the flash chip.  Each of these
partitions has been flashed with a file system.  The kernel resides in yet
another partition.  The bootloader loads the kernel into RAM, passes it
the kernel command line, and passes control to the kernel.  The kernel
boots and mounts the partition it was told to do so via the command line.

So, for instance, I may have this scheme:

/dev/mtd2  ---> kernel
/dev/mtd3 -----> FS #1
/dev/mtd4 -----> FS #2

The kernel can boot and mount either /dev/mtd3 or /dev/mtd4 depending on
what command line the bootloader passed to the kernel.
What I'd like is to detect from userspace is which /dev/mtdX partition is
the currently executing program running on because that is the partition
that has been obviously booted.

My fallback idea is to just bite the bullet and parse /proc/cmdline to see
which partition is being passed to the kernel.  This should work fine. 
But I was curious if there is a "cleaner" more programmatic method of
determining this information without resorting to clever regular
expressions in parsing /proc/cmdline.

  parent reply	other threads:[~2011-04-27  7:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 23:43 Discovering current MTD partition Umar Qureshey
2011-04-27  5:31 ` Artem Bityutskiy
2011-04-27  6:22   ` Ricard Wanderlof
2011-04-27 17:08     ` umar
2011-04-28  7:31       ` Ricard Wanderlof
2011-04-28  7:37         ` Artem Bityutskiy
2011-04-28  8:00           ` Ricard Wanderlof
2011-04-28  8:52             ` Artem Bityutskiy
2011-04-28  9:09               ` Ricard Wanderlof
2011-04-27  7:25   ` umar [this message]
     [not found]     ` <4DB7C9F9.9000609@free-electrons.com>
2011-04-27 17:14       ` umar
2011-04-28  4:27         ` Iwo Mergler
2011-04-28  7:39           ` Ricard Wanderlof
2011-04-28 17:26           ` umar
2011-04-28 17:48             ` Artem Bityutskiy
2011-04-29  0:53               ` umar
2011-04-28 18:08 ` Bjørn Forsman
2011-04-28 18:21   ` Atlant Schmidt

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=896346e425b9fed6ed42ee9c4144e135.squirrel@emailmg.startlogic.com \
    --to=umar@janteq.com \
    --cc=dedekind1@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