Home | History | Annotate | Line # | Download | only in amd
      1 /*	$NetBSD: amfs_error.c,v 1.1.1.3 2015/01/17 16:34:15 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997-2014 Erez Zadok
      5  * Copyright (c) 1989 Jan-Simon Pendry
      6  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
      7  * Copyright (c) 1989 The Regents of the University of California.
      8  * All rights reserved.
      9  *
     10  * This code is derived from software contributed to Berkeley by
     11  * Jan-Simon Pendry at Imperial College, London.
     12  *
     13  * Redistribution and use in source and binary forms, with or without
     14  * modification, are permitted provided that the following conditions
     15  * are met:
     16  * 1. Redistributions of source code must retain the above copyright
     17  *    notice, this list of conditions and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  * 3. Neither the name of the University nor the names of its contributors
     22  *    may be used to endorse or promote products derived from this software
     23  *    without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  * SUCH DAMAGE.
     36  *
     37  *
     38  * File: am-utils/amd/amfs_error.c
     39  *
     40  */
     41 
     42 /*
     43  * Error file system.
     44  * This is used as a last resort catchall if
     45  * nothing else worked.  EFS just returns lots
     46  * of error codes, except for unmount which
     47  * always works of course.
     48  */
     49 
     50 #ifdef HAVE_CONFIG_H
     51 # include <config.h>
     52 #endif /* HAVE_CONFIG_H */
     53 #include <am_defs.h>
     54 #include <amd.h>
     55 
     56 static char *amfs_error_match(am_opts *fo);
     57 static int amfs_error_mount(am_node *am, mntfs *mf);
     58 static int amfs_error_umount(am_node *am, mntfs *mf);
     59 
     60 
     61 /*
     62  * Ops structure
     63  */
     64 am_ops amfs_error_ops =
     65 {
     66   "error",
     67   amfs_error_match,
     68   0,				/* amfs_error_init */
     69   amfs_error_mount,
     70   amfs_error_umount,
     71   amfs_error_lookup_child,
     72   amfs_error_mount_child,
     73   amfs_error_readdir,
     74   0,				/* amfs_error_readlink */
     75   0,				/* amfs_error_mounted */
     76   0,				/* amfs_error_umounted */
     77   amfs_generic_find_srvr,
     78   0,				/* amfs_error_get_wchan */
     79   FS_DISCARD,			/* nfs_fs_flags */
     80 #ifdef HAVE_FS_AUTOFS
     81   AUTOFS_ERROR_FS_FLAGS,
     82 #endif /* HAVE_FS_AUTOFS */
     83 };
     84 
     85 
     86 
     87 /*
     88  * EFS file system always matches
     89  */
     90 static char *
     91 amfs_error_match(am_opts *fo)
     92 {
     93   return xstrdup("(error-hook)");
     94 }
     95 
     96 
     97 static int
     98 amfs_error_mount(am_node *am, mntfs *mf)
     99 {
    100   return ENOENT;
    101 }
    102 
    103 
    104 static int
    105 amfs_error_umount(am_node *am, mntfs *mf)
    106 {
    107   /*
    108    * Always succeed
    109    */
    110   return 0;
    111 }
    112 
    113 
    114 /*
    115  * EFS interface to RPC lookup() routine.
    116  * Should never get here in the automounter.
    117  * If we do then just give an error.
    118  */
    119 am_node *
    120 amfs_error_lookup_child(am_node *mp, char *fname, int *error_return, int op)
    121 {
    122   *error_return = ESTALE;
    123   return 0;
    124 }
    125 
    126 
    127 /*
    128  * EFS interface to RPC lookup() routine.
    129  * Should never get here in the automounter.
    130  * If we do then just give an error.
    131  */
    132 am_node *
    133 amfs_error_mount_child(am_node *ap, int *error_return)
    134 {
    135   *error_return = ESTALE;
    136   return 0;
    137 }
    138 
    139 
    140 /*
    141  * EFS interface to RPC readdir() routine.
    142  * Should never get here in the automounter.
    143  * If we do then just give an error.
    144  */
    145 int
    146 amfs_error_readdir(am_node *mp, voidp cookie, voidp dp, voidp ep, u_int count)
    147 {
    148   return ESTALE;
    149 }
    150