public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Dr. Werner Fink" <werner@suse.de>
To: Werner Fink <werner@suse.de>,
	util-linux@vger.kernel.org, Karel Zak <kzak@redhat.com>
Subject: Re: [util-linux] [PATCH 4/5] sulogin: mount temporary /dev and /proc if not found
Date: Fri, 7 Dec 2012 16:49:17 +0100	[thread overview]
Message-ID: <20121207154917.GA24191@boole.suse.de> (raw)
In-Reply-To: <20121207141709.GF603@rampage>

On Fri, Dec 07, 2012 at 09:17:09AM -0500, Dave Reisner wrote:
> On Fri, Dec 07, 2012 at 09:00:57AM +0100, Werner Fink wrote:
> > +# define dovoid(f)	if ((f)){}
> > +static __attribute__((__constructor__)) void getmounts(void)
> > +{
> > +	struct statfs st;
> > +	if (statfs("/proc", &st) == 0 && st.f_type != PROC_SUPER_MAGIC) {
> 
> Why not use the standard mountpoint check -- compare the devno with / ?
> 
> > +		if (mount("proc", "/proc", "proc", MS_RELATIME, NULL) == 0)
> > +			mounts |= MNT_PROCFS;
> > +	}
> > +	if (statfs("/dev", &st) == 0 && st.f_type != TMPFS_MAGIC) {
> > +		if (mount("devtmpfs", "/dev", "devtmpfs", MS_RELATIME, "mode=0755,nr_inodes=0") == 0) {
> > +			mounts |= MNT_DEVTMPFS;
> 
> Isn't all the work below here redundant? devtmpfs provides these
> things.
> 
> > +			(void)mknod("/dev/console", S_IFCHR|S_IRUSR|S_IWUSR, makedev(TTYAUX_MAJOR, 1));
> > +			if (symlink("/proc/self/fd", "/dev/fd") == 0) {
> > +				dovoid(symlink("fd/0", "/dev/stdin"));
> > +				dovoid(symlink("fd/1", "/dev/stdout"));
> > +				dovoid(symlink("fd/2", "/dev/stderr"));
> > +			}
> > +		}
> > +	}
> > +	if (mounts) atexit(putmounts);
> > +}
> > +# undef dovoid
> > +#endif
> > +
> >  static void usage(FILE *out)
> >  {
> >  	fputs(USAGE_HEADER, out);

We're talking about the very early boot stage, there is no udev nor anything else
and the I've choosen this as this had worked very well in initrd where it had crashed
before.  I do not say that there is no other way to do this but this way it works and
the links I've done had been missed.

If in initrd the sulogin will be called after mounting /proc and /dev and running
udev rules or enabling the links in initrd then the code does only check for existence
of /proc and /dev.

  Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

  reply	other threads:[~2012-12-07 15:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  8:00 [PATCH 1/5] sulogin: use the linked lists from list.h for consoles list Werner Fink
2012-12-07  8:00 ` [PATCH 2/5] sulogin: make usleep() workaround work Werner Fink
2012-12-18 15:07   ` Karel Zak
2012-12-07  8:00 ` [PATCH 3/5] sulogin: use alarm function to indicate if a timeout occurs Werner Fink
2012-12-18 15:15   ` Karel Zak
2012-12-07  8:00 ` [PATCH 4/5] sulogin: mount temporary /dev and /proc if not found Werner Fink
2012-12-07 14:17   ` Dave Reisner
2012-12-07 15:49     ` Dr. Werner Fink [this message]
2012-12-07 17:01       ` [util-linux] " Dave Reisner
2012-12-07 17:25         ` Dr. Werner Fink
2012-12-10 12:27         ` Werner Fink
2012-12-18 15:23           ` Karel Zak
2012-12-23  4:33             ` Dave Reisner
2012-12-23 21:53               ` Karel Zak
2012-12-10 12:27         ` [PATCH 5/5] sulogin: add multi console feature from SysVinit sulogin Werner Fink
2012-12-18 15:18           ` Karel Zak
2012-12-18 15:17   ` [PATCH 4/5] sulogin: mount temporary /dev and /proc if not found Karel Zak
2012-12-07  8:00 ` [PATCH 5/5] sulogin: add multi console feature from SysVinit sulogin Werner Fink
2012-12-07 10:27   ` Dr. Werner Fink
2012-12-18 15:05 ` [PATCH 1/5] sulogin: use the linked lists from list.h for consoles list Karel Zak

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=20121207154917.GA24191@boole.suse.de \
    --to=werner@suse.de \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.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