summaryrefslogtreecommitdiffstats
path: root/tapset/svc_export.stp
blob: c0dbf9bdd84043381cde8e6c3c2962f0cab664b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
%{
#include <linux/fs.h>
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
#include <linux/path.h>
#else
#include <linux/sunrpc/svc.h>
#include <linux/nfsd/nfsfh.h>
#endif
#include <linux/nfsd/export.h>
%}

function svc_export_dump:string(_exp:long)
%{
	struct svc_export *exp = (struct svc_export *)(long) kread(&(THIS->_exp));
	struct dentry *dentry = NULL;
	struct vfsmount *mnt = NULL;
	char buf[64], *fname=NULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
	struct path ex_path;
#endif
	int cc=0;

	if (exp <= 0) {
		sprintf(buf+cc, "exp NULL");
	} else {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
		sprintf(buf+cc, "exp %p path %s flg 0x%x fsid %d nflavors %d\n", 
			exp, exp->ex_path > 0 ? exp->ex_path : NULL, 
			exp->ex_flags, exp->ex_fsid, exp->ex_nflavors);
		cc = strlen(buf);
		dentry = (struct dentry *) (long) kread(&(exp->ex_dentry));
		mnt = (struct vfsmount *) kread(&(exp->ex_mnt));
		if (mnt && dentry)
			fname = d_path(dentry, mnt, buf, 64);
		sprintf(buf+cc, "    mnt %p dentry %p(%s)", 
			exp->ex_mnt, exp->ex_dentry, fname > 0 ? fname : NULL);
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
		sprintf(buf+cc, "exp %p path %s flg 0x%x fsid %d nflavors %d\n", 
			exp, exp->ex_pathname > 0 ? exp->ex_pathname : NULL, 
			exp->ex_flags, exp->ex_fsid, exp->ex_nflavors);
#else
		dentry = (struct dentry *) (long) kread(&(exp->ex_path.dentry));
		mnt = (struct vfsmount *) kread(&(exp->ex_path.mnt));
		if (mnt && dentry)
			fname = d_path(&exp->ex_path, buf, 64);
		sprintf(buf+cc, "exp %p   mnt %p dentry %p(%s) flg 0x%x fsid %d nflavors %d\n", 
			exp, mnt, dentry, fname > 0 ? fname : NULL,
			exp->ex_flags, exp->ex_fsid, exp->ex_nflavors);
#endif
		cc = strlen(buf);
		ex_path.dentry = (struct dentry *) (long) kread(&(exp->ex_path.dentry));
		ex_path.mnt = (struct vfsmount *) kread(&(exp->ex_path.mnt));
		if (ex_path.mnt && ex_path.dentry)
			fname = d_path(&ex_path, buf, 64);
		sprintf(buf+cc, "                   mnt %p dentry %p(%s)", 
			ex_path.mnt, ex_path.dentry, fname > 0 ? fname : NULL);
#endif
	}
	snprintf(THIS->__retvalue, 64, "%s", buf); 

	CATCH_DEREF_FAULT();
%}

function svc_export_flavors:string(_exp:long)
%{
	struct svc_export *exp = (struct svc_export *)(long) kread(&(THIS->_exp));
	struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;
	struct exp_flavor_info *f;
	char buf[64], *fname=NULL;
	int cc=0;

	if (exp <= 0) {
		sprintf(buf+cc, "exp NULL");
	} else {
		sprintf(buf+cc, "ex_flavors[%d] ", exp->ex_nflavors);
		cc = strlen(buf);
		if (exp->ex_nflavors) {
			sprintf(buf+cc, "[");
			cc = strlen(buf);
			for (f = exp->ex_flavors; f < end; f++) {
				sprintf(buf+cc, "%d,", f->pseudoflavor);
				cc = strlen(buf);
			}
			sprintf(buf+cc, "]");
			cc = strlen(buf);
		}
	}
	snprintf(THIS->__retvalue, 64, "%s", buf); 

	CATCH_DEREF_FAULT();
%}