Annotation of kernel/bsd/miscfs/procfs/procfs_vfsops.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /*     $NetBSD: procfs_vfsops.c,v 1.23 1995/03/09 12:05:54 mycroft Exp $       */
        !            26: 
        !            27: /*
        !            28:  * Copyright (c) 1993 Jan-Simon Pendry
        !            29:  * Copyright (c) 1993
        !            30:  *     The Regents of the University of California.  All rights reserved.
        !            31:  *
        !            32:  * This code is derived from software contributed to Berkeley by
        !            33:  * Jan-Simon Pendry.
        !            34:  *
        !            35:  * Redistribution and use in source and binary forms, with or without
        !            36:  * modification, are permitted provided that the following conditions
        !            37:  * are met:
        !            38:  * 1. Redistributions of source code must retain the above copyright
        !            39:  *    notice, this list of conditions and the following disclaimer.
        !            40:  * 2. Redistributions in binary form must reproduce the above copyright
        !            41:  *    notice, this list of conditions and the following disclaimer in the
        !            42:  *    documentation and/or other materials provided with the distribution.
        !            43:  * 3. All advertising materials mentioning features or use of this software
        !            44:  *    must display the following acknowledgement:
        !            45:  *     This product includes software developed by the University of
        !            46:  *     California, Berkeley and its contributors.
        !            47:  * 4. Neither the name of the University nor the names of its contributors
        !            48:  *    may be used to endorse or promote products derived from this software
        !            49:  *    without specific prior written permission.
        !            50:  *
        !            51:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            52:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            53:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            54:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            55:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            56:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            57:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            58:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            59:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            60:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            61:  * SUCH DAMAGE.
        !            62:  *
        !            63:  *     @(#)procfs_vfsops.c     8.5 (Berkeley) 6/15/94
        !            64:  */
        !            65: 
        !            66: /*
        !            67:  * procfs VFS interface
        !            68:  */
        !            69: 
        !            70: #include <sys/param.h>
        !            71: #include <sys/time.h>
        !            72: #include <sys/kernel.h>
        !            73: #include <sys/proc.h>
        !            74: #include <sys/buf.h>
        !            75: #include <sys/syslog.h>
        !            76: #include <sys/mount.h>
        !            77: #include <sys/signalvar.h>
        !            78: #include <sys/vnode.h>
        !            79: #include <miscfs/procfs/procfs.h>
        !            80: #include <vm/vm.h>                     /* for PAGE_SIZE */
        !            81: 
        !            82: /*
        !            83:  * VFS Operations.
        !            84:  *
        !            85:  * mount system call
        !            86:  */
        !            87: /* ARGSUSED */
        !            88: procfs_mount(mp, path, data, ndp, p)
        !            89:        struct mount *mp;
        !            90:        char *path;
        !            91:        caddr_t data;
        !            92:        struct nameidata *ndp;
        !            93:        struct proc *p;
        !            94: {
        !            95:        size_t size;
        !            96: 
        !            97:        if (UIO_MX & (UIO_MX-1)) {
        !            98:                log(LOG_ERR, "procfs: invalid directory entry size");
        !            99:                return (EINVAL);
        !           100:        }
        !           101: 
        !           102:        if (mp->mnt_flag & MNT_UPDATE)
        !           103:                return (EOPNOTSUPP);
        !           104: 
        !           105:        mp->mnt_flag |= MNT_LOCAL;
        !           106:        mp->mnt_data = 0;
        !           107:        getnewfsid(mp, makefstype(MOUNT_PROCFS));
        !           108: 
        !           109:        (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN, &size);
        !           110:        bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
        !           111:        bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
        !           112:        bcopy("procfs", mp->mnt_stat.f_mntfromname, sizeof("procfs"));
        !           113:        return (0);
        !           114: }
        !           115: 
        !           116: /*
        !           117:  * unmount system call
        !           118:  */
        !           119: procfs_unmount(mp, mntflags, p)
        !           120:        struct mount *mp;
        !           121:        int mntflags;
        !           122:        struct proc *p;
        !           123: {
        !           124:        int error;
        !           125:        extern int doforce;
        !           126:        int flags = 0;
        !           127: 
        !           128:        if (mntflags & MNT_FORCE) {
        !           129:                /* procfs can never be rootfs so don't check for it */
        !           130:                if (!doforce)
        !           131:                        return (EINVAL);
        !           132:                flags |= FORCECLOSE;
        !           133:        }
        !           134: 
        !           135:        if (error = vflush(mp, 0, flags))
        !           136:                return (error);
        !           137: 
        !           138:        return (0);
        !           139: }
        !           140: 
        !           141: procfs_root(mp, vpp)
        !           142:        struct mount *mp;
        !           143:        struct vnode **vpp;
        !           144: {
        !           145: 
        !           146:        return (procfs_allocvp(mp, vpp, 0, Proot));
        !           147: }
        !           148: 
        !           149: /* ARGSUSED */
        !           150: procfs_start(mp, flags, p)
        !           151:        struct mount *mp;
        !           152:        int flags;
        !           153:        struct proc *p;
        !           154: {
        !           155: 
        !           156:        return (0);
        !           157: }
        !           158: 
        !           159: /*
        !           160:  * Get file system statistics.
        !           161:  */
        !           162: procfs_statfs(mp, sbp, p)
        !           163:        struct mount *mp;
        !           164:        struct statfs *sbp;
        !           165:        struct proc *p;
        !           166: {
        !           167: 
        !           168: #ifdef COMPAT_09
        !           169:        sbp->f_type = 10;
        !           170: #else
        !           171:        sbp->f_type = 0;
        !           172: #endif
        !           173:        sbp->f_bsize = PAGE_SIZE;
        !           174:        sbp->f_iosize = PAGE_SIZE;
        !           175:        sbp->f_blocks = 1;      /* avoid divide by zero in some df's */
        !           176:        sbp->f_bfree = 0;
        !           177:        sbp->f_bavail = 0;
        !           178:        sbp->f_files = maxproc;                 /* approx */
        !           179:        sbp->f_ffree = maxproc - nprocs;        /* approx */
        !           180:        if (sbp != &mp->mnt_stat) {
        !           181:                bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
        !           182:                bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
        !           183:                bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
        !           184:        }
        !           185:        strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
        !           186:        sbp->f_fstypename[MFSNAMELEN] = '\0';
        !           187:        return (0);
        !           188: }
        !           189: 
        !           190: procfs_quotactl(mp, cmds, uid, arg, p)
        !           191:        struct mount *mp;
        !           192:        int cmds;
        !           193:        uid_t uid;
        !           194:        caddr_t arg;
        !           195:        struct proc *p;
        !           196: {
        !           197: 
        !           198:        return (EOPNOTSUPP);
        !           199: }
        !           200: 
        !           201: procfs_sync(mp, waitfor)
        !           202:        struct mount *mp;
        !           203:        int waitfor;
        !           204: {
        !           205: 
        !           206:        return (0);
        !           207: }
        !           208: 
        !           209: procfs_vget(mp, ino, vpp)
        !           210:        struct mount *mp;
        !           211:        ino_t ino;
        !           212:        struct vnode **vpp;
        !           213: {
        !           214: 
        !           215:        return (EOPNOTSUPP);
        !           216: }
        !           217: 
        !           218: procfs_fhtovp(mp, fhp, vpp)
        !           219:        struct mount *mp;
        !           220:        struct fid *fhp;
        !           221:        struct vnode **vpp;
        !           222: {
        !           223: 
        !           224:        return (EINVAL);
        !           225: }
        !           226: 
        !           227: procfs_vptofh(vp, fhp)
        !           228:        struct vnode *vp;
        !           229:        struct fid *fhp;
        !           230: {
        !           231: 
        !           232:        return (EINVAL);
        !           233: }
        !           234: 
        !           235: procfs_init()
        !           236: {
        !           237: 
        !           238:        return (0);
        !           239: }
        !           240: 
        !           241: struct vfsops procfs_vfsops = {
        !           242:        MOUNT_PROCFS,
        !           243:        procfs_mount,
        !           244:        procfs_start,
        !           245:        procfs_unmount,
        !           246:        procfs_root,
        !           247:        procfs_quotactl,
        !           248:        procfs_statfs,
        !           249:        procfs_sync,
        !           250:        procfs_vget,
        !           251:        procfs_fhtovp,
        !           252:        procfs_vptofh,
        !           253:        procfs_init,
        !           254: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.