#include "cm_rpc.h"
+#ifdef _DEBUG
+#include <crtdbg.h>
+#endif
+
/* Copied from afs_tokens.h */
#define PIOCTL_LOGON 0x1
#define MAX_PATH 260
osi_mutex_t cm_Afsdsbmt_Lock;
-#ifdef AFS_FREELANCE_CLIENT
-extern osi_mutex_t cm_Freelance_Lock;
-#endif
extern afs_int32 cryptall;
*/
void TranslateExtendedChars(char *str)
{
- char *p;
-
- if (!str || !*str)
- return;
+#ifdef DJGPP
+ char *p;
+#endif
+
+ if (!str || !*str)
+ return;
#ifndef DJGPP
- CharToOem(str, str);
+ CharToOem(str, str);
#else
- p = str;
- while (*p) *p++ &= 0x7f; /* turn off high bit; probably not right */
+ p = str;
+ while (*p) *p++ &= 0x7f; /* turn off high bit; probably not right */
#endif
}
vlonly = spin->flags;
if ( vlonly )
type = CM_SERVER_VLDB;
- else type = CM_SERVER_FILE;
+ else
+ type = CM_SERVER_FILE;
for ( i=0; i < noServers; i++)
{
tmp.sin_family = AF_INET;
tsp = cm_FindServer(&tmp, type);
- if ( tsp ) /* an existing server */
+ if ( tsp ) /* an existing server - ref count increased */
{
tsp->ipRank = rank; /* no need to protect by mutex*/
/* set preferences for an existing vlserver */
cm_ChangeRankCellVLServer(tsp);
}
+ cm_PutServer(tsp); /* decrease refcount */
}
- else /* add a new server without a cell*/
+ else /* add a new server without a cell */
{
- tsp = cm_NewServer(&tmp, type, NULL);
+ tsp = cm_NewServer(&tmp, type, NULL); /* refcount = 1 */
tsp->ipRank = rank;
}
- cm_PutServer(tsp);
}
return 0;
}
long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
{
char leaf[256];
- long code;
- cm_scache_t *dscp;
- cm_attr_t tattr;
- char *cp;
+ long code;
+ cm_scache_t *dscp;
+ cm_attr_t tattr;
+ char *cp;
cm_req_t req;
- char mpInfo[256];
- char fullCell[256];
+ char mpInfo[256];
+ char fullCell[256];
char volume[256];
char cell[256];
int ttl;
cm_InitReq(&req);
- code = cm_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
- if (code) return code;
+ code = cm_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
+ if (code) return code;
- /* Translate chars for the mount point name */
- TranslateExtendedChars(leaf);
+ /* Translate chars for the mount point name */
+ TranslateExtendedChars(leaf);
- /*
- * The fs command allows the user to specify partial cell names on NT. These must
- * be expanded to the full cell name for mount points so that the mount points will
- * work on UNIX clients.
- */
+ /*
+ * The fs command allows the user to specify partial cell names on NT. These must
+ * be expanded to the full cell name for mount points so that the mount points will
+ * work on UNIX clients.
+ */
/* Extract the possibly partial cell name */
strcpy(cell, ioctlp->inDatap + 1); /* Skip the mp type character */
- if (cp = strchr(cell, ':')) {
+ if (cp = strchr(cell, ':')) {
/* Extract the volume name */
- *cp = 0;
+ *cp = 0;
strcpy(volume, cp + 1);
- /* Get the full name for this cell */
- code = cm_SearchCellFile(cell, fullCell, 0, 0);
+ /* Get the full name for this cell */
+ code = cm_SearchCellFile(cell, fullCell, 0, 0);
#ifdef AFS_AFSDB_ENV
if (code && cm_dnsEnabled)
- code = cm_SearchCellByDNS(cell, fullCell, &ttl, 0, 0);
+ code = cm_SearchCellByDNS(cell, fullCell, &ttl, 0, 0);
#endif
- if (code)
+ if (code)
return CM_ERROR_NOSUCHCELL;
- sprintf(mpInfo, "%c%s:%s", *ioctlp->inDatap, fullCell, volume);
+ sprintf(mpInfo, "%c%s:%s", *ioctlp->inDatap, fullCell, volume);
} else {
- /* No cell name specified */
- strcpy(mpInfo, ioctlp->inDatap);
- }
+ /* No cell name specified */
+ strcpy(mpInfo, ioctlp->inDatap);
+ }
#ifdef AFS_FREELANCE_CLIENT
if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
}
#endif
/* create the symlink with mode 644. The lack of X bits tells
- * us that it is a mount point.
- */
+ * us that it is a mount point.
+ */
tattr.mask = CM_ATTRMASK_UNIXMODEBITS | CM_ATTRMASK_CLIENTMODTIME;
- tattr.unixModeBits = 0644;
+ tattr.unixModeBits = 0644;
tattr.clientModTime = time(NULL);
- code = cm_SymLink(dscp, leaf, mpInfo, 0, &tattr, userp, &req);
+ code = cm_SymLink(dscp, leaf, mpInfo, 0, &tattr, userp, &req);
if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
smb_NotifyChange(FILE_ACTION_ADDED,
- FILE_NOTIFY_CHANGE_DIR_NAME,
- dscp, leaf, NULL, TRUE);
-
- cm_ReleaseSCache(dscp);
+ FILE_NOTIFY_CHANGE_DIR_NAME,
+ dscp, leaf, NULL, TRUE);
- return code;
+ cm_ReleaseSCache(dscp);
+ return code;
}
long cm_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
cm_scache_t *dscp;
cm_scache_t *scp;
char *cp;
- cm_space_t *spacep;
- cm_scache_t *newRootScp;
cm_req_t req;
cm_InitReq(&req);