kernels/linux-2.4.0/fs/smbfs/proc.c
/*
 * smb_build_path: build the path to entry and name storing it in buf.
 * The path returned will have the trailing '\0'.
 */
build the path to entry and name storing it in buf.
The path returned will have the trailing '\0'.
build the path to entry and name storing it in buf . The path returned will have the trailing ' \ 0 ' .
static int smb_build_path(struct smb_sb_info *server, char * buf,
			  struct dentry * entry, struct qstr * name)
{
	char *path = buf;
	int len;
	if (entry == NULL)
		goto test_name_and_out;
	if (IS_ROOT(entry)) {
		*(path++) = '\\';
		if (name != NULL)
			goto name_and_out;
		goto out;
	}
	for (;;) {
		if (entry->d_name.len > SMB_MAXNAMELEN)
			return -ENAMETOOLONG;
		if (path - buf + entry->d_name.len > SMB_MAXPATHLEN)
			return -ENAMETOOLONG;
		len = server->convert(path, SMB_MAXNAMELEN, 
				      entry->d_name.name, entry->d_name.len,
				      server->local_nls, server->remote_nls);
		reverse_string(path, len);
		path += len;
		*(path++) = '\\';
		entry = entry->d_parent;
		if (IS_ROOT(entry))
			break;
	}
	reverse_string(buf, path-buf);
test_name_and_out:
	if (name != NULL) {
		*(path++) = '\\';
name_and_out:
		len = server->convert(path, SMB_MAXNAMELEN, 
				      name->name, name->len,
				      server->local_nls, server->remote_nls);
		path += len;
	}
out:
	*(path++) = '\0';
	return (path-buf);
}
static int smb_build_path ( struct smb_sb_info * server , char * buf , struct dentry * entry , struct qstr * name ) { char * path = buf ; int len ; if ( entry == NULL ) goto test_name_and_out ; if ( IS_ROOT ( entry ) ) { * ( path ++ ) = ' \\ ' ; if ( name != NULL ) goto name_and_out ; goto out ; } for ( ; ; ) { if ( entry -> d_name . len > SMB_MAXNAMELEN ) return - ENAMETOOLONG ; if ( path - buf + entry -> d_name . len > SMB_MAXPATHLEN ) return - ENAMETOOLONG ; len = server -> convert ( path , SMB_MAXNAMELEN , entry -> d_name . name , entry -> d_name . len , server -> local_nls , server -> remote_nls ) ; reverse_string ( path , len ) ; path += len ; * ( path ++ ) = ' \\ ' ; entry = entry -> d_parent ; if ( IS_ROOT ( entry ) ) break ; } reverse_string ( buf , path - buf ) ; test_name_and_out : if ( name != NULL ) { * ( path ++ ) = ' \\ ' ; name_and_out : len = server -> convert ( path , SMB_MAXNAMELEN , name -> name , name -> len , server -> local_nls , server -> remote_nls ) ; path += len ; } out : * ( path ++ ) = ' \0 ' ; return ( path - buf ) ; }
smb_build_path: build the path to entry and name storing it in buf.
smb_build_path : build the path to entry and name storing it in buf .
/*
	 * If IS_ROOT, we have to do no walking at all.
	 */ /*
	 * Build the path string walking the tree backward from end to ROOT
	 * and store it in reversed order [see reverse_string()]
	 */