From patchwork Mon Jun 13 22:24:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cwillu X-Patchwork-Id: 876672 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5DMOR3w025263 for ; Mon, 13 Jun 2011 22:24:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755142Ab1FMWYO (ORCPT ); Mon, 13 Jun 2011 18:24:14 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:63206 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755092Ab1FMWYN (ORCPT ); Mon, 13 Jun 2011 18:24:13 -0400 Received: by vxi39 with SMTP id 39so4012222vxi.19 for ; Mon, 13 Jun 2011 15:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:date:x-google-sender-auth :message-id:subject:from:to:content-type; bh=H+OlOrhlwFmyyrgZfvJOWMxAniHepW9utqUziP1dW5Q=; b=ouBIG8BANao/HxFx5ggGGjwVWc0VNKWALr68kjA/2CYSvIE9QqQ0ttye0M4C6QKU+0 DJgsAuw9LKM/Fpibc2Vi9+RlPMaakm8BSYNOK717/hWNGM6cO1M3IZvuGxvEAF7YyG9v swoj4drfb9Q9DslCEJb/QfF5Dz4t87FdMeIB0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=cAQsdf5p8bgKAppN9LbBbvQ2VwBiPyjOZaImTtAd2J8m2ejKdl56q3iDI94w+9JhnF 5BDDLn5kIr5usXLZQl36pbM0MXJbXgS3SFY6q7p9dLcveJlDnTmshK1anwcZoyKshhVy Bvxa3s6gJeua8sDtxUDpSs3cqwdeq8OcuGaQs= MIME-Version: 1.0 Received: by 10.52.73.34 with SMTP id i2mr1902218vdv.166.1308003851638; Mon, 13 Jun 2011 15:24:11 -0700 (PDT) Received: by 10.52.187.36 with HTTP; Mon, 13 Jun 2011 15:24:11 -0700 (PDT) Date: Mon, 13 Jun 2011 16:24:11 -0600 X-Google-Sender-Auth: 2x4fzwAPByJaWYNBSwoA161BEHM Message-ID: Subject: [PATCH] Btrfs-progs: Correct path munging in bcp From: cwillu To: linux-btrfs Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Bcp was assuming that a path on the command line would never have a slash after it, which is silly, and would cause the first letter of everything in the root of the source to be truncated. Instead, use os.path.relpath to handle it properly. Signed-off-by: Carey Underwood --- bcp | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bcp b/bcp index 5729e91..e7ca641 100755 --- a/bcp +++ b/bcp @@ -136,8 +136,7 @@ for srci in xrange(0, src_args): srcname = os.path.join(dirpath, x) statinfo = os.lstat(srcname) - if srcname.startswith(src): - part = srcname[len(src) + 1:] + part = os.path.relpath(srcname, src) if stat.S_ISLNK(statinfo.st_mode): copylink(srcname, dst, part, statinfo, None) @@ -152,8 +151,7 @@ for srci in xrange(0, src_args): for f in filenames: srcname = os.path.join(dirpath, f) - if srcname.startswith(src): - part = srcname[len(src) + 1:] + part = os.path.relpath(srcname, src) statinfo = os.lstat(srcname) copyfile(srcname, dst, part, statinfo, None)