[130] in arla-drinkers

home help back first fref pref prev next nref lref last post

Re: Arla 0.8 and .@sys

daemon@ATHENA.MIT.EDU (Assar Westerlund)
Wed Jul 22 22:46:44 1998

From arla-drinkers-request@sundance.stacken.kth.se Thu Jul 23 02:46:43 1998
Return-Path: <arla-drinkers-request@sundance.stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 21725 invoked from network); 23 Jul 1998 02:46:42 -0000
Received: from unknown (HELO sundance.stacken.kth.se) (130.237.234.41)
  by bloom-picayune.mit.edu with SMTP; 23 Jul 1998 02:46:42 -0000
Received: from assaris.sics.se (assaris.sics.se [193.10.66.108])
	by sundance.stacken.kth.se (8.8.8/8.8.8) with ESMTP id EAA18287
	for <arla-drinkers@stacken.kth.se>; Thu, 23 Jul 1998 04:41:27 +0200 (MET DST)
Received: (from assar@localhost) by assaris.sics.se (8.8.5/8.7.3) id EAA00386; Thu, 23 Jul 1998 04:43:06 +0200 (MET DST)
To: David Morrison <dave@bnl.gov>
Cc: arla-drinkers@stacken.kth.se
Subject: Re: Arla 0.8 and .@sys
References: <35B3C4AF.C0872951@bnl.gov> <5lemvgf7jy.fsf@assaris.sics.se> <35B4B968.9CFC3BE6@bnl.gov>
Mime-Version: 1.0 (generated by tm-edit 7.68)
Content-Type: text/plain; charset=US-ASCII
From: Assar Westerlund <assar@sics.se>
Date: 23 Jul 1998 04:43:05 +0200
In-Reply-To: David Morrison's message of "Tue, 21 Jul 1998 11:53:12 -0400"
Message-ID: <5lzpe1i8xy.fsf@assaris.sics.se>
Lines: 91
X-Mailer: Gnus v5.5/Emacs 19.34

David Morrison <dave@bnl.gov> writes:
> Here's a patch to inter.c to do a more complete job of replacing all
> occurrences of `@sys' in filenames with sysname.

Thanks for sending the patch.  I fixed this based on your patch but it
turned out a little bit different.  I append my patch at the end of
this mail.

> properly - if I `cd' into a directory named `.@sys' I end up right
> back where I started!

I'm not able to get this error with the current code.  Could you try
it and see if you still get the same problem?

Index: arlad/inter.c
===================================================================
RCS file: /usr/local/cvsroot/arla/arlad/inter.c,v
retrieving revision 1.51
diff -u -w -u -w -r1.51 inter.c
--- inter.c	1998/07/22 07:03:37	1.51
+++ inter.c	1998/07/23 02:39:51
@@ -438,6 +438,47 @@
 }
 
 /*
+ * Expand `src' into `dest' (of size `dst_sz'), expanding `str' to
+ * `replacement' Return number of characters written to `dest'
+ * (excluding terminating zero) or `dst_sz' if there's not enough
+ * room.
+ */
+
+static int
+expand_sys (char *dest, size_t dst_sz, const char *src,
+	    const char *str, const char *rep)
+{
+    char *destp = dst;
+    const char *srcp = src;
+    char *s;
+    int n = 0;
+    int len;
+    size_t str_len = strlen(str);
+    size_t rep_len = strlen(rep);
+    size_t src_len = strlen(src);
+    
+    while ((s = strstr (srcp, str)) != NULL) {
+	len = s - srcp;
+
+	if (dst_sz <= n + len + rep_len)
+	    return dst_sz;
+
+	memcpy (destp, srcp, len);
+	memcpy (destp + len, rep, rep_len);
+	n += len + rep_len;
+	destp += len + rep_len;
+	srcp = s + str_len;
+    }
+    len = src_len - (srcp - src);
+    if (dst_sz <= n + len)
+	return dst_sz;
+    memcpy (destp, srcp, len);
+    n += len;
+    destp[len] = '\0';
+    return n;
+}
+
+/*
  * 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
  * the volume. Hopefully this is the only place where we need to think
@@ -450,11 +491,19 @@
 	   VenusFid *res,
 	   CredCacheEntry** ce)
 {
+     char tmp_name[MAXPATHLEN];
      Result ret;
      int error;
 
-     if (strcmp(name, "@sys") == 0)
-	 name = arlasysname;
+     if (strstr (name, "@sys") != NULL) {
+	 if (expand_sys (tmp_name, sizeof(tmp_name), name,
+			 "@sys", arlasysname) >= sizeof(tmp_name)) {
+	     ret.res   = -1;
+	     ret.error = ENAMETOOLONG;
+	     return ret;
+	 }
+	 name = tmp_name;
+     }
 
      error = adir_lookup (dir_fid, name, res, *ce);
      if (error) {

home help back first fref pref prev next nref lref last post