From: cwillu <cwillu@cwillu.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs-progs: Correct path munging in bcp
Date: Mon, 13 Jun 2011 16:24:11 -0600 [thread overview]
Message-ID: <BANLkTikN-Ueh6vfuSGgn+Bvxuco-kxdAcw@mail.gmail.com> (raw)
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 <cwillu@cwillu.com>
---
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)
--
1.7.4.1
reply other threads:[~2011-06-13 22:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTikN-Ueh6vfuSGgn+Bvxuco-kxdAcw@mail.gmail.com \
--to=cwillu@cwillu.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).