if(!CIFSSMBQFSUnixInfo(xid, tcon, cifs_sb->local_nls)) { 
if(!CIFSSMBQFSUnixInfo(xid, tcon)) { 
cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,	   char *mount_data, const char *devname){	int rc = 0;	int xid;	int address_type = AF_INET;	struct socket *csocket = NULL;	struct sockaddr_in sin_server;	struct sockaddr_in6 sin_server6;	struct smb_vol volume_info;	struct cifsSesInfo *pSesInfo = NULL;	struct cifsSesInfo *existingCifsSes = NULL;	struct cifsTconInfo *tcon = NULL;	struct TCP_Server_Info *srvTcp = NULL;	xid = GetXid();/* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */		memset(&volume_info,0,sizeof(struct smb_vol));	if (cifs_parse_mount_options(mount_data, devname, &volume_info)) {		if(volume_info.UNC)			kfree(volume_info.UNC);		if(volume_info.password)			kfree(volume_info.password);		FreeXid(xid);		return -EINVAL;	}	if (volume_info.username) {		/* BB fixme parse for domain name here */		cFYI(1, ("Username: %s ", volume_info.username));	} else {		cifserror("No username specified ");        /* In userspace mount helper we can get user name from alternate           locations such as env variables and files on disk */		if(volume_info.UNC)			kfree(volume_info.UNC);		if(volume_info.password)			kfree(volume_info.password);		FreeXid(xid);		return -EINVAL;	}	if (volume_info.UNCip && volume_info.UNC) {		rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr);		if(rc <= 0) {			/* not ipv4 address, try ipv6 */			rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); 			if(rc > 0)				address_type = AF_INET6;		} else {			address_type = AF_INET;		}       		if(rc <= 0) {			/* we failed translating address */			if(volume_info.UNC)				kfree(volume_info.UNC);			if(volume_info.password)				kfree(volume_info.password);			FreeXid(xid);			return -EINVAL;		}		cFYI(1, ("UNC: %s ip: %s", volume_info.UNC, volume_info.UNCip));		/* success */		rc = 0;	} else if (volume_info.UNCip){		/* BB using ip addr as server name connect to the DFS root below */		cERROR(1,("Connecting to DFS root not implemented yet"));		if(volume_info.UNC)			kfree(volume_info.UNC);		if(volume_info.password)			kfree(volume_info.password);		FreeXid(xid);		return -EINVAL;	} else /* which servers DFS root would we conect to */ {		cERROR(1,		       ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified  "));		if(volume_info.UNC)			kfree(volume_info.UNC);		if(volume_info.password)			kfree(volume_info.password);		FreeXid(xid);		return -EINVAL;	}	/* this is needed for ASCII cp to Unicode converts */	if(volume_info.iocharset == NULL) {		cifs_sb->local_nls = load_nls_default();	/* load_nls_default can not return null */	} else {		cifs_sb->local_nls = load_nls(volume_info.iocharset);		if(cifs_sb->local_nls == NULL) {			cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset));			if(volume_info.UNC)				kfree(volume_info.UNC);			if(volume_info.password)				kfree(volume_info.password);			FreeXid(xid);			return -ELIBACC;		}	}	if(address_type == AF_INET)		existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr,			NULL /* no ipv6 addr */,			volume_info.username, &srvTcp);	else if(address_type == AF_INET6)		existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */,			&sin_server6.sin6_addr,			volume_info.username, &srvTcp);	else {		if(volume_info.UNC)			kfree(volume_info.UNC);		if(volume_info.password)			kfree(volume_info.password);		FreeXid(xid);		return -EINVAL;	}	if (srvTcp) {		cFYI(1, ("Existing tcp session with server found "));                	} else {	/* create socket */		if(volume_info.port)			sin_server.sin_port = htons(volume_info.port);		else			sin_server.sin_port = 0;		rc = ipv4_connect(&sin_server,&csocket,volume_info.source_rfc1001_name);		if (rc < 0) {			cERROR(1,			       ("Error connecting to IPv4 socket. Aborting operation"));			if(csocket != NULL)				sock_release(csocket);			if(volume_info.UNC)				kfree(volume_info.UNC);			if(volume_info.password)				kfree(volume_info.password);			FreeXid(xid);			return rc;		}		srvTcp = kmalloc(sizeof (struct TCP_Server_Info), GFP_KERNEL);		if (srvTcp == NULL) {			rc = -ENOMEM;			sock_release(csocket);			if(volume_info.UNC)				kfree(volume_info.UNC);			if(volume_info.password)				kfree(volume_info.password);			FreeXid(xid);			return rc;		} else {			memset(srvTcp, 0, sizeof (struct TCP_Server_Info));			memcpy(&srvTcp->addr.sockAddr, &sin_server, sizeof (struct sockaddr_in));			atomic_set(&srvTcp->inFlight,0);			/* BB Add code for ipv6 case too */			srvTcp->ssocket = csocket;			srvTcp->protocolType = IPV4;			init_waitqueue_head(&srvTcp->response_q);			init_waitqueue_head(&srvTcp->request_q);			INIT_LIST_HEAD(&srvTcp->pending_mid_q);			/* at this point we are the only ones with the pointer			to the struct since the kernel thread not created yet			so no need to spinlock this init of tcpStatus */			srvTcp->tcpStatus = CifsNew;			init_MUTEX(&srvTcp->tcpSem);			rc = (int)kernel_thread((void *)(void *)cifs_demultiplex_thread, srvTcp,				      CLONE_FS | CLONE_FILES | CLONE_VM);			if(rc < 0) {				rc = -ENOMEM;				sock_release(csocket);				if(volume_info.UNC)					kfree(volume_info.UNC);				if(volume_info.password)					kfree(volume_info.password);				FreeXid(xid);				return rc;			} else				rc = 0;			memcpy(srvTcp->workstation_RFC1001_name, volume_info.source_rfc1001_name,16);			srvTcp->sequence_number = 0;		}	}	if (existingCifsSes) {		pSesInfo = existingCifsSes;		cFYI(1, ("Existing smb sess found "));		if(volume_info.password)			kfree(volume_info.password);		/* volume_info.UNC freed at end of function */	} else if (!rc) {		cFYI(1, ("Existing smb sess not found "));		pSesInfo = sesInfoAlloc();		if (pSesInfo == NULL)			rc = -ENOMEM;		else {			pSesInfo->server = srvTcp;			sprintf(pSesInfo->serverName, "%u.%u.%u.%u",				NIPQUAD(sin_server.sin_addr.s_addr));		}		if (!rc){			/* volume_info.password freed at unmount */   			if (volume_info.password)				pSesInfo->password = volume_info.password;			if (volume_info.username)				strncpy(pSesInfo->userName,					volume_info.username,MAX_USERNAME_SIZE);			if (volume_info.domainname)				strncpy(pSesInfo->domainName,					volume_info.domainname,MAX_USERNAME_SIZE);			pSesInfo->linux_uid = volume_info.linux_uid;			down(&pSesInfo->sesSem);			rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls);			up(&pSesInfo->sesSem);			if(!rc)				atomic_inc(&srvTcp->socketUseCount);		} else			if(volume_info.password)				kfree(volume_info.password);	}    	/* search for existing tcon to this server share */	if (!rc) {		if((volume_info.rsize) && (volume_info.rsize <= CIFSMaxBufSize))			cifs_sb->rsize = volume_info.rsize;		else			cifs_sb->rsize = srvTcp->maxBuf - MAX_CIFS_HDR_SIZE; /* default */		if((volume_info.wsize) && (volume_info.wsize <= CIFSMaxBufSize))			cifs_sb->wsize = volume_info.wsize;		else			cifs_sb->wsize = CIFSMaxBufSize; /* default */		if(cifs_sb->rsize < PAGE_CACHE_SIZE) {			cifs_sb->rsize = PAGE_CACHE_SIZE;			cERROR(1,("Attempt to set readsize for mount to less than one page (4096)"));		}		cifs_sb->mnt_uid = volume_info.linux_uid;		cifs_sb->mnt_gid = volume_info.linux_gid;		cifs_sb->mnt_file_mode = volume_info.file_mode;		cifs_sb->mnt_dir_mode = volume_info.dir_mode;		cFYI(1,("file mode: 0x%x  dir mode: 0x%x",cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode));		if(volume_info.noperm)			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;		if(volume_info.setuids)			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;		if(volume_info.server_ino)			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;		if(volume_info.remap)			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;		if(volume_info.no_xattr)			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;		if(volume_info.direct_io) {			cERROR(1,("mounting share using direct i/o"));			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;		}		tcon =		    find_unc(sin_server.sin_addr.s_addr, volume_info.UNC,			     volume_info.username);		if (tcon) {			cFYI(1, ("Found match on UNC path "));			/* we can have only one retry value for a connection			   to a share so for resources mounted more than once			   to the same server share the last value passed in 			   for the retry flag is used */			tcon->retry = volume_info.retry;		} else {			tcon = tconInfoAlloc();			if (tcon == NULL)				rc = -ENOMEM;			else {				/* check for null share name ie connect to dfs root */				/* BB check if this works for exactly length three strings */				if ((strchr(volume_info.UNC + 3, '\\') == NULL)				    && (strchr(volume_info.UNC + 3, '/') ==					NULL)) {					rc = connect_to_dfs_path(xid,								 pSesInfo,								 "",								 cifs_sb->								 local_nls);					if(volume_info.UNC)						kfree(volume_info.UNC);					FreeXid(xid);					return -ENODEV;				} else {					rc = CIFSTCon(xid, pSesInfo, 						volume_info.UNC,						tcon, cifs_sb->local_nls);					cFYI(1, ("CIFS Tcon rc = %d", rc));				}				if (!rc) {					atomic_inc(&pSesInfo->inUse);					tcon->retry = volume_info.retry;				}			}		}	}	if(pSesInfo) {		if (pSesInfo->capabilities & CAP_LARGE_FILES) {			sb->s_maxbytes = (u64) 1 << 63;		} else			sb->s_maxbytes = (u64) 1 << 31;	/* 2 GB */	}	sb->s_time_gran = 100;/* on error free sesinfo and tcon struct if needed */	if (rc) {		/* if session setup failed, use count is zero but		we still need to free cifsd thread */		if(atomic_read(&srvTcp->socketUseCount) == 0) {			spin_lock(&GlobalMid_Lock);			srvTcp->tcpStatus = CifsExiting;			spin_unlock(&GlobalMid_Lock);			if(srvTcp->tsk)				send_sig(SIGKILL,srvTcp->tsk,1);		}		 /* If find_unc succeeded then rc == 0 so we can not end */		if (tcon)  /* up accidently freeing someone elses tcon struct */			tconInfoFree(tcon);		if (existingCifsSes == NULL) {			if (pSesInfo) {				if ((pSesInfo->server) && 				    (pSesInfo->status == CifsGood)) {					int temp_rc;					temp_rc = CIFSSMBLogoff(xid, pSesInfo);					/* if the socketUseCount is now zero */					if((temp_rc == -ESHUTDOWN) &&					   (pSesInfo->server->tsk))						send_sig(SIGKILL,pSesInfo->server->tsk,1);				} else					cFYI(1, ("No session or bad tcon"));				sesInfoFree(pSesInfo);				/* pSesInfo = NULL; */			}		}	} else {		atomic_inc(&tcon->useCount);		cifs_sb->tcon = tcon;		tcon->ses = pSesInfo;		/* do not care if following two calls succeed - informational only */		CIFSSMBQFSDeviceInfo(xid, tcon, cifs_sb->local_nls);		CIFSSMBQFSAttributeInfo(xid, tcon, cifs_sb->local_nls);		if (tcon->ses->capabilities & CAP_UNIX) {			if(!CIFSSMBQFSUnixInfo(xid, tcon, cifs_sb->local_nls)) {				if(!volume_info.no_psx_acl) {					if(CIFS_UNIX_POSIX_ACL_CAP & 					   le64_to_cpu(tcon->fsUnixInfo.Capability))						cFYI(1,("server negotiated posix acl support"));						sb->s_flags |= MS_POSIXACL;				}			}		}	}	/* volume_info.password is freed above when existing session found	(in which case it is not needed anymore) but when new sesion is created	the password ptr is put in the new session structure (in which case the	password will be freed at unmount time) */	if(volume_info.UNC)		kfree(volume_info.UNC);	FreeXid(xid);	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/737b758c965a9b223ac1243ab38d9e507ac86c64/connect.c/clean/fs/cifs/connect.c