macos: bulkstat sysctl
[openafs.git] / src / afs / DARWIN / osi_vfsops.c
index ed34e60..7f0aac7 100644 (file)
@@ -4,8 +4,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <afs/sysincludes.h>   /* Standard vendor system headers */
 #include <afsincludes.h>       /* Afs-based standard headers */
@@ -30,25 +28,18 @@ int afs_vfs_typenum;
 int
 afs_quotactl()
 {
-    return EOPNOTSUPP;
+    return ENOTSUP;
 }
 
 int
-afs_fhtovp(mp, fhp, vpp)
-     struct mount *mp;
-     struct fid *fhp;
-     struct vnode **vpp;
+afs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
 {
-
     return (EINVAL);
 }
 
 int
-afs_vptofh(vp, fhp)
-     struct vnode *vp;
-     struct fid *fhp;
+afs_vptofh(struct vnode *vp, struct fid *fhp)
 {
-
     return (EINVAL);
 }
 
@@ -65,10 +56,7 @@ afs_vptofh(vp, fhp)
 #define PROC_DECL(out,in) struct proc *out = CTX_PROC_CONVERT(in)
 
 int
-afs_start(mp, flags, p)
-     struct mount *mp;
-     int flags;
-     CTX_TYPE p;
+afs_start(struct mount *mp, int flags, CTX_TYPE p)
 {
     return (0);                        /* nothing to do. ? */
 }
@@ -77,19 +65,10 @@ int
 afs_statfs(struct mount *mp, STATFS_TYPE *abp, CTX_TYPE ctx);
 #ifdef AFS_DARWIN80_ENV
 int
-afs_mount(mp, devvp, data, ctx)
-     register struct mount *mp;
-     vnode_t *devvp;
-     user_addr_t data;
-     vfs_context_t ctx;
+afs_mount(struct mount *mp, vnode_t *devvp, user_addr_t data, vfs_context_t ctx)
 #else
 int
-afs_mount(mp, path, data, ndp, p)
-     register struct mount *mp;
-     char *path;
-     caddr_t data;
-     struct nameidata *ndp;
-     CTX_TYPE ctx;
+afs_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, CTX_TYPE ctx)
 #endif
 {
     /* ndp contains the mounted-from device.  Just ignore it.
@@ -118,7 +97,7 @@ afs_mount(mp, path, data, ndp, p)
     afs_globalVFS = mp;
 #ifdef AFS_DARWIN80_ENV
     vfs_ioattr(mp, &ioattr);
-    ioattr.io_devblocksize = 8192;
+    ioattr.io_devblocksize = (16 * 32768);
     vfs_setioattr(mp, &ioattr);
     /* f_iosize is handled in VFS_GETATTR */
 #else
@@ -191,10 +170,7 @@ afs_mount(mp, path, data, ndp, p)
 }
 
 int
-afs_unmount(mp, flags, ctx)
-     struct mount *mp;
-     int flags;
-     CTX_TYPE ctx;
+afs_unmount(struct mount *mp, int flags, CTX_TYPE ctx)
 {
     void *mdata = vfs_fsprivate(mp);
     AFS_GLOCK();
@@ -245,23 +221,23 @@ afs_root(struct mount *mp, struct vnode **vpp)
     void *mdata = vfs_fsprivate(mp);
     int error;
     struct vrequest treq;
-    register struct vcache *tvp = 0;
+    struct vcache *tvp = 0;
 #ifdef AFS_DARWIN80_ENV
     struct ucred *cr = vfs_context_ucred(ctx);
     int needref=0;
 #else
     struct proc *p = current_proc();
     struct ucred _cr;
-    struct ucred *cr =&_cr;
+    struct ucred *cr = &_cr;
 
     pcred_readlock(p);
-    cr = *p->p_cred->pc_ucred;
+    _cr = *p->p_cred->pc_ucred;
     pcred_unlock(p);
 #endif
     AFS_GLOCK();
     AFS_STATCNT(afs_root);
     if (mdata == NULL && afs_globalVp
-       && (afs_globalVp->states & CStatd)) {
+       && (afs_globalVp->f.states & CStatd)) {
        tvp = afs_globalVp;
        error = 0;
 #ifdef AFS_DARWIN80_ENV
@@ -278,11 +254,11 @@ afs_root(struct mount *mp, struct vnode **vpp)
 #ifdef AFS_DARWIN80_ENV
             if (tvp) {
                AFS_GUNLOCK();
-                error = afs_darwin_finalizevnode(tvp, NULL, NULL, 1);
+                error = afs_darwin_finalizevnode(tvp, NULL, NULL, 1, 0);
                AFS_GLOCK();
                 if (error)
                    tvp = NULL;
-                else 
+                else
                    /* re-acquire the usecount that finalizevnode disposed of */
                    vnode_ref(AFSTOV(tvp));
             }
@@ -335,10 +311,7 @@ afs_root(struct mount *mp, struct vnode **vpp)
 
 #ifndef AFS_DARWIN80_ENV /* vget vfsop never had this prototype AFAIK */
 int
-afs_vget(mp, lfl, vp)
-     struct mount *mp;
-     struct vnode *vp;
-     int lfl;
+afs_vget(struct mount *mp, int lfl, struct vnode *vp)
 {
     int error;
     //printf("vget called. help!\n");
@@ -366,22 +339,23 @@ afs_statfs(struct mount *mp, STATFS_TYPE *abp, CTX_TYPE ctx)
     AFS_GLOCK();
     AFS_STATCNT(afs_statfs);
 
-#if 0
-    abp->f_type = MOUNT_AFS;
-#endif
 #ifdef AFS_DARWIN80_ENV
-    abp->f_bsize = abp->f_iosize = vfs_devblocksize(mp);
+    abp->f_iosize = (256 * 1024);
+    abp->f_bsize = vfs_devblocksize(mp);
 #else
     abp->f_bsize = mp->vfs_bsize;
     abp->f_iosize = mp->vfs_bsize;
 #endif
+#if 0
+    abp->f_type = MOUNT_AFS;
+#endif
 
     /* Fake a high number below to satisfy programs that use the statfs call
      * to make sure that there's enough space in the device partition before
      * storing something there.
      */
     abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
-       abp->f_ffree = 2000000;
+      abp->f_ffree = 0x7fffffff;
 
     if (abp != sysstat) {
         abp->f_fsid.val[0] = sysstat->f_fsid.val[0];
@@ -463,34 +437,58 @@ afs_vfs_getattr(struct mount *mp, struct vfs_attr *outattrs,
 
 #ifdef AFS_DARWIN80_ENV
 int
-afs_sync(mp, waitfor, ctx)
-     struct mount *mp;
-     int waitfor;
-     CTX_TYPE ctx;
+afs_sync(struct mount *mp, int waitfor, CTX_TYPE ctx)
 #else
 int
-afs_sync(mp, waitfor, cred, p)
-     struct mount *mp;
-     int waitfor;
-     struct ucred *cred;
-     struct proc *p;
+afs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct proc *p)
 #endif
 {
     return 0;
 }
 
 u_int32_t afs_darwin_realmodes = 0;
+u_int32_t afs_darwin_fsevents = 0;
+extern int AFSDOBULK;
 
+int
+afs_sysctl_int(int *name, u_int namelen, user_addr_t oldp, size_t *oldlenp,
+              user_addr_t newp, size_t newlen, u_int32_t *object)
+{
 #ifdef AFS_DARWIN80_ENV
-int afs_sysctl(int *name, u_int namelen, user_addr_t oldp, size_t *oldlenp, 
+    int error;
+
+    if (oldp != USER_ADDR_NULL && oldlenp == NULL)
+       return (EFAULT);
+    if (oldp && *oldlenp < sizeof(u_int32_t))
+       return (ENOMEM);
+    if (newp && newlen != sizeof(u_int32_t))
+       return (EINVAL);
+    *oldlenp = sizeof(u_int32_t);
+    if (oldp) {
+       if ((error = copyout(object,
+                            oldp, sizeof(u_int32_t)))) {
+           return error;
+       }
+    }
+    if (newp)
+       return copyin(newp, object, sizeof(u_int32_t));
+    return 0;
+#else
+    return sysctl_int(oldp, oldlenp, newp, newlen,
+                     object);
+#endif
+}
+
+#ifdef AFS_DARWIN80_ENV
+int
+afs_sysctl(int *name, u_int namelen, user_addr_t oldp, size_t *oldlenp,
               user_addr_t newp, size_t newlen, vfs_context_t context)
 #else
-int afs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, 
+int
+afs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
               void *newp, size_t newlen, struct proc *p)
 #endif
 {
-    int error;
-
     switch (name[0]) {
     case AFS_SC_ALL:
         /* nothing defined */
@@ -502,20 +500,21 @@ int afs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
        case AFS_SC_DARWIN_ALL:
            switch (name[2]) {
            case AFS_SC_DARWIN_ALL_REALMODES:
-#ifdef AFS_DARWIN80_ENV
-               newlen;
-               /* XXX complicated */
-#else
-               return sysctl_int(oldp, oldlenp, newp, newlen,
-                                 &afs_darwin_realmodes);
-#endif
+               return afs_sysctl_int(name, namelen, oldp, oldlenp,
+                                     newp, newlen, &afs_darwin_realmodes);
+           case AFS_SC_DARWIN_ALL_FSEVENTS:
+               return afs_sysctl_int(name, namelen, oldp, oldlenp,
+                                     newp, newlen, &afs_darwin_fsevents);
+           case AFS_SC_DARWIN_ALL_BULKSTAT:
+               return afs_sysctl_int(name, namelen, oldp, oldlenp,
+                                     newp, newlen, &AFSDOBULK);
            }
            break;
            /* darwin version specific sysctl's goes here */
        }
        break;
     }
-    return EOPNOTSUPP;
+    return ENOTSUP;
 }
 
 typedef (*PFI) ();