Changeset 131
- Timestamp:
- Apr 24, 2008, 7:31:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/ndpsmb/ndpsmb.c
r127 r131 184 184 return dst; 185 185 } 186 187 // ------------------------------------------------------------- 186 188 187 189 /* uppercased type of resource */ … … 914 916 } 915 917 918 // ------------------------------------------------------------- 919 920 /* check if the requested resource is available */ 921 static int checkMountResource( Resource* pRes) 922 { 923 int rc; 924 unsigned long action; 925 smb_request req = {0}; 926 smb_response resp = {0}; 927 Connection Conn = {0}; 928 929 debug_printf("checkMountResource in tid#%d\n", _gettid()); 930 931 // open the pipe 932 Conn.pRes = pRes; 933 Conn.file.fd = -1; 934 debug_printf("checkMountResource open pipe\n"); 935 rc = openpipe(pRes, &Conn.pipe); 936 if (rc) 937 { 938 debug_printf("checkMountResource open pipe failed rc=%d\n", rc); 939 return rc; 940 } 941 942 // init, get client pid 943 debug_printf("checkMountResource send INIT for '%s'\n", pRes->srv.share_name); 944 req.request = SMBREQ_INIT; 945 req.param = (char *)0xFFFFFFFF; 946 rc = _DosTransactNPipe(&Conn, &req, sizeof(req), &resp, sizeof(resp), &action); 947 if (rc || action < sizeof(resp) || resp.rc) 948 { 949 debug_printf("checkMountResource INIT failed rc=%d\n", rc); 950 // close pipe 951 DosClose( Conn.pipe); 952 return rc; 953 } 954 Conn.clientpid = resp.value & 0xFFFF; 955 956 // allocate shared memory 957 rc = DosAllocSharedMem((PPVOID)&Conn.mem, NULL, pRes->memlen, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE | pRes->objany); 958 if (rc) 959 { 960 debug_printf("checkMountResource DosAllocSharedMem failed rc=%d\n", rc); 961 // close pipe 962 DosClose( Conn.pipe); 963 return rc; 964 } 965 rc = DosGiveSharedMem( Conn.mem, Conn.clientpid, PAG_READ | PAG_WRITE); 966 if (!rc) 967 { 968 // open connection with samba server, just to check share type 969 debug_printf("checkMountResource send CONNECT\n"); 970 MemCpy( Conn.mem, &pRes->srv, sizeof(pRes->srv)); 971 req.request = SMBREQ_CONNECT; 972 req.param = Conn.mem; 973 req.paramlen = sizeof( Conn.srv); 974 req.length = req.paramlen; 975 rc = _DosTransactNPipe( &Conn, &req, sizeof(req), &resp, sizeof(resp), &action); 976 if (rc || action < sizeof(resp) || resp.rc) 977 { 978 debug_printf("checkMountResource SMBREQ_CONNECT failed rc=%d, resp.rc=%d\n", rc, resp.rc); 979 rc = (rc == NO_ERROR ? resp.rc : rc); 980 } 981 // no more data, close connection 982 req.request = SMBREQ_DISCONNECT; 983 req.param = Conn.mem; 984 req.length = 0; 985 req.paramlen = 0; 986 _DosTransactNPipe( &Conn, &req, sizeof(req), &resp, sizeof(resp), &action); 987 } 988 989 // free memory 990 DosFreeMem( Conn.mem); 991 // close pipe 992 DosClose( Conn.pipe); 993 994 return rc; 995 } 916 996 917 997 int APIENTRY NdpMountResource (HRESOURCE *presource, int type, NDPROPERTYHANDLE properties) … … 920 1000 unsigned long objany = OBJ_ANY; 921 1001 Resource *pRes = NULL; 922 /* since we support only 1 type of resources we do not need */ 1002 1003 log("NdpMountResource in\n"); 1004 1005 /* since samba plugin support only 1 type of resources we do not need */ 923 1006 /* to check what the found type really is */ 924 1007 rc = DosAllocMem((void **)&pRes, sizeof(Resource), PAG_COMMIT | PAG_READ | PAG_WRITE | objany); … … 937 1020 pRes->properties = properties; 938 1021 pRes->objany = objany; 1022 // parse init string 939 1023 rc = initResource (pRes); 940 if (rc == NO_ERROR) 941 { 1024 // try to connect to resource (check type) only if thread!=1, so ndctl startup 1025 // is not slowed down by network connections. 1026 // ndctl does mounting on main thread (#1) 1027 // nd/ndpm do not use main thread 1028 if (!rc && _gettid()!=1) 1029 rc = checkMountResource( pRes); 1030 if (!rc) 1031 { 1032 // store resource data 942 1033 *presource = (HRESOURCE)pRes; 943 1034 } … … 947 1038 } 948 1039 } 949 log("NdpMountResource %d\n", rc); 950 return rc; 951 } 1040 log("NdpMountResource rc=%d\n", rc); 1041 return rc; 1042 } 1043 1044 // ------------------------------------------------------------- 952 1045 953 1046 int APIENTRY NdpCreateConnection (HRESOURCE resource, HCONNECTION *pconn) … … 1043 1136 } 1044 1137 1138 // ------------------------------------------------------------- 1045 1139 1046 1140 int APIENTRY NdpFreeConnection (HCONNECTION conn)
Note:
See TracChangeset
for help on using the changeset viewer.