From owner-freebsd-current@FreeBSD.ORG Sun Apr 22 19:37:24 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EBB6316A401 for ; Sun, 22 Apr 2007 19:37:24 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id CD2F613C45B for ; Sun, 22 Apr 2007 19:37:24 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 8703 invoked from network); 22 Apr 2007 19:37:25 -0000 Received: from ppp-71-139-34-102.dsl.snfc21.pacbell.net (HELO ?10.0.0.235?) (nate-mail@71.139.34.102) by root.org with ESMTPA; 22 Apr 2007 19:37:25 -0000 Message-ID: <462BB96E.3050303@root.org> Date: Sun, 22 Apr 2007 12:37:18 -0700 From: Nate Lawson User-Agent: Thunderbird 1.5.0.7 (X11/20061027) MIME-Version: 1.0 To: =?ISO-8859-1?Q?Dag-Erling_Sm=F8rgrav?= References: <460AE39B.4070706@root.org> <86ps6g5759.fsf@dwp.des.no> <4617F563.40502@root.org> <200704181648.46348.jhb@freebsd.org> <20070420074423.GA22594@comp.chem.msu.su> <4628F76F.80608@root.org> <20070421000649.GD52136@comp.chem.msu.su> <462956BE.3050904@root.org> <867is6194t.fsf@dwp.des.no> In-Reply-To: <867is6194t.fsf@dwp.des.no> X-Enigmail-Version: 0.94.1.0 Content-Type: multipart/mixed; boundary="------------020007010800090305070005" Cc: Yar Tikhiy , freebsd-current@freebsd.org Subject: Re: libfetch ftp patch for less latency X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Apr 2007 19:37:25 -0000 This is a multi-part message in MIME format. --------------020007010800090305070005 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Dag-Erling Smørgrav wrote: > Nate Lawson writes: >> Anyone have an issue with me committing the code under an #ifdef, off by >> default? I'll make a note in the src about TVFS support as a todo. > > Go ahead. > > DES Thanks! Please review the attached patch. -- Nate --------------020007010800090305070005 Content-Type: text/x-patch; name="fetch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fetch.diff" Index: src/lib/libfetch/ftp.c =================================================================== RCS file: /home/ncvs/src/lib/libfetch/ftp.c,v retrieving revision 1.91.2.1 diff -u -r1.91.2.1 ftp.c --- src/lib/libfetch/ftp.c 22 Jul 2006 06:01:58 -0000 1.91.2.1 +++ src/lib/libfetch/ftp.c 22 Apr 2007 19:36:16 -0000 @@ -267,6 +267,7 @@ char pwd[PATH_MAX]; int e, i, len; + /* If no slashes in name, no need to change dirs. */ if ((end = strrchr(file, '/')) == NULL) return (0); if ((e = _ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY || @@ -276,7 +277,8 @@ } for (;;) { len = strlen(pwd); - /* look for a common prefix */ + + /* Look for a common prefix between PWD and dir to fetch. */ for (i = 0; i <= len && i <= end - file; ++i) if (pwd[i] != file[i]) break; @@ -284,6 +286,7 @@ DEBUG(fprintf(stderr, "have: [%.*s|%s]\n", i, pwd, pwd + i)); DEBUG(fprintf(stderr, "want: [%.*s|%s]\n", i, file, file + i)); #endif + /* Keep going up a dir until we have a matching prefix. */ if (pwd[i] == '\0' && (file[i - 1] == '/' || file[i] == '/')) break; if ((e = _ftp_cmd(conn, "CDUP")) != FTP_FILE_ACTION_OK || @@ -293,6 +296,23 @@ return (-1); } } + +#ifdef FTP_COMBINE_CWDS + /* Skip leading slashes, even "////". */ + for (beg = file + i; beg < end && *beg == '/'; ++beg, ++i) + /* nothing */ ; + + /* If there is no trailing dir, we're already there. */ + if (beg >= end) + return (0); + + /* Change to the directory all in one chunk (e.g., foo/bar/baz). */ + e = _ftp_cmd(conn, "CWD %.*s", (int)(end - beg), beg); + if (e == FTP_FILE_ACTION_OK) + return (0); +#endif /* FTP_COMBINE_CWDS */ + + /* That didn't work so go back to legacy behavior (multiple CWDs). */ for (beg = file + i; beg < end; beg = file + i + 1) { while (*beg == '/') ++beg, ++i; @@ -966,6 +986,8 @@ if ((e = _ftp_authenticate(conn, url, purl)) != FTP_LOGGED_IN) goto fouch; + /* TODO: Request extended features supported, if any (RFC 3659). */ + /* done */ return (conn); --------------020007010800090305070005--