+2003-08-04 NeilBrown <neilb@cse.unsw.edu.au>
+ * support/nfs/nfsexport.c: open channel file O_WRONLY when
+ only writing.
+ * utils/mountd/cache.c: maintain mountlist when new_cache is
+ active. Also use O_WRONLY for channel files.
+ * utils/mountd/mountd.h: mountlist_{del,add} now take a host name
+ rather than an nfs_export.
+ * utils/mountd/rmtab.c: ditto.
+
2003-07-24 Chip Salzenberg <chip@pobox.com>
* support/nfs/xlog.c (xlog): Revise buffer-overflow fix to
{
struct nfsctl_arg arg;
int fd;
- if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_RDWR))>= 0) {
+ if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
close(fd);
return exp_unexp(exp, 1);
}
struct nfsctl_arg arg;
int fd;
- if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_RDWR))>= 0) {
+ if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
close(fd);
return exp_unexp(exp, 0);
}
qword_print(f, *client?client:"DEFAULT");
qword_eol(f);
+ if (client && strcmp(ipaddr, client))
+ mountlist_add(ipaddr, *client?client:"DEFAULT");
+
if (client) free(client);
}
qword_printint(f, found->m_export.e_anonuid);
qword_printint(f, found->m_export.e_anongid);
qword_printint(f, found->m_export.e_fsid);
+ mountlist_add(dom, path);
}
qword_eol(f);
out:
void cache_export_ent(char *domain, struct exportent *exp)
{
- FILE *f = fopen("/proc/net/rpc/nfsd.export/channel", "r+");
+ FILE *f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
if (!f)
return;
qword_eol(f);
fclose(f);
+
+ mountlist_add(domain, exp->e_path);
}
void cache_export(nfs_export *exp)
{
FILE *f;
- f = fopen("/proc/net/rpc/auth.unix.ip/channel", "r+");
+ f = fopen("/proc/net/rpc/auth.unix.ip/channel", "w");
if (!f)
return;
fclose(f);
+ if (strcmp(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname))
+ mountlist_add(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname);
+
cache_export_ent(exp->m_client->m_hostname, &exp->m_export);
}
if (!(exp = auth_authenticate("unmount", sin, p))) {
return 1;
}
- mountlist_del(exp, p);
- export_reset (exp);
+ if (new_cache) {
+ if (strcmp(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname))
+ mountlist_del(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname);
+ mountlist_del(exp->m_client->m_hostname, p);
+ } else {
+ mountlist_del(exp->m_client->m_hostname, p);
+ export_reset (exp);
+ }
return 1;
}
stb.st_dev, stb.st_ino);
}
if (fh != NULL) {
- mountlist_add(exp, p);
+ mountlist_add(exp->m_client->m_hostname, p);
*error = NFS_OK;
export_reset (exp);
return fh;
char *path);
void auth_export(nfs_export *exp);
-void mountlist_add(nfs_export *exp, const char *path);
-void mountlist_del(nfs_export *exp, const char *path);
+void mountlist_add(char *host, const char *path);
+void mountlist_del(char *host, const char *path);
void mountlist_del_all(struct sockaddr_in *sin);
mountlist mountlist_list(void);
}
void
-mountlist_add(nfs_export *exp, const char *path)
+mountlist_add(char *host, const char *path)
{
struct rmtabent xe;
struct rmtabent *rep;
setrmtabent("r+");
while ((rep = getrmtabent(1, &pos)) != NULL) {
if (strcmp (rep->r_client,
- exp->m_client->m_hostname) == 0
+ host) == 0
&& strcmp(rep->r_path, path) == 0) {
rep->r_count++;
putrmtabent(rep, &pos);
}
}
endrmtabent();
- strncpy(xe.r_client, exp->m_client->m_hostname,
+ strncpy(xe.r_client, host,
sizeof (xe.r_client) - 1);
xe.r_client [sizeof (xe.r_client) - 1] = '\0';
strncpy(xe.r_path, path, sizeof (xe.r_path) - 1);
}
void
-mountlist_del(nfs_export *exp, const char *path)
+mountlist_del(char *hname, const char *path)
{
struct rmtabent *rep;
FILE *fp;
- char *hname = exp->m_client->m_hostname;
int lockid;
int match;