2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software donated to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include
<sys
/types.h
>
39 #include
<sys
/mount.h
>
40 #include
<sys
/sysctl.h
>
43 #include
<afs
/sysctl.h
>
45 #include
<CoreFoundation
/CFString.h
>
46 #include
<Foundation
/Foundation.h
>
54 typedef
struct oidsetting
{
58 struct oidsetting
*children
;
62 mygetvfsbyname
(const
char *fsname
, struct vfsconf
*vfcp
, Setting
*s
, int myoid
[])
68 myoid
[1] = VFS_GENERIC
;
69 myoid
[2] = VFS_MAXTYPENUM
;
71 if (sysctl
(myoid
, 3, &maxtypenum
, &buflen
, (void
*)0, (size_t
)0) < 0)
76 buflen
= sizeof
* vfcp
;
77 for (cnt
= 0; cnt
< maxtypenum
; cnt
++)
80 if (sysctl
(myoid
, 4, vfcp
, &buflen
, (void
*)0, (size_t
)0) < 0)
82 if (errno
!= EOPNOTSUPP
&& errno
!= ENOENT
&& errno
!= ENOTSUP
)
88 if (!strcmp(fsname
, vfcp
->vfc_name
))
90 s
->selector
= vfcp
->vfc_typenum
;
99 oiderror
(int
*oid
, int oidlen
, enum
Type type, void
*obj
)
101 fprintf(stderr
, "sysctl "
);
103 fprintf(stderr
, "
%d", *oid++);
106 fprintf(stderr
, "
%c", '.');
108 fprintf(stderr
, "
=> "
);
110 fprintf(stderr
, "
%d\n", *(int *)obj);
112 fprintf(stderr
, "
%s\n", (char *)obj);
118 recurse
(id obj
, Setting
*s
, int level
, int myoid
[])
125 myoid
[level
] = s
->selector
;
128 for(child
= s
->children
; child
->key
; child
++) {
129 if(child
->type == Node
&& !child
->children
)
131 newobj
= [obj objectForKey
: child
->key
];
133 recurse
(newobj
, child
, level
+1, myoid
);
137 intval
= [obj intValue
];
138 if(sysctl
(myoid
, level
+1, NULL, NULL, &intval
, sizeof
(intval
)) < 0)
139 oiderror
(myoid
, level
+1, s
->type, &intval
);
142 cp
= [obj UTF8String
];
143 if(sysctl
(myoid
, level
+1, NULL, NULL, (void
*)cp
, strlen
(cp
)) < 0)
144 oiderror
(myoid
, level
+1, s
->type, &cp
);
149 Setting sysctl_darwin_all
[] = {
150 {@"RealModes"
, AFS_SC_DARWIN_ALL_REALMODES
, LeafNum
, NULL},
151 {@"FSEvents"
, AFS_SC_DARWIN_ALL_FSEVENTS
, LeafNum
, NULL},
152 {@"Bulkstat"
, AFS_SC_DARWIN_ALL_BULKSTAT
, LeafNum
, NULL},
155 Setting sysctl_darwin
[] = {
156 {@"
All"
, AFS_SC_DARWIN_ALL
, Node
, sysctl_darwin_all
},
157 {@"Darwin60"
, AFS_SC_DARWIN_60
, Node
, NULL},
158 {@"Darwin70"
, AFS_SC_DARWIN_70
, Node
, NULL},
159 {@"Darwin80"
, AFS_SC_DARWIN_80
, Node
, NULL},
160 {@"Darwin90"
, AFS_SC_DARWIN_90
, Node
, NULL},
161 {@"Darwin100"
, AFS_SC_DARWIN_100
, Node
, NULL},
162 {@"Darwin110"
, AFS_SC_DARWIN_110
, Node
, NULL},
163 {@"Darwin120"
, AFS_SC_DARWIN_120
, Node
, NULL},
164 {@"Darwin130"
, AFS_SC_DARWIN_130
, Node
, NULL},
165 {@"Darwin140"
, AFS_SC_DARWIN_140
, Node
, NULL},
168 Setting sysctl_first
[] = {
169 {@"
All"
, AFS_SC_ALL
, Node
, NULL},
170 {@"Darwin"
, AFS_SC_DARWIN
, Node
, sysctl_darwin
},
173 Setting sysctl_top
= {NULL, -1, Node
, sysctl_first
};
176 main
(int argc
, char **argv
)
181 NSAutoreleasePool
* nspool
= [[NSAutoreleasePool alloc
] init
];
182 NSString
*plistpath
= @"
/var
/db
/openafs
/etc
/config
/settings.plist"
;
183 int oid
[CTL_MAXNAME
] = {CTL_VFS
};
185 if (mygetvfsbyname
("afs"
, &vfcp
, &sysctl_top
, oid
) != 0)
187 plistData
= [NSData dataWithContentsOfFile
: plistpath
];
189 plist
= [NSPropertyListSerialization propertyListWithData
: plistData
190 options
: NSPropertyListImmutable
195 NSLog
(@"
Error reading plist from file
'%s'"
, [plistpath UTF8String
]);
200 recurse
(plist
, &sysctl_top
, 1, oid
);