]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Initial revision
authorSam Hartman <hartmans@debian.org>
Sat, 10 Jan 2004 20:56:14 +0000 (20:56 +0000)
committerSam Hartman <hartmans@debian.org>
Sat, 10 Jan 2004 20:56:14 +0000 (20:56 +0000)
src/config/Makefile.ppc_darwin_70.in [new file with mode: 0644]
src/config/param.ppc_darwin_70.h [new file with mode: 0644]
src/config/param.ppc_darwin_70_usr.h [new file with mode: 0644]
src/libafs/afs.ppc_darwin_70.plist.in [new file with mode: 0644]
src/packaging/MacOS/Makefile [new file with mode: 0644]
src/packaging/MacOS/OpenAFS.Description.plist [new file with mode: 0644]
src/packaging/MacOS/OpenAFS.Info.plist [new file with mode: 0644]
src/packaging/MacOS/afssettings.m [new file with mode: 0644]
src/packaging/MacOS/settings.plist [new file with mode: 0644]
src/vol/fstab.c [new file with mode: 0644]

diff --git a/src/config/Makefile.ppc_darwin_70.in b/src/config/Makefile.ppc_darwin_70.in
new file mode 100644 (file)
index 0000000..b18fce4
--- /dev/null
@@ -0,0 +1,47 @@
+# Portions Copyright (c) 2003 Apple Computer, Inc.  All rights reserved.
+#
+# Keep macros within each section in sorted order for clean diff displays.
+#
+# AFS_OSTYPE used to indicate suffixes and os specific subdirectories.
+AFS_OSTYPE = DARWIN
+#
+#
+# compilation and link editor flags
+XCFLAGS=
+MT_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV ${XCFLAGS}
+MT_CC=cc
+KROOT=
+KINCLUDES=-I$(KROOT)/System/Library/Frameworks/Kernel.framework/Headers
+LWP_OPTMZ=-O2
+OPTMZ=-O2
+DBG=-g
+REGEX_OBJ=regex.o
+
+
+#
+# libraries
+XLIBS=@LIB_AFSDB@
+TXLIBS=-lncurses
+#MTLIBS=
+#XLIBELFA=
+#XLIBKVM=
+#
+SHLIB_SUFFIX=
+SHLIB_CFLAGS=
+#
+# programs
+AR=ar
+AS=as
+CC=cc
+CP=cp
+INSTALL=${TOP_SRCDIR}/pinstall/pinstall
+LEX=lex -l
+LD= ld
+LORDER = lorder
+MV=mv
+RANLIB=ranlib
+RM=rm
+STRIP= strip
+
+# override getfsent
+EXTRA_VLIBOBJS=fstab.o
diff --git a/src/config/param.ppc_darwin_70.h b/src/config/param.ppc_darwin_70.h
new file mode 100644 (file)
index 0000000..e13e24e
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Portions Copyright (c) 2003 Apple Computer, Inc.  All rights reserved.
+ */
+#ifndef AFS_PARAM_H
+#define AFS_PARAM_H
+
+#define AFS_ENV                 1
+#define AFS_64BIT_ENV           1       /* Defines afs_int32 as int, not long. */
+#define AFS_64BIT_IOPS_ENV 1
+#define AFS_PPC_ENV 1
+#define AFS_VFSINCL_ENV 1
+
+#include <afs/afs_sysnames.h>
+
+#define AFS_DARWIN_ENV
+#define AFS_DARWIN13_ENV
+#define AFS_DARWIN14_ENV
+#define AFS_DARWIN60_ENV
+#define AFS_DARWIN70_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define AFS_NAMEI_ENV 1
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS    "afs"
+
+/* Machine / Operating system information */
+#define sys_ppc_darwin_12   1
+#define sys_ppc_darwin_13   1
+#define sys_ppc_darwin_14   1
+#define sys_ppc_darwin_60   1
+#define sys_ppc_darwin_70   1
+#define SYS_NAME        "ppc_darwin_70"
+#define SYS_NAME_ID     SYS_NAME_ID_ppc_darwin_70
+#define AFSBIG_ENDIAN   1
+#define AFS_HAVE_FFS    1       /* Use system's ffs. */
+
+#define AFS_GCPAGS                1       /* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV         1
+
+#ifdef KERNEL
+#undef MACRO_BEGIN
+#undef MACRO_END
+#include <kern/macro_help.h>
+#define AFS_GLOBAL_SUNLOCK        1
+#define AFS_VFS34       1       /* What is VFS34??? */
+#define afsio_iov       uio_iov
+#define afsio_iovcnt    uio_iovcnt
+#define afsio_offset    uio_offset
+#define afsio_seg       uio_segflg
+#define afsio_resid     uio_resid
+#define AFS_UIOSYS      UIO_SYSSPACE
+#define AFS_UIOUSER     UIO_USERSPACE
+#define AFS_CLBYTES     CLBYTES
+#define osi_GetTime(x)  microtime(x)
+#define AFS_KALLOC(x)   kalloc(x)
+#define AFS_KFREE(x,y)  kfree(x,y)
+#define v_count         v_usecount
+#define v_vfsp          v_mount
+#define vfs_bsize       mnt_stat.f_bsize
+#define vfs_fsid        mnt_stat.f_fsid
+#define va_nodeid       va_fileid
+#define vfs_vnodecovered mnt_vnodecovered
+#define direct          dirent
+#define vnode_t         struct vnode
+
+#define VN_RELE(vp)     vrele(((struct vnode *)(vp)))
+#define VN_HOLD(vp)     VREF(((struct vnode *)(vp)))
+
+#endif
+
+#define BIND_8_COMPAT
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.ppc_darwin_70_usr.h b/src/config/param.ppc_darwin_70_usr.h
new file mode 100644 (file)
index 0000000..1167c80
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Portions Copyright (c) 2003 Apple Computer, Inc.  All rights reserved.
+ */
+#ifndef AFS_PARAM_H
+#define AFS_PARAM_H
+
+#define AFS_VFSINCL_ENV 1       /* NOBODY uses this.... */
+#define AFS_ENV                 1
+#define AFS_64BIT_ENV           1       /* Defines afs_int32 as int, not long. */
+#define AFS_PPC_ENV 1
+
+#include <afs/afs_sysnames.h>
+#define AFS_USERSPACE_ENV
+#define AFS_USR_DARWIN_ENV
+#define AFS_USR_DARWIN13_ENV
+#define AFS_USR_DARWIN14_ENV
+#define AFS_USR_DARWIN60_ENV
+#define AFS_USR_DARWIN70_ENV
+#define AFS_NONFSTRANS 
+#define AFS_SYSCALL             230
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS    "afs"
+
+/* Machine / Operating system information */
+#define sys_ppc_darwin_12   1
+#define sys_ppc_darwin_13   1
+#define sys_ppc_darwin_14   1
+#define sys_ppc_darwin_60   1
+#define sys_ppc_darwin_70   1
+#define SYS_NAME        "ppc_darwin_70"
+#define SYS_NAME_ID     SYS_NAME_ID_ppc_darwin_70
+#define AFSBIG_ENDIAN   1
+#define AFS_HAVE_FFS    1       /* Use system's ffs. */
+
+#define AFS_UIOSYS      UIO_SYSSPACE
+#define AFS_UIOUSER     UIO_USERSPACE
+
+#define AFS_GCPAGS                0       /* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV          1
+
+#define AFS_VFS34       1       /* What is VFS34??? */
+#define afsio_iov       uio_iov
+#define afsio_iovcnt    uio_iovcnt
+#define afsio_offset    uio_offset
+#define afsio_seg       uio_segflg
+#define afsio_resid     uio_resid
+#define AFS_UIOSYS      UIO_SYSSPACE
+#define AFS_UIOUSER     UIO_USERSPACE
+#define        VATTR_NULL      usr_vattr_null
+
+#define AFS_DIRENT
+#ifndef CMSERVERPREF
+#define CMSERVERPREF
+#endif
+
+#define BIND_8_COMPAT
+
+#endif /* AFS_PARAM_H */
diff --git a/src/libafs/afs.ppc_darwin_70.plist.in b/src/libafs/afs.ppc_darwin_70.plist.in
new file mode 100644 (file)
index 0000000..09fb063
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>English</string>
+       <key>CFBundleExecutable</key>
+       <string>afs</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.openafs.filesystems.afs</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>afs</string>
+       <key>CFBundlePackageType</key>
+       <string>KEXT</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.2.10</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleVersion</key>
+       <string>1.2.10</string>
+       <key>OSBundleLibraries</key>
+       <dict>
+               <key>com.apple.kernel.bsd</key>
+               <string>6.9.9</string>
+               <key>com.apple.kernel.mach</key>
+               <string>6.9.9</string>
+       </dict>
+</dict>
+</plist>
diff --git a/src/packaging/MacOS/Makefile b/src/packaging/MacOS/Makefile
new file mode 100644 (file)
index 0000000..42cf315
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+#
+# @APPLE_LICENSE_HEADER_START@
+# 
+# This file contains Original Code and/or Modifications of Original Code
+# as defined in and that are subject to the Apple Public Source License
+# Version 2.0 (the 'License'). You may not use this file except in
+# compliance with the License. Please obtain a copy of the License at
+# http://www.opensource.apple.com/apsl/ and read it before using this
+# file.
+# 
+# The Original Code and all software distributed under the License are
+# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+# Please see the License for the specific language governing rights and
+# limitations under the License.
+# 
+# @APPLE_LICENSE_HEADER_END@
+
+AFSINCLUDE = /Library/OpenAFS/Tools/include
+CFLAGS = -O -I$(AFSINCLUDE)
+LIBS = -framework Foundation
+ALL = afssettings
+
+all: $(ALL)
+
+afssettings : afssettings.m
+       cc $(CFLAGS) -o $@ $^ $(LIBS)
+
+clean:
+       @rm -f *.o $(ALL)
diff --git a/src/packaging/MacOS/OpenAFS.Description.plist b/src/packaging/MacOS/OpenAFS.Description.plist
new file mode 100644 (file)
index 0000000..d7c2cb8
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IFPkgDescriptionDeleteWarning</key>
+       <string></string>
+       <key>IFPkgDescriptionDescription</key>
+       <string>Mac OS X version of OpenAFS client and server.</string>
+       <key>IFPkgDescriptionTitle</key>
+       <string>OpenAFS</string>
+       <key>IFPkgDescriptionVersion</key>
+       <string>1.2.10</string>
+</dict>
+</plist>
diff --git a/src/packaging/MacOS/OpenAFS.Info.plist b/src/packaging/MacOS/OpenAFS.Info.plist
new file mode 100644 (file)
index 0000000..c50b198
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleGetInfoString</key>
+       <string>OpenAFS 1.2.10</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.openafs.OpenAFS.pkg</string>
+       <key>CFBundleName</key>
+       <string>OpenAFS</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.2.10</string>
+       <key>IFMajorVersion</key>
+       <integer>1</integer>
+       <key>IFMinorVersion</key>
+       <integer>2</integer>
+       <key>IFPkgFlagAllowBackRev</key>
+       <false/>
+       <key>IFPkgFlagAuthorizationAction</key>
+       <string>RootAuthorization</string>
+       <key>IFPkgFlagDefaultLocation</key>
+       <string>/</string>
+       <key>IFPkgFlagInstallFat</key>
+       <false/>
+       <key>IFPkgFlagIsRequired</key>
+       <false/>
+       <key>IFPkgFlagRelocatable</key>
+       <false/>
+       <key>IFPkgFlagRestartAction</key>
+       <string>RecommendedRestart</string>
+       <key>IFPkgFlagRootVolumeOnly</key>
+       <true/>
+       <key>IFPkgFlagUpdateInstalledLanguages</key>
+       <false/>
+       <key>IFPkgFlagUseUserMask</key>
+       <false/>
+       <key>IFPkgFormatVersion</key>
+       <real>0.10000000149011612</real>
+</dict>
+</plist>
diff --git a/src/packaging/MacOS/afssettings.m b/src/packaging/MacOS/afssettings.m
new file mode 100644 (file)
index 0000000..c1e647a
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+#import <Foundation/Foundation.h>
+#import <stdio.h>
+#import <err.h>
+#import <sys/types.h>
+#import <sys/mount.h>
+#import <sys/sysctl.h>
+#import <afs/sysctl.h>
+
+enum Type {
+    TypeNode = 0,
+    TypeNum,
+    TypeStr
+};
+
+typedef struct _setting {
+    NSString *key;
+    int selector;
+    enum Type type;
+    struct _setting *children;
+} Setting;
+
+Setting s_darwin_all[] = {
+    {@"RealModes", AFS_SC_DARWIN_ALL_REALMODES, TypeNum, NULL},
+    {NULL, 0, 0, NULL}
+};
+Setting s_darwin[] = {
+    {@"All", AFS_SC_DARWIN_ALL, TypeNode, s_darwin_all},
+    {@"Darwin12", AFS_SC_DARWIN_12, TypeNode, NULL},
+    {@"Darwin13", AFS_SC_DARWIN_13, TypeNode, NULL},
+    {@"Darwin14", AFS_SC_DARWIN_14, TypeNode, NULL},
+    {@"Darwin60", AFS_SC_DARWIN_60, TypeNode, NULL},
+    {@"Darwin70", AFS_SC_DARWIN_70, TypeNode, NULL},
+    {NULL, 0, 0, NULL}
+};
+Setting s_first[] = {
+    {@"All", AFS_SC_ALL, TypeNode, NULL},
+    {@"Darwin", AFS_SC_DARWIN, TypeNode, s_darwin},
+    {NULL, 0, 0, NULL}
+};
+Setting s_top = {NULL, -1, TypeNode, s_first};
+
+int oid[CTL_MAXNAME] = {CTL_VFS};
+NSString *path = @"/var/db/openafs/etc/config/settings.plist";
+
+char *oidString(int *oid, int len);
+void init(void);
+void walk(id obj, Setting *s, int level);
+
+void
+init(void)
+{
+    int oidmax[] = {CTL_VFS, VFS_GENERIC, VFS_MAXTYPENUM};
+    int oidvfs[] = {CTL_VFS, VFS_GENERIC, VFS_CONF, 0};
+    int max;
+    struct vfsconf conf;
+    size_t len;
+    int i;
+
+    len = sizeof(max);
+    if(sysctl(oidmax, 3, &max, &len, NULL, NULL) < 0)
+       err(1, "sysctl VFS_MAXTYPENUM");
+    for(i = max; --i >= 0; ) {
+       oidvfs[3] = i;
+       len = sizeof(conf);
+       if(sysctl(oidvfs, 4, &conf, &len, NULL, NULL) < 0)
+           continue;
+       if(strcmp("afs", conf.vfc_name) == 0) {
+           s_top.selector = conf.vfc_typenum;
+           break;
+       }
+    }
+    if(s_top.selector < 0)
+       errx(1, "AFS is not loaded");
+}
+
+char *
+oidString(int *oid, int len)
+{
+    static char buf[256];
+    char *cp = buf;
+
+    for(;;) {
+       sprintf(cp, "%d", *oid++);
+       if(--len <= 0)
+           break;
+       cp += strlen(cp);
+       *cp++ = '.';
+    }
+    return buf;
+}
+
+void
+walk(id obj, Setting *s, int level)
+{
+    Setting *child;
+    id newobj;
+    int intval;
+    const char *cp;
+    int level1 = level + 1;
+
+    oid[level] = s->selector;
+    switch(s->type) {
+      case TypeNode:
+       for(child = s->children; child->key; child++) {
+           if(child->type == TypeNode && !child->children)
+               continue;
+           newobj = [obj objectForKey: child->key];
+           if(newobj)
+               walk(newobj, child, level1);
+       }
+       break;
+      case TypeNum:
+       intval = [obj intValue];
+       if(sysctl(oid, level1, NULL, NULL, &intval, sizeof(intval)) < 0)
+           err(1, "sysctl %s => %d", oidString(oid, level1), intval);
+       break;
+      case TypeStr:
+       cp = [obj UTF8String];
+       if(sysctl(oid, level1, NULL, NULL, (void *)cp, strlen(cp)) < 0)
+           err(1, "sysctl %s => %s", oidString(oid, level1), cp);
+       break;
+    }
+}
+
+main()
+{
+    NSData *plistData;
+    id plist;
+    NSString *error;
+    NSPropertyListFormat format;
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+    init();
+    plistData = [NSData dataWithContentsOfFile: path];
+    if(plistData) {
+       plist = [NSPropertyListSerialization propertyListFromData: plistData
+         mutabilityOption: NSPropertyListImmutable
+         format: &format
+         errorDescription: &error
+       ];
+       if(plist)
+           walk(plist, &s_top, 1);
+       else
+           errx(1, "%s: %s", [path UTF8String], [error UTF8String]);
+    }
+
+    [pool release];
+    return 0;
+}
diff --git a/src/packaging/MacOS/settings.plist b/src/packaging/MacOS/settings.plist
new file mode 100644 (file)
index 0000000..36e8977
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>Darwin</key>
+       <dict>
+               <key>All</key>
+               <dict>
+                       <key>RealModes</key>
+                       <false/>
+               </dict>
+       </dict>
+</dict>
+</plist>
diff --git a/src/vol/fstab.c b/src/vol/fstab.c
new file mode 100644 (file)
index 0000000..46e5801
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 1980, 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(AFS_DARWIN_ENV)
+/*-----------------------------------------------------------------------
+ * This version of fstab.c is intended to be used on Darwin systems to
+ * replace getfsent() and family.  It has been modified so that rather
+ * than read /etc/fstab, it calls getfsstat() to get the real list of
+ * mounted volumes.
+ *-----------------------------------------------------------------------*/
+
+#include <errno.h>
+#include <fstab.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+
+#define        STDERR_FILENO   2
+
+static struct fstab _fs_fstab;
+static struct statfs *_fs_buf;
+static struct statfs *_fs_ptr;
+static int _fs_count;
+
+static error __P((int));
+static fstabscan __P((void));
+
+static
+fstabscan()
+{
+       if(_fs_count <= 0)
+               return(0);
+       _fs_fstab.fs_spec = _fs_ptr->f_mntfromname;
+       _fs_fstab.fs_file = _fs_ptr->f_mntonname;
+       _fs_fstab.fs_vfstype = _fs_ptr->f_fstypename;
+       _fs_fstab.fs_mntops = _fs_ptr->f_fstypename;    // no mount options given
+       _fs_fstab.fs_type = (_fs_ptr->f_flags & MNT_RDONLY) ? FSTAB_RO : FSTAB_RW;
+       _fs_fstab.fs_freq = 0;
+       _fs_fstab.fs_passno = 0;
+
+       _fs_ptr++;
+       _fs_count--;
+       return(1);
+}
+
+struct fstab *
+getfsent()
+{
+       if (!_fs_buf && !setfsent() || !fstabscan())
+               return((struct fstab *)NULL);
+       return(&_fs_fstab);
+}
+
+struct fstab *
+getfsspec(name)
+       register const char *name;
+{
+       if (setfsent())
+               while (fstabscan())
+                       if (!strcmp(_fs_fstab.fs_spec, name))
+                               return(&_fs_fstab);
+       return((struct fstab *)NULL);
+}
+
+struct fstab *
+getfsfile(name)
+       register const char *name;
+{
+       if (setfsent())
+               while (fstabscan())
+                       if (!strcmp(_fs_fstab.fs_file, name))
+                               return(&_fs_fstab);
+       return((struct fstab *)NULL);
+}
+
+setfsent()
+{
+       long bufsize;
+
+       if (_fs_buf) {
+               free(_fs_buf);
+               _fs_buf = NULL;
+       }
+       if((_fs_count = getfsstat(NULL, 0, MNT_WAIT)) < 0) {
+               error(errno);
+               return(0);
+       }
+       bufsize = (long)_fs_count * sizeof(struct statfs);
+       if((_fs_buf = malloc(bufsize)) == NULL) {
+               error(errno);
+               return(0);
+       }
+       if(getfsstat(_fs_buf, bufsize, MNT_WAIT) < 0) {
+               error(errno);
+               return(0);
+       }
+       _fs_ptr = _fs_buf;
+       return(1);
+}
+
+void
+endfsent()
+{
+       if (_fs_buf) {
+               free(_fs_buf);
+               _fs_buf = NULL;
+       }
+       _fs_count = 0;
+}
+
+static
+error(err)
+       int err;
+{
+       char *p;
+
+       (void)write(STDERR_FILENO, "fstab: ", 7);
+       (void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
+       (void)write(STDERR_FILENO, ": ", 1);
+       p = strerror(err);
+       (void)write(STDERR_FILENO, p, strlen(p));
+       (void)write(STDERR_FILENO, "\n", 1);
+}
+#endif /* defined(AFS_DARWIN_ENV) */