home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / amd / part03 / ifs_ops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-11  |  3.3 KB  |  152 lines

  1. /*
  2.  * $Id: ifs_ops.c,v 5.1.1.1 89/11/28 17:46:37 jsp Exp Locker: jsp $
  3.  *
  4.  * Copyright (c) 1989 Jan-Simon Pendry
  5.  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
  6.  * Copyright (c) 1989 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * This code is derived from software contributed to Berkeley by
  10.  * Jan-Simon Pendry at Imperial College, London.
  11.  *
  12.  * Redistribution and use in source and binary forms are permitted
  13.  * provided that the above copyright notice and this paragraph are
  14.  * duplicated in all such forms and that any documentation,
  15.  * advertising materials, and other materials related to such
  16.  * distribution and use acknowledge that the software was developed
  17.  * by Imperial College of Science, Technology and Medicine, London, UK.
  18.  * The names of the College and University may not be used to endorse
  19.  * or promote products derived from this software without specific
  20.  * prior written permission.
  21.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  22.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  23.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  24.  *
  25.  *    %W% (Berkeley) %G%
  26.  */
  27.  
  28. #include "am.h"
  29.  
  30. #ifdef HAS_IFS
  31.  
  32. /*
  33.  * Inheritance file system.
  34.  * This implements a filesystem restart.
  35.  *
  36.  * This is a *gross* hack - it knows far too
  37.  * much about the way other parts of the
  38.  * sytem work.  See restart.c too.
  39.  */
  40. static char not_a_filesystem[] = "Attempting to inherit not-a-filesystem";
  41. /*
  42.  * This should never be called.
  43.  */
  44. static int ifs_match()
  45. {
  46.     plog(XLOG_FATAL, "ifs_match called!");
  47.     return FALSE;
  48. }
  49.  
  50. static int ifs_init(mf)
  51. mntfs *mf;
  52. {
  53.     mntfs *mf_link = (mntfs *) mf->mf_private;
  54.     if (mf_link == 0) {
  55.         plog(XLOG_FATAL, not_a_filesystem);
  56.         return EINVAL;
  57.     }
  58.     /*
  59.      * Fill in attribute fields
  60.      */
  61.     mf_link->mf_fattr.type = NFLNK;
  62.     mf_link->mf_fattr.mode = NFSMODE_LNK | 0777;
  63.     mf_link->mf_fattr.nlink = 1;
  64.     mf_link->mf_fattr.size = MAXPATHLEN / 4;
  65.     if (mf_link->mf_ops->fs_init)
  66.         return (*mf_link->mf_ops->fs_init)(mf_link);
  67.     return 0;
  68. }
  69.  
  70. /*ARGSUSED*/
  71. static int ifs_mount(mp)
  72. am_node *mp;
  73. {
  74.     mntfs *mf = mp->am_mnt;
  75.  
  76.     /*
  77.      * Take the linked mount point and
  78.      * propogate.
  79.      */
  80.     mntfs *mf_link = (mntfs *) mf->mf_private;
  81.     if (mf_link == 0) {
  82.         plog(XLOG_FATAL, not_a_filesystem);
  83.         return EINVAL;    /*XXX*/
  84.     }
  85.  
  86.     mf_link->mf_fo = mf->mf_fo;
  87.     mf_link->mf_fattr.fileid = mf->mf_fattr.fileid;
  88.  
  89.     /*
  90.      * Discard the old map.
  91.      * Don't call am_unmounted since this
  92.      * node was never really mounted in the
  93.      * first place.
  94.      */
  95.     mf->mf_private = 0;
  96.     free_mntfs(mf);
  97.     /*
  98.      * Free the dangling reference
  99.      * to the mount link.
  100.      */
  101.     free_mntfs(mf_link);
  102.     /*
  103.      * Get a hold of the other entry
  104.      */
  105.     mp->am_mnt = mf = mf_link;
  106.     mf->mf_flags &= ~MFF_RESTART;
  107.  
  108.     /* Say what happened */
  109.     plog(XLOG_INFO, "restarting %s on %s", mf->mf_info, mf->mf_mount);
  110.  
  111.     /*
  112.      * XXX - must do the am_mounted call here
  113.      */
  114.     if (mf->mf_ops->fs_flags & FS_MBACKGROUND)
  115.         am_mounted(mp);
  116.  
  117.     new_ttl(mp);
  118.  
  119.     return 0;
  120. }
  121.  
  122. /*ARGSUSED*/
  123. static int ifs_umount(mp)
  124. am_node *mp;
  125. {
  126.     /*
  127.      * Always succeed
  128.      */
  129.     return 0;
  130. }
  131.  
  132. /*
  133.  * Ops structure
  134.  */
  135. am_ops ifs_ops = {
  136.     "inherit",
  137.     ifs_match,
  138.     ifs_init,
  139.     ifs_mount,
  140.     ifs_umount,
  141.     efs_lookuppn,
  142.     efs_readdir,
  143.     0, /* ifs_readlink */
  144.     0, /* ifs_mounted */
  145.     0, /* ifs_umounted */
  146.     find_afs_srvr,
  147.     FS_DISCARD,
  148.     &afs_srvr_list
  149. };
  150.  
  151. #endif
  152.