[BACK]Return to osf1_mount.c CVS log [TXT][DIR] Up to [local] / sys / compat / osf1

Annotation of sys/compat/osf1/osf1_mount.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: osf1_mount.c,v 1.11 2006/03/05 21:48:56 miod Exp $ */
        !             2: /*     $NetBSD: osf1_mount.c,v 1.14 1999/05/05 01:51:34 cgd Exp $      */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  * 3. All advertising materials mentioning features or use of this software
        !            16:  *    must display the following acknowledgement:
        !            17:  *      This product includes software developed by Christopher G. Demetriou
        !            18:  *     for the NetBSD Project.
        !            19:  * 4. The name of the author may not be used to endorse or promote products
        !            20:  *    derived from this software without specific prior written permission
        !            21:  *
        !            22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            32:  */
        !            33:
        !            34: /*
        !            35:  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
        !            36:  * All rights reserved.
        !            37:  *
        !            38:  * Author: Chris G. Demetriou
        !            39:  *
        !            40:  * Permission to use, copy, modify and distribute this software and
        !            41:  * its documentation is hereby granted, provided that both the copyright
        !            42:  * notice and this permission notice appear in all copies of the
        !            43:  * software, derivative works or modified versions, and any portions
        !            44:  * thereof, and that both notices appear in supporting documentation.
        !            45:  *
        !            46:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            47:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
        !            48:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            49:  *
        !            50:  * Carnegie Mellon requests users of this software to return to
        !            51:  *
        !            52:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
        !            53:  *  School of Computer Science
        !            54:  *  Carnegie Mellon University
        !            55:  *  Pittsburgh PA 15213-3890
        !            56:  *
        !            57:  * any improvements or extensions that they make and grant Carnegie the
        !            58:  * rights to redistribute these changes.
        !            59:  */
        !            60:
        !            61: #include <sys/param.h>
        !            62: #include <sys/systm.h>
        !            63: #include <sys/namei.h>
        !            64: #include <sys/proc.h>
        !            65: #include <sys/file.h>
        !            66: #include <sys/filedesc.h>
        !            67: #include <sys/kernel.h>
        !            68: #include <sys/mount.h>
        !            69: #include <sys/vnode.h>
        !            70: #include <sys/syscallargs.h>
        !            71:
        !            72: #include <compat/osf1/osf1.h>
        !            73: #include <compat/osf1/osf1_syscallargs.h>
        !            74: #include <compat/osf1/osf1_util.h>
        !            75: #include <compat/osf1/osf1_cvt.h>
        !            76:
        !            77: #include <net/if.h>
        !            78: #include <netinet/in.h>
        !            79:
        !            80: #include <nfs/rpcv2.h>
        !            81: #include <nfs/nfsproto.h>
        !            82: #include <nfs/nfs.h>
        !            83: #include <nfs/nfsmount.h>
        !            84:
        !            85: #include <ufs/ufs/quota.h>
        !            86: #include <ufs/ufs/ufsmount.h>
        !            87:
        !            88: #include <machine/vmparam.h>
        !            89:
        !            90: #define        OSF1_MNT_WAIT           0x1
        !            91: #define        OSF1_MNT_NOWAIT         0x2
        !            92:
        !            93: #define        OSF1_MNT_FORCE          0x1
        !            94: #define        OSF1_MNT_NOFORCE        0x2
        !            95:
        !            96: /* acceptable flags for various calls */
        !            97: #define        OSF1_GETFSSTAT_FLAGS    (OSF1_MNT_WAIT|OSF1_MNT_NOWAIT)
        !            98: #define        OSF1_MOUNT_FLAGS        0xffffffff                      /* XXX */
        !            99: #define        OSF1_UNMOUNT_FLAGS      (OSF1_MNT_FORCE|OSF1_MNT_NOFORCE)
        !           100:
        !           101:
        !           102: static int     osf1_mount_mfs(struct proc *,
        !           103:                    struct osf1_sys_mount_args *, struct sys_mount_args *);
        !           104: static int     osf1_mount_nfs(struct proc *,
        !           105:                    struct osf1_sys_mount_args *, struct sys_mount_args *);
        !           106:
        !           107: int
        !           108: osf1_sys_fstatfs(p, v, retval)
        !           109:        struct proc *p;
        !           110:        void *v;
        !           111:        register_t *retval;
        !           112: {
        !           113:        struct osf1_sys_fstatfs_args *uap = v;
        !           114:        struct file *fp;
        !           115:        struct mount *mp;
        !           116:        struct statfs *sp;
        !           117:        struct osf1_statfs osfs;
        !           118:        int error;
        !           119:
        !           120:        if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
        !           121:                return (error);
        !           122:        mp = ((struct vnode *)fp->f_data)->v_mount;
        !           123:        sp = &mp->mnt_stat;
        !           124:        error = VFS_STATFS(mp, sp, p);
        !           125:        FRELE(fp);
        !           126:        if (error)
        !           127:                goto out;
        !           128:        sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
        !           129:        osf1_cvt_statfs_from_native(sp, &osfs);
        !           130:        error = copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
        !           131:            SCARG(uap, len)));
        !           132:  out:
        !           133:        return (error);
        !           134: }
        !           135:
        !           136: int
        !           137: osf1_sys_getfsstat(p, v, retval)
        !           138:        struct proc *p;
        !           139:        void *v;
        !           140:        register_t *retval;
        !           141: {
        !           142:        struct osf1_sys_getfsstat_args *uap = v;
        !           143:        struct mount *mp, *nmp;
        !           144:        struct statfs *sp;
        !           145:        struct osf1_statfs osfs;
        !           146:        caddr_t osf_sfsp;
        !           147:        long count, maxcount, error;
        !           148:
        !           149:        if (SCARG(uap, flags) & ~OSF1_GETFSSTAT_FLAGS)
        !           150:                return (EINVAL);
        !           151:
        !           152:        maxcount = SCARG(uap, bufsize) / sizeof(struct osf1_statfs);
        !           153:        osf_sfsp = (caddr_t)SCARG(uap, buf);
        !           154:        count = 0;
        !           155:        for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist);
        !           156:            mp = nmp) {
        !           157:                nmp = CIRCLEQ_NEXT(mp, mnt_list);
        !           158:                if (osf_sfsp && count < maxcount) {
        !           159:                        sp = &mp->mnt_stat;
        !           160:                        /*
        !           161:                         * If OSF1_MNT_NOWAIT is specified, do not refresh the
        !           162:                         * fsstat cache.  OSF1_MNT_WAIT overrides
        !           163:                         * OSF1_MNT_NOWAIT.
        !           164:                         */
        !           165:                        if (((SCARG(uap, flags) & OSF1_MNT_NOWAIT) == 0 ||
        !           166:                            (SCARG(uap, flags) & OSF1_MNT_WAIT)) &&
        !           167:                            (error = VFS_STATFS(mp, sp, p)))
        !           168:                                continue;
        !           169:                        sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
        !           170:                        osf1_cvt_statfs_from_native(sp, &osfs);
        !           171:                        if ((error = copyout(&osfs, osf_sfsp,
        !           172:                            sizeof (struct osf1_statfs))))
        !           173:                                return (error);
        !           174:                        osf_sfsp += sizeof (struct osf1_statfs);
        !           175:                }
        !           176:                count++;
        !           177:        }
        !           178:        if (osf_sfsp && count > maxcount)
        !           179:                *retval = maxcount;
        !           180:        else
        !           181:                *retval = count;
        !           182:        return (0);
        !           183: }
        !           184:
        !           185: int
        !           186: osf1_sys_mount(p, v, retval)
        !           187:        struct proc *p;
        !           188:        void *v;
        !           189:        register_t *retval;
        !           190: {
        !           191:        struct osf1_sys_mount_args *uap = v;
        !           192:        struct sys_mount_args a;
        !           193:        int error;
        !           194:
        !           195:        SCARG(&a, path) = SCARG(uap, path);
        !           196:
        !           197:        if (SCARG(uap, flags) & ~OSF1_MOUNT_FLAGS)
        !           198:                return (EINVAL);
        !           199:        SCARG(&a, flags) = SCARG(uap, flags);           /* XXX - xlate */
        !           200:
        !           201:        switch (SCARG(uap, type)) {
        !           202:        case OSF1_MOUNT_NFS:
        !           203:                if ((error = osf1_mount_nfs(p, uap, &a)))
        !           204:                        return error;
        !           205:                break;
        !           206:
        !           207:        case OSF1_MOUNT_MFS:
        !           208:                if ((error = osf1_mount_mfs(p, uap, &a)))
        !           209:                        return error;
        !           210:                break;
        !           211:
        !           212:        default:
        !           213:                return (EINVAL);
        !           214:        }
        !           215:
        !           216:        return sys_mount(p, &a, retval);
        !           217: }
        !           218:
        !           219: int
        !           220: osf1_sys_statfs(p, v, retval)
        !           221:        struct proc *p;
        !           222:        void *v;
        !           223:        register_t *retval;
        !           224: {
        !           225:        struct osf1_sys_statfs_args *uap = v;
        !           226:        struct mount *mp;
        !           227:        struct statfs *sp;
        !           228:        struct osf1_statfs osfs;
        !           229:        int error;
        !           230:        struct nameidata nd;
        !           231:
        !           232:        NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
        !           233:        if ((error = namei(&nd)))
        !           234:                return (error);
        !           235:        mp = nd.ni_vp->v_mount;
        !           236:        sp = &mp->mnt_stat;
        !           237:        vrele(nd.ni_vp);
        !           238:        if ((error = VFS_STATFS(mp, sp, p)))
        !           239:                return (error);
        !           240:        sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
        !           241:        osf1_cvt_statfs_from_native(sp, &osfs);
        !           242:        return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
        !           243:            SCARG(uap, len)));
        !           244: }
        !           245:
        !           246: int
        !           247: osf1_sys_unmount(p, v, retval)
        !           248:        struct proc *p;
        !           249:        void *v;
        !           250:        register_t *retval;
        !           251: {
        !           252:        struct osf1_sys_unmount_args *uap = v;
        !           253:        struct sys_unmount_args a;
        !           254:
        !           255:        SCARG(&a, path) = SCARG(uap, path);
        !           256:
        !           257:        if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS)
        !           258:                return (EINVAL);
        !           259:        SCARG(&a, flags) = 0;
        !           260:        if ((SCARG(uap, flags) & OSF1_MNT_FORCE) &&
        !           261:            (SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0)
        !           262:                SCARG(&a, flags) |= MNT_FORCE;
        !           263:
        !           264:        return sys_unmount(p, &a, retval);
        !           265: }
        !           266:
        !           267: static int
        !           268: osf1_mount_mfs(p, osf_argp, bsd_argp)
        !           269:        struct proc *p;
        !           270:        struct osf1_sys_mount_args *osf_argp;
        !           271:        struct sys_mount_args *bsd_argp;
        !           272: {
        !           273:        struct osf1_mfs_args osf_ma;
        !           274:        struct mfs_args bsd_ma;
        !           275:        caddr_t sg = stackgap_init(p->p_emul);
        !           276:        int error, len;
        !           277:        static const char mfs_name[] = MOUNT_MFS;
        !           278:
        !           279:        if ((error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma)))
        !           280:                return error;
        !           281:
        !           282:        memset(&bsd_ma, 0, sizeof bsd_ma);
        !           283:        bsd_ma.fspec = osf_ma.name;
        !           284:        /* XXX export args */
        !           285:        bsd_ma.base = osf_ma.base;
        !           286:        bsd_ma.size = osf_ma.size;
        !           287:
        !           288:        SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_ma);
        !           289:        if ((error = copyout(&bsd_ma, SCARG(bsd_argp, data), sizeof bsd_ma)))
        !           290:                return error;
        !           291:
        !           292:        len = strlen(mfs_name) + 1;
        !           293:        SCARG(bsd_argp, type) = stackgap_alloc(&sg, len);
        !           294:        if ((error = copyout(mfs_name, (void *)SCARG(bsd_argp, type), len)))
        !           295:                return error;
        !           296:
        !           297:        return 0;
        !           298: }
        !           299:
        !           300: static int
        !           301: osf1_mount_nfs(p, osf_argp, bsd_argp)
        !           302:        struct proc *p;
        !           303:        struct osf1_sys_mount_args *osf_argp;
        !           304:        struct sys_mount_args *bsd_argp;
        !           305: {
        !           306:        struct osf1_nfs_args osf_na;
        !           307:        struct nfs_args bsd_na;
        !           308:        caddr_t sg = stackgap_init(p->p_emul);
        !           309:        int error, len;
        !           310:        static const char nfs_name[] = MOUNT_NFS;
        !           311:        unsigned long leftovers;
        !           312:
        !           313:        if ((error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na)))
        !           314:                return error;
        !           315:
        !           316:        memset(&bsd_na, 0, sizeof bsd_na);
        !           317:        bsd_na.addr = (struct sockaddr *)osf_na.addr;
        !           318:        bsd_na.addrlen = sizeof (struct sockaddr_in);
        !           319:        bsd_na.fh = osf_na.fh;
        !           320:
        !           321:         /* translate flags */
        !           322:         bsd_na.flags = emul_flags_translate(osf1_nfs_mount_flags_xtab,
        !           323:             osf_na.flags, &leftovers);
        !           324:        if (leftovers & OSF1_NFSMNT_HOSTNAME) {
        !           325:                leftovers &= ~OSF1_NFSMNT_HOSTNAME;
        !           326:                bsd_na.hostname = osf_na.hostname;
        !           327:        } else {
        !           328:                /* XXX FILL IN HOST NAME WITH IPADDR? */
        !           329:        }
        !           330:        if (leftovers & OSF1_NFSMNT_TCP) {
        !           331:                leftovers &= ~OSF1_NFSMNT_TCP;
        !           332:                bsd_na.sotype = SOCK_DGRAM;
        !           333:                bsd_na.proto = 0;
        !           334:        } else {
        !           335:                bsd_na.sotype = SOCK_STREAM;
        !           336:                bsd_na.proto = 0;
        !           337:        }
        !           338:         if (leftovers != 0)
        !           339:                 return (EINVAL);
        !           340:
        !           341:        /* copy structure elements based on flags */
        !           342:        if (bsd_na.flags & NFSMNT_WSIZE)
        !           343:                bsd_na.wsize = osf_na.wsize;
        !           344:        if (bsd_na.flags & NFSMNT_RSIZE)
        !           345:                bsd_na.rsize = osf_na.rsize;
        !           346:        if (bsd_na.flags & NFSMNT_TIMEO)
        !           347:                bsd_na.timeo = osf_na.timeo;
        !           348:        if (bsd_na.flags & NFSMNT_RETRANS)
        !           349:                bsd_na.retrans = osf_na.retrans;
        !           350:
        !           351:        SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_na);
        !           352:        if ((error = copyout(&bsd_na, SCARG(bsd_argp, data), sizeof bsd_na)))
        !           353:                return error;
        !           354:
        !           355:        len = strlen(nfs_name) + 1;
        !           356:        SCARG(bsd_argp, type) = stackgap_alloc(&sg, len);
        !           357:        if ((error = copyout(MOUNT_NFS, (void *)SCARG(bsd_argp, type), len)))
        !           358:                return error;
        !           359:
        !           360:        return 0;
        !           361: }

CVSweb