if (!uidp)
return NULL;
- lock_ObtainMutex(&uidp->mx);
- if (uidp->unp) {
- up = uidp->unp->userp;
- cm_HoldUser(up);
- }
- lock_ReleaseMutex(&uidp->mx);
+ up = smb_GetUserFromUID(uidp);
smb_ReleaseUID(uidp);
}
void OutputDebugHexDump(unsigned char * buffer, int len) {
- int i,j,k;
+ int i,j,k,pcts=0;
char buf[256];
static char tr[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
buf[j] = tr[k / 16]; buf[j+1] = tr[k % 16];
j = (i%16);
- j = j + 56 + ((j>7)?1:0);
+ j = j + 56 + ((j>7)?1:0) + pcts;
buf[j] = (k>32 && k<127)?k:'.';
+ if (k == '%') {
+ buf[++j] = k;
+ pcts++;
+ }
}
if(i) {
osi_Log0(smb_logp, osi_LogSaveString(smb_logp, buf));
#endif
}
- userp = smb_GetUser(vcp, inp);
+ uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0);
+ userp = smb_GetUserFromUID(uidp);
lock_ObtainMutex(&vcp->mx);
newTid = vcp->tidCounter++;
tidp = smb_FindTID(vcp, newTid, SMB_FLAG_CREATE);
if (!ipc) {
- uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0);
+ if (!strcmp(shareName, "*."))
+ strcpy(shareName, "all");
shareFound = smb_FindShare(vcp, uidp, shareName, &sharePath);
- if (uidp)
- smb_ReleaseUID(uidp);
if (!shareFound) {
+ smb_ReleaseUID(uidp);
smb_ReleaseTID(tidp);
return CM_ERROR_BADSHARENAME;
}
smb_SetSMBParm(outp, 2, 0);
sharePath = NULL;
}
+ smb_ReleaseUID(uidp);
lock_ObtainMutex(&tidp->mx);
tidp->userp = userp;
int outDataTotal; /* total data bytes */
int code = 0;
DWORD rv;
- DWORD allSubmount;
- USHORT nShares;
- DWORD nRegShares;
- DWORD nSharesRet;
+ DWORD allSubmount = 0;
+ USHORT nShares = 0;
+ DWORD nRegShares = 0;
+ DWORD nSharesRet = 0;
HKEY hkParam;
HKEY hkSubmount = NULL;
smb_rap_share_info_1_t * shares;
outp = smb_GetTran2ResponsePacket(vcp, p, op, totalParam, totalData);
- if(!stricmp(shareName,"all")) {
+ if(!stricmp(shareName,"all") || !strcmp(shareName,"*.")) {
rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, 0,
KEY_QUERY_VALUE, &hkParam);
if (rv == ERROR_SUCCESS) {
long returnEALength;
char *tidPathp;
cm_req_t req;
+ int created = 0;
cm_InitReq(&req);
smb_UnixTimeFromSearchTime(&setAttr.clientModTime, dosTime);
code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp,
&req);
- if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
- smb_NotifyChange(FILE_ACTION_ADDED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- dscp, lastNamep, NULL, TRUE);
- if (!excl && code == CM_ERROR_EXISTS) {
+ if (code == 0) {
+ created = 1;
+ if (dscp->flags & CM_SCACHEFLAG_ANYWATCH)
+ smb_NotifyChange(FILE_ACTION_ADDED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ dscp, lastNamep, NULL, TRUE);
+ } else if (!excl && code == CM_ERROR_EXISTS) {
/* not an exclusive create, and someone else tried
* creating it already, then we open it anyway. We
* don't bother retrying after this, since if this next
fidp->flags |= SMB_FID_OPENREAD;
if (openMode == 1 || openMode == 2)
fidp->flags |= SMB_FID_OPENWRITE;
+
+ /* remember that the file was newly created */
+ if (created)
+ fidp->flags |= SMB_FID_CREATED;
+
lock_ReleaseMutex(&fidp->mx);
smb_ReleaseFID(fidp);
switch (p->parmsp[0]) {
case 1: responseSize = sizeof(qi.u.allocInfo); break;
case 2: responseSize = sizeof(qi.u.volumeInfo); break;
+ break;
case 0x102: responseSize = sizeof(qi.u.FSvolumeInfo); break;
case 0x103: responseSize = sizeof(qi.u.FSsizeInfo); break;
case 0x104: responseSize = sizeof(qi.u.FSdeviceInfo); break;
case 0x105: responseSize = sizeof(qi.u.FSattributeInfo); break;
case 0x200: /* CIFS Unix Info */
case 0x301: /* Mac FS Info */
- default: return CM_ERROR_INVAL;
+ default:
+ return CM_ERROR_INVAL;
}
outp = smb_GetTran2ResponsePacket(vcp, p, op, 0, responseSize);
cm_scache_t *scp, *dscp;
long code = 0;
char *op;
+ char *pathp;
char *tidPathp;
char *lastComp;
cm_req_t req;
smb_SendTran2Error(vcp, p, opx, CM_ERROR_INVAL);
return 0;
}
+
+ pathp = (char *)(&p->parmsp[3]);
+ if (smb_StoreAnsiFilenames)
+ OemToChar(pathp,pathp);
osi_Log2(smb_logp, "T2 QPathInfo type 0x%x path %s", infoLevel,
- osi_LogSaveString(smb_logp, (char *)(&p->parmsp[3])));
+ osi_LogSaveString(smb_logp, pathp));
outp = smb_GetTran2ResponsePacket(vcp, p, opx, 2, nbytesRequired);
*/
if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) {
spacep = cm_GetSpace();
- smb_StripLastComponent(spacep->data, &lastComp,
- (char *)(&p->parmsp[3]));
+ smb_StripLastComponent(spacep->data, &lastComp, pathp);
#ifndef SPECIAL_FOLDERS
/* Make sure that lastComp is not NULL */
if (lastComp) {
}
/* now do namei and stat, and copy out the info */
- code = cm_NameI(cm_data.rootSCachep, (char *)(&p->parmsp[3]),
+ code = cm_NameI(cm_data.rootSCachep, pathp,
CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, tidPathp, &req, &scp);
if (code) {
op = outp->datap;
/* for info level 108, figure out short name */
if (infoLevel == 0x108) {
- code = cm_GetShortName((char *)(&p->parmsp[3]), userp, &req,
+ code = cm_GetShortName(pathp, userp, &req,
tidPathp, scp->fid.vnode, shortName,
(size_t *) &len);
if (code) {
else if (infoLevel == SMB_QUERY_FILE_STANDARD_INFO) {
*((LARGE_INTEGER *)op) = scp->length; op += 8; /* alloc size */
*((LARGE_INTEGER *)op) = scp->length; op += 8; /* EOF */
- *((u_long *)op) = scp->linkCount; op += 4;
- *op++ = 0;
+ *((u_long *)op) = scp->linkCount; op += 4; /* Link count */
+ *op++ = 0; /* Delete Pending */
+ *op++ = ((scp->fileType == CM_SCACHETYPE_DIRECTORY ||
+ scp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
+ scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0);
*op++ = 0;
- *op++ = (scp->fileType == CM_SCACHETYPE_DIRECTORY ? 1 : 0);
*op++ = 0;
}
else if (infoLevel == SMB_QUERY_FILE_EA_INFO) {
unsigned short infoLevel;
int nbytesRequired;
unsigned short fid;
+ int delonclose = 0;
cm_user_t *userp;
smb_fid_t *fidp;
cm_scache_t *scp;
goto done;
}
+ lock_ObtainMutex(&fidp->mx);
+ delonclose = fidp->flags & SMB_FID_DELONCLOSE;
scp = fidp->scp;
+ cm_HoldSCache(scp);
+ lock_ReleaseMutex(&fidp->mx);
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
else if (infoLevel == SMB_QUERY_FILE_STANDARD_INFO) {
*((LARGE_INTEGER *)op) = scp->length; op += 8; /* alloc size */
*((LARGE_INTEGER *)op) = scp->length; op += 8; /* EOF */
- *((u_long *)op) = scp->linkCount; op += 4;
- lock_ObtainMutex(&fidp->mx);
- *op++ = ((fidp->flags & SMB_FID_DELONCLOSE) ? 1 : 0);
- lock_ReleaseMutex(&fidp->mx);
- *op++ = (scp->fileType == CM_SCACHETYPE_DIRECTORY ? 1 : 0);
+ *((u_long *)op) = scp->linkCount; op += 4; /* Link count */
+ *op++ = (delonclose ? 1 : 0); /* Delete Pending */
+ *op++ = ((scp->fileType == CM_SCACHETYPE_DIRECTORY ||
+ scp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
+ scp->fileType == CM_SCACHETYPE_INVALID)? 1 : 0);
*op++ = 0;
*op++ = 0;
}
unsigned long len;
char *name;
+ lock_ReleaseMutex(&scp->mx);
+ lock_ObtainMutex(&fidp->mx);
+ lock_ObtainMutex(&scp->mx);
if (fidp->NTopen_wholepathp)
name = fidp->NTopen_wholepathp;
else
name = "\\"; /* probably can't happen */
+ lock_ReleaseMutex(&fidp->mx);
len = (unsigned long)strlen(name);
outp->totalData = (len*2) + 4; /* this is actually what we want to return */
*((u_long *)op) = len * 2; op += 4;
/* send and free the packets */
done:
lock_ReleaseMutex(&scp->mx);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
if (code == 0)
}
infoLevel = p->parmsp[1];
- osi_Log2(smb_logp,"ReceiveTran2SetFileInfo type=[%x] fid=[%x]", infoLevel, fid);
+ osi_Log2(smb_logp,"ReceiveTran2SetFileInfo type 0x%x fid %d", infoLevel, fid);
if (infoLevel > 0x104 || infoLevel < 0x101) {
osi_Log2(smb_logp, "Bad Tran2 op 0x%x infolevel 0x%x",
p->opcode, infoLevel);
smb_SendTran2Error(vcp, p, op, CM_ERROR_NOACCESS);
return 0;
}
+
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
osi_Log1(smb_logp, "T2 SFileInfo type 0x%x", infoLevel);
goto done;
}
- scp = fidp->scp;
-
if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) {
FILETIME lastMod;
unsigned int attribute;
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_GETSTATUS
| CM_SCACHESYNC_NEEDCALLBACK);
+ lock_ReleaseMutex(&scp->mx);
if (code) {
- lock_ReleaseMutex(&scp->mx);
goto done;
}
+ lock_ObtainMutex(&fidp->mx);
+ lock_ObtainMutex(&scp->mx);
+
/* prepare for setattr call */
attr.mask = 0;
lastMod.dwLowDateTime != -1 && lastMod.dwHighDateTime != -1) {
attr.mask |= CM_ATTRMASK_CLIENTMODTIME;
smb_UnixTimeFromLargeSearchTime(&attr.clientModTime, &lastMod);
- lock_ObtainMutex(&fidp->mx);
fidp->flags |= SMB_FID_MTIMESETDONE;
- lock_ReleaseMutex(&fidp->mx);
}
attribute = *((u_long *)(p->datap + 32));
}
}
lock_ReleaseMutex(&scp->mx);
+ lock_ReleaseMutex(&fidp->mx);
/* call setattr */
if (attr.mask)
}
done:
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
if (code == 0)
requestFileName[0] == '\\' &&
!_strnicmp(cm_NetbiosName,&requestFileName[1],nbnLen) &&
requestFileName[nbnLen+1] == '\\' &&
- !_strnicmp("all",&requestFileName[nbnLen+2],3))
+ (!_strnicmp("all",&requestFileName[nbnLen+2],3) ||
+ !_strnicmp("*.",&requestFileName[nbnLen+2],2)))
{
USHORT * sp;
struct smb_v2_referral * v2ref;
int parmSlot; /* which parm we're dealing with */
char *tidPathp;
cm_req_t req;
+ int created = 0;
cm_InitReq(&req);
free(hexp);
}
#endif
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
dscp = NULL;
code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
return CM_ERROR_BADSHARENAME;
}
#endif /* DFS_SUPPORT */
-
/* otherwise, scp points to the parent directory. Do a lookup,
* and truncate the file if we find it, otherwise we create the
* file.
smb_UnixTimeFromDosUTime(&setAttr.clientModTime, dosTime);
code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp,
&req);
- if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
- smb_NotifyChange(FILE_ACTION_ADDED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- dscp, lastNamep, NULL, TRUE);
- if (!excl && code == CM_ERROR_EXISTS) {
+ if (code == 0) {
+ created = 1;
+ if (dscp->flags & CM_SCACHEFLAG_ANYWATCH)
+ smb_NotifyChange(FILE_ACTION_ADDED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ dscp, lastNamep, NULL, TRUE);
+ } else if (!excl && code == CM_ERROR_EXISTS) {
/* not an exclusive create, and someone else tried
* creating it already, then we open it anyway. We
* don't bother retrying after this, since if this next
if (openMode == 1 || openMode == 2)
fidp->flags |= SMB_FID_OPENWRITE;
+ /* remember if the file was newly created */
+ if (created)
+ fidp->flags |= SMB_FID_CREATED;
+
lock_ReleaseMutex(&fidp->mx);
smb_ReleaseFID(fidp);
smb_ReleaseFID(fidp);
return CM_ERROR_BADFD;
}
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
/* set inp->fid so that later read calls in same msg can find fid */
inp->fid = fid;
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
- scp = fidp->scp;
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
doneSync:
lock_ReleaseMutex(&scp->mx);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
smb_ReleaseFID(fidp);
return CM_ERROR_BADFD;
}
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
- scp = fidp->scp;
/* otherwise, stat the file */
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
- if (code) goto done;
+ if (code)
+ goto done;
/* decode times. We need a search time, but the response to this
* call provides the date first, not the time, as returned in the
done:
lock_ReleaseMutex(&scp->mx);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
return code;
smb_ReleaseFID(fidp);
return CM_ERROR_BADFD;
}
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
- scp = fidp->scp;
/* now prepare to call cm_setattr. This message only sets various times,
* and AFS only implements mtime, and we'll set the mtime if that's
osi_Log1(smb_logp, "**smb_UnixTimeFromSearchTime failed searchTime=%ld", searchTime);
}
}
- else code = 0;
+ else
+ code = 0;
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
return code;
}
+long smb_ReceiveV3WriteX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
+{
+ osi_hyper_t offset;
+ long count, written = 0, total_written = 0;
+ unsigned short fd;
+ unsigned pid;
+ smb_fid_t *fidp;
+ long code = 0;
+ cm_user_t *userp;
+ cm_attr_t truncAttr; /* attribute struct used for truncating file */
+ char *op;
+ int inDataBlockCount;
+
+ fd = smb_GetSMBParm(inp, 2);
+ count = smb_GetSMBParm(inp, 10);
+
+ offset.HighPart = 0;
+ offset.LowPart = smb_GetSMBParm(inp, 3) | (smb_GetSMBParm(inp, 4) << 16);
+
+ if (*inp->wctp == 14) {
+ /* we have a request with 64-bit file offsets */
+#ifdef AFS_LARGEFILES
+ offset.HighPart = smb_GetSMBParm(inp, 12) | (smb_GetSMBParm(inp, 13) << 16);
+#else
+ if ((smb_GetSMBParm(inp, 12) | (smb_GetSMBParm(inp, 13) << 16)) != 0) {
+ /* uh oh */
+ osi_Log0(smb_logp, "smb_ReceiveV3WriteX offset requires largefile support");
+ /* we shouldn't have received this op if we didn't specify
+ largefile support */
+ return CM_ERROR_BADOP;
+ }
+#endif
+ }
+
+ op = inp->data + smb_GetSMBParm(inp, 11);
+ inDataBlockCount = count;
+
+ osi_Log4(smb_logp, "smb_ReceiveV3WriteX fid %d, off 0x%x:%08x, size 0x%x",
+ fd, offset.HighPart, offset.LowPart, count);
+
+ fd = smb_ChainFID(fd, inp);
+ fidp = smb_FindFID(vcp, fd, 0);
+ if (!fidp)
+ return CM_ERROR_BADFD;
+
+ lock_ObtainMutex(&fidp->mx);
+ if (fidp->flags & SMB_FID_IOCTL) {
+ lock_ReleaseMutex(&fidp->mx);
+ code = smb_IoctlV3Write(fidp, vcp, inp, outp);
+ smb_ReleaseFID(fidp);
+ return code;
+ }
+ lock_ReleaseMutex(&fidp->mx);
+ userp = smb_GetUserFromVCP(vcp, inp);
+
+ /* special case: 0 bytes transferred means there is no data
+ transferred. A slight departure from SMB_COM_WRITE where this
+ means that we are supposed to truncate the file at this
+ position. */
+
+ {
+ cm_key_t key;
+ LARGE_INTEGER LOffset;
+ LARGE_INTEGER LLength;
+
+ pid = ((smb_t *) inp)->pid;
+ key = cm_GenerateKey(vcp->vcID, pid, fd);
+
+ LOffset.HighPart = offset.HighPart;
+ LOffset.LowPart = offset.LowPart;
+ LLength.HighPart = 0;
+ LLength.LowPart = count;
+
+ lock_ObtainMutex(&fidp->scp->mx);
+ code = cm_LockCheckWrite(fidp->scp, LOffset, LLength, key);
+ lock_ReleaseMutex(&fidp->scp->mx);
+
+ if (code)
+ goto done;
+ }
+
+ /*
+ * Work around bug in NT client
+ *
+ * When copying a file, the NT client should first copy the data,
+ * then copy the last write time. But sometimes the NT client does
+ * these in the wrong order, so the data copies would inadvertently
+ * cause the last write time to be overwritten. We try to detect this,
+ * and don't set client mod time if we think that would go against the
+ * intention.
+ */
+ lock_ObtainMutex(&fidp->mx);
+ if ((fidp->flags & SMB_FID_MTIMESETDONE) != SMB_FID_MTIMESETDONE) {
+ fidp->scp->mask |= CM_SCACHEMASK_CLIENTMODTIME;
+ fidp->scp->clientModTime = time(NULL);
+ }
+ lock_ReleaseMutex(&fidp->mx);
+
+ code = 0;
+ while ( code == 0 && count > 0 ) {
+#ifndef DJGPP
+ code = smb_WriteData(fidp, &offset, count, op, userp, &written);
+#else /* DJGPP */
+ code = smb_WriteData(fidp, &offset, count, op, userp, &written, FALSE);
+#endif /* !DJGPP */
+ if (code == 0 && written == 0)
+ code = CM_ERROR_PARTIALWRITE;
+
+ offset = LargeIntegerAdd(offset,
+ ConvertLongToLargeInteger(written));
+ count -= written;
+ total_written += written;
+ written = 0;
+ }
+
+ done_writing:
+
+ /* slots 0 and 1 are reserved for request chaining and will be
+ filled in when we return. */
+ smb_SetSMBParm(outp, 2, total_written);
+ smb_SetSMBParm(outp, 3, 0); /* reserved */
+ smb_SetSMBParm(outp, 4, 0); /* reserved */
+ smb_SetSMBParm(outp, 5, 0); /* reserved */
+ smb_SetSMBDataLength(outp, 0);
+
+ done:
+ smb_ReleaseFID(fidp);
+ cm_ReleaseUser(userp);
+
+ return code;
+}
long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
fd = smb_GetSMBParm(inp, 2);
count = smb_GetSMBParm(inp, 5);
- offset.HighPart = 0; /* too bad */
offset.LowPart = smb_GetSMBParm(inp, 3) | (smb_GetSMBParm(inp, 4) << 16);
- osi_Log3(smb_logp, "smb_ReceiveV3Read fd %d, off 0x%x, size 0x%x",
- fd, offset.LowPart, count);
-
+ if (*inp->wctp == 12) {
+ /* a request with 64-bit offsets */
+#ifdef AFS_LARGEFILES
+ offset.HighPart = smb_GetSMBParm(inp, 10) | (smb_GetSMBParm(inp, 11) << 16);
+
+ if (LargeIntegerLessThanZero(offset)) {
+ osi_Log2(smb_logp, "smb_ReceiveV3Read offset too large (0x%x:%08x)",
+ offset.HighPart, offset.LowPart);
+ return CM_ERROR_BADSMB;
+ }
+#else
+ if ((smb_GetSMBParm(inp, 10) | (smb_GetSMBParm(inp, 11) << 16)) != 0) {
+ osi_Log0(smb_logp, "smb_ReceiveV3Read offset is 64-bit. Dropping");
+ return CM_ERROR_BADSMB;
+ } else {
+ offset.HighPart = 0;
+ }
+#endif
+ } else {
+ offset.HighPart = 0;
+ }
+
+ osi_Log4(smb_logp, "smb_ReceiveV3Read fd %d, off 0x%x:%08x, size 0x%x",
+ fd, offset.HighPart, offset.LowPart, count);
+
fd = smb_ChainFID(fd, inp);
fidp = smb_FindFID(vcp, fd, 0);
if (!fidp) {
}
lock_ReleaseMutex(&fidp->mx);
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
/* 0 and 1 are reserved for request chaining, were setup by our caller,
* and will be further filled in after we return.
char *tidPathp;
BOOL foundscp;
cm_req_t req;
+ int created = 0;
cm_InitReq(&req);
}
#endif
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
if (!userp) {
osi_Log1(smb_logp, "NTCreateX Invalid user [%d]", ((smb_t *) inp)->uid);
free(realPathp);
if (shareAccess & FILE_SHARE_WRITE)
fidflags |= SMB_FID_SHARE_WRITE;
+ osi_Log1(smb_logp, "NTCreateX fidflags 0x%x", fidflags);
code = 0;
/* For an exclusive create, we want to do a case sensitive match for the last component. */
setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
setAttr.clientModTime = time(NULL);
code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp, &req);
- if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
- smb_NotifyChange(FILE_ACTION_ADDED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- dscp, lastNamep, NULL, TRUE);
- if (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE) {
+ if (code == 0) {
+ created = 1;
+ if (dscp->flags & CM_SCACHEFLAG_ANYWATCH)
+ smb_NotifyChange(FILE_ACTION_ADDED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ dscp, lastNamep, NULL, TRUE);
+ } else if (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE) {
/* Not an exclusive create, and someone else tried
* creating it already, then we open it anyway. We
* don't bother retrying after this, since if this next
fidp->flags = fidflags;
+ /* remember if the file was newly created */
+ if (created)
+ fidp->flags |= SMB_FID_CREATED;
+
/* save parent dir and pathname for delete or change notification */
if (fidflags & (SMB_FID_OPENDELETE | SMB_FID_OPENWRITE)) {
fidp->flags |= SMB_FID_NTOPEN;
smb_SetSMBParm(outp, parmSlot, 0); parmSlot++; /* filetype */
smb_SetSMBParm(outp, parmSlot, 0); parmSlot++; /* dev state */
smb_SetSMBParmByte(outp, parmSlot,
- scp->fileType == CM_SCACHETYPE_DIRECTORY); /* is a dir? */
+ (scp->fileType == CM_SCACHETYPE_DIRECTORY ||
+ scp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
+ scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0); /* is a dir? */
lock_ReleaseMutex(&scp->mx);
smb_SetSMBDataLength(outp, 0);
ULONG *lparmp;
char *outData;
cm_req_t req;
+ int created = 0;
cm_InitReq(&req);
}
#endif
- userp = smb_GetUser(vcp, inp);
+ userp = smb_GetUserFromVCP(vcp, inp);
if (!userp) {
osi_Log1(smb_logp, "NTTranCreate invalid user [%d]", ((smb_t *) inp)->uid);
free(realPathp);
setAttr.clientModTime = time(NULL);
code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp,
&req);
- if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
- smb_NotifyChange(FILE_ACTION_ADDED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- dscp, lastNamep, NULL, TRUE);
- if (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE) {
+ if (code == 0) {
+ created = 1;
+ if (dscp->flags & CM_SCACHEFLAG_ANYWATCH)
+ smb_NotifyChange(FILE_ACTION_ADDED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ dscp, lastNamep, NULL, TRUE);
+ } else if (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE) {
/* Not an exclusive create, and someone else tried
* creating it already, then we open it anyway. We
* don't bother retrying after this, since if this next
fidp->flags = fidflags;
+ /* remember if the file was newly created */
+ if (created)
+ fidp->flags |= SMB_FID_CREATED;
+
/* save parent dir and pathname for deletion or change notification */
if (fidflags & (SMB_FID_OPENDELETE | SMB_FID_OPENWRITE)) {
fidp->flags |= SMB_FID_NTOPEN;
*((LARGE_INTEGER *)outData) = scp->length; outData += 8; /* EOF */
*((USHORT *)outData) = 0; outData += 2; /* filetype */
*((USHORT *)outData) = 0; outData += 2; /* dev state */
- *((USHORT *)outData) = (scp->fileType == CM_SCACHETYPE_DIRECTORY);
+ *((USHORT *)outData) = ((scp->fileType == CM_SCACHETYPE_DIRECTORY ||
+ scp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
+ scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0);
outData += 2; /* is a dir? */
lock_ReleaseMutex(&scp->mx);
} else {
*((LARGE_INTEGER *)outData) = scp->length; outData += 8; /* EOF */
*((USHORT *)outData) = 0; outData += 2; /* filetype */
*((USHORT *)outData) = 0; outData += 2; /* dev state */
- *((USHORT *)outData) = (scp->fileType == CM_SCACHETYPE_DIRECTORY);
+ *((USHORT *)outData) = ((scp->fileType == CM_SCACHETYPE_DIRECTORY ||
+ scp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
+ scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0);
outData += 1; /* is a dir? */
memset(outData,0,24); outData += 24; /* Volume ID and file ID */
*((ULONG *)outData) = 0x001f01ffL; outData += 4; /* Maxmimal access rights */