[illumos-Developer] [RFC] Dead code in smbfs client

Dan Kruchinin dkruchinin at acm.org
Tue May 17 21:16:21 PDT 2011


Hi list.

Pleas look at uts/common/fs/smbclnt/smbfs_node.h
It contains definition of smbnode structure that contains a field:
	cred_t		*r_cred;	/* current credentials */

This filed is accessed from four functions
File uts/common/fs/smbclnt/smbfs_vnops.c
1) smbfs_open
--
	/*
	 * This thread did the open.
	 * Save our credentials too.
	 */
	mutex_enter(&np->r_statelock);
	oldcr = np->r_cred;
	np->r_cred = cr;
	crhold(cr);
	if (oldcr)
		crfree(oldcr);
	mutex_exit(&np->r_statelock);
--

2) smbfs_rele_fid
--
	/*
	 * Other "last close" stuff.
	 */
	mutex_enter(&np->r_statelock);
	if (np->n_flag & NATTRCHANGED)
		smbfs_attrcache_rm_locked(np);
	oldcr = np->r_cred;
	np->r_cred = NULL;
	mutex_exit(&np->r_statelock);
	if (oldcr != NULL)
		crfree(oldcr);
--

File uts/common/fs/smbclnt/smbfs/smbfs_subr2.c
1) sn_inactive
--
	oldcr = np->r_cred;
	np->r_cred = NULL;
...
	if (oldcr != NULL)
		crfree(oldcr);

--

2) sn_destroy_node
--
	ASSERT(np->r_cred == NULL);
--

As you can see kernel just saves credentials of the last guy who
opened file on smbfs share to r_cred field of smbfsnode and nothing
more.
It doesn't use saved credentials later even for debugging.

What illumos policy says about dead code? Should it be removed or dropped as is?

-- 
W.B.R.
Dan Kruchinin



More information about the Developer mailing list