btrfsprogs/0118-mkfs.btrfs-fail-on-scandir-error-r-mode.patch
Sascha Peilicke 114572d558 Accepting request 76976 from filesystems
- remove debugging printf from
  0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch (forwarded request 76766 from dsterba)

OBS-URL: https://build.opensuse.org/request/show/76976
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/btrfsprogs?expand=0&rev=22
2011-08-04 07:32:48 +00:00

49 lines
1.4 KiB
Diff

From 0b71340df8491fbb78af2c374adaac6b11608e25 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyfox@gentoo.org>
Date: Sat, 4 Jun 2011 11:19:18 +0300
Subject: [PATCH 18/28] mkfs.btrfs: fail on scandir error (-r mode)
mkfs.btrfs does not handle relative pathnames for now. When
they are passed to it it creates empty image. So first time
I thought it does not work at all.
This patch adds error handling for scandir(). With patch it behaves
this way:
$ mkfs.btrfs -r ./root
...
fs created label (null) on output.img
nodesize 4096 leafsize 4096 sectorsize 4096 size 256.00MB
Btrfs v0.19-52-g438c5ff-dirty
scandir for ./root failed: No such file or directory
unable to traverse_directory
Making image is aborted.
mkfs.btrfs: mkfs.c:1402: main: Assertion `!(ret)' failed.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
---
mkfs.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/mkfs.c b/mkfs.c
index 171710e..efd85d5 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -895,6 +895,12 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
count = scandir(parent_dir_entry->path, &files,
directory_select, NULL);
+ if (count == -1)
+ {
+ fprintf(stderr, "scandir for %s failed: %s\n",
+ parent_dir_name, strerror (errno));
+ goto fail;
+ }
for (i = 0; i < count; i++) {
cur_file = files[i];
--
1.7.5.2.353.g5df3e