144630Smckusick /* 244630Smckusick * Copyright (c) 1990 Jan-Simon Pendry 344630Smckusick * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 4*61785Sbostic * Copyright (c) 1990, 1993 5*61785Sbostic * The Regents of the University of California. All rights reserved. 644630Smckusick * 744630Smckusick * This code is derived from software contributed to Berkeley by 844630Smckusick * Jan-Simon Pendry at Imperial College, London. 944630Smckusick * 1044630Smckusick * %sccs.include.redist.c% 1144630Smckusick * 12*61785Sbostic * @(#)mtab_ultrix.c 8.1 (Berkeley) 06/06/93 1349685Spendry * 1452452Spendry * $Id: mtab_ultrix.c,v 5.2.2.1 1992/02/09 15:10:50 jsp beta $ 1549685Spendry * 1644630Smckusick */ 1744630Smckusick 1844630Smckusick #include "am.h" 1944630Smckusick 2044630Smckusick #ifdef READ_MTAB_ULTRIX_STYLE 2144630Smckusick 2244630Smckusick #include <sys/mount.h> 2344630Smckusick #include <sys/fs_types.h> 2444630Smckusick mnt_dup(mp)2544630Smckusickstatic struct mntent *mnt_dup(mp) 2644630Smckusick struct fs_data *mp; 2744630Smckusick { 2844630Smckusick struct mntent *new_mp = ALLOC(mntent); 2944630Smckusick 3044630Smckusick new_mp->mnt_fsname = strdup(mp->fd_devname); 3144630Smckusick new_mp->mnt_dir = strdup(mp->fd_path); 3244630Smckusick if (mp->fd_fstype >= GT_NUMTYPES) 3344630Smckusick mp->fd_fstype = GT_UNKWN; 3444630Smckusick else if (gt_names[mp->fd_fstype] == 0) 3544630Smckusick mp->fd_fstype = GT_UNKWN; 3644630Smckusick new_mp->mnt_type = strdup(gt_names[mp->fd_fstype]); 3744630Smckusick new_mp->mnt_opts = strdup("unset"); 3844630Smckusick 3944630Smckusick new_mp->mnt_freq = 0; 4044630Smckusick new_mp->mnt_passno = mp->fd_dev; 4144630Smckusick 4244630Smckusick return new_mp; 4344630Smckusick } 4444630Smckusick 4544630Smckusick /* 4644630Smckusick * Read a mount table into memory 4744630Smckusick */ read_mtab(fs)4844630Smckusickmntlist *read_mtab(fs) 4944630Smckusick char *fs; 5044630Smckusick { 5144630Smckusick mntlist **mpp, *mhp; 5244630Smckusick 5344630Smckusick /* From: Piete Brooks <pb@cl.cam.ac.uk> */ 5444630Smckusick 5544630Smckusick int loc=0; 5644630Smckusick #undef NMOUNT 5744630Smckusick #define NMOUNT 20 5844630Smckusick struct fs_data mountbuffer[NMOUNT], *fs_data; 5944630Smckusick int ret; 6044630Smckusick 6144630Smckusick mpp = &mhp; 6244630Smckusick while ((ret = getmountent(&loc, mountbuffer, NMOUNT)) > 0) { 6344630Smckusick for (fs_data = mountbuffer; fs_data < &mountbuffer[ret]; fs_data++) { 6444630Smckusick /* 6544630Smckusick * Allocate a new slot 6644630Smckusick */ 6744630Smckusick *mpp = ALLOC(mntlist); 6844630Smckusick 6944630Smckusick /* 7044630Smckusick * Copy the data returned by getmntent 7144630Smckusick */ 7244630Smckusick (*mpp)->mnt = mnt_dup(fs_data); 7344630Smckusick 7444630Smckusick /* 7544630Smckusick * Move to next pointer 7644630Smckusick */ 7744630Smckusick mpp = &(*mpp)->mnext; 7844630Smckusick } 7944630Smckusick } 8044630Smckusick if (ret < 0) { 8144630Smckusick plog(XLOG_ERROR, "getmountent: %m"); 8244630Smckusick return 0; 8344630Smckusick } 8444630Smckusick *mpp = 0; 8544630Smckusick 8644630Smckusick return mhp; 8744630Smckusick } 8844630Smckusick 8944630Smckusick #endif /* READ_MTAB_ULTRIX_STYLE */ 90