diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2009-12-15 15:53:49 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2009-12-15 15:53:49 +0000 |
commit | 4235a0786c7756f63d70130afc85690dc7812e43 (patch) | |
tree | 95d62cf4e99ff8be784c3ba8325291d38b62738d /sys/nfs/nfs_vnops.c | |
parent | c04b7098d33d73ec5977ad46f5a3cf1ee64a1ace (diff) |
Make sillyrename not so damn silly. The kindergarten algorithm here for
picking a name meant that more than 58 sillys in a directory and we fail
with EINVAL, resulting in strange problems for nfs which in turn causes
pain and stress in building, and PTSD in nfs and vfs hackers. Has bit us
in the butt since the vienna f2k7 hackathon.
good suggestions from deraadt@ guenther@ and otto@
ok deraadt@,oga@,blambert@,krw@,guenther@, and a "very special ok" tedu@
Oh god, I'm an nfs hacker..
Diffstat (limited to 'sys/nfs/nfs_vnops.c')
-rw-r--r-- | sys/nfs/nfs_vnops.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 849f6ef5217..0b9fada31f5 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.126 2009/12/10 16:41:45 beck Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.127 2009/12/15 15:53:48 beck Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -186,7 +186,6 @@ extern struct nfsstats nfsstats; extern nfstype nfsv3_type[9]; int nfs_numasync = 0; - void nfs_cache_enter(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { @@ -2519,21 +2518,19 @@ nfs_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) goto bad; } - /* Fudge together a funny name */ - sp->s_namlen = snprintf(sp->s_name, sizeof sp->s_name, - ".nfsA%05x4.4", cnp->cn_proc->p_pid); - if (sp->s_namlen > sizeof sp->s_name) - sp->s_namlen = strlen(sp->s_name); - /* Try lookitups until we get one that isn't there */ - while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_proc, NULL) == 0) { - sp->s_name[4]++; - if (sp->s_name[4] > 'z') { - error = EINVAL; - goto bad; - } + while (1) { + /* Fudge together a funny name */ + sp->s_namlen = snprintf(sp->s_name, sizeof sp->s_name, + ".nfs%08X%08X", arc4random(), arc4random()); + if (sp->s_namlen > sizeof sp->s_name) + sp->s_namlen = strlen(sp->s_name); + + if (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, + cnp->cn_proc, NULL)) + break; } + error = nfs_renameit(dvp, cnp, sp); if (error) goto bad; |