#include "afsd.h"
#include "smb.h"
+#include <winnt/osi_malloc.h>
/* These characters are illegal in Windows filenames */
static char *illegalChars = "\\/:*?\"<>|";
smb_renameRock_t rock;
cm_scache_t *oldDscp;
cm_scache_t *newDscp;
+ cm_scache_t *tmpscp;
char *oldLastNamep;
char *newLastNamep;
osi_hyper_t thyper;
*/
thyper.LowPart = 0; /* search dir from here */
thyper.HighPart = 0;
+ /* search for file to already exhist, if so return error*/
+
+ code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp);
+ if((code != CM_ERROR_NOSUCHFILE) && (code != CM_ERROR_NOSUCHPATH) && (code != CM_ERROR_NOSUCHVOLUME) ) {
+ cm_ReleaseSCache(tmpscp);
+ return CM_ERROR_EXISTS; /* file exist, do not rename, also
+ fixes move*/
+ }
code = cm_ApplyDir(oldDscp, smb_RenameProc, &rock, &thyper, userp, &req, NULL);
if (code == CM_ERROR_STOPNOW)
long len;
long i, j;
smb_vc_t *vcp;
- int flags = 0;
+ int flags;
char rname[NCBNAMSZ+1];
char cname[MAX_COMPUTERNAME_LENGTH+1];
int cnamelen = MAX_COMPUTERNAME_LENGTH+1;
while (1) {
memset(ncbp, 0, sizeof(NCB));
+ flags = 0;
#ifdef DJGPP
/* terminate if shutdown flag is set */
if (smbShutdownFlag == 1)
int len;
int lana_found = 0;
+ /*******************************************************************/
+ /* ms loopback adapter scan */
+ /*******************************************************************/
+ struct
+ {
+ ADAPTER_STATUS status;
+ NAME_BUFFER NameBuff [30];
+ } Adapter;
+
+ int j;
+ BOOL wla_found;
+
+ /* AFAIK, this is the default for the ms loopback adapter.*/
+ unsigned char kWLA_MAC[6] = { 0x02, 0x00, 0x4c, 0x4f, 0x4f, 0x50 };
+ /*******************************************************************/
+
/* setup the NCB system */
ncbp = GetNCB();
#ifdef DJGPP
sprintf(s, "Netbios NCBRESET lana %d error code %d", lana_list.lana[i], code);
afsi_log(s);
lana_list.lana[i] = 255; /* invalid lana */
- }
- else {
+ } else {
sprintf(s, "Netbios NCBRESET lana %d succeeded", lana_list.lana[i]);
afsi_log(s);
- }
+ /* check to see if this is the "Microsoft Loopback Adapter" */
+ memset( ncbp, 0, sizeof (*ncbp) );
+ ncbp->ncb_command = NCBASTAT;
+ ncbp->ncb_lana_num = lana_list.lana[i];
+ strcpy( ncbp->ncb_callname, "* " );
+ ncbp->ncb_buffer = (char *) &Adapter;
+ ncbp->ncb_length = sizeof(Adapter);
+ code = Netbios( ncbp );
+
+ if ( code == 0 ) {
+ wla_found = TRUE;
+ for (j=0; wla_found && (j<6); j++)
+ wla_found = ( Adapter.status.adapter_address[j] == kWLA_MAC[j] );
+
+ if ( wla_found ) {
+ sprintf(s, "Windows Loopback Adapter detected lana %d", lana_list.lana[i]);
+ afsi_log(s);
+
+ /* select this lana; no need to continue */
+ lana_list.length = 1;
+ lana_list.lana[0] = lana_list.lana[i];
+ break;
+ }
+ }
+ }
}
#else
/* for DJGPP, there is no NCBENUM and NCBRESET is a real reset. so