4 * Add or delete an NFS export in knfsd.
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
14 #include <sys/types.h>
15 #include <asm/types.h>
22 /* if /proc/net/rpc/... exists, then
23 * write to it, as that interface is more stable.
25 * client fsidtype fsid path
26 * to /proc/net/rpc/nfsd.fh/channel
28 * client path expiry flags anonuid anongid fsid
29 * to /proc/net/rpc/nfsd.export/channel
33 exp_unexp(struct nfsctl_export *exp, int export)
43 f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
44 if (f == NULL) return -1;
45 qword_print(f, exp->ex_client);
46 qword_print(f, exp->ex_path);
48 qword_printint(f, 0x7fffffff);
49 qword_printint(f, exp->ex_flags);
50 qword_printint(f, exp->ex_anon_uid);
51 qword_printint(f, exp->ex_anon_gid);
52 qword_printint(f, exp->ex_dev);
59 if (stat(exp->ex_path, &stb) != 0)
61 f = fopen("/proc/net/rpc/nfsd.fh/channel", "w");
62 if (f==NULL) return -1;
63 if (exp->ex_flags & NFSEXP_FSID) {
64 qword_print(f,exp->ex_client);
67 qword_printhex(f, (char*)&fsid, 4);
69 qword_printint(f, 0x7fffffff);
70 qword_print(f, exp->ex_path);
76 qword_print(f,exp->ex_client);
78 dev = htons(major(stb.st_dev)); memcpy(fsidstr, &dev, 2);
79 dev = htons(minor(stb.st_dev)); memcpy(fsidstr+2, &dev, 2);
80 inode = stb.st_ino; memcpy(fsidstr+4, &inode, 4);
82 qword_printhex(f, fsidstr, 8);
84 qword_printint(f, 0x7fffffff);
85 qword_print(f, exp->ex_path);
94 nfsexport(struct nfsctl_export *exp)
96 struct nfsctl_arg arg;
98 if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
100 return exp_unexp(exp, 1);
102 arg.ca_version = NFSCTL_VERSION;
103 memcpy(&arg.ca_export, exp, sizeof(arg.ca_export));
104 return nfsctl(NFSCTL_EXPORT, &arg, NULL);
108 nfsunexport(struct nfsctl_export *exp)
110 struct nfsctl_arg arg;
113 if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
115 return exp_unexp(exp, 0);
118 arg.ca_version = NFSCTL_VERSION;
119 memcpy(&arg.ca_export, exp, sizeof(arg.ca_export));
120 return nfsctl(NFSCTL_UNEXPORT, &arg, NULL);