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);
45 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);
55 if (stat(exp->ex_path, &stb) != 0)
57 f = fopen("/proc/net/rpc/nfsd.fh/channel", "w");
58 if (f==NULL) return -1;
59 if (exp->ex_flags & NFSEXP_FSID) {
60 qword_print(f,exp->ex_client);
63 qword_printhex(f, (char*)&fsid, 4);
64 qword_printint(f, 0x7fffffff);
66 qword_print(f, exp->ex_path);
69 qword_print(f,exp->ex_client);
71 dev = htons(major(stb.st_dev)); memcpy(fsidstr, &dev, 2);
72 dev = htons(minor(stb.st_dev)); memcpy(fsidstr+2, &dev, 2);
73 inode = stb.st_ino; memcpy(fsidstr+4, &inode, 4);
75 qword_printhex(f, fsidstr, 8);
76 qword_printint(f, 0x7fffffff);
78 qword_print(f, exp->ex_path);
85 nfsexport(struct nfsctl_export *exp)
87 struct nfsctl_arg arg;
89 if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_RDWR))>= 0) {
91 return exp_unexp(exp, 1);
93 arg.ca_version = NFSCTL_VERSION;
94 memcpy(&arg.ca_export, exp, sizeof(arg.ca_export));
95 return nfsctl(NFSCTL_EXPORT, &arg, NULL);
99 nfsunexport(struct nfsctl_export *exp)
101 struct nfsctl_arg arg;
104 if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_RDWR))>= 0) {
106 return exp_unexp(exp, 0);
109 arg.ca_version = NFSCTL_VERSION;
110 memcpy(&arg.ca_export, exp, sizeof(arg.ca_export));
111 return nfsctl(NFSCTL_UNEXPORT, &arg, NULL);