sysctl variable creation

Eric Anderson anderson at centtech.com
Fri Sep 30 21:14:12 PDT 2005


Peter Jeremy wrote:
> On Fri, 2005-Sep-30 16:51:51 -0500, Eric Anderson wrote:
> 
>>I'm hacking up sys/ufs/ufs/ufs_vnops.c, and I've added a sysctl entry, 
>>but it doesn't appear via sysctl -a -c vfs.ufs.  Here's what I've done:
> 
> 
> The code looks correct but I can't find a '-c' option to sysctl in
> 4.x, 5.x or 7.x.  Note that SYSCTL_STRUCT defines an opaque type that
> won't be displayed by default.  You may want "sysctl -x vfs.ufs"
> 

Yea, that's what I meant, sorry about that.  I think I am missing a 
SYSCTL_DECL in there, so maybe this would work:

--- /usr/src/sys/ufs/ufs/ufs_vnops.c-orig       Thu Sep 29 20:47:50 2005
+++ /usr/src/sys/ufs/ufs/ufs_vnops.c    Fri Sep 30 23:14:34 2005
@@ -79,6 +79,7 @@
  #include <ufs/ufs/dir.h>
  #include <ufs/ufs/ufsmount.h>
  #include <ufs/ufs/ufs_extern.h>
+#include <ufs/ufs/ufsstats.h>
  #ifdef UFS_DIRHASH
  #include <ufs/ufs/dirhash.h>
  #endif
@@ -122,6 +123,13 @@
         0, DIRBLKSIZ - 12, 2, ".."
  };

+struct ufsstats ufsstats;
+
+SYSCTL_DECL(_vfs_ufs);
+
+SYSCTL_STRUCT(_vfs_ufs, OID_AUTO, ufsstats, CTLFLAG_RW,
+        &ufsstats, ufsstats, "S,ufsstats");
+
  void
  ufs_itimes(vp)
         struct vnode *vp;
@@ -172,6 +180,7 @@
         error =
             ufs_makeinode(MAKEIMODE(ap->a_vap->va_type, 
ap->a_vap->va_mode),
             ap->a_dvp, ap->a_vpp, ap->a_cnp);
+        ufsstats.create++;
         if (error)
                 return (error);
         return (0);


Thanks for the reply!

Eric



-- 
------------------------------------------------------------------------
Eric Anderson        Sr. Systems Administrator        Centaur Technology
Anything that works is better than anything that doesn't.
------------------------------------------------------------------------


More information about the freebsd-hackers mailing list