DF-3017 / offsets2.c
/* DF-3017 chain: kernel structure offsets (guest-side, _KERNEL_STRUCTURES) */ #define _KERNEL_STRUCTURES #include <sys/types.h> #include <sys/param.h> #include <sys/sysref.h> #include <sys/conf.h> #include <sys/device.h> #include <sys/devfs.h> #include <sys/proc.h> #include <sys/ucred.h> #include <sys/uio.h> #include <sys/globaldata.h> #include <sys/slaballoc.h> #include <sys/objcache.h> #include <sys/mutex2.h> #include <stddef.h> #include <stdio.h> int main(void) { printf("sizeof(struct cdev) = %zu\n", sizeof(struct cdev)); printf(" si_uminor=%zu si_name=%zu si_ops=%zu si_bops=%zu si_iosize_max=%zu si_sysref=%zu si_hlist=%zu\n", offsetof(struct cdev, si_uminor), offsetof(struct cdev, si_name), offsetof(struct cdev, si_ops), offsetof(struct cdev, si_bops), offsetof(struct cdev, si_iosize_max), offsetof(struct cdev, si_sysref), offsetof(struct cdev, si_hlist)); printf(" sysref: refcnt=%zu flags=%zu size=%zu\n", offsetof(struct sysref, refcnt), offsetof(struct sysref, flags), sizeof(struct sysref)); printf("sizeof(struct devfs_node) = %zu (d_dev=%zu)\n", sizeof(struct devfs_node), offsetof(struct devfs_node, d_dev)); printf("sizeof(struct devfs_msg) = %zu\n", sizeof(struct devfs_msg)); printf("privatespace: sizeof=%zu\n", sizeof(struct privatespace)); printf("globaldata: gd_slab=%zu gd_cpuid=%zu sizeof=%zu\n", offsetof(struct globaldata, gd_slab), offsetof(struct globaldata, gd_cpuid), sizeof(struct globaldata)); printf("SLZone: sizeof=%zu z_Magic=%zu z_ZoneIndex=%zu z_NMax=%zu z_NFree=%zu\n", sizeof(SLZone), offsetof(SLZone, z_Magic), offsetof(SLZone, z_ZoneIndex), offsetof(SLZone, z_NMax), offsetof(SLZone, z_NFree)); printf(" z_BasePtr=%zu z_UIndex=%zu z_Cpu=%zu z_CpuGd=%zu z_ChunkSize=%zu\n", offsetof(SLZone, z_BasePtr), offsetof(SLZone, z_UIndex), offsetof(SLZone, z_Cpu), offsetof(SLZone, z_CpuGd), offsetof(SLZone, z_ChunkSize)); printf(" z_Entry=%zu (tqe_next=%zu) z_LChunks=%zu z_RChunks=%zu z_RSignal=%zu z_RCount=%zu z_Flags=%zu\n", offsetof(SLZone, z_Entry), offsetof(SLZone, z_Entry), offsetof(SLZone, z_LChunks), offsetof(SLZone, z_RChunks), offsetof(SLZone, z_RSignal), offsetof(SLZone, z_RCount), offsetof(SLZone, z_Flags)); printf("SLGlobalData: ZoneAry=%zu (NZONES=%d) FreeZones=%zu\n", offsetof(SLGlobalData, ZoneAry), NZONES, offsetof(SLGlobalData, FreeZones)); { int i; unsigned long b,a; for (i=0;i<NZONES;i++){b=289;a=0;(void)a;} } printf("objcache: sizeof=%zu cache_percpu=%zu depot=%zu alloc=%zu ctor=%zu\n", sizeof(struct objcache), offsetof(struct objcache, cache_percpu), offsetof(struct objcache, depot), offsetof(struct objcache, alloc), offsetof(struct objcache, ctor)); printf("percpu_objcache: loaded=%zu previous=%zu sizeof=%zu\n", offsetof(struct percpu_objcache, loaded_magazine), offsetof(struct percpu_objcache, previous_magazine), sizeof(struct percpu_objcache)); printf("magazinedepot: fullmagazines=%zu emptymagazines=%zu magcapacity=%zu unallocated=%zu cluster_limit=%zu\n", offsetof(struct magazinedepot, fullmagazines), offsetof(struct magazinedepot, emptymagazines), offsetof(struct magazinedepot, magcapacity), offsetof(struct magazinedepot, unallocated_objects), offsetof(struct magazinedepot, cluster_limit)); printf("magazine: rounds=%zu capacity=%zu nextmagazine=%zu objects=%zu\n", offsetof(struct magazine, rounds), offsetof(struct magazine, capacity), offsetof(struct magazine, nextmagazine), offsetof(struct magazine, objects)); printf("struct proc: p_pid=%zu p_ucred=%zu size=%zu\n", offsetof(struct proc, p_pid), offsetof(struct proc, p_ucred), sizeof(struct proc)); printf("struct ucred: cr_uid=%zu cr_ruid=%zu cr_svuid=%zu cr_ngroups=%zu cr_groups=%zu\n", offsetof(struct ucred, cr_uid), offsetof(struct ucred, cr_ruid), offsetof(struct ucred, cr_svuid), offsetof(struct ucred, cr_ngroups), offsetof(struct ucred, cr_groups)); printf("struct thread: td_proc=%zu td_lwp=%zu\n", offsetof(struct thread, td_proc), offsetof(struct thread, td_lwp)); printf("struct lwp: lwp_proc=%zu\n", offsetof(struct lwp, lwp_proc)); return 0; } |