public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Iwo Mergler <IwoM@netcomm.com.au>
To: <linux-mtd@lists.infradead.org>
Cc: David Wagner <david.wagner@free-electrons.com>,
	"umar@janteq.com" <umar@janteq.com>
Subject: Re: Discovering current MTD partition
Date: Thu, 28 Apr 2011 14:27:52 +1000	[thread overview]
Message-ID: <201104281427.52402.IwoM@netcomm.com.au> (raw)
In-Reply-To: <d7bb9e8d1c11cece8092e2f4c40436e2.squirrel@emailmg.startlogic.com>

On Thu, 28 Apr 2011 03:14:36 umar@janteq.com wrote:
> > On 04/27/2011 09:25 AM, umar@janteq.com wrote:
> >> Hi,
> >> [...]
> >> 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.
> > 
> > I think you might want to take a look at getmntent (3) : it is a libc
> > function for getting the /etc/mtab entries. It also seems to be portable.
> > 
> > Cheers,
> > David.
> > 
> > --
> > David Wagner, Free Electrons
> > Kernel, drivers, real-time and embedded Linux
> > development, consulting, training and support.
> > http://free-electrons.com
> 
> This will give me the same info as /proc/mtab.  I cannot figure out how I
> can infer which /dev/mtdXX was booted from with this information.
> 

Here is an example from the embedded system I have on my desk
right now:

root:/proc# cat /proc/mounts
rootfs / rootfs rw 0 0
mtd:rfs / jffs2 rw,relatime 0 0
proc /proc proc rw,relatime 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
etc.

From this we can see that the current root file system is
mtd:rfs

root:/proc# cat mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "S1S2EN"
mtd1: 00400000 00020000 "rkern"
mtd2: 00b00000 00020000 "rfs"
mtd3: 00400000 00020000 "kernel"
mtd4: 02000000 00020000 "root"
etc.

This tells us that mtd:rfs corresponds to mtd2, which
should be accessible under /dev/mtd2, /dev/mtdblock2, etc.


Best regards,

Iwo



This communication contains information which may be confidential or privileged.
The information is intended solely for the use of the individual or entity named
above. If you are not the intended recipient, be aware that any disclosure,
copying, distribution or use of the contents of this information is prohibited. 
If you have received this communication in error, please notify me by telephone
immediately.

  reply	other threads:[~2011-04-28  4:32 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
     [not found]     ` <4DB7C9F9.9000609@free-electrons.com>
2011-04-27 17:14       ` umar
2011-04-28  4:27         ` Iwo Mergler [this message]
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=201104281427.52402.IwoM@netcomm.com.au \
    --to=iwom@netcomm.com.au \
    --cc=david.wagner@free-electrons.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=umar@janteq.com \
    /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