home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.sbin / amd / config / mtab_ultrix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-12  |  3.5 KB  |  116 lines

  1. /*
  2.  * Copyright (c) 1990 Jan-Simon Pendry
  3.  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * 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. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  *
  38.  *    @(#)mtab_ultrix.c    5.3 (Berkeley) 5/12/91
  39.  *
  40.  * $Id: mtab_ultrix.c,v 5.2.1.2 91/05/07 22:20:02 jsp Alpha $
  41.  *
  42.  */
  43.  
  44. #include "am.h"
  45.  
  46. #ifdef READ_MTAB_ULTRIX_STYLE
  47.  
  48. #include <sys/mount.h>
  49. #include <sys/fs_types.h>
  50.  
  51. static struct mntent *mnt_dup(mp)
  52. struct fs_data *mp;
  53. {
  54.     struct mntent *new_mp = ALLOC(mntent);
  55.  
  56.     new_mp->mnt_fsname = strdup(mp->fd_devname);
  57.     new_mp->mnt_dir = strdup(mp->fd_path);
  58.         if (mp->fd_fstype >= GT_NUMTYPES)
  59.                 mp->fd_fstype = GT_UNKWN;
  60.         else if (gt_names[mp->fd_fstype] == 0)
  61.                 mp->fd_fstype = GT_UNKWN;
  62.         new_mp->mnt_type = strdup(gt_names[mp->fd_fstype]);
  63.     new_mp->mnt_opts = strdup("unset");
  64.  
  65.     new_mp->mnt_freq = 0;
  66.     new_mp->mnt_passno = mp->fd_dev;
  67.  
  68.     return new_mp;
  69. }
  70.  
  71. /*
  72.  * Read a mount table into memory
  73.  */
  74. mntlist *read_mtab(fs)
  75. char *fs;
  76. {
  77.     mntlist **mpp, *mhp;
  78.  
  79. /* From: Piete Brooks <pb@cl.cam.ac.uk> */
  80.  
  81.     int loc=0;
  82. #undef    NMOUNT
  83. #define    NMOUNT    20
  84.     struct fs_data mountbuffer[NMOUNT], *fs_data;
  85.     int ret;
  86.  
  87.     mpp = &mhp;
  88.     while ((ret = getmountent(&loc, mountbuffer, NMOUNT)) > 0) {
  89.             for (fs_data = mountbuffer; fs_data < &mountbuffer[ret]; fs_data++) {
  90.             /*
  91.              * Allocate a new slot
  92.              */
  93.             *mpp = ALLOC(mntlist);
  94.  
  95.             /*
  96.              * Copy the data returned by getmntent
  97.              */
  98.             (*mpp)->mnt = mnt_dup(fs_data);
  99.  
  100.             /*
  101.              * Move to next pointer
  102.              */
  103.             mpp = &(*mpp)->mnext;
  104.         }
  105.     }
  106.     if (ret < 0) {
  107.         plog(XLOG_ERROR, "getmountent: %m");
  108.         return 0;
  109.     }
  110.     *mpp = 0;
  111.  
  112.     return mhp;
  113. }
  114.  
  115. #endif /* READ_MTAB_ULTRIX_STYLE */
  116.