Arla 0.8 and .@sys
David Morrison
dave at bnl.gov
Tue Jul 21 18:05:27 CEST 1998
Dear arla-ites,
Here's a patch to inter.c to do a more complete job of replacing all occurrences
of `@sys' in filenames with sysname. It seems to do the right thing, but it
doesn't seem to completely solve the problem I am having. If you apply this
patch and run `arlad --test', everything seems just fine. But, when I run arlad
as a daemon and try and navigate the filesystem just using `ls' and `cd' it
doesn't work properly - if I `cd' into a directory named `. at sys' I end up right
back where I started! Anyway, hope this helps a bit. Feedback welcome.
Dave
diff -rc arla-0.8-vanilla/arlad/arla_local.h arla-0.8/arlad/arla_local.h
*** arla-0.8-vanilla/arlad/arla_local.h Sun Jul 19 20:38:32 1998
--- arla-0.8/arlad/arla_local.h Mon Jul 20 17:53:11 1998
***************
*** 135,140 ****
--- 135,141 ----
#define SYSNAMEMAXLEN 2048
extern char arlasysname[SYSNAMEMAXLEN];
+ extern char arlatmpname[SYSNAMEMAXLEN];
enum connected_mode { CONNECTED = 0,
FETCH_ONLY = 1,
diff -rc arla-0.8-vanilla/arlad/fcache.c arla-0.8/arlad/fcache.c
*** arla-0.8-vanilla/arlad/fcache.c Sun Jul 19 20:38:39 1998
--- arla-0.8/arlad/fcache.c Mon Jul 20 17:52:57 1998
***************
*** 151,156 ****
--- 151,157 ----
*/
char arlasysname[SYSNAMEMAXLEN];
+ char arlatmpname[SYSNAMEMAXLEN];
/*
* Create `n' new entries
diff -rc arla-0.8-vanilla/arlad/inter.c arla-0.8/arlad/inter.c
*** arla-0.8-vanilla/arlad/inter.c Sun Jul 19 20:38:42 1998
--- arla-0.8/arlad/inter.c Tue Jul 21 11:02:09 1998
***************
*** 437,442 ****
--- 437,477 ----
return ret;
}
+ /**
+ * Replace all occurrences of `oldString' with `newString'.
+ */
+
+ static char *
+ cm_replace (char* out, const char* in,
+ char* oldString, char* newString)
+ {
+ char *s;
+ const char *inPtr;
+ char *outPtr;
+ size_t oLen, nLen;
+
+ /* Initialize the indexing pointers */
+ inPtr = in;
+ outPtr = out;
+
+ oLen = strlen(oldString);
+ nLen = strlen(newString);
+
+ while ((s = strstr(inPtr, oldString)))
+ {
+ strncpy(outPtr, inPtr, (size_t)(s - inPtr));
+ outPtr += s - inPtr;
+ strncpy(outPtr, newString, nLen + 1);
+ outPtr += nLen + 1;
+ inPtr = s + oLen;
+ }
+
+ /* append the rest of the input string to the output string. */
+ strcat(outPtr, inPtr);
+
+ return out;
+ }
+
/*
* Find this entry in the directory. If the entry happens to point to
* a mount point, then we follow that and return the root directory of
***************
*** 453,460 ****
Result ret;
int error;
! if (strcmp(name, "@sys") == 0)
! name = arlasysname;
error = adir_lookup (dir_fid, name, res, *ce);
if (error) {
--- 488,495 ----
Result ret;
int error;
! if (strstr(name, "@sys") != NULL)
! name = cm_replace(arlatmpname, name, "@sys", arlasysname);
error = adir_lookup (dir_fid, name, res, *ce);
if (error) {
--
David Morrison Brookhaven National Laboratory phone: 516-344-5840
Physics Department, Bldg 510 C fax: 516-344-3253
Upton, NY 11973-5000 email: dave at bnl.gov
More information about the Arla-drinkers
mailing list