From: Anuj Mittal <anuj.mittal@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] wic/engine: improve error reporting when using rm with wic
Date: Fri, 20 Jul 2018 15:44:50 +0800 [thread overview]
Message-ID: <20180720074450.23555-1-anuj.mittal@intel.com> (raw)
When trying to delete something from an ext partition using debugfs, we
don't show any error to the user when that operation fails.
Change this behavior to show the error generated by debugfs. Also,
fallback to use rmdir in case we are trying to delete a directory. However,
unlike mdeltree that is used for a FAT partition, there's no easy way to
delete a non empty directory. Show an error instead when that happens so
user can take appropriate action.
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
scripts/lib/wic/engine.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index f0c5ff0aaf..3f2eaa4ff8 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -340,9 +340,21 @@ class Disk:
"""Remove files/dirs from the partition."""
partimg = self._get_part_image(pnum)
if self.partitions[pnum].fstype.startswith('ext'):
- exec_cmd("{} {} -wR 'rm {}'".format(self.debugfs,
+ cmd = "{} {} -wR 'rm {}'".format(self.debugfs,
self._get_part_image(pnum),
- path), as_shell=True)
+ path)
+ out = exec_cmd(cmd , as_shell=True)
+ for line in out.splitlines():
+ if line.startswith("rm:"):
+ if "file is a directory" in line:
+ # Try rmdir to see if this is an empty directory. This won't delete
+ # any non empty directory so let user know about any error that this might
+ # generate.
+ print(exec_cmd("{} {} -wR 'rmdir {}'".format(self.debugfs,
+ self._get_part_image(pnum),
+ path), as_shell=True))
+ else:
+ raise WicError("Could not complete operation: wic %s" % str(line))
else: # fat
cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
try:
--
2.17.1
reply other threads:[~2018-07-20 7:44 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=20180720074450.23555-1-anuj.mittal@intel.com \
--to=anuj.mittal@intel.com \
--cc=openembedded-core@lists.openembedded.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