4 * Add or delete an NFS export in knfsd.
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
12 #include <sys/types.h>
13 #include <asm/types.h>
20 /* if /proc/net/rpc/... exists, then
21 * write to it, as that interface is more stable.
23 * client fsidtype fsid path
24 * to /proc/net/rpc/nfsd.fh/channel
26 * client path expiry flags anonuid anongid fsid
27 * to /proc/net/rpc/nfsd.export/channel
31 exp_unexp(struct nfsctl_export *exp, int export)
41 f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
42 if (f == NULL) return -1;
43 qword_print(f, exp->ex_client);
44 qword_print(f, exp->ex_path);
46 qword_printint(f, 0x7fffffff);
47 qword_printint(f, exp->ex_flags);
48 qword_printint(f, exp->ex_anon_uid);
49 qword_printint(f, exp->ex_anon_gid);
50 qword_printint(f, exp->ex_dev);
57 if (stat(exp->ex_path, &stb) != 0)
59 f = fopen("/proc/net/rpc/nfsd.fh/channel", "w");
60 if (f==NULL) return -1;
61 if (exp->ex_flags & NFSEXP_FSID) {
62 qword_print(f,exp->ex_client);
65 qword_printhex(f, (char*)&fsid, 4);
67 qword_printint(f, 0x7fffffff);
68 qword_print(f, exp->ex_path);
74 qword_print(f,exp->ex_client);
76 dev = htons(major(stb.st_dev)); memcpy(fsidstr, &dev, 2);
77 dev = htons(minor(stb.st_dev)); memcpy(fsidstr+2, &dev, 2);
78 inode = stb.st_ino; memcpy(fsidstr+4, &inode, 4);
80 qword_printhex(f, fsidstr, 8);
82 qword_printint(f, 0x7fffffff);
83 qword_print(f, exp->ex_path);
92 nfsexport(struct nfsctl_export *exp)
94 struct nfsctl_arg arg;
96 if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
98 return exp_unexp(exp, 1);
100 arg.ca_version = NFSCTL_VERSION;
101 memcpy(&arg.ca_export, exp, sizeof(arg.ca_export));
102 return nfsctl(NFSCTL_EXPORT, &arg, NULL);
106 nfsunexport(struct nfsctl_export *exp)
108 struct nfsctl_arg arg;
111 if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
113 return exp_unexp(exp, 0);
116 arg.ca_version = NFSCTL_VERSION;
117 memcpy(&arg.ca_export, exp, sizeof(arg.ca_export));
118 return nfsctl(NFSCTL_UNEXPORT, &arg, NULL);