[BACK]Return to mount_puffs.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sbin / mount_puffs

Annotation of src/sbin/mount_puffs/mount_puffs.c, Revision 1.1

1.1     ! pooka       1: /*     $NetBSD$        */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
        !             5:  *
        !             6:  * Redistribution and use in source and binary forms, with or without
        !             7:  * modification, are permitted provided that the following conditions
        !             8:  * are met:
        !             9:  * 1. Redistributions of source code must retain the above copyright
        !            10:  *    notice, this list of conditions and the following disclaimer.
        !            11:  * 2. Redistributions in binary form must reproduce the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer in the
        !            13:  *    documentation and/or other materials provided with the distribution.
        !            14:  *
        !            15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
        !            16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        !            18:  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
        !            19:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            21:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            25:  * SUCH DAMAGE.
        !            26:  */
        !            27:
        !            28: /*
        !            29:  * This is to support -o getargs without having to replicate
        !            30:  * it in every file server.
        !            31:  */
        !            32:
        !            33: #include <sys/cdefs.h>
        !            34: #ifndef lint
        !            35: __RCSID("$NetBSD$");
        !            36: #endif /* !lint */
        !            37:
        !            38: #include <sys/param.h>
        !            39: #include <sys/mount.h>
        !            40:
        !            41: #include <fs/puffs/puffs_msgif.h>
        !            42:
        !            43: #include <err.h>
        !            44: #include <mntopts.h>
        !            45: #include <stdio.h>
        !            46: #include <stdlib.h>
        !            47: #include <unistd.h>
        !            48:
        !            49: const struct mntopt getargmopt[] = {
        !            50:        MOPT_GETARGS,
        !            51:        MOPT_NULL,
        !            52: };
        !            53:
        !            54: static void
        !            55: usage(void)
        !            56: {
        !            57:
        !            58:        fprintf(stderr, "usage: %s -o getargs spec dir\n", getprogname());
        !            59:        exit(1);
        !            60: }
        !            61:
        !            62: int
        !            63: main(int argc, char *argv[])
        !            64: {
        !            65:        const char *vtypes[] = { VNODE_TYPES };
        !            66:        struct puffs_kargs kargs;
        !            67:        mntoptparse_t mp;
        !            68:        int mntflags, f;
        !            69:        int ch;
        !            70:
        !            71:        if (argc < 3)
        !            72:                usage();
        !            73:
        !            74:        mntflags = 0;
        !            75:        while ((ch = getopt(argc, argv, "o:")) != -1) {
        !            76:                switch (ch) {
        !            77:                case 'o':
        !            78:                        mp = getmntopts(optarg, getargmopt, &mntflags, &f);
        !            79:                        if (mp == NULL)
        !            80:                                err(1, "getmntopts");
        !            81:                        freemntopts(mp);
        !            82:                        break;
        !            83:                default:
        !            84:                        usage();
        !            85:                }
        !            86:        }
        !            87:        argc -= optind;
        !            88:        argv += optind;
        !            89:
        !            90:        if (argc != 2)
        !            91:                usage();
        !            92:
        !            93:        if (mntflags != MNT_GETARGS)
        !            94:                usage();
        !            95:
        !            96:        if (mount(MOUNT_PUFFS, argv[1], mntflags, &kargs, sizeof(kargs)) == -1)
        !            97:                err(1, "mount");
        !            98:
        !            99:        printf("version=%d, ", kargs.pa_vers & ~PUFFSDEVELVERS);
        !           100:        printf("flags=0x%x, ", kargs.pa_flags);
        !           101:
        !           102:        printf("root cookie=%p, ", kargs.pa_root_cookie);
        !           103:        printf("root type=%s", vtypes[kargs.pa_root_vtype]);
        !           104:
        !           105:        if (kargs.pa_root_vtype != VDIR)
        !           106:                printf(", root size=%llu",
        !           107:                    (unsigned long long)kargs.pa_root_vsize);
        !           108:        if (kargs.pa_root_vtype == VCHR || kargs.pa_root_vtype == VBLK)
        !           109:                printf(", root rdev=0x%" PRIx64, (uint64_t)kargs.pa_root_rdev);
        !           110:        printf("\n");
        !           111: }

CVSweb <webmaster@jp.NetBSD.org>