1  | 
     | 
     | 
    /*  | 
    
    
    2  | 
     | 
     | 
     * Copyright (c) 1989 Jan-Simon Pendry  | 
    
    
    3  | 
     | 
     | 
     * Copyright (c) 1989 Imperial College of Science, Technology & Medicine  | 
    
    
    4  | 
     | 
     | 
     * Copyright (c) 1989, 1993  | 
    
    
    5  | 
     | 
     | 
     *	The Regents of the University of California.  All rights reserved.  | 
    
    
    6  | 
     | 
     | 
     *  | 
    
    
    7  | 
     | 
     | 
     * This code is derived from software contributed to Berkeley by  | 
    
    
    8  | 
     | 
     | 
     * Jan-Simon Pendry at Imperial College, London.  | 
    
    
    9  | 
     | 
     | 
     *  | 
    
    
    10  | 
     | 
     | 
     * Redistribution and use in source and binary forms, with or without  | 
    
    
    11  | 
     | 
     | 
     * modification, are permitted provided that the following conditions  | 
    
    
    12  | 
     | 
     | 
     * are met:  | 
    
    
    13  | 
     | 
     | 
     * 1. Redistributions of source code must retain the above copyright  | 
    
    
    14  | 
     | 
     | 
     *    notice, this list of conditions and the following disclaimer.  | 
    
    
    15  | 
     | 
     | 
     * 2. Redistributions in binary form must reproduce the above copyright  | 
    
    
    16  | 
     | 
     | 
     *    notice, this list of conditions and the following disclaimer in the  | 
    
    
    17  | 
     | 
     | 
     *    documentation and/or other materials provided with the distribution.  | 
    
    
    18  | 
     | 
     | 
     * 3. Neither the name of the University nor the names of its contributors  | 
    
    
    19  | 
     | 
     | 
     *    may be used to endorse or promote products derived from this software  | 
    
    
    20  | 
     | 
     | 
     *    without specific prior written permission.  | 
    
    
    21  | 
     | 
     | 
     *  | 
    
    
    22  | 
     | 
     | 
     * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND  | 
    
    
    23  | 
     | 
     | 
     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  | 
    
    
    24  | 
     | 
     | 
     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  | 
    
    
    25  | 
     | 
     | 
     * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE  | 
    
    
    26  | 
     | 
     | 
     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL  | 
    
    
    27  | 
     | 
     | 
     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS  | 
    
    
    28  | 
     | 
     | 
     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  | 
    
    
    29  | 
     | 
     | 
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT  | 
    
    
    30  | 
     | 
     | 
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY  | 
    
    
    31  | 
     | 
     | 
     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  | 
    
    
    32  | 
     | 
     | 
     * SUCH DAMAGE.  | 
    
    
    33  | 
     | 
     | 
     *  | 
    
    
    34  | 
     | 
     | 
     *	from: @(#)ifs_ops.c	8.1 (Berkeley) 6/6/93  | 
    
    
    35  | 
     | 
     | 
     *	$Id: ifs_ops.c,v 1.6 2017/07/28 22:41:10 fcambus Exp $  | 
    
    
    36  | 
     | 
     | 
     */  | 
    
    
    37  | 
     | 
     | 
     | 
    
    
    38  | 
     | 
     | 
    #include "am.h"  | 
    
    
    39  | 
     | 
     | 
     | 
    
    
    40  | 
     | 
     | 
    #ifdef HAS_IFS  | 
    
    
    41  | 
     | 
     | 
     | 
    
    
    42  | 
     | 
     | 
    /*  | 
    
    
    43  | 
     | 
     | 
     * Inheritance file system.  | 
    
    
    44  | 
     | 
     | 
     * This implements a filesystem restart.  | 
    
    
    45  | 
     | 
     | 
     *  | 
    
    
    46  | 
     | 
     | 
     * This is a *gross* hack - it knows far too  | 
    
    
    47  | 
     | 
     | 
     * much about the way other parts of the  | 
    
    
    48  | 
     | 
     | 
     * sytem work.  See restart.c too.  | 
    
    
    49  | 
     | 
     | 
     */  | 
    
    
    50  | 
     | 
     | 
    static char not_a_filesystem[] = "Attempting to inherit not-a-filesystem";  | 
    
    
    51  | 
     | 
     | 
    /*  | 
    
    
    52  | 
     | 
     | 
     * This should never be called.  | 
    
    
    53  | 
     | 
     | 
     */  | 
    
    
    54  | 
     | 
     | 
    static char *  | 
    
    
    55  | 
     | 
     | 
    ifs_match(am_opts *fo)  | 
    
    
    56  | 
     | 
     | 
    { | 
    
    
    57  | 
     | 
     | 
    	plog(XLOG_FATAL, "ifs_match called!");  | 
    
    
    58  | 
     | 
     | 
    	return 0;  | 
    
    
    59  | 
     | 
     | 
    }  | 
    
    
    60  | 
     | 
     | 
     | 
    
    
    61  | 
     | 
     | 
    static int  | 
    
    
    62  | 
     | 
     | 
    ifs_init(mntfs *mf)  | 
    
    
    63  | 
     | 
     | 
    { | 
    
    
    64  | 
     | 
     | 
    	mntfs *mf_link = (mntfs *) mf->mf_private;  | 
    
    
    65  | 
     | 
     | 
    	if (mf_link == 0) { | 
    
    
    66  | 
     | 
     | 
    		plog(XLOG_FATAL, "%s", not_a_filesystem);  | 
    
    
    67  | 
     | 
     | 
    		return EINVAL;  | 
    
    
    68  | 
     | 
     | 
    	}  | 
    
    
    69  | 
     | 
     | 
    #ifdef notdef  | 
    
    
    70  | 
     | 
     | 
    	/*  | 
    
    
    71  | 
     | 
     | 
    	 * Fill in attribute fields  | 
    
    
    72  | 
     | 
     | 
    	 */  | 
    
    
    73  | 
     | 
     | 
    	mf_link->mf_fattr.type = NFLNK;  | 
    
    
    74  | 
     | 
     | 
    	mf_link->mf_fattr.mode = NFSMODE_LNK | 0777;  | 
    
    
    75  | 
     | 
     | 
    	mf_link->mf_fattr.nlink = 1;  | 
    
    
    76  | 
     | 
     | 
    	mf_link->mf_fattr.size = MAXPATHLEN / 4;  | 
    
    
    77  | 
     | 
     | 
    #endif  | 
    
    
    78  | 
     | 
     | 
    	if (mf_link->mf_ops->fs_init)  | 
    
    
    79  | 
     | 
     | 
    		return (*mf_link->mf_ops->fs_init)(mf_link);  | 
    
    
    80  | 
     | 
     | 
    	return 0;  | 
    
    
    81  | 
     | 
     | 
    }  | 
    
    
    82  | 
     | 
     | 
     | 
    
    
    83  | 
     | 
     | 
    static mntfs *  | 
    
    
    84  | 
     | 
     | 
    ifs_inherit(mntfs *mf)  | 
    
    
    85  | 
     | 
     | 
    { | 
    
    
    86  | 
     | 
     | 
    	/*  | 
    
    
    87  | 
     | 
     | 
    	 * Take the linked mount point and  | 
    
    
    88  | 
     | 
     | 
    	 * propagate.  | 
    
    
    89  | 
     | 
     | 
    	 */  | 
    
    
    90  | 
     | 
     | 
    	mntfs *mf_link = (mntfs *) mf->mf_private;  | 
    
    
    91  | 
     | 
     | 
    	if (mf_link == 0) { | 
    
    
    92  | 
     | 
     | 
    		plog(XLOG_FATAL, "%s", not_a_filesystem);  | 
    
    
    93  | 
     | 
     | 
    		return 0;	/*XXX*/  | 
    
    
    94  | 
     | 
     | 
    	}  | 
    
    
    95  | 
     | 
     | 
     | 
    
    
    96  | 
     | 
     | 
    	mf_link->mf_fo = mf->mf_fo;  | 
    
    
    97  | 
     | 
     | 
    #ifdef notdef  | 
    
    
    98  | 
     | 
     | 
    	mf_link->mf_fattr.fileid = mf->mf_fattr.fileid;  | 
    
    
    99  | 
     | 
     | 
    #endif /* notdef */  | 
    
    
    100  | 
     | 
     | 
     | 
    
    
    101  | 
     | 
     | 
    	/*  | 
    
    
    102  | 
     | 
     | 
    	 * Discard the old map.  | 
    
    
    103  | 
     | 
     | 
    	 * Don't call am_unmounted since this  | 
    
    
    104  | 
     | 
     | 
    	 * node was never really mounted in the  | 
    
    
    105  | 
     | 
     | 
    	 * first place.  | 
    
    
    106  | 
     | 
     | 
    	 */  | 
    
    
    107  | 
     | 
     | 
    	mf->mf_private = 0;  | 
    
    
    108  | 
     | 
     | 
    	free_mntfs(mf);  | 
    
    
    109  | 
     | 
     | 
    	/*  | 
    
    
    110  | 
     | 
     | 
    	 * Free the dangling reference  | 
    
    
    111  | 
     | 
     | 
    	 * to the mount link.  | 
    
    
    112  | 
     | 
     | 
    	 */  | 
    
    
    113  | 
     | 
     | 
    	free_mntfs(mf_link);  | 
    
    
    114  | 
     | 
     | 
    	/*  | 
    
    
    115  | 
     | 
     | 
    	 * Get a hold of the other entry  | 
    
    
    116  | 
     | 
     | 
    	 */  | 
    
    
    117  | 
     | 
     | 
    	mf_link->mf_flags &= ~MFF_RESTART;  | 
    
    
    118  | 
     | 
     | 
     | 
    
    
    119  | 
     | 
     | 
    	/* Say what happened */  | 
    
    
    120  | 
     | 
     | 
    	plog(XLOG_INFO, "restarting %s on %s", mf_link->mf_info, mf_link->mf_mount);  | 
    
    
    121  | 
     | 
     | 
     | 
    
    
    122  | 
     | 
     | 
    	return mf_link;  | 
    
    
    123  | 
     | 
     | 
    }  | 
    
    
    124  | 
     | 
     | 
     | 
    
    
    125  | 
     | 
     | 
    static int  | 
    
    
    126  | 
     | 
     | 
    ifs_mount(am_node *mp)  | 
    
    
    127  | 
     | 
     | 
    { | 
    
    
    128  | 
     | 
     | 
    	mntfs *newmf = ifs_inherit(mp->am_mnt);  | 
    
    
    129  | 
     | 
     | 
    	if (newmf) { | 
    
    
    130  | 
     | 
     | 
    		mp->am_mnt = newmf;  | 
    
    
    131  | 
     | 
     | 
    		/*  | 
    
    
    132  | 
     | 
     | 
    		 * XXX - must do the am_mounted call here  | 
    
    
    133  | 
     | 
     | 
    		 */  | 
    
    
    134  | 
     | 
     | 
    		if (newmf->mf_ops->fs_flags & FS_MBACKGROUND)  | 
    
    
    135  | 
     | 
     | 
    			am_mounted(mp);  | 
    
    
    136  | 
     | 
     | 
     | 
    
    
    137  | 
     | 
     | 
    		new_ttl(mp);  | 
    
    
    138  | 
     | 
     | 
    		return 0;  | 
    
    
    139  | 
     | 
     | 
    	}  | 
    
    
    140  | 
     | 
     | 
    	return EINVAL;  | 
    
    
    141  | 
     | 
     | 
    }  | 
    
    
    142  | 
     | 
     | 
     | 
    
    
    143  | 
     | 
     | 
    static int  | 
    
    
    144  | 
     | 
     | 
    ifs_fmount(mntfs *mf)  | 
    
    
    145  | 
     | 
     | 
    { | 
    
    
    146  | 
     | 
     | 
    	am_node *mp = find_mf(mf);  | 
    
    
    147  | 
     | 
     | 
    	if (mp)  | 
    
    
    148  | 
     | 
     | 
    		return ifs_mount(mp);  | 
    
    
    149  | 
     | 
     | 
    	return ifs_inherit(mf) ? 0 : EINVAL;  | 
    
    
    150  | 
     | 
     | 
    }  | 
    
    
    151  | 
     | 
     | 
     | 
    
    
    152  | 
     | 
     | 
    static int  | 
    
    
    153  | 
     | 
     | 
    ifs_fumount(mntfs *mf)  | 
    
    
    154  | 
     | 
     | 
    { | 
    
    
    155  | 
     | 
     | 
    	/*  | 
    
    
    156  | 
     | 
     | 
    	 * Always succeed  | 
    
    
    157  | 
     | 
     | 
    	 */  | 
    
    
    158  | 
     | 
     | 
    	return 0;  | 
    
    
    159  | 
     | 
     | 
    }  | 
    
    
    160  | 
     | 
     | 
     | 
    
    
    161  | 
     | 
     | 
    /*  | 
    
    
    162  | 
     | 
     | 
     * Ops structure  | 
    
    
    163  | 
     | 
     | 
     */  | 
    
    
    164  | 
     | 
     | 
    am_ops ifs_ops = { | 
    
    
    165  | 
     | 
     | 
    	"inherit",  | 
    
    
    166  | 
     | 
     | 
    	ifs_match,  | 
    
    
    167  | 
     | 
     | 
    	ifs_init,  | 
    
    
    168  | 
     | 
     | 
    	ifs_mount,  | 
    
    
    169  | 
     | 
     | 
    	ifs_fmount,  | 
    
    
    170  | 
     | 
     | 
    	auto_fumount,  | 
    
    
    171  | 
     | 
     | 
    	ifs_fumount,  | 
    
    
    172  | 
     | 
     | 
    	efs_lookuppn,  | 
    
    
    173  | 
     | 
     | 
    	efs_readdir,  | 
    
    
    174  | 
     | 
     | 
    	0, /* ifs_readlink */  | 
    
    
    175  | 
     | 
     | 
    	0, /* ifs_mounted */  | 
    
    
    176  | 
     | 
     | 
    	0, /* ifs_umounted */  | 
    
    
    177  | 
     | 
     | 
    	find_afs_srvr,  | 
    
    
    178  | 
     | 
     | 
    	FS_DISCARD  | 
    
    
    179  | 
     | 
     | 
    };  | 
    
    
    180  | 
     | 
     | 
     | 
    
    
    181  | 
     | 
     | 
    #endif /* HAS_IFS */  |