[127] in arla-drinkers
Re: Arla 0.8 and .@sys
daemon@ATHENA.MIT.EDU (David Morrison)
Tue Jul 21 12:11:40 1998
From arla-drinkers-request@sundance.stacken.kth.se Tue Jul 21 16:11:40 1998
Return-Path: <arla-drinkers-request@sundance.stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 19979 invoked from network); 21 Jul 1998 16:11:39 -0000
Received: from unknown (HELO sundance.stacken.kth.se) (130.237.234.41)
by bloom-picayune.mit.edu with SMTP; 21 Jul 1998 16:11:39 -0000
Received: from bnl.gov (bnl.gov [130.199.128.163])
by sundance.stacken.kth.se (8.8.8/8.8.8) with ESMTP id SAA20548
for <arla-drinkers@stacken.kth.se>; Tue, 21 Jul 1998 18:05:27 +0200 (MET DST)
Received: from bnl.gov (morrison.rhic.bnl.gov [130.199.80.17])
by bnl.gov (8.8.8/8.8.8) with ESMTP id MAA18733;
Tue, 21 Jul 1998 12:05:26 -0400 (EDT)
Sender: dave@bnl.gov
Message-ID: <35B4B968.9CFC3BE6@bnl.gov>
Date: Tue, 21 Jul 1998 11:53:12 -0400
From: David Morrison <dave@bnl.gov>
Organization: Brookhaven National Laboratory
X-Mailer: Mozilla 4.5b1 [en] (X11; I; Linux 2.1.109 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: arla-drinkers@stacken.kth.se
Subject: Re: Arla 0.8 and .@sys
References: <35B3C4AF.C0872951@bnl.gov> <5lemvgf7jy.fsf@assaris.sics.se>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
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 `.@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@bnl.gov