if (dep->flag != CM_DIR_FFIRST ||
strlen(dep->name) > 256) {
code = CM_ERROR_INVAL;
+ osi_Log2(afsd_logp,
+ "cm_ApplyDir invalid directory entry for scp %p bufp %p",
+ scp, bufferp);
+ osi_Log4(afsd_logp,"... cell %u vol %u vnode %u uniq %u",
+ scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique);
+ bufferp->dataVersion = CM_BUF_VERSION_BAD;
break;
}
long cm_ReadMountPoint(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
{
long code;
- cm_buf_t *bufp = NULL;
- osi_hyper_t thyper;
- int tlen;
if (scp->mountPointStringp[0])
return 0;
} else
#endif /* AFS_FREELANCE_CLIENT */
{
- /* otherwise, we have to read it in */
- lock_ReleaseWrite(&scp->rw);
+ char temp[MOUNTPOINTLEN];
+ osi_hyper_t thyper;
+ /* otherwise, we have to read it in */
thyper.LowPart = thyper.HighPart = 0;
- code = buf_Get(scp, &thyper, reqp, &bufp);
-
- lock_ObtainWrite(&scp->rw);
+ code = cm_GetData(scp, &thyper, temp, MOUNTPOINTLEN, userp, reqp);
if (code)
return code;
- while (1) {
- code = cm_SyncOp(scp, bufp, userp, reqp, 0,
- CM_SCACHESYNC_READ | CM_SCACHESYNC_NEEDCALLBACK);
- if (code)
- goto done;
-
- cm_SyncOpDone(scp, bufp, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_READ);
-
- if (cm_HaveBuffer(scp, bufp, 0))
- break;
-
- /* otherwise load buffer */
- code = cm_GetBuffer(scp, bufp, NULL, userp, reqp);
- if (code)
- goto done;
- }
- /* locked, has callback, has valid data in buffer */
- if ((tlen = scp->length.LowPart) > MOUNTPOINTLEN - 1)
- return CM_ERROR_TOOBIG;
- if (tlen <= 0) {
- code = CM_ERROR_INVAL;
- goto done;
- }
-
- /* someone else did the work while we were out */
- if (scp->mountPointStringp[0]) {
- code = 0;
- goto done;
- }
-
- /* otherwise, copy out the link */
- memcpy(scp->mountPointStringp, bufp->datap, tlen);
-
- /* now make it null-terminated. Note that the original contents of a
- * link that is a mount point is "#volname." where "." is there just to
- * be turned into a null. That is, we can trash the last char of the
- * link without damaging the vol name. This is a stupid convention,
- * but that's the protocol.
+ /*
+ * scp->length is the actual length of the mount point string.
+ * It is current because cm_GetData merged the most up to date
+ * status info into scp and has not dropped the rwlock since.
*/
- scp->mountPointStringp[tlen-1] = 0;
- code = 0;
+ if (scp->length.LowPart > MOUNTPOINTLEN - 1)
+ return CM_ERROR_TOOBIG;
+ if (scp->length.LowPart == 0)
+ return CM_ERROR_INVAL;
- done:
- if (bufp)
- buf_Release(bufp);
+ /* convert the terminating dot to a NUL */
+ temp[thyper.LowPart - 1] = 0;
+ memcpy(scp->mountPointStringp, temp, thyper.LowPart);
}
+
return code;
}
if (cnamep[0] == '.') {
if (cm_GetCell_Gen(&fnamep[1], &fullname[1], CM_FLAG_CREATE)) {
found = 1;
- code = cm_FreelanceAddMount(fullname, &fullname[1], "root.cell.", 1, &rock.fid);
+ code = cm_FreelanceAddMount(fullname, &fullname[1], "root.cell", 1, &rock.fid);
if ( cm_FsStrCmpI(&fnamep[1], &fullname[1])) {
/*
* Do not permit symlinks that are one of:
} else {
if (cm_GetCell_Gen(fnamep, fullname, CM_FLAG_CREATE)) {
found = 1;
- code = cm_FreelanceAddMount(fullname, fullname, "root.cell.", 0, &rock.fid);
+ code = cm_FreelanceAddMount(fullname, fullname, "root.cell", 0, &rock.fid);
if ( cm_FsStrCmpI(fnamep, fullname)) {
/*
* Do not permit symlinks that are one of:
/* tscp is now held */
lock_ObtainWrite(&tscp->rw);
- code = cm_SyncOp(tscp, NULL, userp, reqp, 0,
- CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_NEEDCALLBACK);
- if (code) {
- lock_ReleaseWrite(&tscp->rw);
- cm_ReleaseSCache(tscp);
- goto done;
+
+ /*
+ * Do not get status if we do not already have a callback.
+ * The process of reading the mount point string will obtain status information
+ * in a single RPC. No reason to add a second round trip.
+ *
+ * If we do have a callback, use cm_SyncOp to get status in case the
+ * current cm_user_t is not the same as the one that obtained the
+ * mount point string contents.
+ */
+ if (cm_HaveCallback(tscp)) {
+ code = cm_SyncOp(tscp, NULL, userp, reqp, 0,
+ CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_NEEDCALLBACK);
+ if (code) {
+ lock_ReleaseWrite(&tscp->rw);
+ cm_ReleaseSCache(tscp);
+ goto done;
+ }
+ cm_SyncOpDone(tscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
}
- cm_SyncOpDone(tscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
/* tscp is now locked */
if (!(flags & CM_FLAG_NOMOUNTCHASE)
*/
long cm_HandleLink(cm_scache_t *linkScp, cm_user_t *userp, cm_req_t *reqp)
{
- long code;
- cm_buf_t *bufp;
- long temp;
- osi_hyper_t thyper;
+ long code = 0;
lock_AssertWrite(&linkScp->rw);
if (!linkScp->mountPointStringp[0]) {
} else
#endif /* AFS_FREELANCE_CLIENT */
{
- /* read the link data from the file server*/
- lock_ReleaseWrite(&linkScp->rw);
+ char temp[MOUNTPOINTLEN];
+ osi_hyper_t thyper;
+
+ /* read the link data from the file server */
thyper.LowPart = thyper.HighPart = 0;
- code = buf_Get(linkScp, &thyper, reqp, &bufp);
- lock_ObtainWrite(&linkScp->rw);
- if (code)
+ code = cm_GetData(linkScp, &thyper, temp, MOUNTPOINTLEN, userp, reqp);
+ if (code)
return code;
- while (1) {
- code = cm_SyncOp(linkScp, bufp, userp, reqp, 0,
- CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_READ);
- if (code) {
- buf_Release(bufp);
- return code;
- }
- cm_SyncOpDone(linkScp, bufp, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_READ);
-
- if (cm_HaveBuffer(linkScp, bufp, 0))
- break;
- code = cm_GetBuffer(linkScp, bufp, NULL, userp, reqp);
- if (code) {
- buf_Release(bufp);
- return code;
- }
- } /* while loop to get the data */
-
- /* now if we still have no link read in,
- * copy the data from the buffer */
- if ((temp = linkScp->length.LowPart) >= MOUNTPOINTLEN) {
- buf_Release(bufp);
+ /*
+ * linkScp->length is the actual length of the symlink target string.
+ * It is current because cm_GetData merged the most up to date
+ * status info into scp and has not dropped the rwlock since.
+ */
+ if (linkScp->length.LowPart > MOUNTPOINTLEN - 1)
return CM_ERROR_TOOBIG;
- }
+ if (linkScp->length.LowPart == 0)
+ return CM_ERROR_INVAL;
- /* otherwise, it fits; make sure it is still null (could have
- * lost race with someone else referencing this link above),
- * and if so, copy in the data.
- */
- if (!linkScp->mountPointStringp[0]) {
- strncpy(linkScp->mountPointStringp, bufp->datap, temp);
- linkScp->mountPointStringp[temp] = 0; /* null terminate */
- }
- buf_Release(bufp);
+ /* convert the terminating dot to a NUL */
+ temp[thyper.LowPart - 1] = 0;
+ memcpy(linkScp->mountPointStringp, temp, thyper.LowPart);
}
if ( !strnicmp(linkScp->mountPointStringp, "msdfs:", strlen("msdfs:")) )
linkScp->fileType = CM_SCACHETYPE_DFSLINK;
- } /* don't have sym link contents cached */
+ } /* don't have symlink contents cached */
- return 0;
+ return code;
}
/* called with a held vnode and a path suffix, with the held vnode being a
*newSpaceBufferp = NULL;
lock_ObtainWrite(&linkScp->rw);
+ /*
+ * Do not get status if we do not already have a callback.
+ * The process of reading the symlink string will obtain status information
+ * in a single RPC. No reason to add a second round trip.
+ *
+ * If we do have a callback, use cm_SyncOp to get status in case the
+ * current cm_user_t is not the same as the one that obtained the
+ * symlink string contents.
+ */
+ if (cm_HaveCallback(linkScp)) {
+ code = cm_SyncOp(linkScp, NULL, userp, reqp, 0,
+ CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_NEEDCALLBACK);
+ if (code) {
+ lock_ReleaseWrite(&linkScp->rw);
+ cm_ReleaseSCache(linkScp);
+ goto done;
+ }
+ cm_SyncOpDone(linkScp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ }
code = cm_HandleLink(linkScp, userp, reqp);
if (code)
goto done;