From owner-freebsd-current Wed Apr 5 22:28:04 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id WAA10739 for current-outgoing; Wed, 5 Apr 1995 22:28:04 -0700 Received: from mail.barrnet.net (mail.BARRNET.NET [131.119.246.7]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id WAA10732 for ; Wed, 5 Apr 1995 22:28:03 -0700 Received: from estienne.cs.berkeley.edu (estienne.CS.Berkeley.EDU [128.32.42.147]) by mail.barrnet.net (8.6.10/MAIL-RELAY-LEN) with ESMTP id WAA01436 for ; Wed, 5 Apr 1995 22:24:50 -0700 Received: from localhost (localhost [127.0.0.1]) by estienne.cs.berkeley.edu (8.6.11/8.6.9) with SMTP id WAA21470; Wed, 5 Apr 1995 22:26:01 -0700 Message-Id: <199504060526.WAA21470@estienne.cs.berkeley.edu> X-Authentication-Warning: estienne.cs.berkeley.edu: Host localhost didn't use HELO protocol To: Kai.Vorma@hut.fi cc: current@FreeBSD.org Subject: Re: patch for sup In-reply-to: Your message of "Wed, 05 Apr 1995 12:15:45 +0300." <199504050915.MAA10911@vinkku.hut.fi> Date: Wed, 05 Apr 1995 22:26:00 -0700 From: "Justin T. Gibbs" Sender: current-owner@FreeBSD.org Precedence: bulk >Here is a simple patch for sup that makes it possible to have local >modifications in your source tree so that sup won't overwrite them. The >idea is simple (stolen from this mailing-list, I think :) > > If sup is updating file foo.c and there exists file foo.c#sup it > will update the latter file an leave the former untouched. > >This patch should work with regular files and perhaps with links but >you _cannot_ create shadow directory #foo. I have not tested this >too much (I did it yesterday evening) but I has worked so far just >fine :-) > >Btw, why is freefall's supserver so abysmally slow? Is it because >supservers uses fork() like almost all badly designed network >servers or something else? If the problem is not fork() then I'll try >to see if I can make it faster. > >..vode > >PS. This patch is agains sup.tar.gz from ports-collection. Can you rewrite this so that it doesn't double the number of stat calls needed to do an upgrade? I think you should be doing this check only after a file has been deemed an upgrade target and the test should be made conditionally on a an option to SUP. The test could be done much more simply by doing the stat on upgrade_target.suffix and then if it exists, change the name of the target in the tnode and goto the top of the "upgrade" test cases and loop through them a second time. That way we penalize the special case and leave the common case alone. >+ >+ >+ char *SUFFIX = "#sup"; >+ >+ int tdostat(ls, path, sbuf) >+ int ls; >+ char *path; >+ struct stat *sbuf; >+ { >+ int x, l = strlen(path); >+ >+ strcpy(rname, path); >+ if (l + strlen(SUFFIX) < sizeof(rname)) { >+ strcat(rname, SUFFIX); >+ if ((x = ls ? lstat(rname, sbuf): stat(rname, sbuf)) != -1) { >+ if (sbuf->st_mode&S_IFMT == S_IFDIR) >+ goaway("%s must not be a directory", rname); >+ return x; >+ } >+ if (errno != ENOENT) >+ goaway ("%sstat for %s failed (%d)", ls ? "tl" : "t", rname, errno); >+ rname[l] = '\0'; >+ } >+ return (ls ? lstat(rname, sbuf) : stat(rname, sbuf)); >+ } >+ -- Justin T. Gibbs ============================================== TCS Instructional Group - Programmer/Analyst 1 Cory | Po | Danube | Volga | Parker | Torus ==============================================