Date: Wed, 05 Apr 1995 22:26:00 -0700 From: "Justin T. Gibbs" <gibbs@estienne.CS.Berkeley.EDU> To: Kai.Vorma@hut.fi Cc: current@FreeBSD.org Subject: Re: patch for sup Message-ID: <199504060526.WAA21470@estienne.cs.berkeley.edu> In-Reply-To: Your message of "Wed, 05 Apr 1995 12:15:45 %2B0300." <199504050915.MAA10911@vinkku.hut.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
>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 <dir>#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
==============================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199504060526.WAA21470>
