On Sun, Aug 18, 2013 at 07:55:12PM -0500, Strake wrote:
> On 18/08/2013, Isaac <ibid...@gmail.com> wrote:
> > On Sun, Aug 18, 2013 at 09:38:42AM -0500, Strake wrote:
> >> From 999f64b2615cd53504e4ad312f7a72eb2170da5f Mon Sep 17 00:00:00 2001
> >> From: Strake <strake...@gmail.com>
> >> Date: Sun, 18 Aug 2013 09:29:51 -0500
> >> Subject: [PATCH] add u?mount
> >>
> >
> > Good start, but I'd suggest looking at Rob's mount.c
> 
> Damn it; if I had known I wouldn't have written another. I just
> checked the source tree.

Some things you have to search the list and the blog.

I've given up on finding it on the list, so...here goes.
It doesn't look to me like it would be too hard to adapt your code to 
the general approach.

BTW, 2<<index is the value of the MS_* macros in order (where index is an int
starting at 0, as in the array referred to).

HTH,
Isaac Dunham
/* vi: set sw=4 ts=4:
 *
 * mount.c - Mount filesystem on directory.
 *
 * Copyright 2012 Rob Landley <r...@landley.net>
 *
 * See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/mount.html
 *
 * After RO mount, access(W_OK) and warn if doesn't fail
 *
USE_MOUNT(NEWTOY(mount, "<2wr?t:o*", TOYFLAG_BIN))

config MOUNT
    bool "mount"
    default y
    help
      usage: mount [-t TYPE] [-o OPTIONS] SOURCE DIR

      Mount SOURCE on DIR

      -t	Type of filesystem (see /proc/filesystems)
      -o	Options to mount
      -r	Read only (Same as -o ro)
      -w	Writeable (Same as -o rw)
*/

#include "toys.h"

DEFINE_GLOBALS(
    struct arg_list *options;
    char *filesystem;

    unsigned long vfs_flags;
    char *data;
)

#define TT this.mount

#define FLAG_o	1
#define FLAG_t	2
#define FLAG_r	4
#define FLAG_w	8

// Categories of VFS flags:
// Superblock: SYNC DIRSYNC MAND
// mountpoint: NOATIME, NOSUID, NODEV, NOEXEC, NODIRATIME, STRICTATIME, RDONLY
// NOP: RELATIME, ACTIVE, BORN, KERNMOUNT (filtered out in kernel do_mount())
//  Yes, including RELATIME. It defaults to on of NOATIME not set.
// Select codepaths: REMOUNT, BIND (REC), MOVE
// shared subtrees: SHARED, PRIVATE, SLAVE, UNBINDABLE

// Remount affects: ro, sync, mandlock, iversion
//    "silent", "i_version",

// These entries are in the order the corresponding linux vfs bits occur in.
static char *vfsflags[] = {
    "ro", "nosuid", "nodev", "noexec", "sync", "remount", "mand", "dirsync",
    "", "", "noatime", "nodiratime", "bind", "move", "rec", "silent",
    "", "unbindable", "private", "slave", "shared", "relatime",
    "", "iversion", "strictatime"
};

// atime noatime defaults user group
static char *explain[] = {
 "read only", // ro
 "ignore setuid bit", // nosuid
 "ignore block/char devices", //nodev
 "ignore executable bit", // noexec
 "writes block until data written to backing store", //sync
 "modify existing mount", // remount
 "allow mandatory file locking", // mand
 "directory writes block until on disk", // dirsync
 "", "", "don't modify file access times", //noatime
 "don't modify directory access times", //nodiratime
 "mirror existing file/dir at new location", // bind
 "relocate existing mount point", // move
 "allow recursive loopback/bind mount", // rec
 "filesystem should not log to dmesg or console", //silent
 "", "don't allow binds into or out of this mount", //unbindable
 "don't show this mount in other namespaces", //private
 "slave", //slave
 "show this mount in other namespaces", //shared
 "NOP", //relatime
  "", "trace inode generation number", //iversion
  "spam disk with legacy atime updates" // strictatime
};

// Collate option string into TT.vfs_flags and TT.data
static void add_opts(char *opts)
{
    if (TT.data) {
        char *temp = xsmprintf("%s
}

void mount_main(void)
{
	struct arg_list *options;
	int i;

	// Collate options

	for(options = TT.options; options; options=options->next)
		add_opts(options);

	if (!TT.filesystem) error_exit("Can't scan for -t yet");

	for (i=0; i<ARRAY_LEN(vfsflags); i++)
		printf("%10s %s\n", vfsflags[i], explain[i]);
}
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to